/* Console surface CSS: AUTH+INVITE, DASHBOARD SHELL, RESPONSIVE. */

/* AUTH+INVITE */

.auth-page {
  min-height: 100vh;
}

.auth-nav {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  padding: 0 clamp(22px, 5vw, 72px);
}

.auth-nav a:first-child {
  color: var(--ink);
  font-size: clamp(1.45rem, 2.6vw, 1.9rem);
  font-weight: 800;
}

.auth-nav a:last-child {
  color: var(--muted);
  font-weight: 700;
}

.auth-shell {
  width: min(100%, 720px);
  padding: clamp(76px, 16vh, 156px) clamp(22px, 6vw, 72px) 72px;
}

.auth-title {
  max-width: 9ch;
  margin-bottom: 22px;
  font-size: clamp(3.6rem, 8vw, 6.6rem);
  line-height: 0.96;
}

.auth-copy {
  max-width: 34rem;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: clamp(1.25rem, 2.8vw, 1.72rem);
  line-height: 1.22;
}

.auth-shell .button-row .button-primary-link,
.auth-shell .button-row .button-secondary {
  min-height: 46px;
  padding-inline: 18px;
}

.invite-page {
  background: var(--surface);
}

.invite-accept-actions {
  margin-top: 24px;
}

.invite-identity {
  max-width: 38rem;
  margin-bottom: 18px;
  color: var(--muted-strong);
  font-size: 1rem;
}

.invite-actions {
  align-items: center;
  margin-top: 18px;
}

.auth-consent {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  max-width: 38rem;
  margin-top: 18px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 500;
}

.auth-consent input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
}

.auth-consent a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* DASHBOARD SHELL */

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface-muted);
  padding: 16px 8px;
}

.topbar-brand {
  display: none;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0;
}

.project-switcher {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding-inline: 8px;
}

.project-switcher span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.project-switcher select {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  border-color: transparent;
  background: transparent;
  padding: 2px 0;
  font-size: 14px;
  font-weight: 500;
}

.nav-group {
  display: grid;
  gap: 0;
  margin-top: 8px;
}

.nav-group p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.93rem;
  font-weight: 500;
}

.nav-group a {
  display: flex;
  align-items: center;
  min-height: 36px;
  gap: 8px;
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

.nav-group a > span[aria-hidden="true"] {
  display: inline-flex;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  align-items: center;
  justify-content: center;
}

.nav-group a > span[aria-hidden="true"] svg,
.icon-button svg {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

.nav-group a:hover {
  background: #e9e9e9;
}

.nav-group a.is-active,
.nav-group a[aria-current="page"] {
  background: #e1e1df;
  font-weight: 600;
}

.nav-group-secondary {
  margin-top: 18px;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: 28px;
  padding-inline: 12px;
  color: var(--muted);
  font-size: 14px;
}

.sidebar-footer > a {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-card {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--ink);
}

.account-card strong,
.account-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-card strong {
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.account-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.account-avatar {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.footer-signout {
  justify-self: start;
}

.main-shell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: var(--surface);
}

.topbar {
  display: none;
  min-height: 64px;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  padding: 0 36px;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.topbar nav a {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
}

.content {
  width: auto;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  padding: 48px 48px 72px;
}

.hero {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 36px;
  font-weight: 600;
  line-height: 40px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.43rem;
  font-weight: 600;
  line-height: 1.25;
}

h3 {
  margin-bottom: 12px;
  font-size: 1.14rem;
  font-weight: 600;
  line-height: 1.25;
}

.hero p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.hero > p:not(.eyebrow) {
  display: none;
}

.hero-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 16px;
}

.page-heading,
.panel-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.page {
  display: none;
  min-width: 0;
}

.page.is-active {
  display: grid;
  gap: 22px;
}

.page-heading p,
.panel-copy,
.empty-copy {
  display: block;
  max-width: 100%;
  margin-bottom: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: break-word;
}

.panel-copy span {
  display: block;
}

.panel-copy a,
.empty a,
.notice a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.panel,
.empty,
.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel,
.empty {
  padding: 20px;
}

.panel-wide {
  grid-column: 1 / -1;
}

.metric-grid,
.home-grid,
.split-grid,
.form-grid {
  display: grid;
  gap: 14px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.home-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.home-grid .metric {
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.home-grid .metric:nth-child(3n) {
  border-right: 0;
}

.home-grid .metric:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.split-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.form-field-wide {
  grid-column: 1 / -1;
}

.metric {
  min-height: 112px;
  padding: 20px 22px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(1.5rem, 1.8vw, 1.86rem);
  font-weight: 600;
  line-height: 1;
}

.metric small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.api-base {
  display: block;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 11px 12px;
  font-size: 1rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 38px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 0 10px;
  box-shadow: none;
  font-size: 1rem;
}

.tab.is-active {
  border-color: var(--ink);
  color: var(--ink);
}

.billing-panel {
  display: none;
}

.billing-panel.is-active {
  display: grid;
  gap: 24px;
}

dl {
  display: grid;
  grid-template-columns: minmax(150px, 230px) minmax(0, 1fr);
  gap: 11px 18px;
  margin: 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

dd a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.definition-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  overflow-wrap: anywhere;
  border: 1px solid #c9d7ff;
  border-radius: 8px;
  background: #f4f7ff;
  padding: 12px 14px;
  color: #17346f;
}

.notice-neutral {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--muted-strong);
}

.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.list-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  border: 0;
  border-radius: 0;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
  vertical-align: middle;
  white-space: pre-line;
  font-size: 14px;
  line-height: 20px;
}

th {
  border-top: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.empty-table-cell {
  color: var(--muted);
  text-align: center;
  padding: 34px 12px;
}

.empty-table-cell strong,
.empty-table-cell span {
  display: block;
}

.empty-table-cell strong {
  color: var(--ink);
  font-size: 15px;
}

.empty-table-cell span {
  margin: 6px 0 14px;
}

.key-status-badge {
  display: inline-flex;
  margin-left: 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 1px 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}

.icon-button {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.icon-button:hover {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--ink);
}

.icon-button.danger:hover {
  color: var(--danger);
}

.secret-reveal {
  align-items: center;
}

.secret-reveal > span {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.secret-reveal strong {
  color: var(--ink);
  font-weight: 600;
}

.secret-reveal code {
  overflow-wrap: anywhere;
  color: var(--muted-strong);
}

.error {
  border-color: #f2b8b5;
  background: var(--danger-surface);
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 42%);
  padding: 24px;
}

.modal {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 16px 48px rgb(0 0 0 / 18%);
  padding: 22px;
}

.modal h2 {
  margin-bottom: 10px;
  font-size: 18px;
  line-height: 24px;
}

.modal p {
  margin-bottom: 22px;
  color: var(--muted-strong);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* RESPONSIVE */

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100vw;
    height: auto;
    min-width: 0;
    max-width: 100vw;
    max-height: 38dvh;
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 16px;
  }

  .nav-group {
    display: flex;
    gap: 6px;
    margin-inline: -16px;
    overflow-x: auto;
    padding: 0 16px 6px;
    scrollbar-width: thin;
  }

  .nav-group a {
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
  }

  .nav-group-secondary {
    display: none;
  }

  .sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    padding-inline: 0;
  }

  .sidebar-footer > a {
    display: none;
  }

  .account-card {
    min-width: 0;
    margin-bottom: 0;
  }

  .topbar {
    display: flex;
    justify-content: space-between;
    padding: 0 24px;
  }

  .topbar-brand {
    display: inline-flex;
  }

  .project-switcher select {
    min-height: var(--control-height);
  }

  .metric-grid,
  .home-grid,
  .split-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .home-grid .metric {
    border-right: 0;
  }

  .home-grid .metric:nth-last-child(-n + 3) {
    border-bottom: 1px solid var(--line);
  }

  .home-grid .metric:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 640px) {
  .auth-nav {
    min-height: 72px;
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    gap: 12px;
    padding-inline: 20px;
  }

  .auth-shell {
    padding: 32px 20px 48px;
  }

  .auth-title {
    max-width: 10ch;
    font-size: clamp(3rem, 16vw, 4.8rem);
    line-height: 1.04;
  }

  .auth-shell .button-row {
    flex-direction: column;
  }

  .page-heading,
  .panel-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar nav {
    gap: 14px;
  }

  .content {
    width: 100%;
    max-width: 100%;
    padding: 32px 20px 56px;
  }

  .button-row {
    flex-direction: column;
  }

  button,
  .button-primary-link,
  .button-secondary {
    min-height: 44px;
    width: 100%;
  }

  .hero-main {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions {
    justify-content: stretch;
  }

  .list-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .tabs {
    flex-wrap: nowrap;
    gap: 20px;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .tab {
    width: auto;
    min-width: max-content;
  }

  .list-toolbar p {
    grid-column: 1 / -1;
    max-width: none;
  }

  .icon-button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .table-wrap {
    overflow-x: visible;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
  }

  td {
    display: grid;
    grid-template-columns: 1fr;
    min-width: 0;
    gap: 4px;
    border-top: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
  }

  td > * {
    min-width: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
  }

  .empty-table-cell {
    display: block;
  }

  .empty-table-cell::before {
    content: "";
  }

  dl {
    display: block;
  }

  dt {
    margin-top: 12px;
  }

  .notice {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-backdrop {
    align-items: end;
    padding: 12px;
  }

  .modal {
    width: 100%;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }
}
