/* Suaponte admin — the console design system (ADR-0100). ONE file under
 * `style-src 'self'`: an inline style is refused SILENTLY, so there is none. */

:root {
  /* Dark only: `light dark` paints light form controls on a dark surface. */
  color-scheme: dark;
  /* Chrome is sans, DATA is mono; a webfont would need a CSP host. */
  --font-mono: ui-monospace, Menlo, Consolas, monospace;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-xs: 0.6875rem; --fs-sm: 0.75rem; --fs-base: 0.8125rem;
  --fs-md: 0.875rem; --fs-lg: 1rem; --fs-xl: 1.25rem;
  --lh-tight: 1.35; --lh-prose: 1.6;
  --bg-base: #0d1117; --bg-surface: #131920; --bg-raised: #1a212b;
  --bg-inset: #0a0e13; --border: #232c38; --border-strong: #313c4b;
  /* On --bg-surface: text 15.3:1, dim 7.1:1, accent 6.6:1; --text-faint is
     4.0:1 and is DISABLED STATE ONLY, never prose and never a value. */
  --text: #e6edf3; --text-dim: #9aa7b4; --text-faint: #6e7d8c;
  --accent: #4c9aff; --accent-dim: #1f3a5f;
  /* Status tones, all >= 4.5:1. Colour is redundant with the word. */
  --ok: #3fb950; --warn: #d29922; --bad: #f85149; --info: #58a6ff; --mute: #8b949e;
  --s-1: 2px; --s-2: 4px; --s-3: 6px; --s-4: 8px; --s-5: 12px;
  --s-6: 16px; --s-7: 24px; --s-8: 32px; --s-9: 48px;
  --r-sm: 3px; --r-md: 5px; --r-lg: 8px;
  --hair: 1px solid #232c38;
}
*, *::before, *::after { box-sizing: border-box; }
body.admin {
  margin: 0; background: var(--bg-base); color: var(--text);
  font: var(--fs-base)/var(--lh-tight) var(--font-sans); -webkit-text-size-adjust: 100%;
}
/* The `hidden` ATTRIBUTE stays authoritative: pairing.js toggles it, a
   `display` rule beats the UA's [hidden], and the form that goes visible wipes
   a credential. No `.panel` rule may set display; a test asserts both. */
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code, kbd, samp { font-family: var(--font-mono); font-size: 0.95em; }
h2, h3, h4 { margin: 0 0 var(--s-4); font-weight: 600; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); color: var(--text-dim); }
p { margin: 0 0 var(--s-5); }
/* Prose has a MEASURE: 1600px paragraphs are the wall-of-text bug. */
.hint, .panel__blurb, .cmd__blurb {
  max-width: 68ch; color: var(--text-dim); font-size: var(--fs-sm); line-height: var(--lh-prose);
}
.hint code { color: var(--text); }
.kv__v, .fieldrow__value, .pair-meta, .operator, .titlerow__id, .panel__summary, .savebar__note {
  font-family: var(--font-mono);
}
.operator, .titlerow__id, .panel__summary, .savebar__note, .pair-meta, .crumbs, .pager,
.fieldrow__label, .kv__k, .sidebar__foot { color: var(--text-dim); font-size: var(--fs-sm); }
.topbar, .titlerow, .savebar, .page-actions, .filter-bar, .cmd__head, .pair-meta, .panel__head, .kv {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-5);
}
.titlerow, .panel__head, .kv { align-items: baseline; }
.page-actions, .filter-bar, .cmd__head { gap: var(--s-4); }
.main, .record__main, .rail, .content, .fieldrow__control, .kv__v { min-width: 0; }

.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; }
.sidebar {
  position: sticky; top: 0; display: flex; flex-direction: column; height: 100dvh;
  overflow-y: auto; padding: var(--s-6) var(--s-4);
  background: var(--bg-inset); border-right: var(--hair);
}
.wordmark {
  margin: 0 0 var(--s-6); padding: 0 10px; font-size: var(--fs-sm); font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
}
.sidebar__foot { margin-top: auto; padding: var(--s-5) 10px 0; border-top: var(--hair); }
.topbar {
  position: sticky; top: 0; z-index: 20; min-height: 48px; padding: var(--s-5) var(--s-7);
  background: var(--bg-surface); border-bottom: var(--hair);
}
.crumbs { flex: 1 1 auto; white-space: nowrap; }
.crumbs a { color: var(--text-dim); }
.crumbs b { color: var(--text); font-weight: 600; }
.crumbs > * + *::before { content: " / "; color: var(--text-faint); }
.content { padding: var(--s-7) var(--s-7) var(--s-9); }
.titlerow { margin-bottom: var(--s-6); }
.page-title, .panel__title, .fieldrow__label { margin: 0; }

/* Nav. `.on` is asserted by name in the suite: styling moved, name did not. */
.nav-primary { display: flex; flex-direction: column; gap: var(--s-1); margin-bottom: var(--s-6); }
.nav-item, nav.sub a {
  display: block; padding: 7px 10px; border-radius: var(--r-md);
  color: var(--text-dim); font-size: var(--fs-md);
}
.nav-item, nav.sub a, button { transition: background-color .12s, border-color .12s, color .12s; }
.nav-item:hover, nav.sub a:hover { background: var(--bg-raised); color: var(--text); text-decoration: none; }
.nav-item.on, nav.sub a.on { background: var(--accent-dim); color: var(--text); font-weight: 600; }
nav.sub { display: block; border-top: var(--hair); padding-top: var(--s-5); }
nav.sub a { font-size: var(--fs-sm); }
nav.sub .group {
  display: block; margin: var(--s-5) 0 var(--s-2); padding: 0 10px; font-size: var(--fs-xs);
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim);
}
nav.sub .group:first-child { margin-top: 0; }

/* One raised surface, four names. NO `display` in it — see [hidden]. */
.panel, .savebar, .table-wrap, .auth-card {
  margin: 0 0 var(--s-6); background: var(--bg-surface);
  border: var(--hair); border-radius: var(--r-lg);
}
.table-wrap { overflow-x: auto; }
/* A table sits ON the border of whatever holds it: the list page's against the
   content inset, the rail fragment's against its panel. A panel has no padding
   of its own, so the alternative is a bordered rounded box one pixel inside a
   bordered rounded box — a card in a card, which no other child of one is. */
.table-wrap--flush, .table-wrap--inline { border-width: 0 0 1px; border-radius: 0; }
.table-wrap--flush { margin-inline: calc(-1 * var(--s-7)); }
.table-wrap--inline th { position: static; }
table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: var(--fs-base); }
th {
  position: sticky; top: 0; z-index: 1; padding: var(--s-4) var(--s-5);
  background: var(--bg-raised); border-bottom: var(--hair); color: var(--text-dim);
  font-family: var(--font-sans); font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; text-align: left; white-space: nowrap;
}
th a { color: inherit; }
td { padding: var(--s-3) var(--s-5); border-bottom: var(--hair); vertical-align: top; white-space: nowrap; }
/* No zebra: the hover band tracks the eye. */
table tr:hover td { background: var(--bg-raised); }
/* Only `bad` is tinted: tint every tone and the exception vanishes. */
tr.row--bad td { background: rgba(248,81,73,.05); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td .row-link { color: var(--text); text-decoration: underline dotted var(--border-strong); text-underline-offset: 3px; }
td .row-link:hover { color: var(--accent); text-decoration: underline; }
td.empty { padding: var(--s-8) var(--s-5); text-align: center; color: var(--text-dim); font-family: var(--font-sans); white-space: normal; }

.badge {
  display: inline-block; padding: var(--s-1) var(--s-3);
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent); border-radius: var(--r-sm);
  background: color-mix(in srgb, currentColor 14%, transparent); font-family: var(--font-mono);
  font-size: var(--fs-xs); line-height: 1.5; white-space: nowrap;
}
.badge--ok { color: var(--ok); }
.badge--warn { color: var(--warn); }
.badge--bad { color: var(--bad); }
.badge--info { color: var(--info); }
.badge--mute { color: var(--mute); }

.record { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s-6); align-items: start; }
/* No rail to draw: twelve of sixteen record pages have nothing live, nothing to
   command and nothing to link, and a reserved 340px of nothing reads as broken. */
.record--wide { grid-template-columns: minmax(0, 1fr); }
/* A panel whose CONTENT is a form rather than rows carries its own inset. */
.panel--pad { padding: var(--s-6); }
/* No `--danger` panel: the repair is a command row now, and its danger is the button. */
/* NO uppercase: it was the wall-of-text tell. A panel has no padding of its
   own, so every child of one carries its inset or sits on the border. */
.panel__title { font-size: var(--fs-md); }
.panel__head, .savebar, .cmd { padding: var(--s-5) var(--s-6); }
.panel__summary { margin-left: auto; }
.panel__blurb { margin: 0; padding: var(--s-5) var(--s-6) 0; }
/* An inline fragment's own heading takes the panel inset too. */
.panel > h4, .panel > .hint { margin: 0; padding: var(--s-5) var(--s-6); }
/* Activity's destinations are PLAIN links in a column, not cards with a
   sentence each: four blurbs in a 340px rail was the wall of text. */
.linklist { display: flex; flex-direction: column; gap: var(--s-3); margin: 0; padding: var(--s-5) var(--s-6); }

.fieldrow { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: var(--s-5); padding: 10px var(--s-6); }
.fieldrow__label { display: block; padding-top: var(--s-3); }
.fieldrow__control p { margin: var(--s-2) 0 0; }
.fieldrow__value, .kv__v { overflow-wrap: anywhere; }
.fieldrow__mode { margin-left: var(--s-4); color: var(--text-faint); font-size: var(--fs-xs); }
.kv { padding: var(--s-4) var(--s-6); }
.kv__k { flex: 0 0 40%; }
/* A kv whose value is FIXED COPY and not a reading: dim, so it cannot be
   mistaken for the live values the same layout carries elsewhere. */
.kv--static .kv__v { color: var(--text-dim); }
/* A command in the rail; one that collects input opens a <details>. The marker
   is drawn here because `display: flex` takes a <summary>'s own away. */
.cmd__head { cursor: pointer; }
summary .cmd__name::after { content: " ▾"; color: var(--text-dim); }
.cmd__disclosure[open] .cmd__name::after { content: " ▴"; }
.cmd__name { font-size: var(--fs-md); font-weight: 600; }
/* COMPACT: the blurb shares the row with its button instead of forcing a line
   of its own. Inside a disclosure it is a <p> and takes the block spacing. */
.cmd__blurb { flex: 1 1 auto; }
p.cmd__blurb { margin: var(--s-4) 0 0; }
.cmd__head button { margin-left: auto; }
.cmd__disclosure[open] .cmd__head { margin-bottom: var(--s-5); }
.panel__head, .fieldrow, .kv, .cmd { border-bottom: var(--hair); }
tr:last-child td, .fieldrow:last-child, .kv:last-child, .cmd:last-child { border-bottom: 0; }

/* Scoped: the record form and the topbar lay their own labels out. */
.panel--pad label, .auth-card label, .cmd label {
  display: block; margin: var(--s-5) 0 var(--s-2); font-size: var(--fs-sm); color: var(--text-dim);
}
input, select, textarea, button {
  padding: var(--s-3) var(--s-4); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); color: var(--text); font-size: var(--fs-base);
}
input, select, textarea { max-width: 100%; background: var(--bg-inset); font-family: var(--font-mono); }
textarea { width: 100%; line-height: var(--lh-prose); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
button {
  padding: var(--s-3) var(--s-5); background: var(--bg-raised);
  font-family: var(--font-sans); font-weight: 600; cursor: pointer;
}
button:hover { border-color: var(--accent); }
/* pairing.js disables a button per request; unstyled it reads as unresponsive. */
button:disabled, button:disabled:hover { color: var(--text-faint); border-color: var(--border); cursor: default; }
/* The rail's buttons: one command per row, so the control is the small one. */
.btn--sm { padding: var(--s-2) var(--s-4); font-size: var(--fs-sm); }
/* A page-scope action in the topbar: a link that reads as the primary control. */
.btn-link { margin-left: auto; color: var(--accent); font-weight: 600; white-space: nowrap; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #0d1117; }
.btn--quiet { background: none; }
/* Danger is PRESENTATION ONLY (ADR-0098 §9): it never gates or authorises. */
.btn--danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn--danger:hover { border-color: var(--bad); }
form.inline { display: inline; }
/* ONE form: split in two and either submit resets the other's order. */
.filter-bar { margin: 0; }
.page-actions { margin-top: var(--s-5); }

/* One banner; --tone is all that differs, and the secret is the loudest. */
.notice, .failure, .secret, .emergency {
  margin: 0 0 var(--s-6); padding: var(--s-5) var(--s-6); max-width: 88ch;
  border: 1px solid color-mix(in srgb, var(--tone) 45%, transparent); border-left-width: 3px;
  border-radius: var(--r-md); background: color-mix(in srgb, var(--tone) 8%, transparent);
  font-size: var(--fs-md); line-height: var(--lh-prose);
}
.notice { --tone: var(--ok); }
.failure { --tone: var(--bad); }
/* Emergency direct egress: its own class so no refusal check reads it as one. */
.emergency { --tone: var(--bad); background: color-mix(in srgb, var(--bad) 18%, transparent); font-weight: 600; }
.secret { --tone: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.secret code {
  display: block; margin-top: var(--s-4); padding: var(--s-4); background: var(--bg-inset);
  border-radius: var(--r-md); font-size: var(--fs-lg); word-break: break-all; user-select: all;
}

/* Pairing. The QR needs a LIGHT plate — a dark-on-dark code does not scan —
   and it is the image's OWN padding, so `hidden` takes the white square too. */
.pair-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; padding: var(--s-6); }
.pair-qr {
  display: block; max-width: 100%; height: auto; margin-right: var(--s-7);
  padding: var(--s-5); background: #f0f6fc; border-radius: var(--r-lg);
}
#pair-headline { margin: 0 0 var(--s-4); font-size: var(--fs-xl); font-weight: 600; }
.pair-meta { margin: var(--s-5) 0; }
/* Blank on most phases, and a blank flex item still spends its gap. */
.pair-meta :empty, #pair-status:empty { display: none; }
#pair-countdown { font-variant-numeric: tabular-nums; }

.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: var(--s-7); }
.auth-inner { width: 100%; max-width: 420px; }
.auth-card { margin: 0; padding: var(--s-7); }
.auth-inner .wordmark { margin-bottom: var(--s-6); padding: 0; color: var(--text-dim); }
.auth-card input, .auth-card button { width: 100%; }
.auth-card button { margin-top: var(--s-5); }

/* Narrow: one column, then the sidebar becomes a strip. */
@media (max-width: 1100px) { .record { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static; flex-direction: row; flex-wrap: wrap; gap: var(--s-5); height: auto;
    padding: var(--s-4) var(--s-5); border-right: 0; border-bottom: var(--hair);
  }
  .wordmark, .sidebar__foot { margin: 0; padding: 0; border-top: 0; }
  .nav-primary { flex-direction: row; margin-bottom: 0; }
  nav.sub { display: flex; gap: var(--s-3); padding-top: 0; border-top: 0; white-space: nowrap; overflow-x: auto; }
  nav.sub .group { margin: 0; padding: var(--s-3) 0 0; }
  .content { padding: var(--s-6) var(--s-5) var(--s-8); }
  .table-wrap--flush { margin-inline: calc(-1 * var(--s-5)); }
  .fieldrow { grid-template-columns: minmax(0, 1fr); gap: var(--s-2); }
  .pair-grid { grid-template-columns: minmax(0, 1fr); }
}

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