/* Developer portal styles — shared by /login, /register/confirm and
   /portal. Chart colors are read from these tokens by dashboard.ts at draw
   time; the categorical set is the dataviz reference palette, validated as
   a set in both modes (don't swap one hex in isolation). */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --raised: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --critical: #d03b3b;
  --good: #137a47;
  --code-bg: #f0efec;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --series-other: #898781;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --raised: #222220;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --critical: #e66767;
    --good: #1d8f56;
    --code-bg: #2c2c2a;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --series-other: #6d6c67;
  }
}
/* The portal's explicit Dark choice (web/portal/theme.ts sets data-theme on
   <html>), whatever the OS says; an explicit Light is the :not() above. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --raised: #222220;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --critical: #e66767;
  --good: #1d8f56;
  --code-bg: #2c2c2a;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #6d6c67;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

button, .btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  display: inline-block;
}
button:disabled { opacity: 0.6; cursor: default; }
.btn-pay { background: var(--good); color: #fff; }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-ghost {
  background: transparent; color: var(--ink-2); border-color: transparent;
  padding: 0.3rem 0.6rem; font-weight: 500;
}
.btn-ghost:hover { background: var(--code-bg); }
.btn-ghost.danger { color: var(--critical); }
input, textarea, select {
  font: inherit;
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  width: 100%;
}
textarea { resize: vertical; min-height: 5.5rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
label, .field-label { display: block; font-weight: 600; margin: 0 0 0.35rem; }
.hint { color: var(--ink-2); font-size: 0.86rem; margin: 0.35rem 0 0; }
.muted { color: var(--muted); }
.status { min-height: 1.4em; color: var(--ink-2); margin: 0.75rem 0 0; font-size: 0.92rem; }
.status.error, .error-banner { color: var(--critical); }

/* --- sign-in pages --- */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  width: 100%;
  max-width: 420px;
}
.card h1 { font-size: 1.3rem; margin: 0.75rem 0 0.4rem; }
.card p { color: var(--ink-2); margin: 0 0 1.25rem; }
.card .logo { width: 36px; height: 36px; }
.card form > * + * { margin-top: 0.75rem; }
.card .row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.card .row > * { flex: 1 1 auto; }
.card .footnote { font-size: 0.85rem; color: var(--muted); margin: 1.25rem 0 0; }

/* --- dashboard --- */

main { max-width: 1120px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
section + section { margin-top: 2.5rem; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.section-head h2 { margin: 0; font-size: 1.2rem; }
.section-head p { margin: 0.2rem 0 0; color: var(--ink-2); font-size: 0.92rem; }
.controls { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.table-wrap { overflow-x: auto; position: relative; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.7rem 1rem; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
tr.revoked td { color: var(--muted); }
.key-name { font-weight: 600; }
.chip {
  display: inline-block; margin: 0 0.3rem 0.3rem 0; padding: 0.1rem 0.5rem;
  border-radius: 999px; background: var(--code-bg); font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.badge {
  display: inline-block; margin-left: 0.4rem; padding: 0 0.45rem; border-radius: 4px;
  border: 1px solid var(--border); font-size: 0.75rem; color: var(--muted);
}
.empty { padding: 2rem 1rem; text-align: center; color: var(--ink-2); }
.revoked-toggle { display: flex; align-items: center; gap: 0.4rem; font-weight: 500; color: var(--ink-2); margin: 0; font-size: 0.9rem; }
.revoked-toggle input { width: auto; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented button {
  background: transparent; color: var(--ink-2); border: none; border-radius: 0;
  padding: 0.4rem 0.8rem; font-weight: 500;
}
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--code-bg); color: var(--ink); font-weight: 700; }
#key-filter { width: auto; min-width: 10rem; padding: 0.4rem 0.6rem; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { padding: 1rem 1.1rem; }
.kpi .label { color: var(--ink-2); font-size: 0.85rem; }
.kpi .value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; margin-top: 0.2rem; }
.kpi .sub { color: var(--muted); font-size: 0.8rem; }

.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.chart { padding: 1rem 1.1rem 0.75rem; min-width: 0; }
.chart h3 { margin: 0 0 0.15rem; font-size: 0.95rem; }
.chart p { margin: 0 0 0.6rem; color: var(--muted); font-size: 0.8rem; }
.chart .canvas { position: relative; height: 240px; }
.chart.wide { grid-column: 1 / -1; }
.chart.wide .canvas { height: 280px; }
.freshness { color: var(--muted); font-size: 0.8rem; margin: 0.75rem 0 0; }

dialog {
  border: 1px solid var(--border); border-radius: 14px; padding: 0;
  background: var(--surface); color: var(--ink);
  width: min(520px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog .dialog-body { padding: 1.5rem; }
dialog h2 { margin: 0 0 1rem; font-size: 1.15rem; }
dialog form > * + * { margin-top: 1rem; }
dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }
.copy-row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.copy-row .hint { margin: 0; }
pre.example {
  background: var(--code-bg); border-radius: 8px; padding: 0.75rem;
  overflow-x: auto; margin: 0.5rem 0 0; white-space: pre;
}

/* Admin pages (/portal/admin): the Dashboard / Users / Usage tabs under the header. */
.admin-tabs {
  /* Lined up with main's content box (1120px less its 16px gutters). */
  max-width: 1088px; margin: 0.75rem auto 0; width: calc(100% - 32px);
  display: flex; gap: 1.25rem; border-bottom: 1px solid var(--border);
}
.admin-tabs a {
  padding: 0.45rem 0; color: var(--ink-2); text-decoration: none; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.admin-tabs a:hover { color: var(--ink); }
.admin-tabs a[aria-current="page"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--accent); }
.breadcrumb { margin: 0 0 0.75rem; font-size: 0.9rem; }
#users-search { width: 16rem; max-width: 100%; }
/* Sortable headers: the button is the header text. */
table.sortable th button {
  all: unset; cursor: pointer; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit;
}
table.sortable th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
table.sortable th[aria-sort="ascending"] button::after { content: " \2191"; }
table.sortable th[aria-sort="descending"] button::after { content: " \2193"; }

@media (max-width: 800px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts { grid-template-columns: minmax(0, 1fr); }
  th.hide-sm, td.hide-sm { display: none; }
}

/* /portal/docs: one card per reference. */
.doc-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.doc-link { display: block; padding: 1.1rem 1.25rem; color: var(--ink); text-decoration: none; }
.doc-link:hover { border-color: var(--accent); }
.doc-link h3 { margin: 0 0 0.4rem; font-size: 1.05rem; color: var(--accent); }
.doc-link p { margin: 0; color: var(--ink-2); font-size: 0.92rem; }
.doc-link.soon { cursor: default; }
.doc-link.soon:hover { border-color: var(--border); }
.doc-link.soon h3 { color: var(--ink-2); }
.doc-links.sdks { margin-top: 1rem; }
.doc-link .sdk-links { margin-top: 0.7rem; display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; }
.doc-link .sdk-links a { color: var(--accent); font-weight: 600; text-decoration: none; }
.doc-link .sdk-links a:hover { text-decoration: underline; }
.doc-link .sdk-links [hidden] { display: none; }
