/* BigBrotherBot portal — dark "security-ops" console theme, echoing the
   marketing site. No framework, no build, no web fonts or images: the CSP is
   default-src 'self', so every style lives in this one same-origin file and
   no template carries a style attribute.

   Sections: tokens · base · layout & topbar · page header · cards · tabs ·
   buttons · forms · alerts · tables · status pills · detail lists · stats ·
   components · mobile. */

/* ---------- tokens ---------- */

:root {
  color-scheme: dark;

  /* Surfaces, darkest to lightest. */
  --bg: #0a0e14;
  --surface: #111824;
  --surface-2: #141d2b;
  --surface-3: #1a2433;

  /* --border separates (cards, table rows) and is decoration only.
     --border-strong outlines interactive controls and stays >= 3:1 against
     every surface above (WCAG 1.4.11 non-text contrast). */
  --border: #1f2a3a;
  --border-strong: #64748b;

  /* Text: both >= 4.5:1 on every surface above (muted is ~6:1 on surface-3). */
  --text: #e6edf3;
  --muted: #94a3b5;

  --accent: #22d3ee;
  --accent-hover: #67e8f9;
  --accent-strong: #06b6d4;
  --accent-ink: #04181d;
  --green: #34d399;
  --green-soft: #6ee7b7;
  --amber: #fbbf24;
  --red: #f87171;
  --red-soft: #fca5a5;

  /* 4px spacing scale. */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  --gutter: 20px;
  --card-pad: var(--s5);
  --card-radius: 14px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --maxw: 860px;
  --maxw-wide: 1200px;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

/* Components set display (.btn is inline-flex), which would beat the UA's
   [hidden] rule; the copy buttons ship hidden until portal.js reveals them. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  /* Safety net: a long email or id breaks instead of widening the page. */
  overflow-wrap: break-word;
}

/* The accent alone is only ~1.5:1 against body text, so links also carry an
   underline (WCAG 1.4.1). Nav, tabs and buttons drop it: their shape is the cue. */
a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(34, 211, 238, 0.45);
  text-underline-offset: 3px;
}
a:hover { color: var(--accent-hover); text-decoration-color: currentColor; }

h1, h2, h3 { margin: 0 0 var(--s3); line-height: 1.2; letter-spacing: -0.015em; font-weight: 700; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.125rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 var(--s4); }
strong { font-weight: 600; color: var(--text); }
code, .mono { font-family: var(--mono); font-size: 0.875em; }

::selection { background: rgba(34, 211, 238, 0.3); }

/* One visible focus ring for everything a keyboard can reach. */
:where(a, button, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
:where(input, select, textarea):focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent-strong);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------- layout & topbar ---------- */

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container.wide { max-width: var(--maxw-wide); }

.main { flex: 1 0 auto; padding-block: var(--s6) var(--s7); }

.skip-link {
  position: absolute;
  left: var(--s3);
  top: -64px;
  z-index: 50;
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: var(--s3); color: var(--accent-ink); }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s5);
  min-height: 60px;
  padding-block: var(--s2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.brand::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}
.brand:hover { color: var(--text); }
.brand span { color: var(--accent); font-family: var(--mono); font-size: 0.8em; }

.topnav { display: flex; flex-wrap: wrap; gap: var(--s1); }
.topnav a {
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9375rem;
}
.topnav a:hover { color: var(--text); background: var(--surface-3); }
/* Current page (or, for Admin, current section): underlined, not colour alone. */
.topnav a[aria-current] {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 8px;
}

.topbar-user { margin-left: auto; display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.user-email { min-width: 0; color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
/* Above phone width a long address is cut short so the account stays on the
   nav's row (the dashboard shows it in full). */
@media (min-width: 641px) {
  .user-email { max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.inline { margin: 0; }

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8125rem;
  padding-block: var(--s5);
}

/* ---------- page header ---------- */

.back-link {
  display: inline-block;
  margin-bottom: var(--s3);
  color: var(--muted);
  font-size: 0.875rem;
  text-decoration: none;
}
.back-link:hover { color: var(--text); }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s3) var(--s5);
  margin-bottom: var(--s5);
}
/* Header rows are flex: let their text column shrink so a long unbroken email
   wraps instead of pushing the page wider. */
.page-head > *, .card-head > * { min-width: 0; }
.page-head h1 { margin: 0; }
.page-sub { margin: var(--s1) 0 0; color: var(--muted); max-width: 72ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: var(--card-pad);
  margin-bottom: var(--s5);
}
.card > :last-child { margin-bottom: 0; }
.card.narrow { max-width: 460px; margin-inline: auto; }

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s2) var(--s4);
  margin-bottom: var(--s4);
}
.card-head h2 { margin: 0; }
/* Wider than a phone the action (Copy, Full history) stays on the title's row:
   the text column takes the room and wraps, the action keeps its size. */
@media (min-width: 641px) {
  .card-head { flex-wrap: nowrap; }
  .card-head > div { flex: 1 1 auto; }
  .card-head > :not(div) { flex: none; }
}
/* A card inside a titled group (the queue's paid requests) is one level down. */
.card-head h3 { margin: 0; font-size: 1.125rem; font-weight: 650; }
.section-title { margin: var(--s2) 0 var(--s3); }
.card-sub { margin: var(--s1) 0 0; color: var(--muted); font-size: 0.875rem; }

/* A divided block at the bottom of a card (decision forms, secondary actions). */
.card-section { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--border); }

/* ---------- tabs ---------- */

/* Admin console tabs: an underline marks the current one; the bottom rule is an
   inset shadow so the tab underline paints over it. */
.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s1);
  margin-bottom: var(--s5);
  box-shadow: inset 0 -1px 0 var(--border);
}
.subnav a {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s3) 10px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.subnav a:hover { color: var(--text); border-bottom-color: var(--border-strong); }
/* The current tab: its own page ("page") or a page inside its section ("true"). */
.subnav a[aria-current] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}
.subnav a[aria-current] .count { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Filter tabs (e.g. request status): a segmented control; the current one gets
   a frame, weight and an accent underline, not just a colour change. */
.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--s1);
  max-width: 100%;
  padding: var(--s1);
  margin-bottom: var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.tabs a {
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}
/* Sentence case ("Over cap", not "Over Cap"): only the first letter is raised. */
.tabs a::first-letter { text-transform: uppercase; }
.tabs a:hover { color: var(--text); background: var(--surface-3); }
.tabs a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--border-strong);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--accent-strong);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); color: var(--accent-ink); }

.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-danger { background: transparent; color: var(--red-soft); border-color: var(--red); }
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.14); color: #fecaca; }

.btn-sm { min-height: 32px; padding: 4px 12px; border-radius: var(--radius-xs); font-size: 0.8125rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }

/* ---------- forms ---------- */

.stack { display: flex; flex-direction: column; gap: var(--s4); }

/* Admin forms lay fields out in columns on the wide container and collapse to
   one column as space runs out; .span-all takes a full row. */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  /* Bottom-aligned, so a label that wraps to two lines doesn't push its input
     below its neighbours'. */
  align-items: end;
  gap: var(--s4) var(--s5);
}
.form-grid .span-all { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > legend { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.hint { color: var(--muted); font-size: 0.8125rem; font-weight: 400; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 6px; }

input[type="email"],
input[type="text"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
/* A rejected input; the reason is always in the alert it is described by. */
/* :is() lifts it over the input[type=…] border rule above. */
:is(input, select, textarea)[aria-invalid="true"] { border-color: var(--red); border-width: 2px; }
::placeholder { color: var(--muted); opacity: 1; }

input[type="checkbox"], input[type="radio"] {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}
.check { display: flex; align-items: center; gap: var(--s2); color: var(--text); font-size: 0.9375rem; cursor: pointer; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s2) var(--s4); }

/* Fields and their submit button on one line (e.g. the queue's approve form). */
.inline-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3); }
.inline-fields .field { flex: 1 1 120px; }
.inline-fields .field.narrow { flex: 0 1 9rem; }
.inline-fields + .hint { margin: var(--s2) 0 0; }
/* A listing's search box above its table. */
.search-bar { margin-bottom: var(--s4); }

/* ---------- alerts ---------- */

.alert,
.notice,
.warn {
  margin: 0 0 var(--s4);
  padding: var(--s3) var(--s4);
  border: 1px solid;
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
}
.alert { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.5); border-left-color: var(--red); color: #fecaca; }
.notice { background: rgba(52, 211, 153, 0.1); border-color: rgba(52, 211, 153, 0.45); border-left-color: var(--green); color: #a7f3d0; }
.warn { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.45); border-left-color: var(--amber); color: #fde68a; }
/* A form's inline error, which its action anchors to (#…-err, #err-…, #terr-…),
   lands with its card's heading still in view above it. */
.alert[id] { scroll-margin-top: 8rem; }
.alert strong, .notice strong, .warn strong { color: inherit; }
.alert a, .notice a, .warn a { color: inherit; }

.flash { margin-bottom: var(--s5); }
.signer-off { margin-bottom: var(--s5); }

/* ---------- tables ---------- */

/* The only place horizontal scrolling is allowed: a wide table scrolls inside
   its wrapper, never the page. Inside a card it runs edge to edge. position:
   relative makes the wrapper contain the .sr-only (absolutely positioned) cell
   labels too; otherwise they escape the scroller and widen the whole page. */
.table-wrap { position: relative; overflow-x: auto; }
/* A table wider than its card (phones) scrolls sideways; an edge shadow says
   more columns are there. The "local" cover layers scroll with the table and
   hide each shadow once that end is reached, so a table that fits shows none. */
.card > .table-wrap {
  background:
    linear-gradient(to right, var(--surface) 40%, transparent) left center / 32px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 40%, transparent) right center / 32px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(148, 163, 184, 0.4), transparent) left center / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(148, 163, 184, 0.4), transparent) right center / 14px 100% no-repeat scroll;
}
/* Each wrapper is a tabindex="0" region so a keyboard can scroll it (Safari does
   not make scrollers focusable); draw its ring inside, it sits at the card edge. */
.table-wrap:focus-visible { outline-offset: -2px; }
.card > .table-wrap { margin-inline: calc(-1 * var(--card-pad)); }
/* Flush with the card's top/bottom edge too when nothing sits above/below it;
   the wrapper's rounded corners clip the header band and hovered rows. */
.card > .table-wrap:first-child { margin-top: calc(-1 * var(--card-pad)); border-top-left-radius: calc(var(--card-radius) - 1px); border-top-right-radius: calc(var(--card-radius) - 1px); }
.card > .table-wrap:last-child { margin-bottom: calc(-1 * var(--card-pad)); border-bottom-left-radius: calc(var(--card-radius) - 1px); border-bottom-right-radius: calc(var(--card-radius) - 1px); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px var(--s3); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.card > .table-wrap :is(th, td):first-child { padding-left: var(--card-pad); }
.card > .table-wrap :is(th, td):last-child { padding-right: var(--card-pad); }
thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.actions, td.actions { text-align: right; white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 0.8125rem; }
/* The words carry the warning; the tint only reinforces it. */
td .warn-note { color: var(--amber); }
td.mono { white-space: nowrap; }

/* ---------- status pills ---------- */

/* State is always spelled out; the dot and tint only reinforce it. */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 10px;
  border: 1px solid rgba(148, 163, 181, 0.45);
  border-radius: 999px;
  background: rgba(148, 163, 181, 0.1);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  white-space: nowrap;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-active,
.status-approved,
.status-issued { color: var(--green-soft); border-color: rgba(52, 211, 153, 0.45); background: rgba(52, 211, 153, 0.12); }
.status-expiring,
.status-pending,
.status-mismatch { color: var(--amber); border-color: rgba(251, 191, 36, 0.45); background: rgba(251, 191, 36, 0.1); }
.status-expired,
.status-denied,
.status-revoked,
.status-overcap { color: var(--red-soft); border-color: rgba(248, 113, 113, 0.5); background: rgba(248, 113, 113, 0.12); }
/* Multi-word pill labels are written in sentence case; capitalize would make
   every word upper-case. */
.status-overcap,
.status-mismatch { text-transform: none; }
/* superseded, cancelled and dismissed keep the neutral base style. */

/* ---------- detail lists ---------- */

/* Two columns of cards on detail pages (request/license/customer); min() lets
   it collapse to one column on a narrow screen without a media query. */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap: 0 var(--s5);
  align-items: start;
}

.detail {
  display: grid;
  grid-template-columns: minmax(120px, max-content) minmax(0, 1fr);
  gap: var(--s2) var(--s5);
  margin: 0;
}
.detail dt { color: var(--muted); font-size: 0.875rem; padding-top: 1px; }
.detail dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.detail:not(:last-child) { margin-bottom: var(--s4); }
.detail dd .sub { display: block; margin-top: 2px; color: var(--muted); font-size: 0.8125rem; }

/* Compact key/value rows inside a table cell (audit details). */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0 var(--s3); min-width: 260px; margin: 0; font-size: 0.8125rem; }
.kv > div { display: contents; }
.kv dt { color: var(--muted); font-family: var(--mono); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- stats ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
  gap: var(--s4);
  margin: 0 0 var(--s5);
}
/* Each stat spans two rows of the grid and takes them as its own (subgrid), so
   a label that wraps to two lines moves every value in that row down with it:
   the values stay on one line. */
.stat {
  display: grid;
  grid-row: span 2;
  grid-template-rows: subgrid;
  row-gap: var(--s1);
  padding: var(--s4) var(--s5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat dt { color: var(--muted); font-size: 0.8125rem; font-weight: 500; }
.stat dd {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat dd .sub { display: block; margin-top: var(--s1); color: var(--muted); font-size: 0.8125rem; font-weight: 400; letter-spacing: 0; }

/* ---------- components ---------- */

/* License / API tokens: monospace, wraps anywhere, scrolls when very long. */
.token {
  max-height: 240px;
  margin: 0 0 var(--s4);
  padding: var(--s4);
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
}
/* Like a .table-wrap, each box is a tabindex="0" region so a keyboard can
   scroll it (Safari does not make scrollers focusable); its ring sits inside. */
.token:focus-visible { outline-offset: -2px; }

.quote {
  margin: 0 0 var(--s4);
  padding: var(--s2) var(--s4);
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
  white-space: pre-line;
}

/* Free text typed into a textarea (internal notes, denial reasons): keep its line breaks. */
.pre-line { white-space: pre-line; }
/* A plan id (team, enterprise) that starts a heading reads as a name there. */
.plan-name { text-transform: capitalize; }

/* The drilldown's snapshot JSON gets more room than a token box. */
.token-tall { max-height: 70vh; }

/* Analytics bars: inline SVG sized by its rect's width attribute — the CSP forbids style attributes. */
.bar { display: block; width: 100%; min-width: 6rem; height: 8px; }
.bar-track { fill: var(--surface-3); }
.bar-fill { fill: var(--accent); }
td.bar-cell { width: 40%; }
/* A sub-table heading inside an Analytics card, and what follows a card's table. */
.analytics-sub { margin: var(--s4) 0 var(--s2); }
.analytics-after { margin-top: var(--s4); }

.empty { padding: var(--s6) var(--s4); text-align: center; color: var(--muted); }
.empty-title { margin-bottom: var(--s1); color: var(--text); font-weight: 600; }

/* A row action that needs input (e.g. revoke with a reason) folds into a
   native disclosure: no script, keyboard-operable, one compact row. */
.row-action { display: inline-block; vertical-align: top; text-align: left; }
/* Opened, its summary stays at the right edge (next to the row's other
   actions) and the form unfolds below it. */
.row-action[open] { text-align: right; }
.row-action > summary { list-style: none; }
.row-action > summary::-webkit-details-marker { display: none; }
.row-action-body { display: flex; flex-direction: column; align-items: stretch; gap: var(--s2); width: 200px; margin-top: var(--s2); white-space: normal; text-align: left; }
/* The dashboard's pending trial ask: its notice, then a Cancel disclosure that
   unfolds below it in normal flow, left-aligned so its summary stays put. */
.trial-pending { margin-bottom: var(--s4); }
.trial-pending .notice { margin-bottom: var(--s2); }
.trial-pending .row-action[open] { text-align: left; }
/* A row action's inline error sits right above the checkbox it is about: the gap spaces it. */
.row-action-body .alert { margin: 0; }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s3); }
.pager-label { color: var(--muted); font-size: 0.875rem; }

.error-card { text-align: center; }
.error-card .cta-row { justify-content: center; }
.error-code { margin: 0 0 var(--s2); color: var(--accent); font-family: var(--mono); font-size: 3rem; font-weight: 700; line-height: 1; }

/* ---------- mobile ---------- */

@media (max-width: 640px) {
  :root { --gutter: var(--s4); --card-pad: var(--s4); --card-radius: var(--radius-sm); }
  h1 { font-size: 1.45rem; }
  .main { padding-block: var(--s5) var(--s6); }

  /* Topbar wraps: brand and account on top, the nav on its own full row (below
     480px the email is hidden so the account fits there). */
  .topbar-inner { gap: var(--s2) var(--s3); }
  .topnav { order: 3; width: 100%; margin-left: -8px; gap: 0; }
  .topnav a { padding: 6px 8px; font-size: 0.875rem; }
  .topbar-user { gap: var(--s2); }
  .user-email { font-size: 0.8125rem; }

  .page-head { align-items: flex-start; }
  .card.narrow { max-width: none; }

  /* Admin tabs become wrapping chips; the current one keeps its underline. */
  .subnav { gap: var(--s1); box-shadow: none; }
  .subnav a { padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius-xs); font-size: 0.875rem; }
  .subnav a:hover { border-color: var(--border-strong); }
  .subnav a[aria-current] { border-color: var(--border-strong); box-shadow: inset 0 -2px 0 var(--accent); }

  .tabs { display: flex; }
  .tabs a { padding: 6px 10px; font-size: 0.875rem; }
  /* Tighter cells bring more columns (status, actions) into view before the
     sideways scroll. */
  th, td { padding: 8px var(--s2); }
  .detail { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .detail dd { margin-bottom: var(--s2); }
  .stat dd { font-size: 1.35rem; }

  /* A data table (table.stackable) stacks: each row becomes a block of "label
     value" lines, the label from the cell's data-label, so a row's status and
     actions are on screen instead of past a sideways scroll. A cell without a
     label (the actions) takes the full width. Screen readers still hear each
     label, as generated content. */
  table.stackable thead { display: none; }
  table.stackable, table.stackable tbody, table.stackable tr, table.stackable td { display: block; }
  table.stackable tr { padding-block: var(--s2); border-bottom: 1px solid var(--border); }
  table.stackable tbody tr:last-child { border-bottom: 0; }
  .table-wrap table.stackable td { padding: 3px var(--card-pad); border: 0; text-align: left; white-space: normal; }
  .table-wrap table.stackable td[data-label] { position: relative; padding-left: calc(var(--card-pad) + 7.5rem); }
  table.stackable td[data-label]::before {
    content: attr(data-label);
    position: absolute;
    left: var(--card-pad);
    width: 7rem;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 0.8125rem;
  }
  table.stackable td:not([data-label]) { padding-top: var(--s2); }
  table.stackable .kv { min-width: 0; }
  /* Analytics: a bar fills its row and is at least as tall as its label; cards
     with long column names (.long-labels) get a wider label column. */
  table.stackable td.bar-cell { display: flex; align-items: center; width: auto; min-height: 1.6rem; }
  .long-labels .table-wrap table.stackable td[data-label] { padding-left: calc(var(--card-pad) + 11rem); }
  .long-labels table.stackable td[data-label]::before { width: 10.5rem; }
  table.stackable .nowrap { white-space: normal; }
}

/* Small phones: the account email gives way so the brand and Sign out share
   one row (the dashboard says who is signed in). */
@media (max-width: 480px) {
  .user-email { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
