/* ═══════════════════════════════════════════════════════════════════════
   Vortex Licensing — operations console.
   Self-contained. No CDN, no build step.

   1. Tokens        2. Reset       3. Shell        4. Rail
   5. Page head     6. Cards       7. Tables       8. Pills & chips
   9. Buttons      10. Forms      11. Alerts      12. Stats
  13. Toolbar      14. Pager      15. Modal       16. Toast
  17. Gate         18. Utilities
   ═══════════════════════════════════════════════════════════════════════ */

/* ── 1. Tokens ───────────────────────────────────────────────────────── */

:root {
  /* Cool slate, one operational blue. The rail and the page share the same ink. */
  --ground: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --surface-3: #e4eaf1;
  --line: #d5dde8;
  --line-soft: #e7edf4;

  --ink: #121826;
  --body: #2c3548;
  --muted: #5c677a;
  --faint: #8b95a7;

  --rail: #121826;
  --rail-deep: #0c111c;
  --rail-2: #1c2636;
  --rail-txt: #c5cedb;
  --rail-txt-on: #ffffff;

  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #e7eefb;
  --accent-ink: #1e3a8a;

  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf2e4;
  --bad: #b91c1c;
  --bad-soft: #fdebeb;

  --focus: #1d4ed8;

  --r-sm: 4px;
  --r: 6px;
  --r-lg: 8px;

  /* One spacing scale, so vertical rhythm is a choice and not an accident. */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 22px; --s6: 30px; --s7: 44px;

  --sh-1: 0 1px 1px rgba(18, 24, 38, .04);
  --sh-2: 0 1px 2px rgba(18, 24, 38, .06);
  --sh-3: 0 18px 40px -20px rgba(18, 24, 38, .45);
  --sh-lip: inset 0 1px 0 rgba(255, 255, 255, .65);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  --rail-w: 216px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0c1118;
    --surface: #151c27;
    --surface-2: #1c2533;
    --surface-3: #263143;
    --line: #2c3a4e;
    --line-soft: #222c3c;

    --ink: #f2f5f9;
    --body: #c9d2e0;
    --muted: #8b97ab;
    --faint: #6d7a90;

    --rail: #0e1420;
    --rail-deep: #0a0f18;
    --rail-2: #1a2433;
    --rail-txt: #b7c2d2;
    --rail-txt-on: #ffffff;

    --accent: #7aa2ff;
    --accent-hover: #9bb6ff;
    --accent-soft: #1a2744;
    --accent-ink: #c5d7ff;

    --ok: #5cc98a;
    --ok-soft: #133020;
    --warn: #e8a04a;
    --warn-soft: #33230f;
    --bad: #f0787d;
    --bad-soft: #3a1618;

    --focus: #7aa2ff;

    --sh-1: 0 1px 2px rgba(0, 0, 0, .35);
    --sh-2: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 28px -18px rgba(0, 0, 0, .7);
    --sh-3: 0 28px 64px -24px rgba(0, 0, 0, .8);
    --sh-lip: inset 0 1px 0 rgba(255, 255, 255, .045);
  }
}

:root[data-theme="dark"] {
  --ground: #0c1118;
  --surface: #151c27;
  --surface-2: #1c2533;
  --surface-3: #263143;
  --line: #2c3a4e;
  --line-soft: #222c3c;

  --ink: #f2f5f9;
  --body: #c9d2e0;
  --muted: #8b97ab;
  --faint: #6d7a90;

  --rail: #0e1420;
  --rail-deep: #0a0f18;
  --rail-2: #1a2433;
  --rail-txt: #b7c2d2;
  --rail-txt-on: #ffffff;

  --accent: #7aa2ff;
  --accent-hover: #9bb6ff;
  --accent-soft: #1a2744;
  --accent-ink: #c5d7ff;

  --ok: #5cc98a;
  --ok-soft: #133020;
  --warn: #e8a04a;
  --warn-soft: #33230f;
  --bad: #f0787d;
  --bad-soft: #3a1618;

  --focus: #7aa2ff;

  --sh-1: 0 1px 2px rgba(0, 0, 0, .35);
  --sh-2: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 28px -18px rgba(0, 0, 0, .7);
  --sh-3: 0 28px 64px -24px rgba(0, 0, 0, .8);
  --sh-lip: inset 0 1px 0 rgba(255, 255, 255, .045);
}

/* ── 2. Reset ────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--body);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 0 0 var(--r) 0;
  box-shadow: var(--sh-2);
}
.skip:focus { left: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ── 3. Shell ────────────────────────────────────────────────────────── */

.app { display: flex; min-height: 100vh; }

.main {
  flex: 1;
  min-width: 0;                     /* lets wide tables scroll, not the page */
  padding: 28px 32px 72px;
  max-width: 1240px;
}
.main--wide { max-width: none; }

.topbar { display: none; }

@media (max-width: 900px) {
  .topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 10px 14px;
  }
  .topbar-title { font-weight: 650; color: var(--ink); }
  .app { display: block; }
  .main { padding: 20px 16px 64px; max-width: none; }
}

/* ── 4. Rail ─────────────────────────────────────────────────────────── */

.rail {
  width: var(--rail-w);
  flex: 0 0 var(--rail-w);
  background: var(--rail);
  border-right: 1px solid rgba(255, 255, 255, .06);
  color: var(--rail-txt);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--rail-txt-on);
  padding: 0 6px;
  margin-bottom: 26px;
}
.brand-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -.03em;
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt { font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.brand-txt em {
  font-style: normal;
  font-weight: 500;
  font-size: 9.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .62;
}

.rail-nav { display: flex; flex-direction: column; gap: 1px; }
.rail-group + .rail-group { margin-top: 18px; }
.rail-group-name {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--rail-txt);
  opacity: .42;
  padding: 0 10px;
  margin-bottom: 6px;
}
.rail-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--rail-txt);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.rail-nav a .ico { opacity: .72; flex: 0 0 16px; }
.rail-nav a:hover { background: var(--rail-2); color: var(--rail-txt-on); }
.rail-nav a.on {
  background: var(--rail-2);
  color: var(--rail-txt-on);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}
.rail-nav a.on .ico { opacity: 1; color: var(--accent); }

.rail-foot { margin-top: auto; padding-top: 18px; }

.themebtn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .1);
  color: var(--rail-txt);
  padding: 7px 10px;
  border-radius: 8px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  margin-bottom: 14px;
}
.themebtn:hover { background: var(--rail-2); color: var(--rail-txt-on); }
.themebtn-l { font-weight: 550; }
.themebtn .ico-moon { display: none; }
:root[data-theme="dark"] .themebtn .ico-sun { display: none; }
:root[data-theme="dark"] .themebtn .ico-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .themebtn .ico-sun { display: none; }
  :root:not([data-theme="light"]) .themebtn .ico-moon { display: block; }
}

.who {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 12px;
  padding: 0 4px;
  border-top: 1px solid rgba(255, 255, 255, .09);
  padding-top: 13px;
}
.who-n { color: var(--rail-txt-on); font-weight: 600; }
.who-r { color: var(--rail-txt); opacity: .6; text-transform: capitalize; font-size: 11px; }
.who a { color: var(--accent); text-decoration: none; margin-top: 5px; }
.who a:hover { text-decoration: underline; }

.rail-scrim { display: none; }

@media (max-width: 900px) {
  .rail {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .18s ease;
    box-shadow: var(--sh-3);
  }
  .rail.open { transform: none; }
  .rail-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(6, 10, 25, .5);
  }
  .rail-scrim[hidden] { display: none; }
}

/* ── 5. Page head ────────────────────────────────────────────────────── */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-headL { min-width: 0; }
.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.02em;
  color: var(--ink);
  line-height: 1.15;
  text-wrap: balance;
}
.page-sub { margin: 6px 0 0; color: var(--muted); max-width: 72ch; font-size: 13.5px; }
.page-head { padding-bottom: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  margin-bottom: 6px;
}
.backlink:hover { color: var(--accent-ink); }

/* ── 6. Cards ────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface) 100%);
}
.card-title {
  margin: 0;
  font-size: 13px;
  font-weight: 680;
  color: var(--ink);
  letter-spacing: .012em;
}
.card-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-pad { padding: 18px; }
.card--flush { overflow: visible; }

.grid-2 { display: grid; gap: 18px; }
/* Grid children default to min-width:auto, so one unbreakable string inside a
   column (a signed document, a signature) stops the column shrinking and the
   whole page scrolls sideways. This is the fix, and it belongs here rather
   than on each offender. */
.grid-2 > * { min-width: 0; }
@media (min-width: 1000px) { .grid-2 { grid-template-columns: 1fr 1fr; align-items: start; } }
.grid-2 > .card { margin-bottom: 0; }

/* ── 7. Tables ───────────────────────────────────────────────────────── */

.tablewrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  white-space: nowrap;
}
/* No sticky thead here on purpose: .tablewrap needs overflow-x for wide tables,
   which forces overflow-y:auto and makes the wrapper — not the page — the
   scroll container, so position:sticky would render but never actually pin. */
tbody td {
  padding: 9px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  color: var(--body);
  transition: background .1s ease;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:hover td:first-child { box-shadow: inset 2px 0 0 var(--line); }
tbody tr.row-sub td { border-bottom: 0; padding-top: 0; color: var(--muted); font-size: 12.5px; }
tbody tr.row-sub:hover td { background: transparent; }

th.t-num, td.t-num { text-align: right; font-variant-numeric: tabular-nums; }
th.t-nowrap, td.t-nowrap { white-space: nowrap; }
th.t-right, td.t-right { text-align: right; }
td .strong, .t-strong { color: var(--ink); font-weight: 600; }

.tnote { color: var(--muted); font-style: italic; }
.when { border-bottom: 1px dotted var(--line); cursor: help; white-space: nowrap; }

/* Below this the columns squeeze and cells wrap; the wrapper scrolls instead. */
.tablewrap table { min-width: 760px; }
.tablewrap--narrow table { min-width: 0; }

/* Row actions stay on one line, so a row is one line tall. */
td .btnrow { flex-wrap: nowrap; justify-content: flex-end; gap: 6px; }
td .btn--sm { padding: 4px 10px; font-size: 12px; }
/* A secondary line under a cell value — date under a state, customer under a
   branch — without inventing a new font size at each call site. */
.subtle { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ── 8. Pills, chips, copy ───────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .01em;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill--muted::before { opacity: .5; }
.pill--ok { background: var(--ok-soft); color: var(--ok); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--bad { background: var(--bad-soft); color: var(--bad); }
.pill--muted { background: var(--surface-2); color: var(--muted); }
.pill--accent { background: var(--accent-soft); color: var(--accent-ink); }

.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
}
.chip--accent { background: var(--accent-soft); color: var(--accent-ink); }
.chip--ok { background: var(--ok-soft); color: var(--ok); }
.chip--warn { background: var(--warn-soft); color: var(--warn); }
.chip--bad { background: var(--bad-soft); color: var(--bad); }
.chip--muted { background: var(--surface-2); color: var(--muted); }

.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -.01em; }

.copyline { display: inline-flex; align-items: center; gap: 6px; }
.copy {
  border: 0;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  padding: 3px;
  border-radius: 5px;
  display: inline-grid;
  place-items: center;
  line-height: 0;
}
.copy:hover { background: var(--surface-3); color: var(--accent-ink); }
.copy.done { color: var(--ok); }

.sigblock {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  word-break: break-all;
  line-height: 1.7;
  color: var(--ink);
}

pre.doc {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 14px;
  overflow-x: auto;
  margin: 0;
  color: var(--ink);
  line-height: 1.6;
}
pre.doc.wrap { white-space: pre-wrap; word-break: break-all; }

/* ── 9. Buttons ──────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--r);
  padding: 8px 15px;
  font: inherit;
  font-weight: 620;
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn:active { transform: translateY(1px); }

.btn--ghost {
  background: var(--surface);
  color: var(--body);
  border-color: var(--line);
}
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn--danger { background: var(--bad); color: #fff; }
.btn--danger:hover { background: var(--bad); filter: brightness(1.08); color: #fff; }

.btn--quiet {
  background: transparent;
  color: var(--accent-ink);
  border-color: transparent;
  padding: 6px 8px;
}
.btn--quiet:hover { background: var(--accent-soft); color: var(--accent-ink); }

.btn--sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn--icon { padding: 7px; border-radius: 8px; background: transparent; color: var(--body); border-color: var(--line); }
.btn--icon:hover { background: var(--surface-2); color: var(--ink); }

.btn.is-busy { opacity: .6; pointer-events: none; }

/* A disabled action must not still look like the action. A greyed-out
   danger button that keeps its red fill reads as "click me", which is
   exactly wrong when a guard is blocking it. */
.btn[disabled] {
  background: var(--surface-2);
  color: var(--faint);
  border-color: var(--line);
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}
.btn.is-busy::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

/* ── 10. Forms ───────────────────────────────────────────────────────── */

.field { margin-bottom: 14px; }
.field > label {
  display: block;
  font-size: 12px;
  font-weight: 620;
  color: var(--ink);
  margin-bottom: 5px;
}
.req { color: var(--bad); }

.input {
  width: 100%;
  max-width: 460px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
}
.input:hover { border-color: var(--surface-3); }
.input:focus-visible { border-color: var(--accent); outline-offset: 0; }
.input--auto { width: auto; max-width: none; }
.input--full { max-width: none; }
textarea.input { max-width: 620px; resize: vertical; line-height: 1.5; }
select.input { cursor: pointer; }

.hint { color: var(--muted); font-size: 12px; margin: 5px 0 0; max-width: 62ch; }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 14px; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-left: -8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}
.check:hover { background: var(--surface-2); }
.check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; flex: 0 0 15px; }
.check span { color: var(--body); }
.check input:checked + span { color: var(--ink); font-weight: 550; }

.modgroup { border-top: 1px solid var(--line-soft); padding: 12px 0 6px; }
.modgroup:first-of-type { border-top: 0; padding-top: 0; }
.modgroup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.modgroup-name {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--accent-ink); box-shadow: var(--sh-1); }

.subpanel {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  background: var(--surface-2);
  margin: 4px 0 16px;
}
.subpanel > :last-child { margin-bottom: 0; }

.summary {
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--r) var(--r) 0;
  padding: 12px 16px;
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--body);
}
.summary b { color: var(--ink); }
.summary ul { margin: 6px 0 0; padding-left: 18px; }
.summary li { margin-bottom: 3px; }

.deflist { display: grid; gap: 0; margin: 0; }
.deflist > div {
  display: flex;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.deflist > div:last-child { border-bottom: 0; }
.deflist dt {
  flex: 0 0 150px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.deflist dd {
  margin: 0;
  flex: 1;
  min-width: 0;
  color: var(--ink);
  /* Signatures, licence ids and URLs have no spaces to break at. Without this
     the row cannot shrink and the whole page scrolls sideways on a phone. */
  overflow-wrap: anywhere;
}

/* Below this the label/value pair reads better stacked than squeezed. */
@media (max-width: 700px) {
  .deflist > div { flex-direction: column; gap: 2px; padding: 10px 0; }
  .deflist dt { flex: none; }
}

/* ── 11. Alerts ──────────────────────────────────────────────────────── */

.alert {
  padding: 10px 14px;
  border-radius: var(--r);
  margin-bottom: 14px;
  font-size: 13.5px;
  border: 1px solid transparent;
}
.alert--ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.alert--bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 22%, transparent); }
.alert--warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.alert--accent { background: var(--accent-soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 26%, transparent); }
.alert a { color: inherit; font-weight: 650; }

ul.body-list { list-style: none; margin: 0; padding: 0; }
ul.body-list li { padding: 3px 0; }

.empty { text-align: center; padding: 44px 24px; }
.empty-ico {
  width: 40px;
  height: 40px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--faint);
}
.empty h3 { margin: 0 0 6px; font-size: 15px; color: var(--ink); font-weight: 620; }
.empty p { margin: 0 auto 14px; color: var(--muted); max-width: 46ch; font-size: 13px; }
.empty p:last-child { margin-bottom: 0; }

/* ── 12. Stats ───────────────────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 1100px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 15px 17px 16px;
  text-decoration: none;
  box-shadow: none;
  transition: border-color .12s ease;
}
a.stat:hover { border-color: var(--accent); }
.stat-l {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
/* Only a toned tile gets a dot, so a neutral count stays quiet. */
.stat--ok .stat-l::before,
.stat--warn .stat-l::before,
.stat--bad .stat-l::before,
.stat--accent .stat-l::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: currentColor;
}
.stat-n {
  font-size: 26px;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stat-s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat--ok .stat-l { color: var(--ok); }
.stat--warn .stat-l { color: var(--warn); }
.stat--bad .stat-l { color: var(--bad); }
.stat--accent .stat-l { color: var(--accent-ink); }
.stat--ok .stat-n { color: var(--ok); }
.stat--warn .stat-n { color: var(--warn); }
.stat--bad .stat-n { color: var(--bad); }

/* ── 13. Toolbar ─────────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}
.search {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  flex: 1 1 230px;
  max-width: 340px;
  color: var(--faint);
}
.search:focus-within { border-color: var(--accent); }
.search input {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  padding: 8px 0;
  width: 100%;
  color: var(--ink);
  outline: none;
}
.search input::-webkit-search-cancel-button { cursor: pointer; }

/* ── 14. Pager ───────────────────────────────────────────────────────── */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--muted);
}
.pager b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 620; }
.pager-count { color: var(--muted); }
.pager-nav { display: flex; align-items: center; gap: 10px; }
.pager-page { font-variant-numeric: tabular-nums; }

/* ── 15. Modal ───────────────────────────────────────────────────────── */

dialog.modal {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--body);
  padding: 0;
  width: min(460px, calc(100vw - 32px));
  box-shadow: var(--sh-3);
}
dialog.modal::backdrop { background: rgba(6, 10, 25, .55); }
.modal-head { padding: 16px 20px 0; }
.modal-head h2 { margin: 0 0 4px; font-size: 16px; color: var(--ink); font-weight: 650; }
.modal-head p { margin: 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 16px 20px; }
.modal-body > :last-child { margin-bottom: 0; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
}

/* ── 16. Toast ───────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--ground);
  padding: 9px 15px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 550;
  box-shadow: var(--sh-3);
  animation: toastin .18s ease;
}
@keyframes toastin { from { opacity: 0; transform: translateY(6px); } }

/* ── 17. Gate (login / setup) ────────────────────────────────────────── */

body.gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px 24px;
  background: #0e1420;
}
.gate-wrap {
  display: grid;
  gap: 40px;
  align-items: center;
  width: 100%;
  max-width: 1000px;
}
@media (min-width: 940px) {
  .gate-wrap { grid-template-columns: 1fr 380px; gap: 72px; }
}
.gate-pitch { display: none; color: #fff; }
@media (min-width: 940px) { .gate-pitch { display: block; } }
.gate-pitch h2 {
  margin: 18px 0 12px;
  font-size: 32px;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -.03em;
  max-width: 16ch;
}
.gate-pitch p { margin: 0; color: var(--rail-txt); max-width: 42ch; line-height: 1.6; }
.gate-facts { display: flex; gap: 26px; margin-top: 30px; flex-wrap: wrap; }
.gate-fact span {
  display: block;
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--rail-txt);
  opacity: .6;
  margin-bottom: 3px;
}
.gate-fact b { font-size: 15px; font-weight: 650; }
.gate-card {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 10px;
  padding: 28px 28px 22px;
  box-shadow: var(--sh-3);
}
.gate-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.gate-brand .brand-mark { width: 32px; height: 32px; flex: 0 0 32px; font-size: 16px; }
.gate-brand b { color: var(--ink); font-size: 15px; font-weight: 700; display: block; line-height: 1.2; }
.gate-brand em {
  font-style: normal;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.gate-card h1 { margin: 0 0 4px; font-size: 19px; color: var(--ink); font-weight: 650; }
.gate-card .lede { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.gate-card .btn { width: 100%; }
.gate-foot { margin: 18px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.gate-foot code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: 4px;
}

/* ── 18. Utilities ───────────────────────────────────────────────────── */

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.strong { color: var(--ink); font-weight: 620; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.mb0 { margin-bottom: 0; }
.mt16 { margin-top: 16px; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
