/* ==========================================================================
   Stripe Relay — operator console
   One stylesheet. Tokens are the single source of truth; every primitive has
   exactly one canonical geometry. Sections:
     1. Fonts           5. Chrome (signal bar, rail)
     2. Tokens          6. Page composition
     3. Base           7. Primitives (buttons, chips, panels, tables, forms…)
     4. Icons          8. Responsive
   ========================================================================== */

/* 1. Fonts — self-hosted, variable, metric-matched to kill layout shift ----- */
@font-face {
  font-family: "Inter Variable";
  src: url("/static/fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900; font-style: normal; font-display: swap;
  size-adjust: 107%; ascent-override: 90%; descent-override: 22.4%; line-gap-override: 0%;
}
@font-face {
  font-family: "JetBrains Mono Variable";
  src: url("/static/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 800; font-style: normal; font-display: swap;
  size-adjust: 100%; ascent-override: 102%; descent-override: 30%; line-gap-override: 0%;
}

/* 2. Tokens ---------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* surfaces */
  --bg: #f6f7f9;
  --bg-subtle: #eff1f4;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --code-bg: #f4f5f8;
  --row-hover: #f7f8fa;

  /* borders */
  --rule: 1px;
  --border: #e3e6eb;
  --border-strong: #cdd2da;

  /* text */
  --text: #161a20;
  --text-muted: #565e6b;
  --text-subtle: #5e6773;     /* AA on --bg-subtle (4.7:1) */
  --text-on-accent: #ffffff;

  /* accent — the only accent; appears where you can act */
  --accent: #2a5bdb;
  --accent-hover: #2450c4;
  --accent-press: #1e45af;
  --accent-soft: #eaf0fe;
  --accent-line: #c9d8fb;
  --accent-text: #2450c4;
  --accent-ring: rgba(42, 91, 219, .32);
  --focus-ring: #2a5bdb;

  /* status tones (text / soft bg / line) */
  --ok: #0e6b3e;            --ok-soft: #e6f4ec;          --ok-line: #c4e3d1;
  --warn: #8a5a00;          --warn-soft: #fbf0d9;        --warn-line: #ebd3a0;
  --err: #b42318;           --err-soft: #fdecea;         --err-line: #f3c6c0;
  --neutral: #5c6470;       --neutral-soft: #eef0f3;     --neutral-line: #d8dce3;
  --info: #2450c4;          --info-soft: #eaf0fe;        --info-line: #c9d8fb;
  --ok-ring: rgba(14, 107, 62, .28);
  --err-ring: rgba(180, 35, 24, .26);

  --selection-bg: #eaf0fe;
  --scrim: rgba(12, 16, 22, .44);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, .10);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .22);

  /* chrome / instrument bezel — identical in both themes */
  --chrome-bg: #14171b;
  --chrome-bg-hover: #1e2228;
  --chrome-active: rgba(255, 255, 255, .075);
  --chrome-border: #262b33;
  --chrome-text: #e6e9ee;
  --chrome-muted: #9aa3af;
  --chrome-faint: #838c99;
  --chrome-accent: #6e96ff;

  /* geometry — one value per dimension, used everywhere */
  --r-control: 6px;
  --r-panel: 10px;
  --r-dialog: 12px;
  --r-chip: 4px;
  --r-notice: 8px;
  --rail-w: 232px;
  --bar-h: 28px;
  --row-h: 40px;
  --head-h: 36px;
  --panel-head-h: 44px;
  --panel-inset: 20px;
  --control-h: 32px;      /* page controls */
  --control-h-sm: 28px;   /* in-row controls */
  --control-h-lg: 40px;   /* form submits */

  /* spacing scale — only these gaps exist */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px; --s16: 64px;

  --font-ui: "Inter Variable", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-std: cubic-bezier(.2, 0, 0, 1);
  --dur-1: 90ms;
  --dur-2: 160ms;
}

/* No-JS fallback: honor the OS preference when theme.js did not run. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
  color-scheme: dark;
      --bg: #0f1115;
      --bg-subtle: #16181d;
      --surface: #191c22;
      --surface-raised: #1f232a;
      --code-bg: #11141a;
      --row-hover: #1e2229;
      --border: #262c35;
      --border-strong: #39414d;
      --text: #e7eaf0;
      --text-muted: #a0a8b5;
      --text-subtle: #8b95a3;
      --text-on-accent: #0a0f1a;
      --accent: #5b8cff;
      --accent-hover: #7aa2ff;
      --accent-press: #4a7bef;
      --accent-soft: #16233f;
      --accent-line: #29406e;
      --accent-text: #8fb0ff;
      --accent-ring: rgba(91, 140, 255, .36);
      --focus-ring: #6e96ff;
      --ok: #6bd39a;     --ok-soft: #0f2a1d;     --ok-line: #1e4632;
      --warn: #f2c04e;   --warn-soft: #2a2210;   --warn-line: #4a3a16;
      --err: #f98076;    --err-soft: #2e1514;    --err-line: #552421;
      --neutral: #a6aebb; --neutral-soft: #1e232b; --neutral-line: #2e353f;
      --info: #9dbbff;   --info-soft: #131f3a;   --info-line: #263a66;
      --ok-ring: rgba(107, 211, 154, .30);
      --err-ring: rgba(249, 128, 118, .30);
      --selection-bg: #16233f;
      --scrim: rgba(0, 0, 0, .62);
      --shadow-sm: 0 1px 2px rgba(0, 0, 0, .50);
      --shadow-md: 0 4px 14px -2px rgba(0, 0, 0, .55);
      --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, .72);
      /* chrome is intentionally NOT redeclared — the bezel never inverts */
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-subtle: #16181d;
  --surface: #191c22;
  --surface-raised: #1f232a;
  --code-bg: #11141a;
  --row-hover: #1e2229;
  --border: #262c35;
  --border-strong: #39414d;
  --text: #e7eaf0;
  --text-muted: #a0a8b5;
  --text-subtle: #8b95a3;
  --text-on-accent: #0a0f1a;
  --accent: #5b8cff;
  --accent-hover: #7aa2ff;
  --accent-press: #4a7bef;
  --accent-soft: #16233f;
  --accent-line: #29406e;
  --accent-text: #8fb0ff;
  --accent-ring: rgba(91, 140, 255, .36);
  --focus-ring: #6e96ff;
  --ok: #6bd39a;     --ok-soft: #0f2a1d;     --ok-line: #1e4632;
  --warn: #f2c04e;   --warn-soft: #2a2210;   --warn-line: #4a3a16;
  --err: #f98076;    --err-soft: #2e1514;    --err-line: #552421;
  --neutral: #a6aebb; --neutral-soft: #1e232b; --neutral-line: #2e353f;
  --info: #9dbbff;   --info-soft: #131f3a;   --info-line: #263a66;
  --ok-ring: rgba(107, 211, 154, .30);
  --err-ring: rgba(249, 128, 118, .30);
  --selection-bg: #16233f;
  --scrim: rgba(0, 0, 0, .62);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .50);
  --shadow-md: 0 4px 14px -2px rgba(0, 0, 0, .55);
  --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, .72);
  /* chrome is intentionally NOT redeclared — the bezel never inverts */
}

/* 3. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 18px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-variant-ligatures: none;
}
h1, h2, h3, h4, p, ul, ol, dl, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent-text); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; text-decoration-thickness: 1px; }
strong, b { font-weight: 600; }
:where(a, button, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--r-control);
}
/* Text controls use their own border + glow focus, so no doubled outline. */
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
.checkbox:focus-visible, .check input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
::selection { background: var(--selection-bg); }
hr { border: 0; border-top: 1px solid var(--border); margin: 0; }
img, svg { display: block; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums slashed-zero; }
.tnum { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.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;
}
.skip-link {
  position: fixed; left: var(--s4); top: var(--s4); z-index: 100;
  padding: var(--s2) var(--s3); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-control);
  transform: translateY(-200%); transition: transform var(--dur-2) var(--ease-out);
}
.skip-link:focus { transform: none; }

/* 4. Icons — one geometry: 24-grid, 1.75 stroke, round ---------------------- */
.i { flex: none; fill: none; stroke: currentColor; stroke-width: 1.75;
     stroke-linecap: round; stroke-linejoin: round; }
.i-16 { width: 16px; height: 16px; }
.i-20 { width: 20px; height: 20px; }

/* 5. Chrome ---------------------------------------------------------------- */
.signalbar {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  height: var(--bar-h);
  display: grid; grid-template-columns: auto 1fr auto; align-items: stretch;
  min-width: 0;
  background: var(--chrome-bg); border-bottom: 1px solid var(--chrome-border);
  color: var(--chrome-text);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 0 var(--s3) 0 0;
}
.signalbar__brand {
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s3) 0 var(--s4); border-right: 1px solid var(--chrome-border);
  color: var(--chrome-text); letter-spacing: .14em; font-size: 11px;
}
.signalbar__brand .i { color: var(--chrome-accent); }
.signalbar__brand:hover { text-decoration: none; }
.sb-chip {
  height: 16px; display: inline-flex; align-items: center; padding: 0 5px;
  border: 1px solid var(--chrome-border); border-radius: var(--r-chip);
  color: var(--chrome-muted); font-size: 9.5px; letter-spacing: .12em;
}
.signalbar__mid { display: flex; align-items: center; }
.signalbar__right { display: flex; align-items: stretch; min-width: 0; }
.signalbar__brand { min-width: 0; overflow: hidden; }
.sigbits { display: flex; align-items: stretch; }
.sigbit {
  display: flex; align-items: center; gap: var(--s1); padding: 0 var(--s3);
  border-left: 1px solid var(--chrome-border);
}
.sigbit__k { color: var(--chrome-faint); }
.sigbit__v { color: var(--chrome-text); font-variant-numeric: tabular-nums; }
.sigbit__v.is-warn { color: #f2c04e; }
.sigbit__v.is-err { color: #ff8f84; }
.clock { display: flex; align-items: center; padding: 0 var(--s3); border-left: 1px solid var(--chrome-border);
         color: var(--chrome-muted); font-variant-numeric: tabular-nums; }
.avatarbtn {
  display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s3);
  border: 0; border-left: 1px solid var(--chrome-border); background: none; cursor: pointer;
  color: var(--chrome-text); font: inherit; letter-spacing: .1em;
}
.avatarbtn:hover { background: var(--chrome-bg-hover); }
.avatar {
  width: 22px; height: 22px; display: grid; place-items: center; flex: none;
  border-radius: 5px; background: #2a2f38; border: 1px solid var(--chrome-border);
  color: var(--chrome-text); font-family: var(--font-mono); font-size: 9.5px; font-weight: 600; letter-spacing: 0;
}
.themeswitch {
  display: inline-flex; align-items: center; gap: 6px; height: 18px; padding: 3px 0; box-sizing: content-box;
  border: 0; background: none; cursor: pointer;
  color: var(--chrome-muted); font: inherit; letter-spacing: .1em;
}
.themeswitch:hover { color: var(--chrome-text); }
.themeswitch__track {
  position: relative; width: 30px; height: 16px; border-radius: 999px;
  background: var(--chrome-bg-hover); border: 1px solid var(--chrome-border);
}
.themeswitch__knob {
  position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--chrome-muted); transition: transform var(--dur-2) var(--ease-out), background var(--dur-2);
}
.themeswitch[aria-checked="true"] .themeswitch__knob { transform: translateX(14px); background: var(--chrome-accent); }

/* Rail ---------------------------------------------------------------------- */
.rail {
  position: fixed; top: var(--bar-h); bottom: 0; left: 0; z-index: 30;
  width: var(--rail-w); display: flex; flex-direction: column;
  background: var(--chrome-bg); border-right: 1px solid var(--chrome-border);
  padding: var(--s3); color: var(--chrome-text);
}
.rail__head { display: flex; align-items: center; gap: var(--s2); height: 40px; padding: 0 var(--s2); }
.rail__mark { color: var(--chrome-accent); }
.rail__name { font-size: 14px; font-weight: 600; letter-spacing: -.01em; color: var(--chrome-text); }
.rail__env {
  margin: 0 0 var(--s3); padding: 6px var(--s2);
  border: 1px solid var(--chrome-border); border-radius: var(--r-control);
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--chrome-faint);
}
.rail__env b { color: var(--chrome-text); font-weight: 600; }
.rail__nav { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.rail__spacer { flex: 1; }
.rail__group {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--chrome-faint); padding: var(--s3) var(--s2) var(--s1);
}
.rail__foot { border-top: 1px solid var(--chrome-border); padding-top: var(--s3); margin-top: var(--s3); }
.navitem {
  position: relative; display: flex; align-items: center; gap: 10px;
  height: 30px; padding: 0 var(--s2); border-radius: var(--r-control);
  color: var(--chrome-muted); font-size: 12.5px; font-weight: 500; white-space: nowrap;
}
.navitem:hover { background: var(--chrome-bg-hover); color: var(--chrome-text); text-decoration: none; }
.navitem .i { color: var(--chrome-muted); }
.navitem__count {
  margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--chrome-faint);
  font-variant-numeric: tabular-nums;
}
.navitem[aria-current="page"] { background: var(--chrome-active); color: #fff; }
.navitem[aria-current="page"] .i { color: var(--chrome-accent); }
.navitem[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px;
  border-radius: 1px; background: var(--chrome-accent);
}
.rail__user { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s2) var(--s1); }
.rail__userinfo { min-width: 0; flex: 1; }
.rail__username { font-size: 12px; font-weight: 500; color: var(--chrome-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail__userrole { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--chrome-faint); }
.iconbtn {
  display: grid; place-items: center; width: var(--control-h-sm); height: var(--control-h-sm);
  border-radius: var(--r-control); border: 1px solid transparent; background: none;
  color: var(--chrome-muted); cursor: pointer;
}
.iconbtn:hover { background: var(--chrome-bg-hover); color: var(--chrome-text); }
.navToggle { display: none; }

/* 6. Composition ----------------------------------------------------------- */
.shell { padding-top: var(--bar-h); min-height: 100vh; }
.main { margin-left: var(--rail-w); }
.page {
  width: 100%; max-width: 1320px; padding: var(--s6) var(--s8) var(--s16);
}
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s6);
  padding-bottom: var(--s5); margin-bottom: var(--s6); border-bottom: 1px solid var(--border);
}
.eyebrow {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-subtle); margin-bottom: var(--s1);
}
.page-title { font-size: 24px; line-height: 28px; font-weight: 600; letter-spacing: -.02em; color: var(--text); }
.page-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2);
  font-size: 12.5px; color: var(--text-muted);
}
.page-meta > * + *::before { content: "·"; margin-right: var(--s2); color: var(--text-subtle); }
.page-actions { display: flex; align-items: center; gap: var(--s2); flex-shrink: 0; }
.section { margin-top: var(--s8); min-width: 0; }
.section:first-child { margin-top: 0; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s3); }
.section__title { font-size: 16px; line-height: 22px; font-weight: 600; letter-spacing: -.01em; }
.section__link { font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; min-height: 24px; }

/* 7. Primitives ------------------------------------------------------------ */

/* Buttons — one height per register; never mixed in a row. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-h); padding: 0 var(--s3);
  border: 1px solid var(--border-strong); border-radius: var(--r-control);
  background: var(--surface); color: var(--text);
  font-family: var(--font-ui); font-size: 12.5px; font-weight: 560; line-height: 1;
  white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1);
}
.btn:hover { background: var(--bg-subtle); border-color: var(--text-subtle); text-decoration: none; }
.btn:active { background: var(--bg-subtle); }
.btn .i { margin-left: -1px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:active { background: var(--accent-press); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--bg-subtle); color: var(--text); border-color: transparent; }
.rail .btn--ghost { color: var(--chrome-muted); }
.rail .btn--ghost:hover { background: var(--chrome-bg-hover); color: var(--chrome-text); }
.btn--danger { background: transparent; border-color: transparent; color: var(--err); }
.btn--danger:hover { background: var(--err-soft); color: var(--err); border-color: var(--err-line); }
.btn--danger-solid { background: var(--err); border-color: var(--err); color: #fff; }
.btn--danger-solid:hover { filter: brightness(.93); border-color: var(--err); }
.btn--sm { height: var(--control-h-sm); padding: 0 10px; font-size: 12px; }
.btn--lg { height: var(--control-h-lg); padding: 0 var(--s4); font-size: 13.5px; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center;
  width: var(--control-h-sm); height: var(--control-h-sm); padding: 0;
  border: 1px solid transparent; border-radius: var(--r-control); background: none;
  color: var(--text-muted); cursor: pointer; }
.btn-icon:hover { background: var(--bg-subtle); color: var(--text); }
.btn-icon[data-copied="true"] { color: var(--ok); }

/* Status chip — the single status primitive. Shape + word + tone, never color alone. */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 7px 0 6px; border-radius: var(--r-chip);
  border: 1px solid var(--neutral-line); background: var(--neutral-soft); color: var(--neutral);
  font-size: 10.5px; font-weight: 600; line-height: 1; letter-spacing: .045em;
  text-transform: uppercase; white-space: nowrap; font-family: var(--font-ui);
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip { box-shadow: inset 0 0 0 .5px rgba(255,255,255,.25); }
.chip--ok { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.chip--ok::before { border-radius: 50%; }
.chip--warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.chip--warn::before {
  width: 0; height: 0; border-radius: 0; background: none;
  border-left: 3.5px solid transparent; border-right: 3.5px solid transparent;
  border-bottom: 6px solid currentColor;
}
.chip--err { color: var(--err); background: var(--err-soft); border-color: var(--err-line); }
.chip--err::before {
  background: currentColor; border-radius: 1.5px; width: 6px; height: 6px;
  clip-path: polygon(28% 0, 72% 0, 100% 28%, 100% 72%, 72% 100%, 28% 100%, 0 72%, 0 28%);
}
.chip--pending { color: var(--neutral); background: var(--neutral-soft); border-color: var(--neutral-line); }
.chip--pending::before { background: none; border: 1.5px solid currentColor; }
.chip--info { color: var(--info); background: var(--info-soft); border-color: var(--info-line); }
.chip--idle { color: var(--neutral); background: var(--neutral-soft); border-color: var(--neutral-line); }
.chip--idle::before { opacity: .55; }
.count {
  display: inline-flex; align-items: center; height: 18px; padding: 0 5px; border-radius: var(--r-chip);
  background: var(--neutral-soft); color: var(--neutral); border: 1px solid var(--neutral-line);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.rolechip {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: var(--r-chip);
  border: 1px solid var(--border-strong); color: var(--text-muted);
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}

/* KPI strip — one panel divided by true 1px separators (gap-on-background). */
.kpis {
  display: grid; grid-template-columns: repeat(var(--kpi-cols, 3), minmax(0, 1fr));
  gap: 1px; background: var(--border); border: 1px solid var(--border);
  border-radius: var(--r-panel); overflow: hidden; margin-bottom: var(--s6);
}
.kpi { background: var(--surface); padding: var(--s4) var(--s5); min-height: 92px;
  display: flex; flex-direction: column; justify-content: center; }
.kpi__label {
  font-size: 10.5px; font-weight: 600; line-height: 14px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-subtle);
}
.kpi__row { display: flex; align-items: baseline; gap: 6px; margin-top: 6px; letter-spacing: 0; }
.kpi__value {
  font-family: var(--font-mono); font-size: 24px; line-height: 28px; font-weight: 500;
  letter-spacing: -.02em; color: var(--text) !important; font-variant-numeric: tabular-nums;
}
.kpi__unit { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-subtle); }
.kpi__note { font-size: 12px; line-height: 16px; color: var(--text-muted); margin-top: 4px; }
.kpi--alert .kpi__value { color: var(--err) !important; }

/* Panel — the only container. Never nested. */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-panel);
  overflow: clip; margin-bottom: var(--s4); min-width: 0;
}
.panel:last-child { margin-bottom: 0; }
.panel__head {
  height: var(--panel-head-h); padding: 0 var(--panel-inset);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  border-bottom: 1px solid var(--border);
}
.panel__head-left { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.panel__title { font-size: 13px; font-weight: 600; letter-spacing: -.005em; }
.panel__head-right { display: flex; align-items: center; gap: var(--s2); }
.panel__body { padding: var(--s5); }
.panel__body--flush { padding: 0; }
.panel__foot {
  height: 36px; padding: 0 var(--panel-inset); display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border); background: var(--bg-subtle);
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-subtle);
}
.panel__note { padding: var(--s3) var(--panel-inset) var(--s4); border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-muted); }
.panel { isolation: isolate; }
.panel .panel { border-radius: 0; border-left: 0; border-right: 0; margin: 0; }

/* Tables — one canonical pattern on every screen. */
.table-wrap {
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent; position: relative;
}
.table-wrap--more { background-image: linear-gradient(to left, var(--surface) 0, transparent 24px); background-attachment: local; }
.table-wrap::-webkit-scrollbar { height: 10px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
caption.sr-only { }
thead th {
  height: var(--head-h); padding: 0 var(--panel-inset); font-size: 10.5px;
  background: var(--bg-subtle); border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap; position: sticky; top: 0; z-index: 2;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-muted);
}
/* Sticky first column keeps the identity cell visible while scrolling the rest. */
.table-wrap table th.col-id, .table-wrap table td.cell-id:first-child { position: sticky; left: 0; z-index: 1;
  background: var(--surface); box-shadow: 1px 0 0 var(--border); }
.table-wrap thead th:first-child { z-index: 3; background: var(--bg-subtle); }
tbody td {
  height: var(--row-h); padding: 0 var(--panel-inset); border-bottom: 1px solid var(--border);
  vertical-align: middle; color: var(--text);
}
tbody td { white-space: nowrap; }
td.cell-sub { white-space: normal; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--dur-1); }
tbody tr:hover td { background: var(--row-hover); }
th.num, td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td.num { font-size: 12.5px; }
td.num { font-weight: 450; }
td.mono, .cell-id { font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums slashed-zero; }
.cell-time { font-family: var(--font-mono); font-size: 12px; color: var(--text-subtle); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-secondary { color: var(--text-muted); font-size: 12.5px; }
.cell-strong { font-weight: 550; }
.cell-actions { text-align: right; white-space: nowrap; }
th.cell-actions { text-align: right; }
.col-check { width: 44px; }
.col-id { width: 120px; }
.col-mono { width: 168px; }
.col-money { width: 128px; }
.col-status { width: 124px; }
.col-time { width: 152px; }
.col-actions { width: 96px; }
.col-source { width: 140px; }      /* event-log source */
.col-meter { width: 200px; }       /* cap-usage meter */
.col-capinput { width: 164px; }    /* inline "set cap" form */
.col-rowform { width: 264px; }     /* inline "mark paid" form */
.col-role { width: 120px; }
table.fixed { table-layout: fixed; }
.stack { display: flex; flex-direction: column; gap: 1px; }
.stack__main { font-size: 13px; }
.stack__sub { font-size: 11.5px; color: var(--text-subtle); font-family: var(--font-mono); }

/* Empty state — identical position on every table. */
.empty {
  min-height: 168px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: var(--s6); text-align: center;
}
.empty__icon {
  width: 36px; height: 36px; display: grid; place-items: center; margin-bottom: 2px;
  border-radius: 50%; background: var(--bg-subtle); color: var(--text-subtle);
}
.empty__title { font-size: 13px; font-weight: 600; color: var(--text); }
.empty__text { font-size: 12.5px; color: var(--text-muted); max-width: 42ch; }
.empty__action { margin-top: var(--s2); }

/* Inline row forms (Mark paid, Set cap) — nowrap, shared control height. */
.rowform { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.rowform .input, .rowform .btn { height: var(--control-h-sm); }
.rowform .input { width: 200px; font-size: 12px; }
.rowform .input--narrow { width: 92px; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Batch bar — replaces panel head while rows are selected; a plain form. */
.batchbar {
  height: var(--panel-head-h); padding: 0 var(--panel-inset); display: flex; align-items: center; gap: var(--s2);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.batchbar__note { margin-left: auto; font-size: 11.5px; color: var(--text-subtle); }
.batchbar label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; }

/* Forms — 12-col grid; 16px gutters; the only grouping is a fieldset. */
.form { display: flex; flex-direction: column; }
.form-row { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s4); margin-bottom: var(--s4); }
.form-row:last-child { margin-bottom: 0; }
.field { grid-column: span 6; min-width: 0; }
.field--xs { grid-column: span 2; }
.field--sm { grid-column: span 3; }
.field--md { grid-column: span 4; }
.field--lg { grid-column: span 8; }
.field--full { grid-column: 1 / -1; }
.field > label {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  margin-bottom: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-muted);
}
.label-opt { font-size: 11px; font-weight: 400; color: var(--text-subtle); }
.input, select.input, textarea.input {
  width: 100%; height: var(--control-h-lg); padding: 0 var(--s3);
  border: 1px solid var(--border-strong); border-radius: var(--r-control);
  background: var(--surface); color: var(--text);
  font-family: var(--font-ui); font-size: 13.5px; line-height: 20px;
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
/* On coarse pointers, 16px minimum avoids iOS ZooM-on-focus while keeping the
   desktop 13.5px register. */
@media (pointer: coarse) {
  .input, select.input, textarea.input, .auth .input, .rowform .input { font-size: 16px; }
}
.input::placeholder { color: var(--text-subtle); }
.input:hover { border-color: var(--text-subtle); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
select.input {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23565e6b' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6.5 9.5 5.5 5.5 5.5-5.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
:root[data-theme="dark"] select.input {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a0a8b5' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6.5 9.5 5.5 5.5 5.5-5.5'/%3E%3C/svg%3E");
}
textarea.input { height: auto; min-height: 96px; padding: 10px var(--s3); resize: vertical; line-height: 20px; }
.input--mono { font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums slashed-zero; }
.input--sm { height: var(--control-h); font-size: 12.5px; }
.field--sm .input, .field--xs .input { height: var(--control-h-lg); }
.field__hint, .field__error { display: block; margin-top: 6px; font-size: 12px; line-height: 16px; min-height: 16px; }
.field__hint { color: var(--text-subtle); }
.field__error { color: var(--err); font-weight: 500; }
.field__error::before {
  content: ""; display: inline-block; width: 0; height: 0; margin-right: 5px; vertical-align: 1px;
  border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-bottom: 6px solid currentColor;
}
.input[aria-invalid="true"] { border-color: var(--err); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--err-ring); }
.check { display: flex; align-items: center; gap: var(--s2); padding: 4px 0; font-size: 13px; cursor: pointer; }
.check input[type="checkbox"], .checkbox {
  appearance: none; width: 16px; height: 16px; margin: 0; flex: none;
  border: 1.5px solid var(--border-strong); border-radius: 4px; background: var(--surface);
  cursor: pointer; display: grid; place-items: center; transition: background var(--dur-1), border-color var(--dur-1);
}
.checkbox:hover { border-color: var(--text-subtle); }
.checkbox:checked { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::after {
  content: ""; width: 9px; height: 5px; border-left: 1.75px solid #fff; border-bottom: 1.75px solid #fff;
  transform: rotate(-45deg) translate(0, -1px);
}
.checkbox:indeterminate { background: var(--accent); border-color: var(--accent); }
.checkbox:indeterminate::after { content: ""; width: 8px; height: 1.75px; background: #fff; }
/* Enlarge the hit area to 24px without moving layout. */
.checkbox { position: relative; }
.checkbox::before { content: ""; position: absolute; inset: -6px; }
fieldset { border: 0; padding: 0; margin: 0 0 var(--s4); }
fieldset:last-of-type { margin-bottom: 0; }
legend {
  display: flex; align-items: center; gap: var(--s3); width: 100%; padding: 0; margin-bottom: var(--s4);
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-subtle);
}
legend::after { content: ""; flex: 1; height: 1px; background: var(--border); }
fieldset + fieldset { border-top: 1px solid var(--border); padding-top: var(--s5); margin-top: var(--s5); }
.form-actions { display: flex; align-items: center; gap: var(--s2); padding-top: var(--s4); margin-top: var(--s1);
  border-top: 1px solid var(--border); }
.form-actions__push { margin-left: auto; }
.panel .form-actions { border-top: 0; padding-top: 0; margin-top: var(--s5); }

/* Segmented filter / tabs */
.segmented {
  display: inline-flex; flex-wrap: wrap; gap: 1px; max-width: 100%; background: var(--border); border: 1px solid var(--border);
  border-radius: var(--r-notice); overflow: hidden;
}
.segmented > a, .segmented > button {
  display: inline-flex; align-items: center; height: 30px; padding: 0 var(--s3);
  background: var(--surface); color: var(--text-muted);
  font-size: 12.5px; font-weight: 500; border: 0; cursor: pointer;
}
.segmented > a:hover, .segmented > button:hover { color: var(--text); text-decoration: none; }
.segmented > [aria-current="page"], .segmented > [aria-pressed="true"] {
  color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent);
}
.filterbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s4);
}
.filterbar__label { font-size: 12px; color: var(--text-muted); }
.filterbar select.input { width: auto; min-width: 160px; height: var(--control-h); font-size: 12.5px; }
.filterbar__count { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-subtle); }

/* Flash / alerts / toast */
.flash {
  display: flex; align-items: flex-start; gap: var(--s2); padding: 10px var(--s3); margin-bottom: var(--s4);
  border: 1px solid var(--info-line); border-left: 2px solid var(--info); border-radius: var(--r-notice);
  background: var(--info-soft); color: var(--info); font-size: 12.5px;
}
.flash .i { margin-top: 1px; }
.flash--ok { border-color: var(--ok-line); border-left-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.flash--err { border-color: var(--err-line); border-left-color: var(--err); background: var(--err-soft); color: var(--err); }
.flash--warn { border-color: var(--warn-line); border-left-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.flash__body { color: var(--text); }
.flash__title { font-weight: 600; }
.error-summary {
  padding: var(--s3) var(--s4); margin-bottom: var(--s5); border: 1px solid var(--err-line);
  border-left: 2px solid var(--err); border-radius: var(--r-notice); background: var(--err-soft);
}
.error-summary__title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--err); margin-bottom: var(--s2); }
.error-summary ul { list-style: disc; padding-left: var(--s5); }
.error-summary a { color: var(--err); font-weight: 500; font-size: 12.5px; }
.toast {
  position: fixed; right: var(--s4); bottom: var(--s4); z-index: 60;
  width: min(340px, calc(100vw - 32px)); display: flex; align-items: center; gap: 10px;
  padding: 10px var(--s3); border: 1px solid var(--border-strong); border-radius: var(--r-notice);
  background: var(--surface-raised); box-shadow: var(--shadow-lg);
  font-size: 12.5px; color: var(--text);
  animation: toast-in var(--dur-2) var(--ease-out);
}
.toast .i { color: var(--ok); }
.toast.is-leaving { animation: toast-out 120ms ease-in forwards; }
.toast__msg { flex: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; } }

/* Copy affordance */
.copyable { display: inline-flex; align-items: center; gap: 6px; }
.address { display: flex; flex-direction: column; gap: var(--s2); }
.address__label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-subtle); }
.address__row { display: flex; align-items: center; gap: var(--s2); }
.address__value {
  flex: 1; min-width: 0; display: flex; align-items: center; height: var(--control-h-lg);
  font-family: var(--font-mono); font-size: 13px; line-height: 20px;
  color: var(--text); word-break: break-all; padding: 0 var(--s3);
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r-control);
}

/* Code block */
.codeblock { border: 1px solid var(--border); border-radius: var(--r-notice); background: var(--code-bg); overflow: hidden; }
.codeblock__bar {
  height: 32px; padding: 0 var(--s3); display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-subtle);
}
.codeblock pre { margin: 0; padding: var(--s3); overflow-x: auto; tab-size: 2; }
.codeblock code { font-family: var(--font-mono); font-size: 12px; line-height: 18px; color: var(--text); }
code.inline, .inline-code {
  font-family: var(--font-mono); font-size: 12px; padding: 1px 5px; border-radius: 4px;
  background: var(--code-bg); border: 1px solid var(--border); color: var(--text);
}

/* Key reveal — one-once secret, high-emphasis but never alarming */
.reveal {
  border: 1px solid var(--accent-line); border-radius: var(--r-panel); background: var(--accent-soft);
  padding: var(--s4) var(--s5); margin-bottom: var(--s4);
}
.reveal__title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--accent-text); }
.reveal__text { margin-top: 4px; font-size: 12.5px; color: var(--text); }
.reveal__key {
  display: flex; align-items: center; gap: var(--s2); margin-top: var(--s3);
  padding: 3px 3px 3px var(--s3); height: var(--control-h-lg);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-control);
}
.reveal__key code { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 13px; word-break: break-all; }

/* Detail disclosure */
details.disclosure { border: 1px solid var(--border); border-radius: var(--r-panel); background: var(--surface); margin-bottom: var(--s4); }
details.disclosure > summary {
  display: flex; align-items: center; gap: var(--s2); height: var(--panel-head-h); padding: 0 var(--panel-inset);
  cursor: pointer; font-size: 13px; font-weight: 600; list-style: none;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary .i { color: var(--text-subtle); transition: transform var(--dur-2) var(--ease-out); }
details.disclosure[open] > summary { border-bottom: 1px solid var(--border); }
details.disclosure[open] > summary .i { transform: rotate(90deg); }
details.disclosure__body { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s3); font-size: 12.5px; color: var(--text-muted); }

/* Stacked page flow */
.layout-stack { display: flex; flex-direction: column; gap: var(--s8); }

/* Split layout */
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.split > * { min-width: 0; }
.page { min-width: 0; }
.split--even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.stack-v { display: flex; flex-direction: column; gap: var(--s4); }
.note { font-size: 12.5px; color: var(--text-muted); margin: 0 0 var(--s4); }
.panel__body > .note:last-child, .disclosure__body > .note:last-child { margin-bottom: 0; }
.note + .form, .note--lead + .form { margin-top: var(--s4); }
.lead-note { margin-bottom: var(--s4); }
.note-area { padding: var(--s3) var(--panel-inset); font-size: 12.5px; color: var(--text-muted);
  border-top: 1px solid var(--border); background: var(--bg-subtle); }
.kv { display: flex; flex-direction: column; gap: var(--s1); }
.kv__k { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-subtle); }
.kv__v { font-family: var(--font-mono); font-size: 13px; color: var(--text); }

/* Progress meter for caps */
.meter { display: flex; flex-direction: column; gap: 5px; min-width: 140px; max-width: 200px; }
.meter--end { margin-left: auto; }
.meter__bar { height: 4px; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
.meter__fill { height: 100%; border-radius: 999px; background: var(--accent); }
.meter__fill.is-warn { background: var(--warn); }
.meter__fill.is-err { background: var(--err); }
.meter--end { text-align: left; }
.meter__label { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Login — a single field, centred, on the dark bezel */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: var(--s6);
  background: var(--chrome-bg); color: var(--chrome-text);
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.05) 1px, transparent 0);
  background-size: 22px 22px;
}
.auth__card {
  width: 100%; max-width: 380px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-panel); box-shadow: var(--shadow-lg);
  padding: var(--s6);
}
.auth__brand { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s5); }
.auth__mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); }
.auth__title { font-size: 20px; line-height: 26px; font-weight: 600; letter-spacing: -.02em; margin-bottom: 4px; }
.auth__sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: var(--s5); }
.auth .field { grid-column: 1 / -1; }
.auth .input { font-family: var(--font-mono); font-size: 13px; letter-spacing: .02em; }
.auth .btn--lg { margin-top: var(--s4); }
.auth__foot { margin-top: var(--s4); font-size: 12px; color: var(--text-muted); line-height: 17px; }

/* Small utilities used by templates */
.flex { display: flex; align-items: center; gap: var(--s2); }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--s1); } .gap-3 { gap: var(--s3); } .gap-4 { gap: var(--s4); }
.w-full { width: 100%; }
.maxw-form { max-width: 620px; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: var(--s4); } .mt-6 { margin-top: var(--s6); }
.text-right { text-align: right; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a.inline-link { color: var(--accent-text); font-weight: 500; }
.dimmed { opacity: .5; }

/* 8. Motion preferences ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

/* 8. Responsive ------------------------------------------------------------ */
@media (max-width: 1280px) {
  .split, .split--even { grid-template-columns: 1fr; }
  .page { padding: var(--s6) var(--s6) var(--s12); }
}
@media (max-width: 960px) {
  .main { margin-left: 0; }
  .rail {
    top: var(--bar-h); left: 0; right: 0; bottom: auto; width: auto; height: auto;
    flex-direction: column; align-items: stretch; padding: 0; border-right: 0;
    border-bottom: 1px solid var(--chrome-border);
  }
  .rail__head, .rail__env, .rail__group, .rail__userinfo, .rail__spacer { display: none; }
  .rail__nav { flex-direction: row; gap: 2px; overflow-x: auto; align-items: stretch; height: 46px;
    padding: 0 var(--s3); scrollbar-width: none; }
  .rail__nav::-webkit-scrollbar { display: none; }
  .navitem { height: 46px; border-radius: 0; padding: 0 10px; }
  .navitem[aria-current="page"] { background: none; }
  .navitem[aria-current="page"]::before { inset: auto 4px 0 4px; width: auto; height: 2px; border-radius: 0; }
  .navitem__count { display: none; }
  /* Keep sign-out reachable on phones without stealing a row: pin the rail foot
     to the right edge of the 46px strip and reserve space in the scrollable nav
     so items never sit underneath it. */
  .rail { position: relative; }
  .rail__nav { padding-right: 84px; }
  .rail__foot { border: 0; margin: 0; padding: 0; position: absolute; right: 0; top: 0; height: 46px;
    display: flex; align-items: stretch; background: var(--chrome-bg);
    border-left: 1px solid var(--chrome-border); }
  .rail__user { display: none; }
  .rail__signout { display: block; height: 46px; }
  .rail__signout .btn { height: 46px; padding: 0 var(--s3); gap: var(--s1);
    justify-content: center; color: var(--chrome-muted); border-radius: 0; }
  .rail__signout .btn:hover { background: var(--chrome-bg-hover); color: var(--chrome-text); }
  .shell { padding-top: var(--bar-h); }
  .main { padding-top: 46px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { flex-direction: column; gap: var(--s3); }
  .page-actions { width: 100%; }
  .sigbits .sigbit:not(.sigbit--keep):nth-child(n+2) { display: none; }
  .page-head { margin-bottom: var(--s5); }
}
@media (max-width: 720px) {
  .page { padding: var(--s5) var(--s4) var(--s10); }
  .page-title { font-size: 20px; line-height: 26px; }
  .field, .field--xs, .field--sm, .field--md, .field--lg { grid-column: 1 / -1; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1; }
  .kpis { grid-template-columns: 1fr; }
  .kpi { min-height: 80px; padding: var(--s3) var(--s4); }
  .panel__body { padding: var(--s4); }
  thead th, tbody td { padding: 0 var(--s4); }
  .batchbar { height: auto; padding-bottom: var(--s2); }
  .batchbar__note { margin-left: 0; }
  .sigbits { display: none; }
  .clock { display: none; }
  .avatarbtn span { display: none; }
}
@media (max-width: 480px) {
  .page { padding: var(--s4) var(--s3) var(--s10); }
  .avatar__label { display: none; }
  .address__row { flex-direction: column; align-items: stretch; }
  .address__row .btn { justify-content: center; }
}

/* Alert list (admin overview) */
.alertlist { display: flex; flex-direction: column; }
.alertlist__item { display: flex; gap: var(--s3); padding: var(--s3) var(--panel-inset); border-bottom: 1px solid var(--border); }
.alertlist__item:last-child { border-bottom: 0; }
.alertlist__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--err); margin-top: 6px; flex: none; }
.alertlist__body { min-width: 0; }
.alertlist__msg { font-size: 12.5px; line-height: 18px; color: var(--text); }
.alertlist__meta .cell-time { font-size: 11.5px; }
.alertlist__meta { font-size: 11.5px; color: var(--text-subtle); margin-top: 2px; display: flex; gap: 6px; align-items: center; }
