/* ============================================================
   Whisper · DB Navigator — styles.css
   Brand & Craft System v1 (app/BRAND.md §2–7) on top of the
   v3 layout system (app/DESIGN.md). Token NAMES are the shared
   contract with view CSS; values follow BRAND.md.
   Air-gapped (INV-1): fonts are self-hosted under /static/fonts.
   Dark mode: prefers-color-scheme (unless [data-theme=light])
   and explicit [data-theme=dark].
   ============================================================ */

/* ---------- Fonts (self-hosted, no external requests) ---------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/InterVariable.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/InterVariable-Italic.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/JetBrainsMono-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/JetBrainsMono-Medium.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("fonts/JetBrainsMono-SemiBold.woff2") format("woff2");
}

/* ---------- Tokens (light) ---------- */
:root {
  color-scheme: light;
  --font: "Inter", "Segoe UI Variable Text", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;

  /* type scale (REFINE §C) — the ONLY font sizes. size/line-height pairs:
     11/16 · 12/18 · 13/20 · 14/22 · 16/24 · 20/28 · 22/28 (page title) · 28/34 (metric) · 32/40 (docs H1).
     Tracking: ≥22px −0.02em · 16–20px −0.01em · ≤14px 0. */
  --fs-11: 11px; --lh-11: 16px;
  --fs-12: 12px; --lh-12: 18px;
  --fs-13: 13px; --lh-13: 20px;
  --fs-14: 14px; --lh-14: 22px;
  --fs-16: 16px; --lh-16: 24px;
  --fs-20: 20px; --lh-20: 28px;
  --fs-22: 22px; --lh-22: 28px;
  --fs-28: 28px; --lh-28: 34px;
  --fs-32: 32px; --lh-32: 40px;
  --type-11: 400 11px/16px var(--font);
  --type-12: 400 12px/18px var(--font);
  --type-13: 400 13px/20px var(--font);
  --type-14: 400 14px/22px var(--font);
  --type-16: 400 16px/24px var(--font);
  --type-20: 600 20px/28px var(--font);
  --type-22: 600 22px/28px var(--font);
  --type-28: 600 28px/34px var(--font);
  /* legacy names alias the semantic tracking tokens (one vocabulary — prefer --track-display/-heading/-code) */
  --track-lg: var(--track-display);
  --track-md: var(--track-heading);
  /* tracking tokens (REFINE2 §4): display ≥22px · heading 16–20px · 0 for ≤14px · code = 11px chips only */
  --track-display: -0.02em;
  --track-heading: -0.01em;
  --track-code: 0.02em;
  /* weights: use these where a heavy weight would bloom on dark (dark offsets 600→560, 500→460) */
  --fw-strong: 600;
  --fw-med: 500;

  /* layout (REFINE §C) */
  --page-x: 32px;
  --pane-w: 280px;
  --inspector-w: 420px;
  --tool-head-h: 48px;
  --sub-row-h: 40px;

  /* brand constants (theme-independent) — RESTRAINT.md: neutral ink, ONE deep-blue accent */
  --ink-950: #0B1220;
  --ink-900: #111A2B;
  --ink-800: #1B2536;
  --ink-700: #2A3446;
  --signal: #1F4FD8;
  --signal-hover: #1A43B8;
  --signal-bright: #6E9BFF;
  --signal-ring: rgba(31, 79, 216, 0.28);
  --aurora: #1A7F5A;

  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #F6F7F9;
  --surface-3: #EEF0F3;
  --pop-bg: #FFFFFF;
  --line: #E4E7EC;
  --line-strong: #D0D5DD;
  --line-hover: #B8BFCA;
  --field-border: #8A93A3;
  --text: #0B1220;
  --text-2: #475467;
  --text-3: #5F6B7C;
  --accent: #1F4FD8;
  --accent-hover: #1A43B8;
  --accent-soft: #EEF3FD;
  --accent-fill: #1F4FD8;
  --on-accent: #FFFFFF;
  --signal-soft: #EEF3FD;
  --aurora-soft: #EDF6F1;
  --ok: #177553;
  --ok-soft: #EDF6F1;
  --warn: #B54708;
  --warn-soft: #FDF3E8;
  --err: #B83A33;
  --err-soft: #FCEFEE;
  --info: #1F4FD8;
  --info-soft: #EEF3FD;
  --brand-navy: #0B1220;

  --field-bg: #FFFFFF;
  --table-head: #F9FAFB;
  --row-hover: #F7F8FA;
  --tip-bg: #0B1220;
  --kbd-bg: #FFFFFF;

  --chart-1: #1F4FD8; --chart-2: #0F8B7E; --chart-3: #B7791F; --chart-4: #C2413A;
  --chart-5: #5B6B85; --chart-6: #2B8FBF; --chart-7: #6B8E23; --chart-8: #8A5A9E;

  --shadow-xs: none;
  --shadow-sm: none;
  --shadow-pop: 0 8px 24px rgba(11, 18, 32, 0.10), 0 1px 3px rgba(11, 18, 32, 0.06);
  --shadow-modal: 0 24px 48px -12px rgba(11, 18, 32, 0.25), 0 2px 6px rgba(11, 18, 32, 0.06);
  --shadow-btn: none;
  --hl: none;
  --scrim: rgba(11, 18, 32, 0.28);
  /* focus: two tokens only (REFINE §C) */
  --ring: 0 0 0 1px var(--accent), 0 0 0 3px var(--signal-ring);
  --ring-inset: inset 0 0 0 2px var(--accent);
  --ring-on-ink: inset 0 0 0 2px rgba(110, 155, 255, 0.8);
  /* logo arcs follow the theme (on-ink variant on dark surfaces) */
  --ring-1: #1B4FE0; --ring-2: #058C6D; --ring-3: #C98A00; --ring-4: #C4243F;
  --rail-bg: #0B1220;
  --err-display: var(--err);
  --warn-display: var(--warn);

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --t-fast: 120ms;
  --t-med: 160ms;
  --t-slow: 200ms;

  --r-sm: 6px;
  --r-ctl: 6px;
  --r-panel: 8px;
  --r-pop: 10px;
  --rail-w: 232px;
  --rail-w-collapsed: 60px;
  --topbar-h: 48px;

  /* legacy aliases (v1/v2 view CSS reads these — keep) */
  --fg: var(--text);
  --muted: var(--text-2);
  --surface2: var(--surface-2);
  --teal: var(--ok);
  --teal-soft: var(--ok-soft);
  --amber: var(--warn);
  --amber-soft: var(--warn-soft);
  --red: var(--err);
  --red-soft: var(--err-soft);
  --radius: var(--r-ctl);
  --shadow: none;
  --font-ui: var(--font);
  --font-head: var(--font);
  --font-mono: var(--mono);
}
@media (max-width: 1100px) { :root { --page-x: 24px; } }
@media (max-width: 719.98px) { :root { --page-x: 16px; } }

/* ---------- Tokens (dark) — REFINE §C ladder: the #0B1220 rail is the deepest plane ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0F141C;
    --surface: #151A23;
    --surface-2: #1B212B;
    --surface-3: #222935;
    --pop-bg: #1B212B;
    --line: #262E3B;
    --line-strong: #323B4A;
    --line-hover: #3E4859;
    --field-border: #626E82;
    --text: #E6E9EE;
    --text-2: #A2ABB8;
    --text-3: #8590A0;
    --accent: #6E9BFF;
    --accent-hover: #8DB0FF;
    --accent-soft: #18243B;
    --accent-fill: #2F62E8;
    --on-accent: #FFFFFF;
    --signal-soft: #18243B;
    --aurora-soft: #13261F;
    --ok: #3FAF84;
    --ok-soft: #13261F;
    --warn: #D99A4A;
    --warn-soft: #2B2117;
    --err: #EA6E66;
    --err-soft: #2D191A;
    --info: #6E9BFF;
    --info-soft: #18243B;
    --field-bg: #0C1018;
    --table-head: #181D27;
    --row-hover: #1A202A;
    --tip-bg: #2A3241;
    --kbd-bg: #1B212B;
    --chart-1: #6E9BFF; --chart-2: #3AA79A; --chart-3: #CC9844; --chart-4: #D9665E;
    --chart-5: #8794AB; --chart-6: #5AAFD6; --chart-7: #8DAA4A; --chart-8: #A882BA;
    --shadow-xs: none;
    --shadow-sm: none;
    --shadow-pop: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 12px 32px rgba(0, 0, 0, 0.55);
    --shadow-modal: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 56px rgba(0, 0, 0, 0.6);
    --shadow-btn: none;
    --hl: none;
    --scrim: rgba(4, 6, 10, 0.74);
    --signal-ring: rgba(110, 155, 255, 0.35);
    --fw-strong: 560;
    --fw-med: 460;
    --ring-1: #4A78F0; --ring-2: #0FA37F; --ring-3: #E6A515; --ring-4: #E0485F;
    --rail-bg: #080C14;
    --err-display: #DE6A62;
    --warn-display: #C98E45;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F141C;
  --surface: #151A23;
  --surface-2: #1B212B;
  --surface-3: #222935;
  --pop-bg: #1B212B;
  --line: #262E3B;
  --line-strong: #323B4A;
  --line-hover: #3E4859;
  --field-border: #626E82;
  --text: #E6E9EE;
  --text-2: #A2ABB8;
  --text-3: #8590A0;
  --accent: #6E9BFF;
  --accent-hover: #8DB0FF;
  --accent-soft: #18243B;
  --accent-fill: #2F62E8;
  --on-accent: #FFFFFF;
  --signal-soft: #18243B;
  --aurora-soft: #13261F;
  --ok: #3FAF84;
  --ok-soft: #13261F;
  --warn: #D99A4A;
  --warn-soft: #2B2117;
  --err: #EA6E66;
  --err-soft: #2D191A;
  --info: #6E9BFF;
  --info-soft: #18243B;
  --field-bg: #0C1018;
  --table-head: #181D27;
  --row-hover: #1A202A;
  --tip-bg: #2A3241;
  --kbd-bg: #1B212B;
  --chart-1: #6E9BFF; --chart-2: #3AA79A; --chart-3: #CC9844; --chart-4: #D9665E;
  --chart-5: #8794AB; --chart-6: #5AAFD6; --chart-7: #8DAA4A; --chart-8: #A882BA;
  --shadow-xs: none;
  --shadow-sm: none;
  --shadow-pop: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 12px 32px rgba(0, 0, 0, 0.55);
  --shadow-modal: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 56px rgba(0, 0, 0, 0.6);
  --shadow-btn: none;
  --hl: none;
  --scrim: rgba(4, 6, 10, 0.74);
  --signal-ring: rgba(110, 155, 255, 0.35);
  --fw-strong: 560;
  --fw-med: 460;
  --ring-1: #4A78F0; --ring-2: #0FA37F; --ring-3: #E6A515; --ring-4: #E0485F;
  --rail-bg: #080C14;
  --err-display: #DE6A62;
  --warn-display: #C98E45;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-13);
  line-height: 20px;
  font-feature-settings: "ss03";
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font);
  font-weight: var(--fw-strong);
  margin: 0;
  color: var(--text);
  font-optical-sizing: auto;
  letter-spacing: var(--track-heading);
}
p { margin: 0; }

code, pre, kbd, samp, .mono { font-family: var(--mono); font-feature-settings: "calt" 0; }
code {
  font-size: var(--fs-12);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 5px;
}
pre {
  font-size: var(--fs-12);
  line-height: 1.6;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  padding: 10px 12px;
  margin: 0;
  overflow: auto;
}
pre code { background: none; border: 0; padding: 0; border-radius: 0; font-size: inherit; }
.code, .sql { font-family: var(--mono); font-size: var(--fs-12); background: var(--surface-2); border-radius: var(--r-ctl); }
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-family: var(--font);
  font-size: var(--fs-11);
  font-weight: var(--fw-med);
  color: var(--text-3);
  background: var(--kbd-bg);
  border: 1px solid var(--line-strong);
  border-bottom-width: 1.5px;
  border-radius: var(--r-sm);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.num, time, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: var(--fs-12); line-height: 18px; }
.eyebrow {
  font-size: var(--fs-12);
  line-height: 16px;
  font-weight: var(--fw-med);
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-3);
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* type scale helpers */
.t-meta { font-size: var(--fs-11); line-height: 16px; }
.t-sec { font-size: var(--fs-12); line-height: 18px; }
.t-body { font-size: var(--fs-13); line-height: 20px; }
.t-emph { font-size: var(--fs-14); line-height: 22px; }
.t-section { font-size: var(--fs-16); line-height: 24px; font-weight: var(--fw-strong); letter-spacing: var(--track-heading); }
.t-title { font-size: var(--fs-22); line-height: 28px; font-weight: var(--fw-strong); letter-spacing: var(--track-display); }
.t-metric { font-size: var(--fs-28); line-height: 36px; font-weight: var(--fw-strong); letter-spacing: var(--track-display); font-variant-numeric: tabular-nums; }

button { font-family: var(--font); font-size: var(--fs-13); cursor: pointer; color: inherit; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; }
input, select, textarea { font-feature-settings: "ss03"; }


a { color: var(--accent); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }

::selection { background: var(--signal-soft); color: inherit; }
:root[data-theme="dark"] ::selection { background: rgba(110, 155, 255, 0.28); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) ::selection { background: rgba(110, 155, 255, 0.28); } }

/* thin, quiet scrollbars (8px, rounded, transparent track) */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--line-hover); }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }

/* ============================================================
   SHELL
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-areas: "rail top" "rail main";
  height: 100vh;
  height: 100dvh;
  transition: grid-template-columns var(--t-med) var(--ease);
}
.shell.rail-collapsed { grid-template-columns: var(--rail-w-collapsed) minmax(0, 1fr); }

/* ---------- Rail (always Ink — the brand's constant) ---------- */
.rail {
  grid-area: rail;
  position: relative;
  background: var(--rail-bg);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.68);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  z-index: 60;
  color-scheme: dark;
}
.rail ::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, 0.12); }
.rail * { scrollbar-color: rgba(255, 255, 255, 0.12) transparent; }

.rail-brand {
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: #FFFFFF;
  border-radius: var(--r-ctl);
  padding: 2px;
  margin-left: -2px;
}
.brand-link:hover { text-decoration: none; }
.brand-link:focus-visible { outline: none; box-shadow: var(--ring-on-ink); }
.logo-mark {
  flex: 0 0 auto;
  display: block;
  width: 28px;
  height: 28px;
}
.logo-mark svg, .logo-mark img { display: block; width: 100%; height: 100%; }
.logo-mark-lg { width: 40px; height: 40px; }
.brand-text { display: flex; flex-direction: column; justify-content: center; min-width: 0; white-space: nowrap; line-height: 1; gap: 1px; }
.brand-name {
  font-size: var(--fs-16);
  font-weight: var(--fw-strong);
  letter-spacing: var(--track-heading);
  color: #FFFFFF;
  line-height: 16px;
  font-optical-sizing: auto;
}
.brand-sub {
  font-size: var(--fs-12);
  font-weight: 400;
  letter-spacing: 0;
  color: rgba(255, 255, 255, 0.45);
  line-height: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-group-label {
  flex: 0 0 auto;
  font-size: var(--fs-11);
  line-height: 16px;
  font-weight: var(--fw-med);
  letter-spacing: var(--track-code);
  text-transform: none;
  color: rgba(255, 255, 255, 0.40);
  padding: 16px 10px 6px;
  white-space: nowrap;
  overflow: hidden;
}
.nav-group-label:first-child { padding-top: 6px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  flex: 0 0 32px;
  padding: 0 10px;
  border-radius: var(--r-ctl);
  color: rgba(255, 255, 255, 0.68);
  font-size: var(--fs-13);
  font-weight: var(--fw-med);
  letter-spacing: 0;
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item svg {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  color: rgba(255, 255, 255, 0.45);
  stroke-width: 1.6;
  transition: color var(--t-fast) var(--ease);
}
.nav-item .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item .nav-kbd { margin-left: auto; display: inline-flex; gap: 2px; }
.nav-item kbd, .rail kbd {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.5);
  height: 18px;
  min-width: 18px;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #FFFFFF; text-decoration: none; }
.nav-item:hover svg { color: rgba(255, 255, 255, 0.8); }
.nav-item:active { background: rgba(255, 255, 255, 0.08); }
.nav-item.active { background: rgba(255, 255, 255, 0.06); color: #FFFFFF; font-weight: var(--fw-med); }
.nav-item.active svg { color: #FFFFFF; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--signal-bright);
}

.rail-foot {
  flex: 0 0 auto;
  padding: 8px 10px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.rail-toggle { color: rgba(255, 255, 255, 0.5); }
.rail-toggle svg { transition: transform var(--t-med) var(--ease); }
.shell.rail-collapsed .rail-toggle svg { transform: rotate(180deg); }

/* collapsed icon rail — mark only */
.shell.rail-collapsed .rail-brand { padding: 0; justify-content: center; }
.shell.rail-collapsed .brand-link { margin-left: 0; }
.shell.rail-collapsed .brand-text,
.shell.rail-collapsed .nav-label,
.shell.rail-collapsed .nav-kbd { display: none; }
.shell.rail-collapsed .nav { padding: 10px 10px 12px; align-items: center; }
.shell.rail-collapsed .nav-item { justify-content: center; width: 40px; padding: 0; }
.shell.rail-collapsed .nav-item.active::before { left: -10px; }
.shell.rail-collapsed .nav-group-label {
  font-size: 0;
  padding: 0;
  margin: 8px 6px;
  height: 1px;
  width: 24px;
  flex: 0 0 1px;
  background: rgba(255, 255, 255, 0.08);
}
.shell.rail-collapsed .nav-group-label:first-child { display: none; }
.shell.rail-collapsed .rail-foot { display: flex; justify-content: center; padding: 8px 10px 10px; }
.shell.rail-collapsed .rail-foot .nav-item { width: 40px; }

/* legacy rail tooltip (superseded by .wsn-tip; kept consistent) */
.rail-tip {
  position: fixed;
  z-index: 900;
  pointer-events: none;
  background: var(--tip-bg);
  color: #FFFFFF;
  font-size: var(--fs-12);
  font-weight: var(--fw-med);
  padding: 5px 8px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  box-shadow: var(--shadow-pop);
}

.rail-backdrop { display: none; }

/* ---------- Topbar ---------- */
.topbar {
  grid-area: top;
  position: relative;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 0 24px;
  min-width: 0;
  z-index: 50;
}
.topbar-menu { display: none !important; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 260px;
  white-space: nowrap;
  font-size: var(--fs-13);
  color: var(--text-3);
}
.crumb-group { flex: 0 0 auto; font-weight: var(--fw-med); }
.crumb-sep { color: var(--line-strong); flex: 0 0 auto; font-weight: 300; font-size: var(--fs-16); }
.crumb-page {
  font-size: var(--fs-13);
  font-weight: var(--fw-strong);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  letter-spacing: 0;
}
.crumbs .crumb-group:empty,
.crumbs .crumb-group:empty + .crumb-sep { display: none; }

/* search = command palette trigger */
.top-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 520px;
  margin: 0 auto;
  min-width: 0;
}
.top-search > svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}
.top-search input {
  width: 100%;
  height: 32px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-13);
  padding: 0 72px 0 34px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.top-search input::-webkit-search-cancel-button { display: none; }
.top-search input::placeholder { color: var(--text-3); }
.top-search input:hover { border-color: var(--line-strong); background: var(--surface); box-shadow: var(--shadow-xs); }
.top-search-kbd {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 3px;
  pointer-events: none;
}
.top-search-btn { display: none !important; }
/* the palette replaces the inline results popover */
.top-search .v2w-gs-pop { display: none !important; }

.top-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.top-actions #top-slot { display: inline-flex; align-items: center; gap: 4px; }
.topbar .icon-btn { border-color: transparent; background: transparent; color: var(--text-2); box-shadow: none; }
.topbar .icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Air-gap seal (BRAND §6.3) ---------- */
.egress-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 26px;
  padding: 0 10px 0 9px;
  margin-right: 6px;
  border-radius: var(--r-sm);
  font-size: var(--fs-12);
  font-weight: var(--fw-med);
  white-space: nowrap;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.egress-pill > svg { display: none; }
.egress-pill .seal-dot {
  position: relative;
  flex: 0 0 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--aurora);
  box-shadow: none;
}
.egress-pill .seal-strong { color: var(--text); font-weight: var(--fw-med); }
@keyframes seal-breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
a.egress-pill:hover { text-decoration: none; border-color: var(--line-hover); background: var(--surface-2); }
.egress-pill.bad { color: #FFFFFF; background: var(--err); border-color: var(--err); }
.egress-pill.bad .seal-strong { color: #FFFFFF; }
.egress-pill.bad .seal-dot { background: #FFFFFF; }
a.egress-pill.bad:hover { background: color-mix(in srgb, var(--err) 88%, #000); border-color: transparent; }

.avatar-btn, .avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  margin-left: 6px;
  background: var(--ink-800);
  color: #FFFFFF;
  font-size: var(--fs-11);
  font-weight: var(--fw-strong);
  letter-spacing: var(--track-code);
  flex: 0 0 auto;
  box-shadow: none;
  transition: box-shadow var(--t-fast) var(--ease);
}
.avatar-btn:hover { box-shadow: 0 0 0 2px var(--line-strong); }

/* ---------- Main + views ---------- */
.main {
  grid-area: main;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  min-height: 0;
  padding: 0;
}
.view { display: none; min-width: 0; }
.view.active { display: block; padding: 24px 28px 40px; min-height: 100%; animation: view-in 160ms var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view.active:has(> .page),
.view.active.flush { padding: 0; }
.view.app.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 0;
}
.view.app > .split,
.view.app > .vsplit,
.view.app > .app-body { flex: 1 1 auto; min-height: 0; }

/* ============================================================
   COMPONENTS
   ============================================================ */

/* ---------- Page anatomy ---------- */
.page { padding: 24px 28px 40px; max-width: none; min-width: 0; }
.page-head {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 36px;
  margin-bottom: 20px;
  min-width: 0;
}
.page-head-text, .page-head > .ph-text { min-width: 0; flex: 1 1 auto; }
.page-title {
  font-size: var(--fs-22);
  font-weight: var(--fw-strong);
  line-height: 28px;
  letter-spacing: var(--track-display);
  color: var(--text);
  margin: 0;
  overflow-wrap: anywhere;
  font-optical-sizing: auto;
}
.page-sub {
  font-size: var(--fs-13);
  line-height: 20px;
  color: var(--text-2);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.page-head + .ptabs { margin-top: -6px; }
.view.app .page-head { padding: 16px 24px 0; margin-bottom: 12px; }
.view.app .ptabs { padding: 0 24px; margin-bottom: 0; }

/* ---------- Underline tabs (animated indicator) ---------- */
.ptabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  min-width: 0;
}
.ptabs::-webkit-scrollbar { display: none; }
.ptabs > button, .ptabs > a, .ptab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-13);
  font-weight: var(--fw-med);
  white-space: nowrap;
  text-decoration: none;
  border-radius: var(--r-ctl) var(--r-ctl) 0 0;
  transition: color var(--t-fast) var(--ease);
}
.ptabs > button::before, .ptabs > a::before, .ptab::before {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 6px;
  bottom: 6px;
  border-radius: var(--r-sm);
  background: transparent;
  transition: background var(--t-fast) var(--ease);
  z-index: -1;
}
.ptabs > button, .ptabs > a, .ptab { z-index: 0; }
.ptabs > button:hover, .ptabs > a:hover, .ptab:hover { color: var(--text); text-decoration: none; }
.ptabs > button:hover::before, .ptabs > a:hover::before, .ptab:hover::before { background: var(--surface-2); }
.ptabs > .active, .ptabs > [aria-selected="true"], .ptab.active { color: var(--text); font-weight: var(--fw-strong); }
.ptabs > .active:hover::before, .ptabs > [aria-selected="true"]:hover::before, .ptab.active:hover::before { background: transparent; }
.ptabs > .active::after, .ptabs > [aria-selected="true"]::after, .ptab.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  transform-origin: center;
  animation: tab-ink var(--t-med) var(--ease);
}
@keyframes tab-ink { from { transform: scaleX(0.3); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }
.ptab-count, .ptabs .count {
  font-size: var(--fs-11);
  font-weight: var(--fw-strong);
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 6px;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
}
.ptabs > .active .ptab-count, .ptabs > .active .count { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* ---------- Metric strip ---------- */
.metric-strip {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-xs), var(--hl);
  margin-bottom: 20px;
  min-width: 0;
  overflow: hidden;
}
.metric {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  padding: 16px 20px 16px;
  border-left: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: background var(--t-fast) var(--ease);
}
.metric:first-child { border-left: 0; }
a.metric:hover, button.metric:hover, .metric.clickable:hover { background: var(--row-hover); text-decoration: none; cursor: pointer; }
button.metric { border-top: 0; border-right: 0; border-bottom: 0; background: transparent; text-align: left; font: inherit; }
.metric-label, .metric-value, .metric-foot { display: block; }
.metric-label {
  font-size: var(--fs-12);
  line-height: 18px;
  font-weight: var(--fw-med);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.metric-value {
  font-size: var(--fs-28);
  font-weight: var(--fw-strong);
  line-height: 36px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--track-display);
  color: var(--text);
  white-space: nowrap;
  font-optical-sizing: auto;
}
.metric-value small, .metric-value .of { font-size: var(--fs-16); font-weight: var(--fw-med); color: var(--text-3); letter-spacing: var(--track-heading); }
.metric-foot {
  font-size: var(--fs-12);
  line-height: 18px;
  color: var(--text-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.metric.ok .metric-value { color: var(--text); }
.metric.warn .metric-value { color: var(--warn); }
.metric.err .metric-value { color: var(--err); }
.metric.info .metric-value { color: var(--text); }

/* ---------- Data table ---------- */
.dtable-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--surface);
  box-shadow: var(--shadow-xs), var(--hl);
  overflow: auto;
  min-width: 0;
}
.dtable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-13);
  color: var(--text);
}
.dtable tbody th, .dtable tfoot th { text-align: left; font-weight: var(--fw-med); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.dtable thead th, .dtable > tr > th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 36px;
  padding: 0 12px;
  background: var(--table-head);
  color: var(--text-3);
  font-size: var(--fs-12);
  font-weight: var(--fw-med);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.dtable thead th:first-child, .dtable td:first-child { padding-left: 16px; }
.dtable thead th:last-child, .dtable td:last-child { padding-right: 16px; }
.dtable td {
  height: 40px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  transition: background var(--t-fast) var(--ease);
}
.dtable.compact td { height: 34px; padding-top: 4px; padding-bottom: 4px; }
.dtable tbody tr:last-child td { border-bottom: 0; }
.dtable tbody tr:hover td { background: var(--row-hover); }
.dtable .num, .dtable th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dtable .nowrap { white-space: nowrap; }
.dtable .ellip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dtable .muted, .dtable .sec { color: var(--text-2); }
.dtable .mono, .dtable code { font-size: var(--fs-12); }
.dtable .actions { text-align: right; white-space: nowrap; width: 1%; }
.dtable .primary, .dtable .name { font-weight: var(--fw-med); color: var(--text); }
.dtable tr.clickable { cursor: pointer; }
.dtable tr.sel td, .dtable tr.sel:hover td { background: var(--accent-soft); }
.dtable tr.sel td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.dtable tr.group-row td, .dtable tr.group td {
  height: 32px;
  background: var(--bg);
  font-size: var(--fs-12);
  font-weight: var(--fw-strong);
  color: var(--text-2);
}
/* row actions: revealed on hover/focus (always visible on touch) */
.dtable .row-actions { opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.dtable tr:hover .row-actions, .dtable tr:focus-within .row-actions, .dtable tr.sel .row-actions { opacity: 1; }
@media (hover: none) { .dtable .row-actions { opacity: 1; } }
.dtable-wrap > .dtable thead th:first-child { border-top-left-radius: calc(var(--r-panel) - 1px); }
.dtable-wrap > .dtable thead th:last-child { border-top-right-radius: calc(var(--r-panel) - 1px); }
.dtable-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  font-size: var(--fs-12);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- Panel ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-xs), var(--hl);
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2, .panel-head h3, .panel-head h4, .panel-title {
  font-size: var(--fs-14);
  line-height: 22px;
  font-weight: var(--fw-strong);
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.panel-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: 0 0 auto; }
.panel-body { padding: 16px; }
.panel-body.flush, .panel > .dtable-wrap { padding: 0; border: 0; box-shadow: none; border-radius: 0 0 var(--r-panel) var(--r-panel); }
.panel-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-12);
  color: var(--text-3);
}

/* ---------- Split panes ---------- */
.split {
  display: flex;
  min-height: 0;
  min-width: 0;
  background: var(--surface);
}
.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--surface);
}
.pane + .pane { border-left: 1px solid var(--line); }
.pane-260 { flex: 0 0 260px; width: 260px; }
.pane-280 { flex: 0 0 280px; width: 280px; }
.pane-300 { flex: 0 0 300px; width: 300px; }
.pane-340 { flex: 0 0 340px; width: 340px; }
.pane-420 { flex: 0 0 420px; width: 420px; }
.pane-flex { flex: 1 1 auto; min-width: 0; }
.pane.subtle, .pane-muted { background: var(--bg); }
.pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 48px;
  min-height: 48px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.pane-head h2, .pane-head h3, .pane-head h4, .pane-title {
  font-size: var(--fs-13);
  font-weight: var(--fw-strong);
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pane-head .pane-actions, .pane-head .spacer { margin-left: auto; }
.pane-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.pane-head .ptabs { border-bottom: 0; margin: 0 0 -1px; align-self: stretch; align-items: stretch; }
.pane-head .ptabs > button, .pane-head .ptabs > a { height: 47px; }
.pane-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.pane-body.pad { padding: 12px 16px; }
.pane-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-12);
  color: var(--text-3);
}

/* list rows inside panes */
.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 6px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.list-row:hover { background: var(--row-hover); }
.list-row.sel, .list-row.active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }

/* ---------- Vertical split ---------- */
.vsplit { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.vsplit > .pane + .pane { border-left: 0; }
.gutter {
  flex: 0 0 7px;
  height: 7px;
  cursor: row-resize;
  background: var(--bg);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  position: relative;
  touch-action: none;
  transition: background var(--t-fast) var(--ease);
}
.gutter::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 1.5px;
  width: 32px;
  height: 2px;
  margin-left: -16px;
  border-radius: 2px;
  background: var(--line-strong);
  transition: background var(--t-fast) var(--ease);
}
.gutter:hover, .gutter.dragging { background: var(--accent-soft); }
.gutter:hover::after, .gutter.dragging::after { background: var(--accent); }
.gutter.col { flex: 0 0 7px; width: 7px; height: auto; cursor: col-resize; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.gutter.col::after { left: 1.5px; top: 50%; width: 2px; height: 32px; margin: -16px 0 0; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 0;
  min-width: 0;
  flex-wrap: wrap;
}
.toolbar .spacer, .toolbar .grow { flex: 1 1 auto; }
.toolbar .search, .toolbar input[type="search"] { width: 240px; max-width: 100%; }
.toolbar .toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pane > .toolbar, .panel > .toolbar { padding: 8px 12px; border-bottom: 1px solid var(--line); }

.search-box { position: relative; min-width: 0; }
.search-box > svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search-box > input { padding-left: 32px !important; width: 100%; }

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-13);
  font-weight: var(--fw-med);
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: var(--shadow-btn), var(--hl);
  user-select: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.btn svg { flex: 0 0 auto; }
.btn:hover { background: var(--surface-2); border-color: var(--line-hover); text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(0.98); background: var(--surface-3); box-shadow: none; }
.btn-primary {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-accent);
  box-shadow: none;
}
.btn-primary:hover { background-color: var(--signal-hover); border-color: var(--signal-hover); }
.btn-primary:active:not(:disabled) { background: var(--signal-hover); box-shadow: none; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-ghost:active:not(:disabled) { background: var(--surface-3); }
.btn-danger {
  background: #B83A33;
  border-color: #B83A33;
  color: #FFFFFF;
  box-shadow: none;
}
.btn-danger:hover { background-color: #A8362F; border-color: #A8362F; }
.btn-danger-ghost { border-color: transparent; background: transparent; color: var(--err); box-shadow: none; }
.btn-danger-ghost:hover { background: var(--err-soft); border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-13); gap: 5px; border-radius: var(--r-sm); }
.btn-lg { height: 40px; padding: 0 18px; font-size: var(--fs-14); }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; box-shadow: none; }
/* loading: spinner inside, width stable */
.btn.is-loading, .btn.loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > *, .btn.loading > * { visibility: hidden; }
.btn.is-loading::after, .btn.loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--text) 22%, transparent);
  border-top-color: var(--text);
  animation: spin 0.7s linear infinite;
}
.btn-primary.is-loading::after, .btn-primary.loading::after, .btn-danger.is-loading::after, .btn-danger.loading::after {
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #FFFFFF;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-2);
  flex: 0 0 auto;
  box-shadow: var(--shadow-btn);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--line-hover); }
.icon-btn:active:not(:disabled) { transform: scale(0.98); }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn.ghost, .icon-btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.icon-btn.ghost:hover, .icon-btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.icon-btn.sm, .icon-btn-sm { width: 28px; height: 28px; }
.btn-group { display: inline-flex; box-shadow: var(--shadow-btn); border-radius: var(--r-ctl); }
.btn-group > .btn { border-radius: 0; box-shadow: none; }
.btn-group > .btn:active:not(:disabled) { transform: none; }
.btn-group > .btn + .btn { margin-left: -1px; }
.btn-group > .btn:first-child { border-radius: var(--r-ctl) 0 0 var(--r-ctl); }
.btn-group > .btn:last-child { border-radius: 0 var(--r-ctl) var(--r-ctl) 0; }
.btn-group > .btn.active { background: var(--surface-3); color: var(--text); border-color: var(--line-strong); z-index: 1; }

/* segmented control */
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-ctl); }
.seg > button { height: 26px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font-size: var(--fs-13); font-weight: var(--fw-med); transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.seg > button:hover { color: var(--text); }
.seg > button.active, .seg > button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs), 0 0 0 1px var(--line); }

.mini-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  border: 0;
  background: transparent;
  color: var(--text-3);
  flex: 0 0 auto;
  padding: 0;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.mini-icon-btn:hover { background: var(--surface-2); color: var(--text); }
.mini-icon-btn:active { background: var(--surface-3); }

/* ---------- Inputs ---------- */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="submit"]):not([type="button"]), select, textarea) {
  font-family: var(--font);
  font-size: var(--fs-13);
  color: var(--text);
  background-color: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--r-ctl);
  min-width: 0;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="submit"]):not([type="button"]), select) {
  height: 32px;
  padding: 0 10px;
}
:where(textarea) { padding: 8px 10px; line-height: 1.55; }
:where(input, select, textarea)::placeholder { color: var(--text-3); opacity: 1; }
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea):hover:not(:disabled):not(:focus) { border-color: var(--line-hover); }
:where(input, select, textarea):disabled { background-color: var(--surface-2); color: var(--text-3); cursor: not-allowed; opacity: 0.7; }
:where(input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"]) { border-color: var(--err); }
:where(select) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237A819C' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 10l4-4 4 4'/%3E%3Cpath d='M8 14l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px 14px;
}
:where(select[multiple]) { background-image: none; height: auto; padding: 4px; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

/* checkboxes, radios, switches */
input[type="checkbox"], input[type="radio"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
  vertical-align: -3px;
  border: 1.5px solid var(--field-border);
  background: var(--field-bg) no-repeat center / 12px 12px;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
input[type="checkbox"] { border-radius: 4px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:hover:not(:disabled), input[type="radio"]:hover:not(:disabled) { border-color: var(--accent); }
input[type="checkbox"]:checked, input[type="checkbox"]:indeterminate {
  background-color: var(--accent-fill);
  border-color: var(--accent-fill);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E");
}
input[type="checkbox"]:indeterminate {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M4 8h8'/%3E%3C/svg%3E");
}
input[type="radio"]:checked { border-color: var(--accent-fill); background: radial-gradient(circle, var(--accent-fill) 0 3.5px, var(--field-bg) 4px); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: 0.5; cursor: not-allowed; }
input[type="checkbox"].switch, input[type="checkbox"][role="switch"] {
  width: 30px;
  height: 18px;
  border-radius: 999px;
  border: 0;
  background: var(--line-strong);
  position: relative;
  vertical-align: -4px;
}
input[type="checkbox"].switch::after, input[type="checkbox"][role="switch"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 2px rgba(7, 11, 26, 0.3);
  transition: transform var(--t-med) var(--ease);
}
input[type="checkbox"].switch:checked, input[type="checkbox"][role="switch"]:checked { background: var(--accent-fill); background-image: none; }
input[type="checkbox"].switch:checked::after, input[type="checkbox"][role="switch"]:checked::after { transform: translateX(12px); }
input[type="range"] { accent-color: var(--accent-fill); }
.input { width: 100%; }

/* form fields */
.field { display: block; margin-bottom: 16px; min-width: 0; }
.field .field-label, .field-label {
  display: block;
  font-size: var(--fs-13);
  line-height: 18px;
  font-weight: var(--fw-med);
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 6px;
}
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea, .text-input {
  width: 100%;
  height: 36px;
  background-color: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--r-ctl);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-13);
  padding: 0 11px;
}
.field select { padding-right: 30px; }
.field textarea { height: auto; padding: 8px 11px; }
.field-help, .field .help { display: block; font-size: var(--fs-12); line-height: 18px; color: var(--text-3); margin-top: 6px; }
.mono-input, input.mono-input, textarea.mono-input { font-family: var(--mono); font-size: var(--fs-12); }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1 1 120px; }
.form-row .field.grow { flex: 2 1 160px; }
.form-row .field.w-90 { flex: 0 0 90px; }

.form-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--err);
  background: var(--err-soft);
  border: 1px solid color-mix(in srgb, var(--err) 30%, transparent);
  border-radius: var(--r-ctl);
  padding: 8px 12px;
  font-size: var(--fs-13);
  line-height: 18px;
  margin-bottom: 12px;
}

/* ---------- Pills, dots, badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px 0 7px;
  border-radius: 999px;
  font-size: var(--fs-12);
  font-weight: var(--fw-med);
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  color: var(--text-2);
  background: var(--surface-2);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.pill::before {
  content: "";
  flex: 0 0 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill.no-dot::before { display: none; }
.pill.no-dot { padding: 0 8px; }
.pill-ok, .pill-teal { color: var(--text-2); background: var(--surface); border-color: var(--line); }
.pill-ok::before, .pill-teal::before { background: var(--ok); }
.pill-warn, .pill-amber { color: var(--warn); background: var(--surface); border-color: var(--line); }
.pill-err, .pill-red { color: var(--err); background: var(--surface); border-color: var(--line); }
.pill-idle, .pill-muted { color: var(--text-2); background: var(--surface); border-color: var(--line); }
.pill-idle::before, .pill-muted::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-3); }
.pill-info { color: var(--text-2); background: var(--surface); border-color: var(--line); }
.pill-info::before { background: var(--accent); }
.pill-blue, .pill-accent { color: var(--accent); background: var(--surface); border-color: var(--line); }
.pill-aurora, .pill-sealed { color: var(--text-2); background: var(--surface); border-color: var(--line); }
.pill-aurora::before, .pill-sealed::before { background: var(--ok); }
.pill-syncing::before { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 6px; vertical-align: middle; flex: 0 0 auto; }
.dot-ok, .dot-teal { background: var(--ok); }
.dot-warn, .dot-amber { background: var(--warn); }
.dot-err, .dot-red { background: var(--err); }
.dot-idle, .dot-muted { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-3); }
.dot-info { background: var(--info); }

/* level badges (RESTRAINT 9): mono text in a 1px outline · L2 accent outline · L3 solid text colour */
.badge-level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  min-width: 26px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: var(--fs-11);
  font-weight: var(--fw-strong);
  line-height: 1;
  letter-spacing: var(--track-code);
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  background: transparent;
  white-space: nowrap;
}
.badge-level.l3, .badge-level.L3, .badge-level[data-level="3"], .badge-level[data-level="L3"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
  box-shadow: none;
}
.badge-level.l2, .badge-level.L2, .badge-level[data-level="2"], .badge-level[data-level="L2"] { border-color: var(--accent); color: var(--accent); background: transparent; }
.badge-level.l1, .badge-level.L1, .badge-level[data-level="1"], .badge-level[data-level="L1"] { border-color: var(--line-strong); color: var(--text-2); }
.badge-level.l0, .badge-level.L0, .badge-level[data-level="0"], .badge-level[data-level="L0"] { border-color: var(--line-strong); color: var(--text-3); }

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  font-size: var(--fs-11);
  font-weight: var(--fw-strong);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.demo-pill { font-size: var(--fs-11); height: 18px; padding: 0 6px; margin-left: 4px; }
.roadmap-pill { font-size: var(--fs-11); }

/* ---------- Empty / loading / error states ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  padding: 32px 20px;
  color: var(--text-2);
  max-width: 400px;
  margin: 0 auto;
}
.empty-illus { display: block; color: var(--text-3); margin-bottom: 8px; line-height: 0; }
.empty-icon, .empty > svg:not(.wsn-illus) { color: var(--text-3); width: 28px; height: 28px; margin-bottom: 6px; }
.empty-icon svg { width: 28px; height: 28px; }
.empty-title { font-size: var(--fs-13); line-height: 20px; font-weight: var(--fw-strong); color: var(--text); letter-spacing: 0; }
.empty-body { font-size: var(--fs-13); line-height: 20px; color: var(--text-2); max-width: 360px; }
.empty .btn { margin-top: 12px; }
.empty.compact { padding: 24px 12px; }

.state {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-2);
  font-size: var(--fs-13);
}
.state .state-title { font-weight: var(--fw-strong); font-size: var(--fs-14); color: var(--text); margin-bottom: 4px; }
.state code { font-size: var(--fs-12); word-break: break-all; }
.state-error, .state-error .state-title { color: var(--err); }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
  flex: 0 0 auto;
}
.spinner.sm { width: 12px; height: 12px; border-width: 1.5px; }
.spinner.lg { width: 20px; height: 20px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* skeletons — shaped like the content, 1.2s shimmer */
.skel, .skeleton {
  display: block;
  height: 12px;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 40%, var(--surface-2) 80%);
  background-size: 300% 100%;
  animation: shimmer 1.2s linear infinite;
  min-height: 8px;
}
.skel.t-sm { height: 10px; }
.skel.t-lg { height: 18px; }
.skel.t-metric { height: 30px; width: 60%; margin-top: 6px; }
.skel.circle { border-radius: 50%; width: 24px; height: 24px; }
.skel.pill { width: 64px; height: 20px; border-radius: 999px; padding: 0; border: 0; }
.skel.pill::before { display: none; }
.skel-row td { height: 40px; }
.skel-stack { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
.fade-in { animation: fade-in var(--t-med) var(--ease) both; }

.error-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--err-soft);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--err) 28%, transparent);
  border-radius: var(--r-ctl);
  padding: 10px 12px;
  font-size: var(--fs-13);
  line-height: 20px;
  margin-bottom: 16px;
}
.error-banner > svg, .error-banner .eb-ico { flex: 0 0 auto; margin-top: 2px; color: var(--err); }
.error-banner .btn { margin-left: auto; flex: 0 0 auto; margin-top: -3px; margin-bottom: -3px; }
.error-banner code, .error-banner pre {
  font-size: var(--fs-12);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  white-space: pre-wrap;
  word-break: break-word;
  color: inherit;
}
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--r-ctl);
  font-size: var(--fs-13);
  line-height: 20px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.notice > svg { flex: 0 0 auto; margin-top: 2px; color: var(--text-3); }
.notice.warn { background: var(--surface-2); border-color: var(--line); }
.notice.warn > svg { color: var(--warn); }

/* ---------- Key / value ---------- */
.kv {
  display: grid;
  grid-template-columns: minmax(96px, max-content) minmax(0, 1fr);
  gap: 10px 24px;
  margin: 0;
  font-size: var(--fs-13);
}
.kv dt, .kv .k { font-size: var(--fs-12); color: var(--text-3); padding-top: 1px; }
.kv dd, .kv .v { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }

/* ---------- Drawer (right slide-over, inset) ---------- */
.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 340;
  background: var(--scrim);
  opacity: 0;
  transition: opacity var(--t-slow) var(--ease);
}
.drawer-scrim.open { opacity: 1; }
.drawer {
  position: fixed;
  top: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 345;
  width: 560px;
  max-width: calc(100vw - 16px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pop);
  box-shadow: var(--shadow-modal);
  transform: translateX(calc(100% + 24px));
  transition: transform var(--t-slow) var(--ease);
  overflow: hidden;
}
.drawer.open, .drawer-scrim.open .drawer { transform: none; }
.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 12px 14px 12px 20px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.drawer-head h2, .drawer-head h3, .drawer-title { font-size: var(--fs-16); line-height: 24px; font-weight: var(--fw-strong); letter-spacing: var(--track-heading); min-width: 0; overflow-wrap: anywhere; }
.drawer-head .icon-btn, .drawer-head .drawer-x { margin-left: auto; }
.drawer-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 20px; }
.drawer-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade-in var(--t-med) var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pop);
  box-shadow: var(--shadow-modal);
  width: 480px;
  max-width: 100%;
  max-height: min(88vh, 780px);
  display: flex;
  flex-direction: column;
  min-width: 0;
  animation: modal-in var(--t-slow) var(--ease);
  overflow: hidden;
}
@keyframes modal-in { from { transform: translateY(8px) scale(0.985); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-wide { width: 720px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 16px 10px 24px;
}
.modal-head h3 { font-size: var(--fs-16); line-height: 24px; font-weight: var(--fw-strong); letter-spacing: var(--track-heading); }
.modal-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-ctl);
  border: 0;
  background: transparent;
  color: var(--text-3);
  padding: 0;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.modal-x:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 6px 24px 20px; overflow-y: auto; min-height: 0; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.foot-spacer { flex: 1; }
.confirm-msg { margin: 0; font-size: var(--fs-14); line-height: 22px; color: var(--text-2); }

/* ---------- Menus / popovers ---------- */
.menu {
  position: fixed;
  z-index: 380;
  min-width: 200px;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  animation: pop-in var(--t-med) var(--ease);
  transform-origin: top right;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.menu-head {
  padding: 8px 10px 10px;
  margin: -6px -6px 6px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.menu-head .mh-name { font-size: var(--fs-13); font-weight: var(--fw-strong); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-top: 4px; }
.menu-head .mh-meta { font-size: var(--fs-12); color: var(--text-3); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-sep { height: 1px; background: var(--line); margin: 6px -6px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 32px;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 0 10px;
  font-size: var(--fs-13);
  font-weight: 400;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease);
}
.menu-item svg { color: var(--text-3); flex: 0 0 auto; }
.menu-item:hover { background: var(--surface-2); }
.menu-item:hover svg { color: var(--text-2); }
.menu-item.danger { color: var(--err); }
.menu-item.danger svg { color: var(--err); }
.menu-item.danger:hover { background: var(--err-soft); }
.menu-item .mi-kbd { margin-left: auto; display: inline-flex; gap: 2px; padding-left: 16px; }
.popover {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pop);
  box-shadow: var(--shadow-pop);
  animation: pop-in var(--t-med) var(--ease);
}

/* ---------- Toasts (icon + accent bar) ---------- */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 950;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 280px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-pop);
  padding: 12px 10px 12px 16px;
  font-size: var(--fs-13);
  line-height: 20px;
  color: var(--text);
  pointer-events: auto;
  overflow: hidden;
  animation: toast-in var(--t-slow) var(--ease);
}
.toast::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}
.toast-ok::before { background: var(--ok); }
.toast-error::before { background: var(--err); }
@keyframes toast-in { from { transform: translateY(10px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.out { opacity: 0; transform: translateX(12px); transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease); }
.toast-ico { flex: 0 0 auto; margin-top: 2px; color: var(--accent); display: inline-flex; }
.toast-ok .toast-ico { color: var(--ok); }
.toast-error .toast-ico { color: var(--err); }
.toast-msg { min-width: 0; overflow-wrap: anywhere; flex: 1; font-weight: var(--fw-med); }
.toast-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--text-3);
  width: 24px;
  height: 24px;
  padding: 0;
  margin: -2px 0 0 auto;
  border-radius: var(--r-sm);
  flex: 0 0 auto;
}
.toast-x:hover { background: var(--surface-2); color: var(--text); }

/* ============================================================
   LEGACY VIEW CLASSES (v1 views in app.js; restyled to v3
   language — keep until each view migrates to v3 components)
   ============================================================ */
.panel-head h3 + * { flex: 0 0 auto; }

/* data grid (gridHTML) */
.grid-wrap {
  overflow: auto;
  max-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--surface);
  min-width: 0;
}
.data-grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: var(--fs-13); }
.data-grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 32px;
  background: var(--surface-2);
  color: var(--text-2);
  text-align: left;
  font-weight: var(--fw-med);
  font-family: var(--mono);
  font-size: var(--fs-12);
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-grid td {
  height: 32px;
  padding: 4px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-family: var(--mono);
  font-size: var(--fs-12);
  font-variant-numeric: tabular-nums;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-grid tbody tr:hover td { background: var(--surface-2); }
.data-grid tbody tr:last-child td { border-bottom: 0; }
.null-val { color: var(--text-3); font-style: italic; }
.grid-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  color: var(--text-3);
  font-size: var(--fs-12);
  padding: 8px 2px;
  font-variant-numeric: tabular-nums;
}
.meta-spacer { flex: 1; }
.grid-meta .btn { margin-left: 0; }
.muted-dash { color: var(--text-3); }
.row-dim td { opacity: 0.6; }
.dirty-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: 0 0 auto; }

/* Sources (v1) */
.sources-layout { display: grid; grid-template-columns: 280px 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.source-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  color: var(--text);
  cursor: pointer;
  position: relative;
}
.source-card:last-child { border-bottom: 0; }
.source-card:hover { background: var(--surface-2); }
.source-card.selected { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.source-card .eng-ico { color: var(--text-3); flex: 0 0 auto; margin-top: 1px; }
.source-card.selected .eng-ico { color: var(--accent); }
.source-card .src-name { font-weight: var(--fw-strong); font-size: var(--fs-13); }
.source-card .src-meta { color: var(--text-3); font-size: var(--fs-12); margin-top: 2px; }
.source-card .src-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.source-card .card-menu-btn { margin: -2px -6px 0 0; }
.src-body { flex: 1; min-width: 0; }

.tree { padding: 6px; font-size: var(--fs-13); }
.tree .schema-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: var(--fs-12);
  text-transform: none;
  letter-spacing: 0;
  font-weight: var(--fw-med);
  padding: 8px 8px 4px;
}
.tree-table {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 28px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--r-ctl);
  padding: 0 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--fs-12);
}
.tree-table:hover { background: var(--surface-2); }
.tree-table.selected { background: var(--accent-soft); color: var(--accent); font-weight: var(--fw-strong); }
.tree-table .rowcount { margin-left: auto; color: var(--text-3); font-size: var(--fs-11); font-variant-numeric: tabular-nums; }
.tree-table.selected .rowcount, .tree-table.selected svg { color: var(--accent); }
.tree-table svg { color: var(--text-3); flex: 0 0 auto; }
.tree-cols { padding: 2px 8px 8px 30px; }
.tree-col { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: var(--fs-12); color: var(--text-2); padding: 2px 0; }

.detail-section { margin-bottom: 16px; }
.detail-section h4 { font-size: var(--fs-13); font-weight: var(--fw-strong); color: var(--text); margin-bottom: 8px; }

.upload-wrap { padding: 12px 12px 4px; border-bottom: 1px solid var(--line); }
.upload-zone {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-panel);
  padding: 12px 14px;
  color: var(--text-2);
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.upload-zone svg { flex: 0 0 auto; }
.upload-zone .uz-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.upload-zone .uz-text strong { font-size: var(--fs-13); font-weight: var(--fw-strong); color: var(--text); }
.upload-zone.drag .uz-text strong, .upload-zone:hover .uz-text strong { color: inherit; }
.upload-zone .uz-text span { font-size: var(--fs-12); }
.upload-row { margin-top: 8px; }
#upload-status { margin-top: 8px; }
#upload-status .error-banner { margin-bottom: 8px; }

/* Worksheets (v1) */
.ws-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
.ws-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ws-toolbar .hint { color: var(--text-3); font-size: var(--fs-12); margin-left: auto; }
select.src-select { height: 30px; font-size: var(--fs-13); }
.sql-editor {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  font-family: var(--mono);
  font-size: var(--fs-13);
  line-height: 1.6;
  padding: 12px;
  margin: 12px 0;
  tab-size: 2;
}
.sql-editor:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.ws-side { min-width: 0; }
.ws-title-chip { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-12); color: var(--text-2); font-weight: var(--fw-med); min-width: 0; }
.ws-title-chip #ws-cur-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.ws-item { display: flex; align-items: center; gap: 6px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.ws-item:last-child { border-bottom: 0; }
.ws-item:hover { background: var(--surface-2); }
.ws-item.selected { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.ws-item-body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.ws-item-name { font-size: var(--fs-13); font-weight: var(--fw-med); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-item.selected .ws-item-name { color: var(--accent); }
.ws-item-meta { color: var(--text-3); font-size: var(--fs-12); margin-top: 1px; }
.history-item { display: block; width: 100%; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 8px 14px; color: var(--text); }
.history-item:last-child { border-bottom: 0; }
.history-item:hover { background: var(--surface-2); }
.history-item .h-sql { font-family: var(--mono); font-size: var(--fs-12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.history-item .h-meta { color: var(--text-3); font-size: var(--fs-12); margin-top: 2px; font-variant-numeric: tabular-nums; }
.history-item .h-meta .fail { color: var(--err); }

/* Chat (v1) */
.chat-layout { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; min-height: calc(100vh - 110px); }
.chat-toolbar { display: flex; align-items: center; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.chat-spacer { flex: 1; }
.chat-thread { flex: 1; display: flex; flex-direction: column; gap: 18px; padding: 12px 0 24px; }
.msg { display: flex; gap: 10px; max-width: 100%; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; max-width: 85%; }
.msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  font-size: var(--fs-11);
  font-weight: var(--fw-strong);
}
.msg-user .msg-avatar { display: none; }
.msg-bot .msg-avatar { background: var(--brand-navy); color: #fff; }
.msg-bubble { font-size: var(--fs-14); line-height: 1.6; min-width: 0; overflow-wrap: break-word; }
.msg-bot .msg-bubble { padding-top: 2px; }
.msg-user .msg-bubble { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 12px; }
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul { margin: 0 0 8px; padding-left: 18px; }
.msg-bubble ul:last-child { margin-bottom: 0; }
.msg-bubble li { margin: 2px 0; }
.msg-bubble details { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); }
.msg-bubble summary { cursor: pointer; padding: 6px 10px; font-size: var(--fs-12); font-weight: var(--fw-med); color: var(--text-2); user-select: none; }
.msg-bubble details pre { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0 0 var(--r-ctl) var(--r-ctl); font-size: var(--fs-12); white-space: pre-wrap; word-break: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 999px;
  padding: 0 10px;
  font-size: var(--fs-12);
}
.chip svg { color: var(--accent); }
.chip-link { cursor: pointer; font: inherit; font-size: var(--fs-12); }
.chip-link:hover { border-color: var(--accent); color: var(--accent); }
.cite-n { display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 3px; margin-right: 2px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: var(--fs-11); font-weight: var(--fw-strong); font-variant-numeric: tabular-nums; }
.route-tag { display: inline-block; margin-right: 6px; padding: 0 5px; border-radius: 4px; border: 1px solid currentColor; font-size: var(--fs-11); }
.example-chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: var(--r-panel); padding: 8px 12px; font-size: var(--fs-13); text-align: left; }
.example-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.chat-empty { text-align: center; padding: 48px 16px; color: var(--text-2); }
.chat-empty h3 { color: var(--text); font-size: var(--fs-20); margin-bottom: 6px; }
.chat-empty .chips { justify-content: center; margin-top: 16px; }
.chat-inputbar { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 12px 0 8px; background: var(--bg); }
.chat-inputbar input { flex: 1; height: 38px; padding: 0 14px; min-width: 0; border-radius: 8px; }
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 70%, 100% { opacity: 0.25; } 35% { opacity: 1; } }
.model-tag { font-size: var(--fs-11); color: var(--text-3); margin-top: 6px; }

/* Agents / admin (v1) */
.stat-row {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  margin-bottom: 16px;
  overflow: hidden;
}
.stat-tile { flex: 1 1 0; min-width: 0; padding: 12px 16px; border-left: 1px solid var(--line); }
.stat-tile:first-child { border-left: 0; }
.stat-tile .stat-label { font-size: var(--fs-12); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-tile .stat-value { font-size: var(--fs-22); font-weight: var(--fw-strong); font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat-tile .stat-value.teal { color: var(--ok); }
.stat-tile .stat-value.amber { color: var(--warn); }
.stat-tile .stat-value.muted { color: var(--text-3); }
.feed { max-height: 360px; overflow-y: auto; }
.feed-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: var(--fs-13); }
.feed-item:last-child { border-bottom: 0; }
.feed-item .f-ts { color: var(--text-3); font-size: var(--fs-12); flex: 0 0 64px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.feed-item .f-agent { font-weight: var(--fw-strong); flex: 0 0 auto; }
.feed-item .f-event { color: var(--accent); font-family: var(--mono); font-size: var(--fs-12); flex: 0 0 auto; }
.feed-item .f-detail { color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }
.feed-item .f-ok { margin-left: auto; flex: 0 0 auto; }

.inv-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.inv-card { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 12px 14px; }
.inv-card svg { color: var(--ok); flex: 0 0 auto; margin-top: 1px; }
.inv-card .inv-id { font-family: var(--mono); font-size: var(--fs-11); font-weight: var(--fw-strong); color: var(--ok); }
.inv-card .inv-text { font-size: var(--fs-12); color: var(--text-2); margin-top: 2px; }
.inv-card .inv-name { font-weight: var(--fw-strong); color: var(--text); font-size: var(--fs-13); }
.doc-links { display: flex; flex-direction: column; }
.doc-link { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line); color: var(--text); font-size: var(--fs-13); }
.doc-link:last-child { border-bottom: 0; }
.doc-link:hover { background: var(--surface-2); text-decoration: none; }
.doc-link svg { color: var(--text-3); flex: 0 0 auto; }
.doc-link .doc-id { margin-left: auto; font-family: var(--mono); font-size: var(--fs-11); color: var(--text-3); }
.section-gap { margin-top: 20px; }

.test-ok, .test-fail { display: flex; align-items: center; gap: 8px; border-radius: var(--r-ctl); padding: 8px 10px; font-size: var(--fs-13); font-weight: var(--fw-med); margin-top: 4px; }
.test-ok { color: var(--ok); background: var(--surface); border: 1px solid var(--line); }
.test-fail { color: var(--err); background: var(--err-soft); border: 1px solid color-mix(in srgb, var(--err) 30%, transparent); }
.hint-line { display: flex; align-items: flex-start; gap: 8px; color: var(--text-2); font-size: var(--fs-13); margin: 8px 0 12px; line-height: 1.5; }
.hint-line svg { flex: 0 0 auto; margin-top: 2px; color: var(--ok); }

/* tabs (v1 — prefer .ptabs) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tab {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-weight: var(--fw-med);
  font-size: var(--fs-13);
  height: 36px;
  padding: 0 10px;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: var(--fw-strong); }
.tab.active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); }
.mini-select { height: 26px; font-size: var(--fs-12); padding: 0 26px 0 8px; background-position: right 7px center; }
.toggle-btn {
  height: 22px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text-2);
  border-radius: 999px;
  padding: 0 10px;
  font-size: var(--fs-12);
  font-weight: var(--fw-med);
}
.toggle-btn.on { color: var(--text); background: var(--surface); border-color: var(--line-hover); }
.toggle-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.users-grid td { vertical-align: middle; }
.audit-action { font-family: var(--mono); font-size: var(--fs-12); color: var(--accent); font-weight: var(--fw-med); }
.audit-detail { max-width: 420px; }
.settings-panel { max-width: 640px; }
.settings-form { max-width: 560px; }
.settings-actions { margin-top: 4px; }

/* Dashboards (v1) */
.dash-topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; min-width: 0; flex-wrap: wrap; }
.dash-name { font-size: var(--fs-20); font-weight: var(--fw-strong); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-spacer { flex: 1; }
.dash-list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.dash-card { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 14px 16px; cursor: pointer; min-width: 0; }
.dash-card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.dash-card-ico { color: var(--accent); flex: 0 0 auto; display: inline-flex; }
.dash-card-body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.dash-card-name { font-weight: var(--fw-strong); font-size: var(--fs-13); overflow-wrap: anywhere; }
.dash-card-meta { color: var(--text-3); font-size: var(--fs-12); margin-top: 2px; font-variant-numeric: tabular-nums; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dash-tile.w2, .dash-empty { grid-column: 1 / -1; }
.dash-tile .panel-head h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tile-body { padding: 12px 14px 14px; min-height: 96px; }
.tile-number { font-size: var(--fs-32); font-weight: var(--fw-strong); font-variant-numeric: tabular-nums; text-align: center; padding: 22px 8px 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-number-cap { text-align: center; color: var(--text-3); font-size: var(--fs-12); padding-bottom: 14px; }
.tile-sql { min-height: 110px; margin: 0; }
.tile-preview { border: 1px dashed var(--line-strong); border-radius: var(--r-ctl); padding: 10px; margin-top: 4px; min-height: 80px; background: var(--bg); }

/* Charts (inline SVG, theme tokens) */
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { stroke: var(--text-3); stroke-width: 1; opacity: 0.6; }
.chart-tick { fill: var(--text-3); font-family: var(--font); font-size: var(--fs-11); font-variant-numeric: tabular-nums; }
.chart-val { fill: var(--text); font-family: var(--font); font-size: var(--fs-11); font-variant-numeric: tabular-nums; opacity: 0.85; }
.chart-note { color: var(--text-3); font-size: var(--fs-12); padding: 4px 2px 0; font-variant-numeric: tabular-nums; }

/* User chip (removed from shell; kept harmless) */
.user-chip { display: none; }

/* ============================================================
   BRAND MOMENTS (BRAND.md §6)
   ============================================================ */

/* ---------- Login — split-screen (§6.1) ---------- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  grid-template-columns: minmax(0, 46fr) minmax(0, 54fr);
  background: var(--surface);
  overflow: auto;
}
.login-backdrop { display: none; }
.login-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 36px 48px 40px;
  min-height: 100%;
  color: #FFFFFF;
  color-scheme: dark;
  background: #0B1220;
}
.login-brand::after {
  /* hairline edge where Ink meets the form */
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.06);
}


.lb-top, .lb-copy, .lb-foot { position: relative; z-index: 1; }
.lb-lockup { display: inline-flex; align-items: center; gap: 10px; color: #FFFFFF; }
.lb-lockup .logo-mark { width: 32px; height: 32px; }
.lb-lockup .brand-name { font-size: var(--fs-16); line-height: 18px; }
.lb-lockup .brand-sub { font-size: var(--fs-12); }
.lb-copy { max-width: 480px; }
.lb-headline {
  font-size: var(--fs-32);
  line-height: 44px;
  font-weight: var(--fw-strong);
  letter-spacing: var(--track-display);
  color: #FFFFFF;
  margin: 0 0 16px;
  max-width: 460px;
}
.lb-sub { font-size: var(--fs-14); line-height: 22px; color: rgba(255, 255, 255, 0.56); max-width: 420px; margin: 0; }
.lb-facts { list-style: none; display: flex; margin: 40px 0 0; padding: 0; max-width: 460px; }
.lb-facts li { flex: 1 1 0; display: flex; flex-direction: column; gap: 2px; padding: 0 20px; border-left: 1px solid rgba(255, 255, 255, 0.10); }
.lb-facts li:first-child { padding-left: 0; border-left: 0; }
.lb-fact-k { font-size: var(--fs-14); line-height: 20px; font-weight: var(--fw-strong); color: #FFFFFF; font-variant-numeric: tabular-nums; }
.lb-fact-v { font-size: var(--fs-12); line-height: 16px; color: rgba(255, 255, 255, 0.5); }
.lb-foot { display: flex; align-items: center; gap: 10px; font-size: var(--fs-12); color: rgba(255, 255, 255, 0.38); }
.lb-foot .sep { width: 3px; height: 3px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); }

.login-main {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 32px 32px;
  min-height: 100%;
  background: var(--surface);
}
.login-help {
  position: absolute;
  top: 28px;
  right: 32px;
  font-size: var(--fs-13);
  color: var(--text-3);
}
.login-help strong { color: var(--text-2); font-weight: var(--fw-med); }
.login-card {
  position: relative;
  width: 360px;
  max-width: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  margin: auto 0;
}
@keyframes login-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.login-logo { display: none; margin-bottom: 20px; }
.login-title { font-size: var(--fs-22); line-height: 28px; font-weight: var(--fw-strong); letter-spacing: var(--track-display); text-align: left; }
.login-sub { text-align: left; color: var(--text-2); font-size: var(--fs-13); line-height: 20px; margin: 4px 0 24px; }
.login-card .field { margin-bottom: 16px; }
.login-card .field input:not([type="checkbox"]):not([type="radio"]) { height: 38px; font-size: var(--fs-13); padding: 0 12px; }
.login-error {
  color: var(--err);
  background: var(--err-soft);
  border: 1px solid color-mix(in srgb, var(--err) 30%, transparent);
  border-radius: var(--r-ctl);
  padding: 9px 12px;
  font-size: var(--fs-13);
  line-height: 18px;
  margin-bottom: 14px;
}
.login-submit { width: 100%; height: 38px; margin-top: 8px; font-size: var(--fs-13); font-weight: var(--fw-med); }
.login-hint {
  text-align: left;
  color: var(--text-3);
  font-size: var(--fs-12);
  margin-top: 16px;
}
.login-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-3);
  font-size: var(--fs-12);
  margin-top: 32px;
  white-space: nowrap;
}
.login-foot svg { color: var(--text-3); flex: 0 0 auto; }

@media (max-width: 959.98px) {
  .login-screen { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .login-brand { min-height: 0; padding: 22px 24px 26px; gap: 22px; }
  .lb-copy { max-width: 560px; }
  .lb-sub, .lb-foot { display: none; }
  .lb-headline { font-size: var(--fs-22); line-height: 28px; margin: 0; letter-spacing: var(--track-display); }
  .lb-facts { margin-top: 18px; }
  .lb-facts li { padding: 0 14px; }
  .login-main { padding: 32px 24px 24px; justify-content: flex-start; }
  .login-card { margin: 0; }
  .login-foot { margin-top: 28px; }
  .login-help { position: static; order: 3; margin-top: 12px; text-align: center; font-size: var(--fs-12); }
}


/* ---------- Boot splash (§6.2) ---------- */
.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity var(--t-slow) var(--ease), visibility 0s linear var(--t-slow);
}
.boot-splash.out { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-splash svg { width: 40px; height: 40px; display: block; }
.boot-splash .bs-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.boot-splash .bs-bar { width: 56px; height: 2px; border-radius: 2px; background: var(--line); overflow: hidden; position: relative; opacity: 0; animation: fade-in 300ms var(--ease) 700ms forwards; }
.boot-splash .bs-bar::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40%; border-radius: 2px; background: var(--accent); animation: bs-slide 1.1s var(--ease) infinite; }
@keyframes bs-slide { from { left: -40%; } to { left: 100%; } }

/* ---------- Global tooltip (WSN.tip) ---------- */
.wsn-tip {
  position: fixed;
  z-index: 1100;
  pointer-events: none;
  max-width: 280px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  background: var(--tip-bg);
  color: #FFFFFF;
  font-size: var(--fs-12);
  line-height: 16px;
  font-weight: var(--fw-med);
  box-shadow: 0 4px 12px rgba(11, 18, 32, 0.16);
  border: 0;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  overflow-wrap: anywhere;
}
.wsn-tip.show { opacity: 1; transform: none; }
.wsn-tip.wrap { white-space: normal; }
.wsn-tip kbd {
  margin-left: 6px;
  height: 16px;
  min-width: 16px;
  font-size: var(--fs-11);
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}
.wsn-tip kbd + kbd { margin-left: 2px; }

/* ---------- Command palette (§6.4) ---------- */
.cmdk-overlay {
  position: fixed;
  inset: 0;
  z-index: 960;
  background: var(--scrim);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;
  animation: fade-in var(--t-med) var(--ease);
}
.cmdk {
  width: 640px;
  max-width: 100%;
  max-height: min(560px, 76vh);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pop);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  animation: modal-in var(--t-slow) var(--ease);
}
.cmdk-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.cmdk-head > svg { color: var(--text-3); flex: 0 0 auto; }
.cmdk-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none;
  padding: 0 !important;
  font-family: var(--font);
  font-size: var(--fs-16);
  font-weight: 400;
  letter-spacing: var(--track-heading);
  color: var(--text);
}
.cmdk-input::placeholder { color: var(--text-3); }
.cmdk-input::-webkit-search-cancel-button { display: none; }
.cmdk-head .spinner { margin: 0; }
.cmdk-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px 8px 8px; scroll-padding: 32px 0 8px; }
.cmdk-group {
  font-size: var(--fs-11);
  line-height: 16px;
  font-weight: var(--fw-med);
  letter-spacing: var(--track-code);
  text-transform: none;
  color: var(--text-3);
  padding: 12px 10px 6px;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: var(--r-ctl);
  cursor: pointer;
  color: var(--text);
  position: relative;
}
.cmdk-item.active { background: var(--surface-2); }
.cmdk-item.active::before { content: ""; position: absolute; left: -8px; top: 10px; bottom: 10px; width: 2px; border-radius: 0 2px 2px 0; background: var(--accent); }
.cmdk-ico {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  color: var(--text-3);
}
.cmdk-ico svg { width: 16px; height: 16px; }
.cmdk-item.active .cmdk-ico { color: var(--text-2); }
.cmdk-main { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; }
.cmdk-label { font-size: var(--fs-14); line-height: 20px; font-weight: var(--fw-med); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-label mark { background: transparent; color: var(--accent); font-weight: var(--fw-strong); }
.cmdk-sub { font-size: var(--fs-12); line-height: 16px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-meta { flex: 0 0 auto; display: inline-flex; gap: 3px; align-items: center; color: var(--text-3); font-size: var(--fs-12); }
.cmdk-item:not(.active) .cmdk-enter { visibility: hidden; }
.cmdk-note { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: var(--fs-13); color: var(--text-3); }
.cmdk-empty { padding: 28px 16px 24px; text-align: center; color: var(--text-2); }
.cmdk-empty .wsn-illus { margin: 0 auto 8px; }
.cmdk-skel { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 10px; }
.cmdk-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 40px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  font-size: var(--fs-12);
  color: var(--text-3);
}
.cmdk-foot span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.cmdk-foot .cmdk-brand { margin-left: auto; gap: 6px; color: var(--text-3); }
.cmdk-foot .cmdk-brand svg { width: 14px; height: 14px; }

/* ---------- Keyboard sheet (§6.5) ---------- */
.keys-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 32px; }
.keys-sec { grid-column: 1 / -1; margin: 14px 0 4px; }
.keys-sec:first-child { margin-top: 0; }
.keys-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 34px; border-bottom: 1px solid var(--line); font-size: var(--fs-13); color: var(--text); }
.keys-row .k { display: inline-flex; gap: 4px; align-items: center; color: var(--text-3); font-size: var(--fs-11); flex: 0 0 auto; }
.keys-row .k kbd { min-width: 22px; height: 22px; font-size: var(--fs-12); color: var(--text-2); }
.chord-hint {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 1050;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  background: var(--tip-bg);
  color: #FFFFFF;
  font-size: var(--fs-12);
  font-weight: var(--fw-med);
  box-shadow: var(--shadow-pop);
  animation: pop-in var(--t-med) var(--ease);
}
.chord-hint kbd { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.18); color: #FFFFFF; }
.chord-hint .ch-dim { color: rgba(255, 255, 255, 0.55); }

/* ---------- Empty-state icon (RESTRAINT 6): small, muted, no illustration ---------- */
.wsn-illus { display: block; width: 20px; height: 20px; color: var(--text-3); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .sources-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .sources-layout .pane-detail { grid-column: 1 / -1; }
  .pane-420 { flex-basis: 340px; width: 340px; }
}

@media (max-width: 1180px) {
  .egress-pill .seal-extra { display: none; }
}

@media (max-width: 900px) {
  .ws-layout { grid-template-columns: minmax(0, 1fr); }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .metric-strip { flex-wrap: wrap; }
  .metric { flex: 1 1 33%; border-top: 1px solid var(--line); margin-top: -1px; }
  .egress-pill .egress-text { display: none; }
  .egress-pill { padding: 0; width: 30px; justify-content: center; margin-right: 0; }
  .crumbs { flex-basis: auto; }
  .top-search-kbd { display: none; }
  .top-search input { padding-right: 12px; }
}

/* mobile: off-canvas rail drawer, compact topbar */
@media (max-width: 719.98px) {
  .shell, .shell.rail-collapsed { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 86vw;
    transform: translateX(-100%);
    transition: transform var(--t-slow) var(--ease);
    z-index: 320;
    box-shadow: none;
  }
  .shell.rail-open .rail { transform: none; box-shadow: var(--shadow-modal); }
  .shell.rail-collapsed .brand-text, .shell.rail-collapsed .nav-label { display: initial; }
  .shell.rail-collapsed .brand-text { display: flex; }
  .shell .rail-brand { padding: 0 14px; justify-content: flex-start; }
  .shell .nav { align-items: stretch; }
  .shell .nav-item { width: 100%; justify-content: flex-start; padding: 0 10px; height: 40px; flex-basis: 40px; font-size: var(--fs-14); }
  .shell .nav-group-label { font-size: var(--fs-11); padding: 16px 10px 6px; margin: 0; height: auto; width: auto; background: none; flex: 0 0 auto; }
  .shell .nav-group-label:first-child { display: block; }
  .shell .nav-item.active::before { left: -10px; }
  .rail-foot { display: none !important; }
  .rail-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 310;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-slow) var(--ease);
  }
  .shell.rail-open .rail-backdrop { opacity: 1; pointer-events: auto; }

  .topbar { padding: 0 8px; gap: 4px; }
  .topbar-menu { display: inline-flex !important; }
  .crumbs { flex: 1 1 auto; padding-left: 2px; }
  .crumbs .crumb-group, .crumbs .crumb-sep { display: none; }
  .crumb-page { font-size: var(--fs-16); }
  .top-search { display: none; }
  .top-search-btn { display: inline-flex !important; }
  .top-search-kbd { display: none; }
  .egress-pill { margin-right: 0; }
  .avatar-btn { margin-left: 2px; }

  .view.active { padding: 16px 16px 28px; }
  .page { padding: 16px 16px 28px; }
  .page-head { flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
  .page-title { font-size: var(--fs-20); line-height: 26px; }
  .page-actions { margin-left: 0; justify-content: flex-start; width: 100%; }
  .page-sub { white-space: normal; }
  .metric { flex: 1 1 50%; padding: 12px 14px; }
  .metric-value { font-size: var(--fs-22); line-height: 28px; }

  .split { flex-direction: column; overflow: auto; }
  .split > .pane { flex: 0 0 auto; width: auto; }
  .split > .pane-flex { flex: 1 0 auto; min-height: 60vh; }
  .split > .pane + .pane { border-left: 0; border-top: 1px solid var(--line); }
  .split > .pane-260, .split > .pane-280, .split > .pane-300, .split > .pane-340 { max-height: 46vh; }
  .split > .pane-420 { width: auto; }

  .drawer { top: 0; right: 0; bottom: 0; width: 100vw; max-width: 100vw; border-radius: 0; border: 0; }
  .sources-layout { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd, .kv .v { margin-bottom: 8px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; align-items: stretch; max-width: none; }
  .toast { min-width: 0; }
  .cmdk-overlay { padding: 8px; align-items: flex-start; }
  .cmdk { max-height: calc(100dvh - 16px); }
  .cmdk-foot .cmdk-hide-sm { display: none; }
  .keys-grid { grid-template-columns: minmax(0, 1fr); }
  /* touch: bigger hit areas, row actions always visible */
  .dtable .row-actions { opacity: 1; }
}

@media (max-width: 480px) {
  .modal-overlay { padding: 8px; align-items: flex-end; }
  .modal { max-height: 92vh; border-radius: var(--r-pop); }
  .modal-body { padding: 4px 16px 16px; }
  .modal-head { padding: 14px 12px 8px 16px; }
  .modal-foot { padding: 12px 16px; }
  .dash-topbar .btn { padding: 0 10px; }
  .audit-detail { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
  .msg-user { max-width: 92%; }
}
.btn.is-loading:disabled, .btn.loading:disabled { opacity: 1; }
/* one icon family: 1.5 stroke (BRAND §7) */
svg[stroke="currentColor"][stroke-width="1.8"] { stroke-width: 1.5; }
.nav-item svg[stroke-width] { stroke-width: 1.6; }
.error-banner code { font-family: var(--font); font-size: var(--fs-13); }

img.eng-logo { width: 16px; height: 16px; object-fit: contain; flex: none; vertical-align: middle; }

/* ---------- Whisper ring loader (C4 rich) ---------- */
@keyframes wr-rot { to { transform: rotate(360deg); } }
.wr-ring { display: block; flex: none; }
.wr-ring.wr-spin { transform-box: fill-box; transform-origin: 50% 50%; animation: wr-rot 1s linear infinite !important; animation-duration: 1s !important; animation-iteration-count: infinite !important; will-change: transform; }
.boot-splash svg.wr-ring { width: 52px; height: 52px; }
@media (prefers-reduced-motion: reduce) {
  .wr-ring.wr-spin { animation: wr-rot 2.4s linear infinite !important; animation-duration: 2.4s !important; }
}

/* ============================================================
   R1 SHELL LAYER (REFINE §C · §E · §H) — owner F1.
   Overrides earlier rules in this file; other teams build on these classes (app/API_FRONTEND_R1.md).
   ============================================================ */
:root { --pop-hover: var(--surface-2); --rail-line: rgba(255, 255, 255, 0.06); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --pop-hover: #262E3B; --rail-line: rgba(255, 255, 255, 0.10); } }
:root[data-theme="dark"] { --pop-hover: #262E3B; --rail-line: rgba(255, 255, 255, 0.10); }

/* ---------- a11y utilities ---------- */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed;
  left: 12px; top: 8px;
  z-index: 1200;
  transform: translateY(-160%);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  padding: 8px 12px;
  font: 500 13px/20px var(--font);
  box-shadow: var(--shadow-pop);
  transition: transform var(--t-fast) var(--ease);
}
.skip-link:focus, .skip-link:focus-visible { transform: none; outline: none; box-shadow: var(--ring); text-decoration: none; }
#main:focus, .view h1[tabindex="-1"]:focus, .view [tabindex="-1"]:focus:not(:focus-visible) { outline: none; }
[inert] { pointer-events: none; }

/* ---------- focus: two tokens only (--ring controls, --ring-inset rows/lists) ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:focus-visible, .icon-btn:focus-visible, .mini-icon-btn:focus-visible, .avatar-btn:focus-visible, .egress-pill:focus-visible,
.modal-x:focus-visible, .toast-x:focus-visible, .toast-act:focus-visible, .top-search:focus-visible, .demo-chip:focus-visible,
.link-btn:focus-visible, .pw-toggle:focus-visible, .crumb-link:focus-visible, .seg > button:focus-visible, a.kpi:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.menu-item:focus-visible, .menu-item:focus, .list-row:focus-visible, [role="option"]:focus-visible, [role="treeitem"]:focus-visible,
.cmdk-item:focus-visible, .ptabs > button:focus-visible, .ptabs > a:focus-visible, [role="tab"]:focus-visible {
  outline: none;
  box-shadow: var(--ring-inset);
}
.dtable tr:focus-visible, .dtable tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dtable td:first-child a:focus-visible, .dtable td:first-child button:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea):focus,
.field input:focus, .field select:focus, .field textarea:focus, .text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { box-shadow: var(--ring); }

/* ---------- type ---------- */
body { font-feature-settings: "ss03"; }
h1, h2, h3, h4, h5 { font-weight: var(--fw-strong); }
/* RESTRAINT.md type scale: page title 20/600, body 13; one rule for every view (R3 D) */
.page-title, .t-title { font-size: var(--fs-20); line-height: var(--lh-20); letter-spacing: var(--track-lg); font-weight: var(--fw-strong); }
.page-sub { font-size: var(--fs-13); line-height: var(--lh-13); color: var(--text-2); }
.t-metric { font-size: var(--fs-28); line-height: var(--lh-28); }
.docs-h1, .t-display { font-size: var(--fs-32); line-height: var(--lh-32); letter-spacing: var(--track-lg); font-weight: var(--fw-strong); }
code { font-size: 0.86em; padding: 1px 4px; border: 0; background: var(--surface-2); border-radius: 4px; }
.mono-id, .id-mono { font-family: var(--mono); font-size: var(--fs-12); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.one-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nowrap { white-space: nowrap; }

/* ---------- layout tokens ---------- */
.main { scrollbar-gutter: stable; }
.page { padding: 24px var(--page-x) 40px; }
.view.active { padding: 24px var(--page-x) 40px; }
.view.active:has(> .page), .view.active.flush, .view.app.active { padding: 0; }
.view.app .page-head { padding: 16px var(--page-x) 0; }
.view.app .ptabs { padding: 0 var(--page-x); }
.page-head { min-height: 36px; margin-bottom: 20px; }
.ptabs { margin-bottom: 24px; }
.page-head + .ptabs { margin-top: -4px; }
.tool-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--tool-head-h);
  flex: 0 0 var(--tool-head-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.tool-head .tool-title, .tool-head h1, .tool-head h2 { font-size: var(--fs-14); line-height: var(--lh-14); font-weight: var(--fw-strong); letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sub-row { display: flex; align-items: center; gap: 8px; height: var(--sub-row-h); flex: 0 0 var(--sub-row-h); padding: 0 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.pane-w { width: var(--pane-w); flex: 0 0 var(--pane-w); }
.inspector-w { width: var(--inspector-w); flex: 0 0 var(--inspector-w); }
.toolbar { gap: 8px; }
.card-foot, .panel-foot { margin-top: auto; }

/* legacy row-class collision guard (REFINE §A1): a <tr> never becomes a flex card */
tr.dash-card, tr.dash-row { display: table-row; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }

/* ---------- buttons: neutral disabled that keeps its tooltip; one busy pattern ---------- */
.btn:disabled, .btn[aria-disabled="true"],
.btn-primary:disabled, .btn-primary[aria-disabled="true"], .btn-danger:disabled, .btn-danger[aria-disabled="true"] {
  opacity: 1;
  pointer-events: auto;
  cursor: not-allowed;
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text-3);
  box-shadow: none;
  transform: none;
}
.btn:disabled:hover, .btn[aria-disabled="true"]:hover { background: var(--surface-2); border-color: var(--line); }
.btn-ghost:disabled, .btn-ghost[aria-disabled="true"] { background: transparent; border-color: transparent; }
.icon-btn:disabled, .mini-icon-btn:disabled { opacity: 1; color: var(--text-3); background: transparent; border-color: var(--line); cursor: not-allowed; }
.btn.is-loading, .btn.is-loading:disabled { cursor: progress; pointer-events: none; }
.btn.is-loading:disabled { background: var(--surface); border-color: var(--line-strong); }
.btn-primary.is-loading, .btn-primary.is-loading:disabled { background: var(--accent-fill); border-color: var(--accent-fill); }
.btn-danger.is-loading, .btn-danger.is-loading:disabled { background: #B83A33; border-color: #B83A33; }
.btn .btn-ring { position: absolute; inset: 0; display: none; place-items: center; color: #FFFFFF; visibility: visible !important; }
.btn.is-loading .btn-ring { display: grid; }
.btn.is-loading:has(.btn-ring)::after { display: none; }
.btn-ring svg { width: 18px; height: 18px; }
[aria-busy="true"]:not(.btn) { cursor: progress; }
.link-btn {
  border: 0; background: none; padding: 0; margin: 0;
  color: var(--accent);
  font: 500 12px/18px var(--font);
  cursor: pointer;
  border-radius: 4px;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- inputs: --field-border (≥3:1) ---------- */
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea, .text-input { border-color: var(--field-border); }
.field-label, .field .field-label { font-size: var(--fs-13); line-height: var(--lh-13); }
.field-help { color: var(--text-3); }
input[type="date"]:invalid, input[type="date"]:placeholder-shown { color: var(--text-3); font-weight: 400; }
::-webkit-calendar-picker-indicator { opacity: 0.55; }

/* ---------- level badge (one component): L0/L1 neutral outline · L2 accent outline · L3 solid text ---------- */
.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  min-width: 26px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: var(--fs-11);
  font-weight: var(--fw-strong);
  line-height: 1;
  letter-spacing: var(--track-code);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
.level-badge.l0 { color: var(--text-3); }
.level-badge.l2 { border-color: var(--line-strong); color: var(--text); }
.level-badge.l3 { background: var(--text); border-color: var(--text); color: var(--surface); }

/* ---------- metric spec (.kpi) — label 12/500 · value 28/600 · "9 / 11" 16/500 · meta 12 · min-height 108 ---------- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  overflow: hidden;
  margin-bottom: 24px;
  min-width: 0;
}
.kpi-strip.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-strip.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-strip.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 108px;
  padding: 16px 20px;
  border-left: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  transition: background var(--t-fast) var(--ease);
}
.kpi:first-child { border-left: 0; }
a.kpi:hover, button.kpi:hover { background: var(--row-hover); text-decoration: none; }
.kpi-label { font-size: var(--fs-12); line-height: var(--lh-12); font-weight: var(--fw-med); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value {
  margin-top: 6px;
  font-size: var(--fs-28);
  line-height: var(--lh-28);
  font-weight: var(--fw-strong);
  letter-spacing: var(--track-lg);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-of, .kpi-unit { font-size: var(--fs-16); font-weight: var(--fw-med); color: var(--text-3); letter-spacing: 0; }
.kpi-meta { margin-top: auto; padding-top: 4px; font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.err .kpi-value { color: var(--err); }
/* existing metric strips follow the same spec */
.metric { min-height: 108px; padding: 16px 20px; display: flex; flex-direction: column; }
.metric-value { font-size: var(--fs-28); line-height: var(--lh-28); font-weight: var(--fw-strong); margin-top: 6px; }
.metric-value small, .metric-value .of { font-size: var(--fs-16); font-weight: var(--fw-med); color: var(--text-3); letter-spacing: 0; }
.metric-foot { margin-top: auto; padding-top: 4px; }
/* secondary stat strips: 20/600 */
.stat-strip { display: flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); overflow: hidden; }
.stat { flex: 1 1 0; min-width: 120px; padding: 12px 16px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat-label { display: block; font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-2); }
.stat-value { display: block; font-size: var(--fs-20); line-height: var(--lh-20); font-weight: var(--fw-strong); letter-spacing: var(--track-md); font-variant-numeric: tabular-nums; color: var(--text); }
@media (max-width: 899.98px) {
  .kpi-strip, .kpi-strip.cols-3, .kpi-strip.cols-4, .kpi-strip.cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-left: 0; border-top: 1px solid var(--line); min-height: 96px; padding: 12px 16px; }
  .kpi:nth-child(-n+2) { border-top: 0; }
  .kpi:nth-child(even) { border-left: 1px solid var(--line); }
  .metric-strip { flex-wrap: wrap; }
  .metric { flex: 1 1 50%; }
}

/* ---------- rail: ring on the icon axis, quieter inactive items, inset active bar ---------- */
.rail { border-right-color: var(--rail-line); }
.rail-brand { padding: 0 18px; border-bottom-color: var(--rail-line); }
.brand-link { margin-left: 0; padding: 0; gap: 0; }
.wsn-lockup { display: inline-flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); }
.wsn-lockup.on-ink { color: #FFFFFF; }
.wsn-lockup .logo-mark { width: var(--lk-ring, 24px); height: var(--lk-ring, 24px); flex: 0 0 auto; }
.wsn-lockup .logo-mark svg { width: 100%; height: 100%; display: block; }
.wsn-lockup .brand-text { gap: 2px; }
.wsn-lockup .brand-name { font-size: var(--lk-name, 14px); line-height: 1.15; font-weight: var(--fw-strong); letter-spacing: var(--track-md); color: inherit; }
.wsn-lockup .brand-sub { font-size: var(--lk-sub, 11px); line-height: 1.3; font-weight: 400; color: var(--text-3); }
.wsn-lockup.on-ink .brand-sub { color: rgba(255, 255, 255, 0.56); }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group > .nav-group-label, .nav-group-label { padding: 16px 10px 6px; color: rgba(255, 255, 255, 0.56); font-size: var(--fs-11); letter-spacing: 0; }
.nav-item { font-weight: 400; color: #A2ABB8; letter-spacing: 0; }
.nav-item svg { color: rgba(255, 255, 255, 0.5); }
.nav-item:hover { color: #FFFFFF; background: rgba(255, 255, 255, 0.05); }
.nav-item.active { font-weight: var(--fw-strong); color: #FFFFFF; background: rgba(255, 255, 255, 0.08); }
.nav-item.active::before { left: 0; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--signal-bright); }
.shell.rail-collapsed .nav-item.active::before { left: 0; }
.rail .nav-item:focus-visible, .rail-toggle:focus-visible { outline: none; box-shadow: var(--ring-on-ink); }
.rail-foot { display: flex; flex-direction: column; gap: 2px; border-top-color: var(--rail-line); }
.rail-foot-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-foot-nav:empty { display: none; }
.shell.rail-collapsed .rail-foot { flex-direction: column; align-items: center; }
.shell.rail-collapsed .rail-foot-nav { align-items: center; }
.shell.rail-collapsed .rail-brand { padding: 0; justify-content: center; }
.shell.rail-collapsed .nav-group { align-items: center; }
.shell.rail-collapsed .nav-group > .nav-group-label { display: block; font-size: 0; padding: 0; margin: 8px 6px; height: 1px; width: 24px; flex: 0 0 1px; background: rgba(255, 255, 255, 0.08); }

/* ---------- topbar: breadcrumb · search button · status · account ---------- */
.topbar { padding: 0 12px 0 var(--page-x); gap: 12px; }
.crumbs { flex: 0 1 auto; min-width: 120px; font-size: var(--fs-13); }
.crumb-list { display: flex; align-items: center; list-style: none; margin: 0; padding: 0; min-width: 0; }
.crumb { display: flex; align-items: center; min-width: 0; flex: 0 1 auto; }
.crumb-section { flex: 0 0 auto; }
.crumb .crumb-sep { display: inline-flex; color: var(--text-3); margin: 0 4px; font-size: inherit; font-weight: 400; }
.crumb-link {
  color: var(--text-2);
  font-weight: var(--fw-med);
  padding: 2px 4px;
  margin: 0 -2px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.crumb-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.crumb-text { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-page { font-size: var(--fs-13); font-weight: var(--fw-strong); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; letter-spacing: 0; padding: 2px 0; }
.crumb-code { font: 500 12px/18px var(--mono); background: var(--surface-2); border: 0; padding: 1px 5px; border-radius: 4px; color: inherit; }
.top-back { display: none !important; }
.top-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 4 420px;
  max-width: 420px;
  min-width: 180px;
  height: 32px;
  margin: 0 auto;
  padding: 0 6px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--surface-2);
  color: var(--text-3);
  font: 400 13px/20px var(--font);
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.top-search > svg { position: static; transform: none; flex: 0 0 auto; color: var(--text-3); }
.top-search .ts-label { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-search .top-search-kbd { position: static; transform: none; display: inline-flex; gap: 3px; flex: 0 0 auto; }
.top-search:hover { background: var(--surface); border-color: var(--line-strong); color: var(--text-2); }
#v2w-gs-pop { display: none !important; }
.demo-chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  margin-right: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font: 500 12px/1 var(--font);
  white-space: nowrap;
  cursor: pointer;
}
.demo-chip:hover { border-color: var(--line-strong); color: var(--text); }
.seal-dot { display: inline-block; flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-3); }
.seal-sealed .seal-dot { background: var(--ok); box-shadow: none; }
.seal-metered .seal-dot { background: var(--warn); box-shadow: none; }
.seal-violations .seal-dot { background: #FFFFFF; box-shadow: none; }
.egress-pill:not([href]) { cursor: default; }
.egress-pill.seal-checking .seal-strong, .egress-pill.seal-unavailable .seal-strong, .egress-pill.seal-perimeter .seal-strong { color: var(--text-2); }
.avatar-btn { width: 28px; height: 28px; }

/* ---------- toasts: status vs alert regions, action slot ---------- */
.toasts { gap: 8px; }
.toast-region { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.toast-region:empty { display: none; }
.toast { align-items: center; padding: 10px 8px 10px 16px; max-width: 100%; }
.toast-ico { margin-top: 0; }
.toast-act {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font: 500 13px/1 var(--font);
  cursor: pointer;
}
.toast-act:hover { background: var(--surface-2); }
.toast-x { width: 28px; height: 28px; margin: 0; }
.toast { background: var(--pop-bg); }

/* ---------- modals + confirm ---------- */
.modal { background: var(--pop-bg); }
.modal-head h2, .modal-head h3 { font-size: var(--fs-16); line-height: var(--lh-16); font-weight: var(--fw-strong); letter-spacing: var(--track-md); margin: 0; }
.modal-overlay.out { opacity: 0; transition: opacity 120ms var(--ease); pointer-events: none; }
.modal-x { width: 32px; height: 32px; }
.confirm-msg { font-size: var(--fs-14); line-height: var(--lh-14); color: var(--text-2); }
.confirm-type { margin: 16px 0 0; }
.confirm-type strong.mono { font-family: var(--mono); font-weight: var(--fw-med); font-size: var(--fs-12); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: var(--text); }
.modal .form-error { margin: 12px 0 0; }
.modal-body > .form-error:first-child { margin-top: 0; }

/* ---------- menus / popovers on the raised surface ---------- */
.menu, .popover { background: var(--pop-bg); }
.menu-item { font-weight: 400; }
.menu-item:hover, .menu-item:focus { background: var(--pop-hover); }
.menu-item.danger:hover, .menu-item.danger:focus { background: var(--err-soft); }
.menu-item[aria-disabled="true"] { color: var(--text-3); cursor: not-allowed; }
.menu-item .mi-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.menu-item .mi-meta { margin-left: auto; padding-left: 16px; color: var(--text-3); font-size: var(--fs-12); }
.menu-head { white-space: normal; }
.menu-head .mh-body { margin-top: 4px; max-width: 300px; font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-2); }
.menu-head .mh-list { margin: 6px 0 0; padding-left: 16px; font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-2); }
.menu-html { padding: 2px 0; }
.menu-seal { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--text); text-decoration: none; }
a.menu-seal:hover { background: var(--pop-hover); text-decoration: none; }
.menu-seal .seal-dot { margin-top: 7px; }
.menu-seal .ms-label { display: block; font-size: var(--fs-13); font-weight: var(--fw-med); }
.menu-seal .ms-tip { display: block; font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-3); white-space: normal; }
.menu-seal.seal-violations .seal-dot { background: var(--err); }
.sheet-scrim { position: fixed; inset: 0; z-index: 375; background: var(--scrim); animation: fade-in var(--t-med) var(--ease); }
.menu.menu-sheet {
  left: 0 !important; right: 0; bottom: 0; top: auto !important;
  width: 100%; max-width: none; min-width: 0;
  border-radius: 12px 12px 0 0;
  border-bottom: 0;
  padding: 8px 8px max(12px, env(safe-area-inset-bottom));
  max-height: 85dvh; overflow-y: auto;
  animation: sheet-in var(--t-slow) var(--ease);
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.menu.menu-sheet .menu-head { margin: -8px -8px 6px; padding: 14px 16px 12px; }
.menu.menu-sheet .menu-item { height: 48px; font-size: var(--fs-16); }

/* ---------- command palette (raised surface; full-screen sheet on phones) ---------- */
.cmdk { background: var(--pop-bg); border-color: var(--line-strong); }
:root:not([data-theme="dark"]) .cmdk { border-color: var(--line); }
.cmdk-item.active { background: var(--pop-hover); }
.cmdk-item.active::before { left: 0; top: 8px; bottom: 8px; }
.cmdk-item { overflow: hidden; }
.cmdk-ask .cmdk-ico, .cmdk-ask.active .cmdk-ico { color: var(--text-2); }
.cmdk-ico .wr-ring { width: 16px; height: 16px; }
.cmdk-cancel { display: none; border: 0; background: none; color: var(--accent); font: 500 16px/1 var(--font); padding: 0 4px; height: 44px; cursor: pointer; }
.cmdk-foot .cmdk-brand svg { width: 16px; height: 16px; }
.cmdk-note { color: var(--text-2); }

/* ---------- login (REFINE §C/§G): one composed block, shared axes, balanced headline ---------- */
.login-brand { justify-content: center; padding: 48px 56px 88px; }
.login-brand::after { background: rgba(255, 255, 255, 0.10); }
.lb-copy { max-width: 560px; }
.lb-lockup { display: flex; margin-bottom: 40px; }
.lb-lockup .wsn-lockup .brand-name { font-size: 20px; }
.lb-lockup .wsn-lockup .brand-sub { font-size: 12px; }
.lb-headline { font-size: var(--fs-32); line-height: var(--lh-32); letter-spacing: var(--track-lg); max-width: 560px; text-wrap: balance; margin: 0 0 16px; font-weight: var(--fw-strong); color: #FFFFFF; }
.lb-sub { color: rgba(255, 255, 255, 0.56); max-width: 460px; }
.lb-fact-k { font-variant-numeric: normal; }
.lb-fact-v { color: rgba(255, 255, 255, 0.56); }
.lb-foot { position: absolute; left: 56px; bottom: 32px; line-height: 16px; color: rgba(255, 255, 255, 0.56); }
.login-main { justify-content: center; padding: 48px 32px 88px; }
.login-help { top: 28px; right: 32px; line-height: 20px; }
.login-card { margin: 0; }
.login-panel[hidden] { display: none; }
.login-title { font-size: var(--fs-22); line-height: var(--lh-22); letter-spacing: var(--track-lg); }
.login-sub { font-size: var(--fs-14); line-height: var(--lh-14); margin: 4px 0 24px; }
.login-card .field input:not([type="checkbox"]):not([type="radio"]) { height: 40px; font-size: var(--fs-14); }
.login-submit { height: 40px; font-size: var(--fs-14); }
.field-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.field-label-row .field-label { margin: 0; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px !important; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-3); padding: 0; cursor: pointer;
}
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }
.caps-hint { color: var(--warn); font-weight: var(--fw-med); }
.login-forgot { color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 8px 10px; margin-top: 8px; }
.pw-cancel { display: block; margin: 16px auto 0; }
.login-foot { position: absolute; left: 32px; right: 32px; bottom: 32px; margin: 0; line-height: 16px; white-space: normal; text-align: center; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .login-main { background: var(--surface); } }
:root[data-theme="dark"] .login-main { background: var(--surface); }
@media (max-width: 959.98px) {
  .login-brand { padding: 24px; justify-content: flex-start; }
  .lb-lockup { margin-bottom: 20px; }
  .lb-headline { font-size: var(--fs-22); line-height: var(--lh-22); }
  .lb-foot { display: none; }
  .login-main { padding: 32px 24px max(24px, env(safe-area-inset-bottom)); justify-content: flex-start; }
  .login-foot { position: static; margin-top: 28px; }
}
@media (max-width: 479.98px) {
  .lb-facts, .lb-sub { display: none; }
}

/* ---------- ring loader: static + opacity pulse under reduced motion ---------- */
.wr-mono circle { stroke: currentColor; }
@keyframes wr-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) {
  .view.active { animation: none; }
}

/* ---------- touch: 44px hit areas, 16px inputs, no keyboard hints ---------- */
@media (pointer: coarse) {
  .btn:not(.is-loading)::after, .mini-icon-btn::after, .toast-x::after, .modal-x::after, .pw-toggle::after, .link-btn::after, .crumb-link::after {
    content: "";
    position: absolute;
    inset: -6px -2px;
  }
  .mini-icon-btn, .toast-x, .modal-x, .link-btn, .crumb-link { position: relative; }
  .mini-icon-btn::after { inset: -9px; }
  .topbar .icon-btn, .topbar .avatar-btn, .top-search { min-width: 40px; min-height: 40px; }
  .nav-item { min-height: 44px; flex-basis: 44px; }
  .menu-item { min-height: 44px; }
  .dtable .row-actions { opacity: 1; }
}
@media (max-width: 719.98px), (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { font-size: 16px !important; }
}
@media (hover: none) and (pointer: coarse) {
  kbd, .kbd, .kbd-hint, .nav-kbd, .top-search-kbd, .cmdk-foot, .cmdk-meta kbd, .cmdk-esc, .chord-hint { display: none !important; }
}

/* ---------- phone shell (≤719px): document scrolls, 5-control topbar, full-screen palette ---------- */
@media (max-width: 719.98px) {
  html, body { height: auto; }
  body { overflow: visible; overflow-x: hidden; }
  .shell, .shell.rail-collapsed { height: auto; min-height: 100dvh; grid-template-rows: var(--topbar-h) auto; }
  .topbar { position: sticky; top: 0; z-index: 300; padding: 0 4px; gap: 2px; padding-top: env(safe-area-inset-top); }
  .main { overflow: visible; min-height: calc(100dvh - var(--topbar-h)); scrollbar-gutter: auto; }
  .view.app.active { height: auto; min-height: calc(100dvh - var(--topbar-h)); overflow: visible; }
  .topbar .crumbs { flex: 1 1 auto; min-width: 0; padding-left: 4px; }
  .crumb:not(.crumb-current) { display: none; }
  .crumb-current .crumb-sep { display: none; }
  .crumb-page { font-size: var(--fs-16); line-height: var(--lh-16); }
  .top-back:not([hidden]) { display: inline-flex !important; }
  .topbar:has(.top-back:not([hidden])) .topbar-menu { display: none !important; }
  .top-search { flex: 0 0 auto; width: 40px; min-width: 40px; height: 40px; padding: 0; margin: 0; justify-content: center; border: 0; background: transparent; color: var(--text-2); }
  .top-search .ts-label, .top-search .top-search-kbd { display: none; }
  .top-search > svg { width: 18px; height: 18px; }
  #theme-toggle, .demo-chip { display: none !important; }
  .egress-pill:not(.bad) { display: none !important; }
  .topbar .icon-btn, .topbar .avatar-btn { width: 40px; height: 40px; }
  .avatar-btn { width: 32px; height: 32px; margin: 0 4px; }
  .toasts { left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .toast-region { align-items: stretch; }
  .cmdk-overlay { padding: 0; }
  .cmdk { width: 100%; height: 100dvh; max-height: none; border-radius: 0; border: 0; }
  .cmdk-head { height: 56px; padding: 0 8px 0 16px; padding-top: env(safe-area-inset-top); }
  .cmdk-input { font-size: 16px !important; }
  .cmdk-esc, .cmdk-foot { display: none !important; }
  .cmdk-cancel { display: inline-block; }
  .cmdk-item { min-height: 48px; }
  /* stacked-card tables (opt-in: add .stack to a .dtable; give cells data-label) */
  .dtable.stack thead { display: none; }
  .dtable.stack, .dtable.stack tbody, .dtable.stack tr, .dtable.stack td { display: block; width: auto; }
  .dtable.stack tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .dtable.stack tr:last-child { border-bottom: 0; }
  .dtable.stack td { height: auto; padding: 2px 0 !important; border: 0; text-align: left !important; }
  .dtable.stack td:first-child { font-weight: var(--fw-med); }
  .dtable.stack td[data-label]:not(:first-child)::before { content: attr(data-label) " · "; color: var(--text-3); font-size: var(--fs-12); }
  .dtable.stack td:empty { display: none; }
}

/* ============================================================
   R2 SHELL LAYER (REFINE2 §2 · §3 · §4 · §8) — owner F1. Extends the R1 layer above.
   ============================================================ */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --tip-bg: #1F2632; } }
:root[data-theme="dark"] { --tip-bg: #1F2632; }
.wsn-tip kbd { color: rgba(255, 255, 255, 0.82); }
.wsn-tip .tip-sub { color: var(--text-2); }

/* ---------- topbar: fixed 3-track grid — search is 420px and centred on every page ---------- */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px minmax(0, 1fr);
  column-gap: 16px;
  align-items: center;
}
.topbar > .topbar-menu, .topbar > .top-back { grid-column: 1; grid-row: 1; }
.topbar > .crumbs { grid-column: 1; grid-row: 1; min-width: 0; max-width: 100%; }
.topbar > .top-search { grid-column: 2; grid-row: 1; width: 100%; max-width: none; min-width: 0; margin: 0; flex: none; }
.topbar > .top-actions { grid-column: 3; grid-row: 1; justify-self: end; min-width: 0; }
@media (max-width: 1100px) { .topbar { grid-template-columns: minmax(0, 1fr) 280px minmax(0, 1fr); } }
.top-actions { flex-wrap: nowrap; }
@media (max-width: 1365.98px) { .egress-pill .seal-extra { display: none; } }
@media (max-width: 1499.98px) { .top-actions .demo-chip .dc-long { display: none; } .top-actions .demo-chip .dc-short { display: inline; } }

/* ---------- breadcrumb: Inter only; middle segments collapse to "…"; leaf ≥16ch ---------- */
.crumb-list { flex-wrap: nowrap; overflow: hidden; flex: 1 1 auto; width: 100%; min-width: 0; }
.crumb { flex: none; }
.crumb-current { flex: 0 1 auto; min-width: min(16ch, 100%); }
.crumb-current .crumb-page { display: block; }
.crumb-code { font: inherit; background: none; padding: 0; }
.crumb-link { max-width: 220px; }
.crumb-more {
  border: 0; background: transparent; color: var(--text-2);
  font: 500 13px/20px var(--font); padding: 2px 6px; border-radius: var(--r-sm); cursor: pointer;
}
.crumb-more:hover { background: var(--surface-2); color: var(--text); }
.crumb-more:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- seal dot: ONE tone rule (topbar + Security card) ---------- */
.seal-dot { display: inline-block; flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; }
.seal-dot.tone-ok { background: var(--ok); box-shadow: none; }
.seal-dot.tone-warn { background: var(--warn); box-shadow: none; }
.seal-dot.tone-neutral { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-3); }
.seal-dot.tone-err { background: var(--err); box-shadow: none; }
.egress-pill.bad .seal-dot.tone-err { background: #FFFFFF; }
.egress-pill .seal-strong, .egress-pill .seal-extra { font-variant-numeric: normal; }

/* ---------- page head: actions top-aligned, one-line subtitle, "As of" in actions ---------- */
.page-head { align-items: flex-start; }
.page-head .page-actions { margin-top: 0; align-self: flex-start; }
.page-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 72ch; }
.as-of {
  display: inline-flex; align-items: center; height: 32px; padding: 0 8px;
  border: 0; background: transparent; border-radius: var(--r-ctl);
  color: var(--text-3); font: 400 13px/20px var(--font); font-variant-numeric: normal; white-space: nowrap;
}
button.as-of { cursor: pointer; }
button.as-of:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
button.as-of:focus-visible { outline: none; box-shadow: var(--ring); }
button.as-of.is-loading { color: transparent; }

/* ---------- KPI: fixed 112px tiles; meta one line ---------- */
.kpi { height: 112px; min-height: 112px; }
.kpi-meta { display: block; }
.kpi.err .kpi-value, .kpi-value.is-err { color: var(--err-display); }
.kpi.warn .kpi-value, .kpi-value.is-warn { color: var(--warn-display); }
.metric { height: 112px; min-height: 112px; }
.metric-foot { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 899.98px) { .kpi { height: 104px; min-height: 104px; } }

/* ---------- data tiers: meta/time/schedule/count cells are text-2 @ 400 ---------- */
.is-meta, .cell-time, .cell-schedule, .cell-count, .rec-meta, td.is-meta, .dtable td.cell-time { color: var(--text-2); font-weight: 400; }
.cell-date, td.cell-date { font-family: var(--mono); font-size: var(--fs-12); font-variant-numeric: normal; }

/* ---------- logo: every ring from brand.js; assistant mark ---------- */
.wsn-assistant { display: inline-grid; place-items: center; color: var(--text-3); line-height: 0; }
.wsn-assistant .wr-ring { display: block; }

/* ---------- one busy pattern (labelled variant for > 2s ops) ---------- */
.btn.is-loading.is-labelled { color: inherit !important; }
.btn.is-loading.is-labelled > * { visibility: visible; }
.btn.is-loading.is-labelled::after { display: none; }
.busy-spin {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
}

/* ---------- skeletons: 150ms show-delay so fast loads never flash ---------- */
@keyframes skel-show { to { opacity: 1; } }
.skel, .skeleton { opacity: 0; animation: skel-show 1ms linear 150ms forwards, shimmer 1.2s linear 150ms infinite; }
@media (prefers-reduced-motion: reduce) { .skel, .skeleton { opacity: 1; animation: none; } }

/* ---------- skip link: no shadow until focused ---------- */
.skip-link { transform: translateY(calc(-100% - 24px)); box-shadow: none; }
.skip-link:focus, .skip-link:focus-visible { transform: none; box-shadow: var(--ring), var(--shadow-pop); }

/* ---------- avatar: 32px visual in a 44px target ---------- */
.avatar-btn { position: relative; }
.demo-chip .dc-short { display: none; }

/* ---------- touch + phone: 44px targets ---------- */
@media (pointer: coarse) {
  .topbar .icon-btn, .top-search, .topbar .avatar-btn { min-width: 44px; min-height: 44px; }
  .w3-row-menu, .w3-kv-copy, .adm-rowact, .row-menu, .copy-link { position: relative; }
  .w3-row-menu::after, .w3-kv-copy::after, .adm-rowact::after, .row-menu::after, .copy-link::after { content: ""; position: absolute; inset: -10px; }
}
@media (max-width: 719.98px) {
  .topbar { display: flex; }
  .topbar .icon-btn, .top-search { width: 44px; height: 44px; min-width: 44px; }
  .topbar { column-gap: 0; }
  .topbar > .top-search { flex: 0 0 44px; width: 44px; min-width: 44px; max-width: 44px; padding: 0; justify-content: center; }
  .topbar > .crumbs { flex: 1 1 auto; min-width: 0; }
  .topbar > .top-actions { flex: 0 0 auto; gap: 0; }
  .top-actions #top-slot { gap: 0; }
  .topbar .avatar-btn { width: 44px; height: 44px; margin: 0; background: transparent; color: #FFFFFF; }
  .topbar .avatar-btn::before {
    content: ""; position: absolute; left: 6px; top: 6px; width: 32px; height: 32px; border-radius: 50%;
    background: var(--ink-800); z-index: -1;
  }
  .topbar .avatar-btn { z-index: 0; isolation: isolate; }
  .topbar .avatar-btn:hover { box-shadow: none; }
  .topbar .avatar-btn:hover::before { box-shadow: 0 0 0 2px var(--line-strong); }
  /* demo indicator stays visible on phones, compact, in the title row */
  .demo-chip:not([hidden]) { display: inline-flex !important; order: -1; height: 22px; padding: 0 6px; margin: 0 2px 0 0; font-size: var(--fs-11); }
  .demo-chip .dc-long { display: none; }
  .demo-chip .dc-short { display: inline; }
  .crumb-current { min-width: 0; }
  /* one stacked-card component for every table (REFINE2 §8): title (2 lines) + status, meta line, 44px ⋮ */
  .dtable.stack tr, #view-dashboards .dtable.stack tr.dash-row, .dtable.stack tr.dash-row {
    display: flex; flex-wrap: wrap; align-items: center; column-gap: 0; row-gap: 2px;
    position: relative; padding: 12px 52px 12px 16px; border-bottom: 1px solid var(--line);
  }
  .dtable.stack td { display: block; flex: 0 0 auto; order: 3; font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-2); }
  .dtable.stack td:first-child {
    order: 1; flex: 1 1 60%; min-width: 0; font-size: var(--fs-14); line-height: var(--lh-14); color: var(--text); font-weight: var(--fw-med);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal;
  }
  .dtable.stack td:first-child * { white-space: normal; }
  .dtable.stack td.sc-status { order: 2; flex: none; margin-left: 8px; }
  .dtable.stack td:not(:first-child):not(.sc-status):not(.sc-menu):not(.actions) + td:not(:first-child):not(.sc-status):not(.sc-menu):not(.actions)::before { content: "\00b7\00a0"; color: var(--text-3); padding-left: 4px; }
  .dtable.stack td[data-label]:not(:first-child)::before { content: attr(data-label) "\00a0"; color: var(--text-3); }
  .dtable.stack td.sc-menu, .dtable.stack td.actions {
    position: absolute; right: 4px; top: 6px; width: 44px; height: 44px; padding: 0 !important;
    display: grid; place-items: center;
  }
  .dtable.stack td.sc-menu > *, .dtable.stack td.actions > * { min-width: 44px; min-height: 44px; }
}

/* ---------- idle lock + MFA (REFINE2 §7) ---------- */
.lock-screen {
  position: fixed; inset: 0; z-index: 1150;
  display: grid; place-items: center; padding: 24px;
  background: var(--bg);
}
.lock-card {
  width: 380px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pop);
  padding: 28px 28px 24px; box-shadow: var(--shadow-modal);
}
.lock-ico { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--text-2); margin-bottom: 12px; }
.lock-card .login-sub { margin-bottom: 20px; }
.lock-card .field input:not([type="checkbox"]) { height: 40px; font-size: var(--fs-14); }
.mfa-code-input { font-family: var(--mono) !important; font-size: 18px !important; letter-spacing: 0.3em; text-align: center; height: 44px !important; }
.mfa-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 16px; }
.mfa-steps li::marker { color: var(--text-3); font-weight: var(--fw-med); }
.mfa-step-t { display: block; font-size: var(--fs-13); font-weight: var(--fw-med); color: var(--text); margin-bottom: 8px; }
.mfa-qr { width: 168px; height: 168px; padding: 8px; background: #FFFFFF; border: 1px solid var(--line); border-radius: var(--r-panel); }
.mfa-qr svg { width: 100%; height: 100%; display: block; }
.mfa-secret-row { margin-top: 8px; font-size: var(--fs-12); }
.mfa-secret { font-size: var(--fs-12); word-break: break-all; }

/* ============================================================
   R3 SHELL LAYER (REFINE3 §B · §E · §F) — owner F1
   ============================================================ */
/* ---------- wrap policy: balanced headings/ledes, pretty prose ---------- */
h1, h2, h3, .page-title, .page-sub, .lb-headline, .empty-title, .login-title, .lede { text-wrap: balance; }
p, li, .empty-body, .confirm-msg, .field-help, .notice { text-wrap: pretty; }
.nowrap, .op-num { white-space: nowrap; }

/* ---------- ID chips / inline code in list & meta context are text-2 ---------- */
.dtable code, .list-row code, .is-meta code, .rec-meta code, .kpi-meta code, .mono-id, .id-chip { color: var(--text-2); }

/* ---------- one row focus (the .dtable outline) + one press vocabulary ---------- */
#main .w3-click-table tr.clickable:focus-visible td:first-child { box-shadow: none; }
.btn:active:not(:disabled), .icon-btn:active:not(:disabled), .mini-icon-btn:active:not(:disabled),
.avatar-btn:active, .demo-chip:active, .top-search:active, .row-menu:active:not(:disabled), .w3-row-menu:active:not(:disabled),
.adm-rowact:active:not(:disabled), .w3-send:active:not(:disabled), .w3-kv-copy:active, .copy-link:active { transform: scale(0.98); }
.dtable tr.clickable:active td, .list-row:active, .menu-item:active, .cmdk-item:active,
[role="option"]:active, [role="treeitem"]:active { background: var(--surface-3); transform: none; }
.rail .nav-item:active { background: rgba(255, 255, 255, 0.1); transform: none; }

/* ---------- palette footer: contextual hints + shortcuts link ---------- */
.cmdk-ctx { display: inline-flex; gap: 16px; }
.cmdk-ctx > span { display: inline-flex; align-items: center; gap: 4px; }
.cmdk-keys {
  display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; padding: 2px 4px; margin: 0 -4px;
  color: var(--text-3); font: 400 12px/18px var(--font); border-radius: var(--r-sm); cursor: pointer;
}
.cmdk-keys:hover { color: var(--text); background: var(--pop-hover); }
.cmdk-keys:focus-visible { outline: none; box-shadow: var(--ring); }
.cmdk-foot .cmdk-brand { margin-left: auto; }

/* ---------- login: one shared top axis (lockup top = form title top), footer group ---------- */
.login-screen { --login-axis: max(72px, calc(50vh - 200px)); }
.login-brand { justify-content: flex-start; padding-top: var(--login-axis); }
.login-main { justify-content: flex-start; padding-top: var(--login-axis); }
.login-card { margin: 0; }
.login-access { margin: 16px 0 0; text-align: center; font-size: var(--fs-13); line-height: var(--lh-13); color: var(--text-3); }
.login-foot-group { position: absolute; left: 32px; right: 32px; bottom: 32px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.login-foot-group .login-foot { position: static; margin: 0; }
.login-build { font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-2); font-variant-numeric: normal; }
.lb-fact-v { white-space: nowrap; }
@media (max-width: 959.98px) {
  .login-brand { padding-top: 24px; }
  .login-main { padding-top: 32px; padding-bottom: 0; min-height: 0; display: flex; flex-direction: column; flex: 1 1 auto; }
  .login-screen { grid-template-rows: auto minmax(0, 1fr); }
  .login-foot-group {
    position: static; margin-top: auto; padding: 32px 0 max(24px, env(safe-area-inset-bottom));
    align-items: flex-start; width: 100%; max-width: 360px; align-self: center;
  }
  .login-foot-group .login-foot { justify-content: flex-start; align-items: flex-start; text-align: left; white-space: normal; }
  .login-foot-group .login-foot svg { margin-top: 2px; }
}

/* ---------- phone: every KPI row is one snap strip; hidden scrollbar ---------- */
@media (max-width: 719.98px) {
  .kpi-strip, .kpi-strip.cols-3, .kpi-strip.cols-4, .kpi-strip.cols-6, .metric-strip {
    display: flex; flex-wrap: nowrap; grid-template-columns: none;
    overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
  }
  .kpi-strip::-webkit-scrollbar, .metric-strip::-webkit-scrollbar { display: none; }
  .kpi-strip > .kpi, .metric-strip > .metric {
    flex: 0 0 148px; min-width: 148px; height: 96px; min-height: 96px; padding: 12px 14px;
    scroll-snap-align: start; border-top: 0; border-left: 1px solid var(--line);
  }
  .kpi-strip > .kpi:first-child, .metric-strip > .metric:first-child { border-left: 0; }
  .kpi-strip > .kpi:nth-child(even), .kpi-strip > .kpi:nth-child(-n+2) { border-top: 0; }
  .kpi-strip .kpi-value, .metric-strip .metric-value { font-size: var(--fs-22); line-height: var(--lh-22); margin-top: 4px; }
  .kpi-strip .kpi-of, .kpi-strip .kpi-unit { font-size: var(--fs-14); }
  .page-head .as-of { padding-left: 0; }
  .page-sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}
.kpi-strip[role="region"]:focus-visible { outline: none; box-shadow: var(--ring); }

/* section loaders use the brand ring (buttons keep the neutral spinner) */
.state-ring { display: inline-flex; width: 24px; height: 24px; margin-right: 10px; vertical-align: middle; }
.state-ring .wr-ring { width: 24px; height: 24px; }

/* ---------- rail brand: own 72px header, 32px ring, breathing room (owner feedback) ---------- */
.rail-brand, .shell .rail-brand { flex: 0 0 72px; min-height: 72px; padding: 0 20px; border-bottom: 0; }
.rail-brand .wsn-lockup { gap: 12px; }
.rail-brand .wsn-lockup .brand-name { font-size: 16px; line-height: 20px; letter-spacing: -0.01em; }
.rail-brand .wsn-lockup .brand-sub { font-size: 12px; line-height: 16px; }
.rail-brand + * { margin-top: 4px; }
.shell.rail-collapsed .rail-brand { padding: 0; justify-content: center; }
.shell.rail-collapsed .rail-brand .wsn-lockup .logo-mark { width: 28px; height: 28px; }
