/* RIVPN Console — "the relationship ledger".
   Atkinson Hyperlegible Next and Mono (SIL OFL) are served by the control plane itself, so the console
   needs nothing from outside and works on an air-gapped network. No inline styles (strict CSP). */

@font-face { font-family: "Atkinson Next"; src: url("/fonts/atkinson-next-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Next"; src: url("/fonts/atkinson-next-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Next"; src: url("/fonts/atkinson-next-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Mono"; src: url("/fonts/atkinson-mono-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }

:root {
  /* identity */
  --ink: #1a1c33;          /* night ink: text, rail, primary buttons */
  --ink-2: #2c2f55;
  --paper: #f3f4f8;
  --surface: #ffffff;
  --line: #dde0ea;
  --line-soft: #eceef4;
  --muted: #5b6078;
  --faint: #8a8fa6;
  --rail-ink: #c9cce0;
  --rail-hi: #ffffff;
  --thread: #f2b33d;       /* the gate's thread in the mark; used once, for the current page */
  /* status — reserved; always paired with a shape and a word */
  --live: #1f7a4d;   --live-bg: #e6f3ec;
  --warn: #a15c00;   --warn-bg: #fbf0dc;
  --stop: #bf3a2f;   --stop-bg: #fbe9e7;
  --idle: #9aa0b6;   --idle-bg: #eef0f5;
  /* relationship threads — validated categorical slots 1–7 (dataviz reference palette); red is never a relationship */
  --rel-1: #2a78d6; --rel-2: #eb6834; --rel-3: #1baf7a; --rel-4: #eda100; --rel-5: #e87ba4; --rel-6: #008300; --rel-7: #6250d6;
  --rel-none: #b4b9cb;
  /* sequential (heat) */
  --seq-0: #f3f4f8; --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95; --seq-7: #0d366b;
  --ui: "Atkinson Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --code: "Atkinson Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --r: 10px;   /* cards */
  --r-sm: 6px; /* controls */
}

* { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--ui); line-height: 1.5; font-variant-numeric: tabular-nums; }
.boot { padding: 3rem; color: var(--muted); }
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1 { font-size: 1.95rem; line-height: 1.15; font-weight: 700; letter-spacing: -0.015em; margin: 0 0 0.35rem; }
h2 { font-size: 1.15rem; line-height: 1.3; font-weight: 700; margin: 2.2rem 0 0.7rem; }
h3 { font-size: 1rem; font-weight: 700; margin: 0 0 0.4rem; }
p { margin: 0 0 0.8rem; max-width: 70ch; }
.lede { color: var(--muted); margin-bottom: 1.5rem; font-size: 1.02rem; }
code, .mono { font-family: var(--code); font-size: 0.9rem; letter-spacing: -0.01em; }
svg.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg.icon.sm { width: 16px; height: 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── shell ── */
.shell { display: grid; grid-template-columns: 15rem 1fr; min-height: 100vh; background: linear-gradient(to right, var(--ink) 15rem, var(--paper) 15rem); }
.rail { background: var(--ink); color: var(--rail-ink); padding: 1.3rem 0 1rem; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 0.7rem; padding: 0 1.2rem 1.3rem; }
.brand svg.mark { width: 34px; height: 34px; flex: none; }
.brand strong { display: block; font-size: 1.3rem; letter-spacing: 0.04em; font-weight: 700; color: var(--rail-hi); line-height: 1.1; }
.brand span { display: block; font-size: 0.8rem; opacity: 0.75; line-height: 1.3; }
.rail nav { display: flex; flex-direction: column; gap: 1px; padding: 0 0.6rem; }
.rail nav .group { font-size: 0.75rem; color: #8d91ad; padding: 1rem 0.7rem 0.3rem; }
.rail nav a { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.7rem; color: var(--rail-ink); text-decoration: none; border-radius: var(--r-sm); }
.rail nav a:hover { background: rgba(255,255,255,0.07); color: var(--rail-hi); }
.rail nav a[aria-current="page"] { background: rgba(255,255,255,0.11); color: var(--rail-hi); font-weight: 700; box-shadow: inset 3px 0 0 var(--thread); }
.rail nav a .count { margin-left: auto; font-size: 0.75rem; background: var(--stop); color: #fff; border-radius: 999px; padding: 0 0.45rem; font-weight: 700; }
.rail .who { margin-top: auto; padding: 1rem 1.2rem 0; font-size: 0.82rem; overflow-wrap: anywhere; display: grid; gap: 0.1rem; }
.rail .who .email { color: var(--rail-hi); }
.rail .who .role { font-size: 0.78rem; opacity: 0.8; }
.rail .who button { margin-top: 0.5rem; justify-self: start; }
main { padding: 2.2rem 2.6rem 5rem; min-width: 0; max-width: 92rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.page-head h1 { margin: 0; }
.page-head .context { color: var(--muted); font-size: 0.95rem; }
.tabbar, .more-sheet { display: none; }

/* ── controls ── */
button, .btn, a.button { font: inherit; display: inline-flex; align-items: center; gap: 0.45rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 0.42rem 0.85rem; border-radius: var(--r-sm); cursor: pointer; text-decoration: none; line-height: 1.3; }
button:hover, .btn:hover, a.button:hover { border-color: var(--faint); }
button.primary { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
button.primary:hover { background: var(--ink-2); }
button.danger { color: var(--stop); border-color: #e9c3bf; }
button.danger:hover { border-color: var(--stop); }
button.danger.armed { background: var(--stop); border-color: var(--stop); color: #fff; font-weight: 700; }
button.quiet { border-color: transparent; background: transparent; color: inherit; text-decoration: underline; text-underline-offset: 3px; padding: 0.2rem 0.3rem; }
.rail button.quiet { color: var(--rail-ink); padding-left: 0; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 5px rgba(42,120,214,0.25); }
.rail a:focus-visible, .rail button:focus-visible { outline-color: var(--thread); box-shadow: none; }
input, select, textarea { font: inherit; padding: 0.45rem 0.6rem; border: 1px solid #cfd3df; border-radius: var(--r-sm); background: var(--surface); color: var(--ink); min-width: 0; }
input::placeholder, textarea::placeholder { color: #a3a8bc; }
input:disabled, select:disabled, textarea:disabled { background: var(--paper); color: var(--muted); border-style: dashed; cursor: not-allowed; }
textarea { font-family: var(--code); font-size: 0.9rem; width: 100%; min-height: 5.5rem; }
label { display: block; font-size: 0.87rem; font-weight: 700; margin-bottom: 0.25rem; }
.field { margin-bottom: 0.9rem; }
.field input, .field select { width: 100%; }
.hint { font-size: 0.84rem; color: var(--muted); font-weight: 400; }
p.hint.pad { font-size: 0.9rem; margin: 0.6rem 0 0.8rem; }
.downloads { display: flex; flex-wrap: wrap; gap: 0.5rem; }
td.wrap { overflow-wrap: anywhere; max-width: 18rem; }
form.row { display: flex; flex-wrap: wrap; gap: 0.8rem 1rem; align-items: flex-end; background: var(--surface); border: 1px solid var(--line); padding: 1.1rem 1.2rem; border-radius: var(--r); margin-bottom: 1.2rem; }
form.row .field { margin: 0; flex: 1 1 12rem; }
form.row .field.narrow { flex: 0 1 9rem; }
form.row .field.wide { flex: 2 1 22rem; }
form.row .field.full { flex: 1 1 100%; }
form.row .field.checks { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 0.4rem 1.6rem; }
form.row .field.checks label { font-weight: 400; font-size: 0.95rem; margin: 0; display: inline-flex; gap: 0.4rem; align-items: center; }
form.row .field.checks input { width: auto; }
form.row .full-row { flex: 1 1 100%; margin: 0; }
form.row textarea[rows='2'] { min-height: 3.6rem; }
td .sub.write button.quiet { font-size: 0.8rem; padding: 0.1rem 0.6rem 0.1rem 0; }
.error { color: var(--stop); font-weight: 700; margin: 0.6rem 0; }
.note { background: #eef1fb; border: 1px solid #d6dcf3; border-left: 4px solid var(--ink); padding: 0.9rem 1.1rem; margin: 0 0 1.2rem; border-radius: var(--r-sm); }
.note p { margin-bottom: 0.5rem; }
.secret { display: flex; gap: 0.5rem; align-items: stretch; margin: 0.4rem 0 0.7rem; }
.secret code { flex: 1; background: var(--ink); color: #eef0fb; padding: 0.6rem 0.75rem; border-radius: var(--r-sm); overflow-x: auto; white-space: nowrap; }

/* ── tables ── */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 0.8rem; font-weight: 700; color: var(--muted); padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfd; }
td { padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:hover td { background: #fafbfd; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button, td.actions a.button { margin-left: 0.3rem; padding: 0.25rem 0.6rem; font-size: 0.88rem; }
td .sub { display: block; font-size: 0.82rem; color: var(--muted); }
td select, td input { padding: 0.25rem 0.45rem; font-size: 0.92rem; max-width: 11rem; }
td.routes input { display: block; width: 100%; max-width: 14rem; margin-bottom: 0.3rem; }
td.routes button { padding: 0.15rem 0.5rem; font-size: 0.85rem; }
td .sub.mono { font-family: var(--code); }
td textarea { min-height: 3.6rem; min-width: 14rem; }
time { white-space: nowrap; }
.empty { padding: 2rem 1.2rem; color: var(--muted); display: flex; gap: 0.8rem; align-items: center; }
.empty svg.icon { color: var(--faint); width: 28px; height: 28px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 0.8rem; border-top: 1px solid var(--line-soft); font-size: 0.88rem; color: var(--muted); }

/* ── state: color + shape + word, never color alone ── */
.state { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; font-size: 0.92rem; }
.state::before { content: ""; width: 0.6rem; height: 0.6rem; border-radius: 50%; border: 1.5px solid var(--idle); background: transparent; flex: none; }
.state.live::before { background: var(--live); border-color: var(--live); }
.state.warn::before { width: 0; height: 0; border-radius: 0; border: 0; border-left: 0.36rem solid transparent; border-right: 0.36rem solid transparent; border-bottom: 0.62rem solid var(--warn); }
.state.stop::before { background: var(--stop); border-color: var(--stop); border-radius: 1px; }
.state.stop { color: var(--stop); }
.state.warn { color: var(--warn); }
.pill { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.82rem; font-weight: 700; background: var(--idle-bg); color: var(--muted); white-space: nowrap; }
.pill.live { background: var(--live-bg); color: var(--live); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.stop { background: var(--stop-bg); color: var(--stop); }

/* relationship thread: identity stripe + chip */
.thread { display: inline-flex; align-items: center; gap: 0.45rem; }
.thread::before { content: ""; width: 0.75rem; height: 0.75rem; border-radius: 3px; background: var(--c, var(--rel-none)); flex: none; }
.c1 { --c: var(--rel-1); } .c2 { --c: var(--rel-2); } .c3 { --c: var(--rel-3); } .c4 { --c: var(--rel-4); } .c5 { --c: var(--rel-5); } .c6 { --c: var(--rel-6); } .c7 { --c: var(--rel-7); } .c0 { --c: var(--rel-none); }

/* ── overview ── */
.summary { font-size: 1.15rem; max-width: 62ch; margin-bottom: 1.2rem; }
.summary b { font-weight: 700; }
ul.attention { list-style: none; margin: 0.6rem 0 1.6rem; padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
ul.attention li { display: grid; grid-template-columns: 2rem 1fr auto; gap: 0.6rem; align-items: center; padding: 0.7rem 1rem; border-top: 1px solid var(--line-soft); }
ul.attention li:first-child { border-top: 0; }
ul.attention li .sev { display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--idle-bg); color: var(--muted); }
ul.attention li.critical { background: #fff8f7; box-shadow: inset 4px 0 0 var(--stop); }
ul.attention li.critical .sev { background: var(--stop-bg); color: var(--stop); }
ul.attention li.warning .sev { background: var(--warn-bg); color: var(--warn); }
ul.attention li .lvl { display: block; font-size: 0.75rem; font-weight: 700; color: var(--muted); }
ul.attention li.critical .lvl { color: var(--stop); }
ul.attention li.warning .lvl { color: var(--warn); }
ul.attention li a.go { font-size: 0.9rem; white-space: nowrap; display: inline-flex; gap: 0.3rem; align-items: center; }
ul.attention li.more { display: block; text-align: center; padding: 0.5rem; }
.all-clear { display: flex; align-items: center; gap: 0.8rem; margin: 0.6rem 0 1.6rem; padding: 0.9rem 1.1rem; background: var(--live-bg); border-radius: var(--r); color: var(--live); font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.9rem; margin: 0 0 1.8rem; }
a.tile { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: end; gap: 0 0.8rem; padding: 1rem 1.1rem 0.9rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: inherit; text-decoration: none; min-height: 6.3rem; }
a.tile b { font-size: 2.1rem; line-height: 1.05; font-weight: 700; letter-spacing: -0.02em; }
a.tile b small { font-size: 1.05rem; color: var(--muted); font-weight: 400; letter-spacing: 0; }
a.tile span.label { grid-column: 1 / -1; font-size: 0.9rem; color: var(--muted); margin-top: 0.25rem; }
a.tile svg.viz { grid-row: 1; grid-column: 2; align-self: center; }
a.tile:hover { border-color: var(--ink); }

/* the ledger: one row per relationship, its thread down the left edge */
.ledger { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.ledger-head, .ledger-row { display: grid; grid-template-columns: minmax(14rem, 2.2fr) minmax(9rem, 1.2fr) minmax(10rem, 1.6fr) minmax(9rem, 1.1fr) minmax(7rem, 0.9fr); gap: 1rem; align-items: center; padding: 0.8rem 1.1rem 0.8rem 1.4rem; }
.ledger-head { font-size: 0.8rem; font-weight: 700; color: var(--muted); background: #fafbfd; border-bottom: 1px solid var(--line); padding-top: 0.6rem; padding-bottom: 0.6rem; }
.ledger-row { position: relative; border-top: 1px solid var(--line-soft); color: inherit; text-decoration: none; }
.ledger-row:first-of-type { border-top: 0; }
.ledger-row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c, var(--rel-none)); }
a.ledger-row:hover { background: #fafbfd; }
.ledger-row .name { font-weight: 700; display: block; }
.ledger-row .sub { display: block; font-size: 0.84rem; color: var(--muted); }
.ledger-row.ended { color: var(--muted); }
.dots { display: flex; flex-wrap: wrap; gap: 3px; max-width: 9rem; }
.dots i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--idle); }
.dots i.on { background: var(--live); border-color: var(--live); }
.dots i.off { border-color: var(--warn); border-style: dotted; }
.reach { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; padding: 0.08rem 0.45rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fafbfd; white-space: nowrap; }
.chip.mono { font-family: var(--code); font-size: 0.78rem; }
.chip svg.icon { width: 13px; height: 13px; }
.endbar { display: grid; gap: 0.25rem; font-size: 0.85rem; }
.endbar .track { height: 5px; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.endbar .track span { display: block; height: 100%; background: var(--ink); border-radius: 3px; }
.endbar.soon .track span { background: var(--warn); }
.endbar.done .track span { background: var(--idle); }
.ledger-foot { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; padding: 0.7rem 1.1rem; border-top: 1px solid var(--line); font-size: 0.84rem; color: var(--muted); background: #fafbfd; }

/* ── charts (hand-drawn SVG; no library) ── */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 1rem; align-items: stretch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.15rem 1.1rem; min-width: 0; position: relative; }
.card h3 { margin-bottom: 0.1rem; }
.card .card-sub { color: var(--muted); font-size: 0.86rem; margin-bottom: 0.7rem; }
.card svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--ui); font-size: 11px; fill: var(--muted); }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .hover, .chart g.col:hover .hover { opacity: 1; }
.chart .hover { fill: rgba(26,28,51,0.05); opacity: 0; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; margin-top: 0.7rem; font-size: 0.84rem; color: var(--muted); }
.legend .thread { color: var(--ink); }
.tip { position: absolute; pointer-events: none; z-index: 5; background: var(--ink); color: #fff; padding: 0.5rem 0.65rem; border-radius: var(--r-sm); font-size: 0.82rem; line-height: 1.4; min-width: 9rem; box-shadow: 0 6px 20px rgba(26,28,51,0.25); }
.tip b { display: block; margin-bottom: 0.15rem; }
.tip .row { display: flex; justify-content: space-between; gap: 1rem; }
.tip .thread::before { width: 0.6rem; height: 0.6rem; }
.barlist { display: grid; gap: 0.55rem; list-style: none; margin: 0; padding: 0; }
.barlist li { display: grid; grid-template-columns: 1fr auto; gap: 0.2rem 0.8rem; font-size: 0.88rem; }
.barlist .lab { font-family: var(--code); font-size: 0.84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist .val { color: var(--muted); }
.barlist .bar { grid-column: 1 / -1; display: flex; height: 8px; gap: 2px; }
.barlist .bar span { display: block; height: 100%; background: var(--c, var(--rel-none)); border-radius: 2px; min-width: 2px; }
.viewtable { margin-top: 0.6rem; font-size: 0.86rem; }
.viewtable summary { cursor: pointer; color: var(--muted); }
.viewtable table { margin-top: 0.4rem; font-size: 0.84rem; }
.viewtable td, .viewtable th { padding: 0.3rem 0.5rem; }

/* ── panels and misc (earlier slices) ── */
.map { display: none; }
.key { display: flex; flex-wrap: wrap; gap: 1.2rem; font-size: 0.85rem; color: var(--muted); margin-bottom: 1.5rem; }
.setting { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 1rem; flex-wrap: wrap; }
.readback { margin: 0; padding: 0.7rem 0.9rem; background: #f4f6fb; border-radius: var(--r-sm); border: 1px solid var(--line-soft); }
.readback-sm { font-size: 0.92rem; }
tr.ended td { color: var(--muted); }
section.panel { border: 1px solid var(--line); border-left: 4px solid var(--stop); border-radius: var(--r-sm); background: var(--surface); padding: 1rem 1.2rem; margin: 0 0 1.3rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-head h2 { margin: 0; }
dl.facts { display: grid; grid-template-columns: 9rem 1fr; gap: 0.4rem 1rem; margin: 0.8rem 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.panel-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
tr.open td { background: var(--stop-bg); }
.field.checks.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.8rem; }
.field.checks.inline .label { font-weight: 700; font-size: 0.9rem; }
form.row .field.checks input.tiny { width: 6rem; flex: none; padding: 0.25rem 0.4rem; }
.quiet-text { color: var(--muted); }
.roles { margin: 0 0 1rem; padding-left: 1.2rem; max-width: 60rem; } .roles li { margin: .15rem 0; }
.warn-text { color: var(--warn); }
button.quiet.write { font-size: 0.8rem; padding: 0 0.2rem; }

/* read-only role */
.readonly form.row.write, .readonly td.actions > *, .readonly .write { display: none; }
.readonly-note { max-width: none; display: flex; gap: 0.6rem; align-items: center; background: var(--idle-bg); border-radius: var(--r-sm); padding: 0.6rem 0.9rem; color: var(--muted); }
.readonly td input:disabled, .readonly td select:disabled, .readonly td textarea:disabled { background: transparent; border-color: transparent; color: inherit; opacity: 1; appearance: none; resize: none; }

/* ── sign-in ── */
.gate-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(22rem, 30rem); }
.gate-art { background: var(--ink); color: var(--rail-ink); padding: 3.2rem; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; position: relative; }
.gate-art .brand { padding: 0; }
.gate-art svg.threads { display: block; width: calc(100% + 6.4rem); margin: 2rem -3.2rem; height: auto; max-height: 46vh; }
.gate-art .claim { margin-bottom: 0.8rem; font-size: 1.55rem; line-height: 1.3; color: var(--rail-hi); max-width: 22ch; font-weight: 700; }
.gate-art .foot { margin: 0; font-size: 0.85rem; color: #8d91ad; max-width: 44ch; }
.gate { align-self: center; padding: 2.5rem; max-width: 30rem; width: 100%; }
.gate h1 { margin-bottom: 0.4rem; font-size: 1.7rem; }
.gate button.primary { width: 100%; justify-content: center; padding: 0.65rem; margin-top: 0.4rem; }
.sso { margin-bottom: 1rem; display: grid; gap: 0.5rem; }
a.sso-btn { justify-content: center; padding: 0.65rem; font-weight: 700; width: 100%; }
.or { display: flex; align-items: center; gap: 0.8rem; color: var(--muted); font-size: 0.85rem; margin: 0.9rem 0 0.5rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* ── narrow screens: a bottom tab bar; the full menu in a sheet ── */
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .ledger-head { display: none; }
  .ledger-row { grid-template-columns: 1fr auto; gap: 0.5rem 0.8rem; }
  .ledger-row > :nth-child(3), .ledger-row > :nth-child(4) { grid-column: 1 / -1; }
  .gate-wrap { grid-template-columns: 1fr; }
  .gate-art { padding: 1.6rem; }
  .gate-art svg.threads { margin: 1rem -1.6rem; max-height: 9rem; }
  .gate-art .claim { font-size: 1.2rem; }
  .gate-art .foot { display: none; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; background: var(--paper); }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; padding: 0.7rem 1rem; }
  .rail nav, .rail .who { display: none; }
  .brand { padding: 0; }
  .brand svg.mark { width: 28px; height: 28px; }
  main { padding: 1.3rem 1rem 6rem; }
  h1 { font-size: 1.6rem; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); padding: 0.35rem 0.3rem calc(0.35rem + env(safe-area-inset-bottom)); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; font-size: 0.7rem; color: var(--muted); text-decoration: none; border: 0; background: none; padding: 0.3rem 0; border-radius: var(--r-sm); }
  .tabbar a[aria-current="page"] { color: var(--ink); font-weight: 700; }
  .tabbar a[aria-current="page"] svg.icon { stroke-width: 2.2; }
  .more-sheet[open] { display: block; position: fixed; inset: auto 0 3.9rem 0; z-index: 19; background: var(--surface); border-top: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0; box-shadow: 0 -10px 30px rgba(26,28,51,0.15); padding: 0.6rem; }
  .more-sheet nav { display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem; }
  .more-sheet a { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem; color: var(--ink); text-decoration: none; border-radius: var(--r-sm); }
  .more-sheet a[aria-current="page"] { background: var(--paper); font-weight: 700; }
  .more-sheet .who { padding: 0.7rem; border-top: 1px solid var(--line-soft); margin-top: 0.4rem; font-size: 0.85rem; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
  ul.attention li { grid-template-columns: 2rem 1fr; }
  ul.attention li a.go { grid-column: 2; }
  dl.facts { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  a.tile { padding: 0.8rem; min-height: 0; }
  a.tile b { font-size: 1.6rem; }
  a.tile svg.viz { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .ledger-row::before { transition: width 0.15s ease; }
  a.ledger-row:hover::before { width: 8px; }
}
@media (forced-colors: active) {
  .ledger-row::before, .thread::before { forced-color-adjust: none; }
}

/* ── UX slice B: side panels, filters, cards ── */
dialog.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; height: 100vh; max-height: 100vh; width: min(34rem, 100vw); max-width: 100vw; border: 0; border-left: 1px solid var(--line);
  padding: 0; background: var(--surface); color: var(--ink); box-shadow: -18px 0 40px rgba(26,28,51,0.18); display: flex; flex-direction: column; }
dialog.drawer::backdrop { background: rgba(26,28,51,0.32); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.3rem 1.4rem 0.9rem; border-bottom: 1px solid var(--line-soft); }
.drawer-head h2 { margin: 0 0 0.15rem; font-size: 1.3rem; }
.drawer-head .card-sub { margin: 0; }
.drawer-body { padding: 1.2rem 1.4rem 2rem; overflow-y: auto; flex: 1; }
.drawer-actions { display: flex; gap: 0.6rem; padding-top: 0.6rem; }
form.stacked .field { margin-bottom: 1.1rem; }
form.stacked textarea { min-height: 6rem; }
span.label { display: block; font-size: 0.82rem; font-weight: 700; color: var(--muted); margin-bottom: 0.25rem; }
.pick-routes { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-top: 0.45rem; }
button.chip-btn { font-size: 0.8rem; padding: 0.12rem 0.5rem; border-radius: 999px; font-family: var(--code); }
button.chip-btn .hint { font-family: var(--ui); }
@media (prefers-reduced-motion: no-preference) {
  dialog.drawer[open] { animation: drawer-in 0.18s ease-out; }
  @keyframes drawer-in { from { transform: translateX(2rem); opacity: 0.4; } to { transform: none; opacity: 1; } }
}
.explain dl.facts { margin-top: 0; }
.explain .panel-actions { margin-top: 1rem; }

form.row.filters { padding: 0.8rem 1rem; gap: 0.6rem 0.9rem; }
.table-caption { display: flex; align-items: center; gap: 1rem; color: var(--muted); font-size: 0.9rem; margin: 0.2rem 0 0.5rem; max-width: none; }
.stack { margin-top: 1rem; }
.chart-empty { display: flex; gap: 0.6rem; align-items: center; color: var(--live); font-weight: 700; padding: 2.2rem 0.4rem; margin: 0; }
.legend .ramp { display: inline-flex; gap: 2px; }
.legend .ramp i { width: 16px; height: 10px; border-radius: 2px; display: block; }
.chart text.label { fill: var(--ink); font-size: 12px; }
.chart text.muted { fill: var(--faint); font-size: 12px; }
.barlist li.pick { cursor: pointer; border-radius: var(--r-sm); padding: 0.15rem 0.3rem; margin: 0 -0.3rem; }
.barlist li.pick:hover, .barlist li.pick:focus-visible { background: var(--paper); }

.confirm-wrap { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.confirm-bar { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; background: var(--warn-bg); color: var(--ink); border-radius: var(--r-sm); padding: 0.3rem 0.5rem; font-size: 0.86rem; }
.confirm-bar[hidden] { display: none; }
.confirm-bar button { padding: 0.15rem 0.55rem; font-size: 0.84rem; }

.setting-card { display: flex; align-items: center; gap: 0.9rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 0.85rem 1.1rem; margin: 0 0 1.2rem; flex-wrap: wrap; }
.setting-card svg.icon { color: var(--muted); }
.setting-card > div { flex: 1 1 18rem; }
.setting-card label { margin: 0; }
.rel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(21rem, 1fr)); gap: 1rem; margin-top: 1rem; }
article.rel-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.15rem 1rem 1.4rem; display: flex; flex-direction: column; gap: 0.7rem; overflow: hidden; }
article.rel-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--c, var(--rel-none)); }
article.rel-card.ended { color: var(--muted); }
.rel-top { display: flex; justify-content: space-between; gap: 0.8rem; align-items: flex-start; }
.rel-top h3 { margin: 0; font-size: 1.05rem; }
.rel-top .card-sub { margin: 0.1rem 0 0; }
.rel-card .readback-sm { margin: 0; padding: 0.6rem 0.75rem; background: #f6f7fb; border-radius: var(--r-sm); }
.rel-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; font-size: 0.9rem; }
.rel-facts .sub { display: block; color: var(--muted); font-size: 0.84rem; margin-top: 0.2rem; }
.rel-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; margin-top: auto; padding-top: 0.3rem; border-top: 1px solid var(--line-soft); padding-top: 0.75rem; }
.empty-state { text-align: left; padding: 1.6rem; }
.page-head > button.primary { align-self: center; }
@media (max-width: 760px) {
  dialog.drawer { width: 100vw; border-left: 0; }
  .rel-grid { grid-template-columns: 1fr; }
}
td.nowrap { white-space: nowrap; }
.rel-top > div:first-child { flex: 1 1 auto; min-width: 0; }
.rel-top .rel-state { flex: none; }

/* ── UX slice B2: devices, gateways, enrollment, applications ── */
.card.fleet { margin-bottom: 1rem; }
.fleet-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.fleet-head h3 { margin: 0; }
.fleet-bar { display: flex; height: 14px; gap: 2px; border-radius: 7px; overflow: hidden; margin: 0.8rem 0 0.2rem; background: var(--line-soft); }
.fleet-bar span { display: block; min-width: 6px; }
.legend .swatch { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 3px; margin-right: 0.4rem; vertical-align: -1px; }
button.legend-btn { border: 1px solid transparent; background: transparent; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.86rem; color: var(--ink); }
button.legend-btn:hover { border-color: var(--line); }
button.legend-btn.on { border-color: var(--ink); background: var(--paper); font-weight: 700; }
td.relcell { box-shadow: inset 3px 0 0 var(--c, transparent); }
.traffic { display: grid; gap: 2px; width: 7rem; margin-left: auto; }
.traffic i { display: block; height: 5px; border-radius: 3px; min-width: 2px; }
.traffic i.rx { background: var(--rel-1); }
.traffic i.tx { background: var(--seq-2); }
a.button.primary-link { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
article.gw-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.15rem 1rem 1.4rem; display: flex; flex-direction: column; gap: 0.7rem; overflow: hidden; }
article.gw-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--idle); }
article.gw-card.live::before { background: var(--live); }
article.gw-card.stop::before { background: var(--stop); }
article.gw-card.warn::before { background: var(--warn); }
article.gw-card h3 { display: flex; align-items: center; gap: 0.35rem; }
dl.facts.compact { grid-template-columns: 8rem 1fr; margin: 0; font-size: 0.92rem; }
.routes-edit { display: flex; gap: 0.4rem; margin-top: 0.5rem; }
.routes-edit input { flex: 1; font-family: var(--code); font-size: 0.88rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.meter { display: block; width: 6rem; height: 6px; margin-left: auto; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ink); }
.pipeline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.9rem; margin: 0 0 1.4rem; }
.pipeline .stage { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 0.8rem 0.9rem; display: flex; flex-direction: column; gap: 0.35rem; min-height: 7rem; }
.pipeline .stage-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line-soft); padding-bottom: 0.4rem; margin-bottom: 0.2rem; }
.pipeline .stage-name { font-weight: 700; font-size: 0.9rem; }
.pipeline .stage-head b { font-size: 1.4rem; }
.pipeline .stage-production { border-top: 4px solid var(--live); }
.pipeline .stage-pilot { border-top: 4px solid var(--warn); }
.pipeline .stage-development, .pipeline .stage-planned { border-top: 4px solid var(--idle); }
.pipeline .arrow { position: absolute; right: -0.85rem; top: 50%; transform: translateY(-50%); z-index: 1; color: var(--faint); background: var(--paper); border-radius: 50%; display: grid; place-items: center; }
button.app-chip { justify-content: flex-start; font-size: 0.84rem; padding: 0.25rem 0.5rem; text-align: left; width: 100%; }
button.app-chip:disabled { opacity: 1; cursor: default; }
.retired-note { grid-column: 1 / -1; color: var(--muted); font-size: 0.86rem; margin: 0; }
@media (max-width: 860px) { .pipeline { grid-template-columns: 1fr 1fr; } .pipeline .arrow { display: none; } }
dl.facts.compact { grid-template-columns: 7.5rem minmax(0, 1fr); }
dl.facts.compact dd { overflow-wrap: anywhere; min-width: 0; }
article.gw-card .rel-top > div:first-child { min-width: 0; }
article.gw-card .rel-top .pill { flex-shrink: 0; white-space: nowrap; }
article.gw-card .card-sub { white-space: nowrap; }
.traffic i[data-zero] { display: none; }
article.gw-card dl.facts.compact { grid-template-columns: 6.6rem minmax(0, 1fr); }
article.gw-card dl.facts.compact dd { overflow-wrap: break-word; }
article.gw-card dl.facts.compact dd.mono { font-size: 0.84rem; }

/* ── UX slice B3: audit log, compliance, integrations, administrators ── */
.swatch-text { display: inline-flex; align-items: center; gap: 0.1rem; }
.card.chain { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; border-left: 6px solid var(--idle); }
.card.chain.live { border-left-color: var(--live); }
.card.chain.stop { border-left-color: var(--stop); background: #fdf3f2; }
.card.chain > div:nth-child(2) { flex: 1; min-width: 0; }
.card.chain h3 { margin: 0 0 0.2rem; }
.chain-icon { width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; background: var(--paper); color: var(--muted); flex-shrink: 0; }
.card.chain.live .chain-icon { color: var(--live); background: #e7f3ec; }
.card.chain.stop .chain-icon { color: var(--stop); background: #fbe4e1; }
.card.chart-card { margin-bottom: 1rem; position: relative; }
tr.audit-row td:first-child { box-shadow: inset 3px 0 0 var(--c, transparent); }
.kindcell { font-weight: 600; }
.card.score { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.card.score .score-text { flex: 1; min-width: 14rem; }
.card.score h3 { margin: 0; font-size: 1.3rem; }
.counts { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
button.count-btn { display: inline-flex; align-items: baseline; gap: 0.35rem; border-radius: 999px; padding: 0.3rem 0.8rem; background: var(--surface); border: 1px solid var(--line); }
button.count-btn b { font-size: 1.05rem; }
button.count-btn.live b { color: var(--live); } button.count-btn.warn b { color: var(--warn); } button.count-btn.stop b { color: var(--stop); }
button.count-btn.on { border-color: var(--ink); background: var(--paper); }
table.fw-grid th[scope=row] { font-weight: 400; min-width: 16rem; }
table.fw-grid tbody tr { box-shadow: inset 4px 0 0 var(--idle); }
table.fw-grid tr.st-pass { box-shadow: inset 4px 0 0 var(--live); }
table.fw-grid tr.st-attention { box-shadow: inset 4px 0 0 var(--warn); }
table.fw-grid tr.st-fail { box-shadow: inset 4px 0 0 var(--stop); }
table.fw-grid tr.detail { box-shadow: none; background: var(--paper); }
table.fw-grid tr.detail p { margin: 0.2rem 0; max-width: 60rem; }
button.check-btn { border: 0; background: transparent; padding: 0; text-align: left; display: flex; flex-direction: column; align-items: flex-start; gap: 0.2rem; font-weight: 400; color: var(--ink); }
button.check-btn:hover .check-name { text-decoration: underline; }
.check-name { font-size: 0.95rem; }
.ref { display: inline-block; font-family: var(--code); font-size: 0.8rem; background: var(--paper); border: 1px solid var(--line-soft); border-radius: 4px; padding: 0.05rem 0.35rem; margin: 0.1rem 0.2rem 0.1rem 0; white-space: nowrap; }
table.fw-grid .none { color: var(--faint); }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.7rem; }
a.dl-card { display: flex; gap: 0.7rem; align-items: center; padding: 0.75rem 0.9rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); text-decoration: none; }
a.dl-card:hover { border-color: var(--ink); }
a.dl-card > svg { transform: rotate(90deg); color: var(--muted); flex-shrink: 0; }
a.dl-card > span { display: flex; flex-direction: column; }
.card.setting-card { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.card.setting-card h3 { margin: 0; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin: 2rem 0 0.8rem; }
.section-head h2 { margin: 0 0 0.2rem; }
.section-head .hint { margin: 0; max-width: 46rem; }
.strip { display: flex; gap: 3px; margin-top: 0.3rem; min-height: 14px; }
.strip i { width: 9px; height: 14px; border-radius: 2px; background: var(--live); }
.strip i.bad { background: var(--stop); }
article.gw-card.idle::before { background: var(--idle); }
.note.warn-note { border-left-color: var(--warn); background: #fdf6ea; }
table.perm-grid caption { caption-side: top; text-align: left; color: var(--muted); padding: 0.6rem 0.9rem; font-size: 0.9rem; }
table.perm-grid th.role-col { text-align: center; }
table.perm-grid th.role-col .sub { font-weight: 400; }
table.perm-grid td.perm { text-align: center; }
table.perm-grid .mine { background: #fff7e6; }
table.perm-grid .yes { color: var(--live); display: inline-grid; }
table.perm-grid .no { color: var(--faint); }
table.perm-grid tbody th { font-weight: 400; }
details.card.setup { margin-top: 1rem; }
details.card.setup summary { cursor: pointer; }
@media (max-width: 860px) { .section-head { flex-direction: column; align-items: flex-start; } }
table.perm-grid thead th .sub, table.fw-grid thead th .sub { display: block; }
table.fw-grid th[scope=row] { min-width: 13rem; max-width: 22rem; }
table.fw-grid td { min-width: 5.5rem; }
table.fw-grid tr.expanded { background: var(--paper); }
details.card.setup summary { margin-bottom: 0.6rem; }
details.card.setup summary .sub { display: inline; }
button.check-btn { white-space: normal; width: 100%; }
dl.facts dd .sub { display: block; }

/* UX part C: daily history */
.chart-empty.neutral { color: var(--muted); font-weight: 400; }
.chart .norecord { fill: var(--idle-bg); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spark30 { display: flex; align-items: center; justify-content: flex-end; gap: 0.35rem; }
.uptime { position: relative; margin: 0.2rem 0 0.8rem; }
.uptime-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.86rem; }
.uptime-head .label { color: var(--muted); }
.uptime-strip { display: block; width: 100%; height: 18px; margin-top: 0.3rem; }
.uptime-strip rect { cursor: default; }
.uptime-strip .up-live { fill: var(--live); }
.uptime-strip .up-warn { fill: var(--warn); }
.uptime-strip .up-stop { fill: var(--stop); }
.uptime-strip .up-none { fill: var(--idle-bg); }
.uptime-axis { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }
table.day-grid { font-size: 0.82rem; }
table.day-grid th[scope=row] { font-weight: 400; min-width: 11rem; }
table.day-grid th[scope=row] .sub { display: block; }
table.day-grid td, table.day-grid th { padding: 0.25rem 0.35rem; white-space: nowrap; }
table.day-grid tbody th[scope=row] { white-space: normal; }
.day-cell { position: relative; display: inline-flex; width: 1.4rem; height: 1.4rem; align-items: center; justify-content: center; border-radius: 4px; }
.day-cell.live { background: var(--live-bg); color: var(--live); }
.day-cell.warn { background: var(--warn-bg); color: var(--warn); }
.day-cell.stop { background: var(--stop-bg); color: var(--stop); }
.uptime-legend { font-size: 0.78rem; gap: 0.3rem 0.8rem; margin-top: 0.3rem; }
.uptime-legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.swatch.up-live { background: var(--live); } .swatch.up-warn { background: var(--warn); }
.swatch.up-stop { background: var(--stop); } .swatch.up-none { background: var(--idle-bg); border: 1px solid var(--line); }
