/* chai-ui — the one design system every Chai-Org console renders on (UX-007, UX-008).
 *
 * Served to both consoles at /shared/chai-ui.css, before each console's own stylesheet. The colour
 * tokens are site/page.py's, under the site's own names; common/tests/test_kit_tokens.py keeps them
 * equal. A console never declares a colour of its own: it uses these tokens, and the component
 * classes below (`ui-*`), and the lint in common/tests/test_colour_literals.py only lets the count of
 * literal colours in console files go down.
 *
 * Light is the default; dark follows the viewer's preference unless the page says otherwise
 * (`<html data-theme="light|dark|auto">`, set by ChaiUI.theme and remembered per viewer).
 */

/* -- faces: self-hosted, so a Cell with no internet still renders them (UX-007, amended 2026-09-26) */
@font-face { font-family: "Sora"; src: url("fonts/sora.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/plex-sans.woff2") format("woff2"); font-weight: 100 700; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/plex-mono.woff2") format("woff2"); font-weight: 400; font-display: swap; }

/* -- tokens ------------------------------------------------------------------------------------ */
:root {
  color-scheme: light;
  --bg: #F3F4F9;  --bg2: #FFFFFF;  --surface-2: #F8F9FC;
  --ink: #111633; --ink2: #4B5275; --mute: #8A90AD; --line: #DCDFEC;
  --accent: #1FB8A9; --accent2: #7C6CF0;
  --glow: rgba(31,184,169,.18); --glow2: rgba(124,108,240,.16);
  --panel: rgba(255,255,255,.84);
  --shadow: 0 12px 40px rgba(17,22,51,.10);
  --ok: #1FA36B; --warn: #D48A1C; --bad: #C4443A; --info: #4776C7;
  /* soft backgrounds and legible inks for each semantic colour and the accents (AA on their bg) */
  --ok-bg: #E4F5EC;     --ok-ink: #14764B;
  --warn-bg: #FBF0DD;   --warn-ink: #8A5A0E;
  --bad-bg: #FAE5E3;    --bad-ink: #8C2F28;
  --info-bg: #E6EEFA;   --info-ink: #2F5596;
  --mute-bg: #EEF0F6;
  --accent-bg: #E4F6F3; --accent-ink: #0E6F65;
  --accent2-bg: #ECE9FD;
  --button-ink: #111633;                       /* text on the teal→violet primary, both themes */
  --overlay: rgba(17,22,51,.42);
  --head: "Sora", "IBM Plex Sans", system-ui, sans-serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-chip: 6px; --r: 10px; --r-lg: 16px;
  --target: 44px;
  --text-body: 13.5px;                          /* screen text: the Flight Deck's size, both consoles */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0B1020;  --bg2: #121833;  --surface-2: #0F1530;
    --ink: #EEF0FA; --ink2: #B9BED8; --mute: #7C82A6; --line: #252C4E;
    --accent: #3DD6C8; --accent2: #9A8CFF;
    --glow: rgba(61,214,200,.16); --glow2: rgba(154,140,255,.16);
    --panel: rgba(18,24,51,.88);
    --shadow: 0 12px 40px rgba(0,0,0,.45);
    --ok: #43D48E; --warn: #F0B44A; --bad: #F07A70; --info: #7C9BFF;
    --ok-bg: #12321F;     --ok-ink: #8FE7B8;
    --warn-bg: #332811;   --warn-ink: #F5CF86;
    --bad-bg: #3A1B1E;    --bad-ink: #F5A8A2;
    --info-bg: #17223F;   --info-ink: #A9BEFF;
    --mute-bg: #1A2040;
    --accent-bg: #123A3A; --accent-ink: #7FE6DC;
    --accent2-bg: #221E45;
    --overlay: rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B1020;  --bg2: #121833;  --surface-2: #0F1530;
  --ink: #EEF0FA; --ink2: #B9BED8; --mute: #7C82A6; --line: #252C4E;
  --accent: #3DD6C8; --accent2: #9A8CFF;
  --glow: rgba(61,214,200,.16); --glow2: rgba(154,140,255,.16);
  --panel: rgba(18,24,51,.88);
  --shadow: 0 12px 40px rgba(0,0,0,.45);
  --ok: #43D48E; --warn: #F0B44A; --bad: #F07A70; --info: #7C9BFF;
  --ok-bg: #12321F;     --ok-ink: #8FE7B8;
  --warn-bg: #332811;   --warn-ink: #F5CF86;
  --bad-bg: #3A1B1E;    --bad-ink: #F5A8A2;
  --info-bg: #17223F;   --info-ink: #A9BEFF;
  --mute-bg: #1A2040;
  --accent-bg: #123A3A; --accent-ink: #7FE6DC;
  --accent2-bg: #221E45;
  --overlay: rgba(0,0,0,.6);
}

/* -- base -------------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--head); letter-spacing: -.01em; text-wrap: balance; }
code, kbd, samp, pre, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
a { color: var(--accent-ink); }
/* One focus ring, everywhere, never removed: the accent's ink so it clears 3:1 on every surface. */
:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; }
[hidden] { display: none !important; }
.ui-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ui-skip { position: absolute; left: 12px; top: -60px; z-index: 300; background: var(--bg2); color: var(--ink);
  padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r); }
.ui-skip:focus { top: 10px; }

/* -- shell: sticky translucent header, section rail, main, footer (both consoles' index.html) ---- */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 20px; min-height: 60px; background: var(--panel); backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; font-size: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--button-ink); }
.brand-title { font: 600 16px/1.1 var(--head); letter-spacing: .02em; }
.brand-sub { font: 400 11.5px/1.3 var(--mono); color: var(--ink2); letter-spacing: .04em; }
.top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
/* The shell spans the window, so the rail sits flush at its left edge at every width (work-1445: a centred,
   max-width shell left dead space left of the rail on a wide window). The content keeps its measure instead:
   the viewport is capped and centred in what the rail leaves — 1680 px of rail and content together, as before. */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 0; }
.leftnav { position: sticky; top: 60px; align-self: start; max-height: calc(100vh - 60px); overflow-y: auto;
  padding: 16px 10px 24px; border-right: 1px solid var(--line); }
.viewport { min-width: 0; width: 100%; max-width: 1444px; justify-self: center; padding: 12px 24px 48px; }
.shell[data-rail="collapsed"] .viewport { max-width: 1624px; }
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 14px 24px;
  border-top: 1px solid var(--line); color: var(--ink2); font-size: 13px; }
.kbd-help b, .nav-key { font-family: var(--mono); font-weight: 400; }

/* the rail: links, the current one marked with an accent left border and a glow wash */
/* Groups are visibly separate: in PAC, an operator diagnosing an outage must never be one click from
   re-pointing a founder's coding agent without seeing the boundary. */
.nav-group + .nav-group { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.nav-group-h { font: 400 11.5px/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink2);
  padding: 6px 12px; }
.nav-group-h span { display: block; letter-spacing: .04em; text-transform: none; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--target); padding: 8px 12px;
  border: 0; border-left: 3px solid transparent; border-radius: 0 var(--r) var(--r) 0; background: none; color: var(--ink2);
  font: 500 14.5px/1.3 var(--sans); text-align: left; text-decoration: none; cursor: pointer; }
.nav-item:hover { color: var(--ink); background: var(--surface-2); }
.nav-item[aria-current="page"] { color: var(--ink); border-left-color: var(--accent); background: var(--glow); }
.nav-key { min-width: 1.6em; font-size: 12px; color: var(--ink2); border: 1px solid var(--line); border-radius: 5px;
  text-align: center; padding: 0 4px; }
.nav-count { margin-left: auto; font: 400 12px var(--mono); color: var(--ink2); }
.nav-item { position: relative; }
.nav-icon { flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; font: 400 18px/1 var(--sans);
  color: var(--ink2); }
.nav-item:hover .nav-icon, .nav-item[aria-current="page"] .nav-icon { color: var(--accent-ink); }
/* the pin at the rail's foot (ChaiUI.railMode): sticky, so a rail longer than the window still shows it; its
   icon is the whole control — the name and tooltip say what it does (work-1445) */
.nav-foot { position: sticky; bottom: 0; margin-top: 14px; padding: 8px 0; border-top: 1px solid var(--line); background: inherit; }
.nav-pin { display: flex; align-items: center; min-width: var(--target); min-height: var(--target); padding: 8px 12px;
  border: 0; border-left: 3px solid transparent; border-radius: 0 var(--r) var(--r) 0; background: none; color: var(--ink2);
  cursor: pointer; }
.nav-pin:hover { color: var(--ink); background: var(--surface-2); }
.nav-pin[aria-pressed="true"] { color: var(--accent-ink); }
.nav-pin-icon { flex: none; width: 24px; transition: transform .16s ease; }
.nav-pin[aria-pressed="false"] .nav-pin-icon { transform: rotate(45deg); }

/* -- the rail folded to icons (work-1442; round 2 work-1445) ------------------------------------
   ChaiUI.railMode sets data-rail on .shell and .leftnav: "pinned" is the rail above; "collapsed" is a
   56 px icon column. Its edge half opens the whole rail OVER the page (data-rail-open) — the grid column
   stays 56 px, so the content never moves; its content half peeks: only the nearest item's label unrolls
   out over the page (data-peek). Labels stay in the links, clipped, so every link keeps its name. Wide
   screens only: below 1100 px the rail is the strip, whatever the mode. */
@media (min-width: 1101px) {
  /* flush at the window edge; opaque, so the sticky pin at its foot hides what scrolls under it, and no
     bottom padding below the pin */
  .leftnav { background: var(--bg); padding-left: 0; padding-bottom: 0; }
  .shell[data-rail="collapsed"] { grid-template-columns: 56px minmax(0, 1fr); }
  .leftnav[data-rail="collapsed"] { z-index: 45; width: 56px; padding: 12px 6px 0 0; overflow-x: hidden;
    transition: width .16s ease, box-shadow .16s ease; }
  /* open, it is the same rail, wider: its own background, lifted off the page by a shadow only */
  .leftnav[data-rail="collapsed"][data-rail-open] { width: 248px; box-shadow: var(--shadow); }
  .leftnav[data-rail="collapsed"] .nav-item, .leftnav[data-rail="collapsed"] .nav-pin { padding-left: 13px; padding-right: 8px; white-space: nowrap; }
  /* the peek: the item nearest the pointer unrolls its own label out over the page, level with it */
  .leftnav[data-rail="collapsed"]:not([data-rail-open]) .nav-item[data-peek] { color: var(--ink); background: var(--surface-2); border-radius: 0; }
  .leftnav[data-rail="collapsed"]:not([data-rail-open]) .nav-item[data-peek] .nav-label { position: fixed; left: var(--peek-x); top: var(--peek-y);
    z-index: 46; display: flex; align-items: center; width: auto; height: var(--target); margin: 0; padding: 0 16px 0 10px; clip: auto;
    overflow: visible; transform: translateY(-50%); background: var(--surface-2); color: var(--ink); border-radius: 0 var(--r) var(--r) 0;
    box-shadow: var(--shadow); white-space: nowrap; animation: nav-peek .18s ease-out; }
  .leftnav[data-rail="collapsed"] .nav-label { overflow: hidden; text-overflow: ellipsis; }
  .leftnav[data-rail="collapsed"] .nav-group + .nav-group { margin-top: 8px; padding-top: 6px; }
  /* a group's name keeps its row, so the icons do not jump when the overlay opens; folded, it is blank */
  .leftnav[data-rail="collapsed"] .nav-group-h { height: 22px; padding: 3px 9px; overflow: hidden; white-space: nowrap; font-size: 10.5px; }
  .leftnav[data-rail="collapsed"] .nav-group-h span { display: none; }
  .leftnav[data-rail="collapsed"]:not([data-rail-open]) .nav-group-h { opacity: 0; }
  .leftnav[data-rail="collapsed"]:not([data-rail-open]) .nav-key { display: none; }
  .leftnav[data-rail="collapsed"]:not([data-rail-open]) .nav-label { position: absolute; width: 1px; height: 1px; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* folded, a count is a dot on its icon; the number is still the link's text */
  .leftnav[data-rail="collapsed"]:not([data-rail-open]) .nav-count { position: absolute; top: 8px; left: 30px; width: 9px; height: 9px;
    margin: 0; overflow: hidden; border: 2px solid var(--bg); border-radius: 50%; background: var(--accent); font-size: 0; }
}
@keyframes nav-peek { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) {
  .leftnav, .nav-pin-icon { transition: none !important; }
  .nav-item[data-peek] .nav-label { animation: none !important; }
}
@media (max-width: 1100px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .leftnav { position: sticky; top: 60px; z-index: 40; max-height: none; display: flex; gap: 4px; overflow-x: auto;
    padding: 6px 12px; border-right: 0; border-bottom: 1px solid var(--line); background: var(--panel);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
  .nav-group { display: contents; }
  .nav-group + .nav-group { border-top: 0; padding-top: 0; margin-top: 0; }
  .nav-group-h, .nav-key, .nav-icon, .nav-foot { display: none; }
  .nav-item { width: auto; white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; border-radius: var(--r) var(--r) 0 0; }
  .nav-item[aria-current="page"] { border-bottom-color: var(--accent); }
  .viewport { padding: 12px 16px 40px; }
}
@media (max-width: 760px) {
  .topbar { padding: 8px 16px; flex-wrap: wrap; }
  .brand-sub, .kbd-help { display: none; }
  .footer { padding: 12px 16px; }
}

/* -- header controls ---------------------------------------------------------------------------- */
.ui-icon-btn, .btn { display: inline-grid; place-items: center; min-width: var(--target); min-height: var(--target);
  padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg2); color: var(--ink);
  font: 500 16px/1 var(--sans); cursor: pointer; }
.ui-icon-btn:hover, .btn:hover { border-color: var(--accent); }
.ui-theme { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg2); overflow: hidden; }
.ui-theme label { display: inline-flex; align-items: center; min-height: var(--target); padding: 0 11px; cursor: pointer;
  font: 500 13px var(--sans); color: var(--ink2); }
.ui-theme input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ui-theme input:checked + span { color: var(--ink); }
.ui-theme label:has(input:checked) { background: var(--glow); color: var(--ink); }
.ui-theme label:has(input:focus-visible) { outline: 3px solid var(--accent-ink); outline-offset: -3px; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 3px 11px; border-radius: 999px;
  border: 1px solid var(--line); font: 500 12.5px/1.2 var(--sans); white-space: nowrap; background: var(--bg2); color: var(--ink2); }
.pill-ok { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn); }
.pill-down { background: var(--bad-bg); color: var(--bad-ink); border-color: var(--bad); }
.pill-muted { background: var(--mute-bg); color: var(--ink2); border-color: var(--line); }

/* -- a screen: the root every migrated view renders into ---------------------------------------- */
.ui-screen { font: var(--text-body)/1.6 var(--sans); color: var(--ink); min-width: 0; }
.ui-screen p { max-width: 72ch; }

/* heading block: eyebrow, one h1, one line of description, actions on the right */
.ui-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; margin: 15px 0 17px; }
.ui-head > div:first-child { min-width: 0; }
.ui-eyebrow { font: 400 12px/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink2); }
.ui-head h1 { font: 600 clamp(23.5px, 16px + 1.4vw, 32.5px)/1.15 var(--head); margin: 3.5px 0 5px; }
.ui-head h1:focus { outline: none; }
.ui-lede { margin: 0; color: var(--ink2); max-width: 72ch; }
.ui-actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.ui-screen h2 { font: 600 18px/1.3 var(--head); margin: 23.5px 0 10px; }
.ui-screen h3 { font: 600 14px/1.35 var(--head); margin: 15px 0 7px; }

.ui-crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; list-style: none; margin: 7px 0 0; padding: 0; font-size: 13.5px; color: var(--ink2); }
.ui-crumbs li { display: inline-flex; align-items: center; gap: 5px; }
.ui-crumbs li + li::before { content: "/"; color: var(--mute); }
.ui-crumbs a { display: inline-flex; align-items: center; min-height: var(--target); color: var(--ink2); }
.ui-crumbs [aria-current="page"] { color: var(--ink); }

/* section sub-nav (links) and in-page tabs (buttons with role=tab) share one look */
.ui-subnav, .ui-tabs { display: flex; gap: 3.5px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 0 0 15px; }
.ui-subnav a, .ui-tabs [role="tab"] { display: inline-flex; align-items: center; gap: 5px; min-height: var(--target); padding: 7px 12px;
  border: 0; border-bottom: 3px solid transparent; background: none; color: var(--ink2); font: 500 14.5px var(--sans);
  text-decoration: none; cursor: pointer; border-radius: var(--r) var(--r) 0 0; }
.ui-subnav a:hover, .ui-tabs [role="tab"]:hover { color: var(--ink); background: var(--surface-2); }
.ui-subnav a[aria-current="page"], .ui-tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); background: var(--glow); }
@media (max-width: 760px) { .ui-subnav, .ui-tabs { flex-wrap: nowrap; overflow-x: auto; } .ui-subnav a, .ui-tabs [role="tab"] { white-space: nowrap; } }

/* -- chips and dots: status states a fact; the word is always there, colour is never alone ------ */
.ui-chip { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 1.5px 7.5px; border: 1px solid var(--line);
  border-radius: var(--r-chip); background: var(--bg2); color: var(--ink2); font: 400 12.5px/1.3 var(--mono);
  font-variant-numeric: tabular-nums; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.ui-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--mute); flex: none; }
/* In a flex row a chip keeps its word whole rather than shrinking to "up to dat". */
.ui-chip { flex-shrink: 0; }
.ui-chip[data-tone="none"]::before { display: none; }
.ui-chip[data-tone="ok"] { color: var(--ok-ink); border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); background: var(--ok-bg); }
.ui-chip[data-tone="ok"]::before { background: var(--ok); }
.ui-chip[data-tone="warn"] { color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); background: var(--warn-bg); }
.ui-chip[data-tone="warn"]::before { background: var(--warn); }
.ui-chip[data-tone="bad"] { color: var(--bad-ink); border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); background: var(--bad-bg); }
.ui-chip[data-tone="bad"]::before { background: var(--bad); }
.ui-chip[data-tone="info"] { color: var(--info-ink); background: var(--info-bg); }
.ui-chip[data-tone="info"]::before { background: var(--info); }
.ui-chip[data-tone="accent"] { color: var(--accent-ink); background: var(--accent-bg); }
.ui-chip[data-tone="accent"]::before { background: var(--accent); }
.ui-chip[data-live]::before { box-shadow: 0 0 0 3px var(--glow); }
a.ui-chip, button.ui-chip { cursor: pointer; text-decoration: none; position: relative; overflow: visible; }
/* A link chip, or a link leading a list item, keeps its size in a dense row and gains a 44 px hit
   area (UX-008 §7) — the browser pass found 26 px targets on the Deck and the Work board. A 22 px
   chip (the 13.5 px scale, work-909) needs 11 px above and below. */
a.ui-chip::after, button.ui-chip::after, .ui-screen li > a:first-child::after { content: ""; position: absolute; inset: -11px -2px; }
.ui-screen li > a:first-child { position: relative; }
.ui-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--mute); vertical-align: middle; }
.ui-dot[data-tone="ok"] { background: var(--ok); } .ui-dot[data-tone="warn"] { background: var(--warn); } .ui-dot[data-tone="bad"] { background: var(--bad); }
.ui-absent { color: var(--ink2); font-style: italic; }

/* -- surfaces ---------------------------------------------------------------------------------- */
.ui-card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 15px 17px; min-width: 0; }
.ui-card > h2:first-child, .ui-card > h3:first-child { margin-top: 0; }
.ui-grid { display: grid; gap: 13.5px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.ui-stack > * + * { margin-top: 13.5px; }
.ui-stats { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; margin: 0 0 17px; }
.ui-stat { padding: 12px 15px; border-right: 1px solid var(--line); min-width: 0; color: inherit; text-decoration: none; }
.ui-stat:last-child { border-right: 0; }
.ui-stat-label { font: 400 12px/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink2); }
.ui-stat-value { display: block; font: 600 23px/1.2 var(--head); font-variant-numeric: tabular-nums; margin: 3.5px 0 1.5px; }
.ui-stat-sub { font-size: 13px; color: var(--ink2); }
.ui-stat[data-tone="bad"] .ui-stat-value { color: var(--bad-ink); } .ui-stat[data-tone="warn"] .ui-stat-value { color: var(--warn-ink); }
.ui-stat[data-tone="ok"] .ui-stat-value { color: var(--ok-ink); }
a.ui-stat:hover { background: var(--surface-2); }
.ui-kv { display: grid; grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr); gap: 5px 13.5px; margin: 0; font-size: 14.5px; }
.ui-kv dt { color: var(--ink2); } .ui-kv dd { margin: 0; overflow-wrap: anywhere; }

.ui-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg2); }
.ui-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.ui-table th, .ui-table td { padding: 8.5px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.ui-table thead th { font: 400 12px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); background: var(--surface-2); }
.ui-table tbody tr:last-child td { border-bottom: 0; }
.ui-table tbody tr:hover { background: var(--surface-2); }
.ui-table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* -- controls ---------------------------------------------------------------------------------- */
.ui-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: var(--target); padding: 7px 13.5px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--bg2); color: var(--ink); font: 500 14.5px/1.2 var(--sans);
  text-decoration: none; cursor: pointer; white-space: nowrap; }
.ui-btn:hover { border-color: var(--accent2); }
.ui-btn[data-variant="primary"] { background: linear-gradient(105deg, var(--accent), var(--accent2)); color: var(--button-ink); border: 0; }
.ui-btn[data-variant="danger"] { background: var(--bad-bg); color: var(--bad-ink); border-color: var(--bad); }
.ui-btn[data-variant="quiet"] { background: none; border-color: transparent; color: var(--accent-ink); }
.ui-btn:disabled, .ui-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.ui-field { display: flex; flex-direction: column; gap: 3.5px; font-size: 13.5px; color: var(--ink2); min-width: 0; }
.ui-field :is(input, select, textarea), .ui-input { min-height: var(--target); padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg2); color: var(--ink); font: 400 15px/1.4 var(--sans); max-width: 100%; }
.ui-field textarea { min-height: 81px; }
.ui-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8.5px 12px; margin: 0 0 13.5px; }
.ui-filter .ui-field { flex: 1 1 12rem; }
@media (max-width: 760px) { .ui-filter > *, .ui-filter .ui-field { flex: 1 1 100%; } }

/* -- disclosure: detail one step away, in place (UX-006) --------------------------------------- */
.ui-more { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 3.5px; }
.ui-more > summary { display: flex; align-items: center; gap: 7px; min-height: var(--target); cursor: pointer; font-weight: 500; color: var(--ink2); list-style: none; }
.ui-more > summary::-webkit-details-marker { display: none; }
.ui-more > summary::before { content: "▸"; font-size: 12px; transition: transform .15s; }
.ui-more[open] > summary::before { transform: rotate(90deg); }
.ui-more pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 12.5px/1.5 var(--mono); max-height: 28rem; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; }

/* -- states: waiting, unavailable, empty, gaps — never an empty element, never a silent zero ---- */
.ui-status { color: var(--ink2); font-size: 14.5px; margin: 10px 0; }
.ui-alert { border: 1px solid var(--bad); border-left-width: 4px; border-radius: var(--r); background: var(--bad-bg); color: var(--bad-ink);
  padding: 12px 13.5px; margin: 10px 0; }
.ui-alert[data-tone="warn"] { border-color: var(--warn); background: var(--warn-bg); color: var(--warn-ink); }
.ui-alert strong { display: block; font-family: var(--head); margin-bottom: 1.5px; }
.ui-alert .ui-btn { margin-top: 8.5px; }
.ui-empty { border: 1px dashed var(--line); border-radius: var(--r-lg); padding: 18.5px; color: var(--ink2); text-align: center; }
.ui-gaps { border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: var(--r); background: var(--bg2); padding: 10px 13.5px; margin: 13.5px 0; }
.ui-gaps h2, .ui-gaps h3 { font-size: 1rem; margin: 0 0 5px; }
.ui-gaps ul { margin: 0; padding-left: 1.2em; color: var(--ink2); }
.ui-fresh { font: 400 12.5px var(--mono); color: var(--ink2); }

/* -- floating: dialog, drawer, toast, tooltip — the only places --shadow is spent -------------- */
.ui-overlay { position: fixed; inset: 0; z-index: 200; background: var(--overlay); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 13.5px 13.5px; }
.ui-dialog { width: min(520px, 100%); background: var(--bg2); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 17px 18.5px; }
.ui-dialog h2 { font: 600 16px/1.3 var(--head); margin: 0 0 7px; }
.ui-dialog p { color: var(--ink2); margin: 0 0 10px; }
.ui-dialog-detail { max-height: 40vh; overflow: auto; margin: 0 0 10px; }
.ui-dialog-detail pre { white-space: pre-wrap; font: 12.5px/1.5 var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 8.5px; margin: 0; }
.ui-dialog-actions { display: flex; justify-content: flex-end; gap: 7px; flex-wrap: wrap; margin-top: 13.5px; }
.ui-drawer-host { position: fixed; inset: 0; z-index: 190; background: var(--overlay); }
.ui-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 191; width: min(620px, 100%); background: var(--bg2); color: var(--ink);
  border-left: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.ui-drawer[data-size="wide"] { width: min(1240px, 96vw); }
.ui-drawer > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 13.5px 17px; border-bottom: 1px solid var(--line); }
.ui-drawer > header h2 { font: 600 16px/1.3 var(--head); margin: 1.5px 0 0; }
.ui-drawer-body { padding: 13.5px 17px 23.5px; overflow-y: auto; }
.ui-toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 250; display: flex; flex-direction: column; gap: 7px; align-items: center; pointer-events: none; }
.ui-toast { pointer-events: auto; max-width: min(90vw, 560px); padding: 8.5px 13.5px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--bg2); color: var(--ink); box-shadow: var(--shadow); font-weight: 500; font-size: 14.5px; }
.ui-toast[data-tone="ok"] { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--ok); }
.ui-toast[data-tone="bad"] { background: var(--bad-bg); color: var(--bad-ink); border-color: var(--bad); }
.ui-toast[data-tone="warn"] { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn); }
.ui-toast[data-tone="accent"] { background: var(--accent-bg); color: var(--accent-ink); border-color: var(--accent); }
.ui-tip { position: fixed; z-index: 260; max-width: 320px; padding: 7px 9.5px; border-radius: var(--r); background: var(--ink); color: var(--bg);
  font-size: 13px; line-height: 1.45; box-shadow: var(--shadow); pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .leftnav, .footer, .ui-actions { display: none !important; }
  .shell { display: block; }
}
