/* SAE localhost panel — visual identity (S7 Round 3B visual prototype, contract docs/22).
   Original SAE look: deep charcoal workstation, SAE green data accents, a sparse
   canvas data-stream behind the content. System fonts only; no remote asset,
   no CSS image references, no web font. Motion is decorative and stops under reduced motion. */

/* ======================================================================
   Tokens — light (default)
   ====================================================================== */

:root {
  color-scheme: light;
  --bg: #eef2ef;
  --bg-grid: rgba(11, 110, 56, 0.06);
  --surface: rgba(255, 255, 255, 0.94);
  --surface-solid: #ffffff;
  --surface-2: #f4f7f5;
  --surface-3: #e9eeeb;
  --border: #d2dbd5;
  --border-strong: #b5c3ba;
  --text: #0f1712;
  --text-muted: #46564c;
  --text-faint: #6b7a71;
  --accent: #0b6e38;
  --accent-strong: #08592d;
  --accent-soft: rgba(11, 110, 56, 0.1);
  --accent-ink: #ffffff;
  --glow: rgba(11, 110, 56, 0.18);
  --shadow: 0 1px 2px rgba(15, 23, 18, 0.06), 0 6px 18px rgba(15, 23, 18, 0.06);
  --appbar-bg: rgba(255, 255, 255, 0.92);

  --stream-glyph: #0b6e38;
  --stream-head: #0b6e38;
  --stream-alpha: 0.09;

  /* Demo designation: violet stripes, never used for status. */
  --demo-fg: #4b36b8;
  --demo-bg: #ece8ff;
  --demo-stripe: rgba(75, 54, 184, 0.14);
  --demo-edge: rgba(75, 54, 184, 0.45);
  --live-fg: #08592d;
  --live-bg: #dff3e7;

  /* Status tokens — every use also carries text and a shape. */
  --st-verified-fg: #0b5d30;
  --st-verified-bg: #ddf2e5;
  --st-partial-fg: #7a4a00;
  --st-partial-bg: #fbedd0;
  --st-severe-fg: #9b1c1c;
  --st-severe-bg: #fbe0e0;
  --st-neutral-fg: #3e4c5a;
  --st-neutral-bg: #e4e9ee;
  --st-gated-fg: #5a3a8a;
  --st-gated-bg: #efe6fb;
  --st-muted-fg: #59615c;
  --st-muted-bg: #eceeed;

  /* Chart fills (status-coded instruments). */
  --fill-verified: #1f8a4c;
  --fill-partial: #d08a00;
  --fill-neutral: #7b8ea3;
  --fill-muted: #b9c1bc;
  --fill-severe: #c62828;

  /* Categorical series (validated reference palette, light steps). */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-other: #9aa39e;
  --hatch-bg: #e3e7e5;
  --hatch-line: #6f7a74;

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --gap: 14px;
  --pad: 16px;
  --gutter: clamp(12px, 2vw, 28px);
}

/* ======================================================================
   Tokens — dark (system preference, unless light is forced)
   ====================================================================== */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #040605;
    --bg-grid: rgba(61, 220, 132, 0.035);
    --surface: rgba(11, 16, 13, 0.82);
    --surface-solid: #0b100d;
    --surface-2: #101713;
    --surface-3: #16201a;
    --border: #1b2620;
    --border-strong: #2a3a31;
    --text: #e2ebe5;
    --text-muted: #94a39a;
    --text-faint: #66756c;
    --accent: #3ddc84;
    --accent-strong: #6ff0a6;
    --accent-soft: rgba(61, 220, 132, 0.1);
    --accent-ink: #03120a;
    --glow: rgba(61, 220, 132, 0.28);
    --shadow: 0 0 0 1px rgba(61, 220, 132, 0.03), 0 10px 30px rgba(0, 0, 0, 0.55);
    --appbar-bg: rgba(5, 8, 6, 0.86);
    --stream-glyph: #2fd47a;
    --stream-head: #c9ffe0;
    --stream-alpha: 0.22;
    --demo-fg: #c4b8ff;
    --demo-bg: #1d1838;
    --demo-stripe: rgba(196, 184, 255, 0.12);
    --demo-edge: rgba(196, 184, 255, 0.4);
    --live-fg: #8ff0b7;
    --live-bg: #0f2a1b;
    --st-verified-fg: #7cebab;
    --st-verified-bg: #10291b;
    --st-partial-fg: #f2c36b;
    --st-partial-bg: #2e2412;
    --st-severe-fg: #ff9b9b;
    --st-severe-bg: #331616;
    --st-neutral-fg: #b4c1ce;
    --st-neutral-bg: #1b232b;
    --st-gated-fg: #cdb3ff;
    --st-gated-bg: #241a36;
    --st-muted-fg: #a5ada8;
    --st-muted-bg: #1a1f1c;
    --fill-verified: #2fc472;
    --fill-partial: #e0a530;
    --fill-neutral: #6f8296;
    --fill-muted: #46504a;
    --fill-severe: #ef5350;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-other: #6c7570;
    --hatch-bg: #1e2421;
    --hatch-line: #8d9891;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #040605;
  --bg-grid: rgba(61, 220, 132, 0.035);
  --surface: rgba(11, 16, 13, 0.82);
  --surface-solid: #0b100d;
  --surface-2: #101713;
  --surface-3: #16201a;
  --border: #1b2620;
  --border-strong: #2a3a31;
  --text: #e2ebe5;
  --text-muted: #94a39a;
  --text-faint: #66756c;
  --accent: #3ddc84;
  --accent-strong: #6ff0a6;
  --accent-soft: rgba(61, 220, 132, 0.1);
  --accent-ink: #03120a;
  --glow: rgba(61, 220, 132, 0.28);
  --shadow: 0 0 0 1px rgba(61, 220, 132, 0.03), 0 10px 30px rgba(0, 0, 0, 0.55);
  --appbar-bg: rgba(5, 8, 6, 0.86);
  --stream-glyph: #2fd47a;
  --stream-head: #c9ffe0;
  --stream-alpha: 0.22;
  --demo-fg: #c4b8ff;
  --demo-bg: #1d1838;
  --demo-stripe: rgba(196, 184, 255, 0.12);
  --demo-edge: rgba(196, 184, 255, 0.4);
  --live-fg: #8ff0b7;
  --live-bg: #0f2a1b;
  --st-verified-fg: #7cebab;
  --st-verified-bg: #10291b;
  --st-partial-fg: #f2c36b;
  --st-partial-bg: #2e2412;
  --st-severe-fg: #ff9b9b;
  --st-severe-bg: #331616;
  --st-neutral-fg: #b4c1ce;
  --st-neutral-bg: #1b232b;
  --st-gated-fg: #cdb3ff;
  --st-gated-bg: #241a36;
  --st-muted-fg: #a5ada8;
  --st-muted-bg: #1a1f1c;
  --fill-verified: #2fc472;
  --fill-partial: #e0a530;
  --fill-neutral: #6f8296;
  --fill-muted: #46504a;
  --fill-severe: #ef5350;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-other: #6c7570;
  --hatch-bg: #1e2421;
  --hatch-line: #8d9891;
}

:root[data-density="compact"] {
  --gap: 10px;
  --pad: 12px;
}

/* ======================================================================
   Base
   ====================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  /* Static technical grid; the moving data-stream is the canvas below. */
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 48px 48px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14.5px;
  line-height: 1.5;
  overflow-x: hidden;
}

.datastream {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  overflow-wrap: anywhere;
  unicode-bidi: isolate;
}

.fine {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 50;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.skip-link:focus {
  top: 12px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.view:focus,
.view-head__title:focus {
  outline: none;
}

/* ======================================================================
   App bar and navigation
   ====================================================================== */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.brand__mark {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 0 6px var(--glow));
}

.brand__hex {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 1.6;
}

.brand__bar {
  fill: var(--accent);
}

.brand__bar--b {
  opacity: 0.75;
}

.brand__bar--c {
  opacity: 0.5;
}

.brand__text {
  display: grid;
  line-height: 1.1;
}

.brand__name {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.32em;
  color: var(--text);
}

.brand__sub {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.appbar__panel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.appbar__panel-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-faint);
}

.preview-flag {
  padding: 3px 8px;
  border: 1px solid var(--demo-edge);
  border-radius: 4px;
  color: var(--demo-fg);
  background: repeating-linear-gradient(135deg, var(--demo-bg) 0 6px, var(--demo-stripe) 6px 9px);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle__icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--text);
  background: linear-gradient(90deg, var(--text) 50%, transparent 50%);
}

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px var(--gutter);
  border-top: 1px solid var(--demo-edge);
  background: repeating-linear-gradient(135deg, var(--demo-bg) 0 10px, color-mix(in srgb, var(--demo-bg) 70%, var(--demo-stripe)) 10px 14px);
  color: var(--demo-fg);
  font-size: 0.8rem;
}

.banner__tag {
  flex: none;
  font-family: var(--font-mono);
  font-weight: 800;
  letter-spacing: 0.14em;
}

.banner__text strong {
  font-weight: 800;
}

.session-message {
  margin: 0;
  padding: 8px var(--gutter);
  border-top: 1px solid var(--st-severe-fg);
  background: var(--st-severe-bg);
  color: var(--st-severe-fg);
  font-size: 0.85rem;
}

/* ======================================================================
   Chips, provenance badges, buttons
   ====================================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 650;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
}

.chip--verified { color: var(--st-verified-fg); background: var(--st-verified-bg); }
.chip--partial { color: var(--st-partial-fg); background: var(--st-partial-bg); }
.chip--severe,
.chip--severe-soft { color: var(--st-severe-fg); background: var(--st-severe-bg); }
.chip--neutral { color: var(--st-neutral-fg); background: var(--st-neutral-bg); }
.chip--gated { color: var(--st-gated-fg); background: var(--st-gated-bg); }
.chip--muted { color: var(--st-muted-fg); background: var(--st-muted-bg); }

/* Shapes: circle = verified/active, triangle = partial, square = severe,
   ring = neutral, diamond = gated, bar = excluded/muted, dashed square = unknown. */
.chip[data-shape="verified"]::before { border-radius: 50%; background: currentColor; }
.chip[data-shape="partial"]::before {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 9px solid currentColor;
}
.chip[data-shape="severe"]::before { background: currentColor; }
.chip[data-shape="severe-soft"]::before { border: 1.5px dashed currentColor; }
.chip[data-shape="neutral"]::before { border-radius: 50%; border: 2px solid currentColor; }
.chip[data-shape="gated"]::before { width: 7px; height: 7px; transform: rotate(45deg); background: currentColor; }
.chip[data-shape="muted"]::before { height: 3px; background: currentColor; }

.provenance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.provenance--demo {
  color: var(--demo-fg);
  border: 1px dashed var(--demo-edge);
  background: repeating-linear-gradient(135deg, var(--demo-bg) 0 6px, var(--demo-stripe) 6px 9px);
}

.provenance--live {
  color: var(--live-fg);
  border: 1px solid var(--live-fg);
  background: var(--live-bg);
}

.provenance__glyph {
  width: 8px;
  height: 8px;
}

.provenance--demo .provenance__glyph {
  border: 1.5px dashed currentColor;
  border-radius: 2px;
}

.provenance--live .provenance__glyph {
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  cursor: pointer;
}

.btn:hover {
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 14px var(--glow);
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}

.btn--ghost:hover {
  border-color: var(--accent);
}

.btn:disabled,
.btn:disabled:hover {
  cursor: not-allowed;
  box-shadow: none;
}

.btn--start {
  padding: 12px 22px;
  font-size: 1rem;
}

.btn--start:disabled {
  background: repeating-linear-gradient(135deg, var(--surface-3) 0 8px, var(--surface-2) 8px 14px);
  color: var(--text-faint);
  border: 1px dashed var(--border-strong);
}

.kbd {
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ======================================================================
   Views
   ====================================================================== */

.view {
  position: relative;
  z-index: 1;
  padding: 18px var(--gutter) 24px;
  display: grid;
  gap: var(--gap);
  align-content: start;
}

.view-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  justify-content: space-between;
}

.view-head__kicker {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.view-head__title {
  margin: 2px 0 0;
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.view-head__lede {
  margin: 4px 0 0;
  max-width: 75ch;
  color: var(--text-muted);
}

.view-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* ---- situation strip -------------------------------------------------- */

.situation {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
}

.situation > * {
  background: var(--surface-solid);
}

.situation__evidence {
  flex: 2 1 220px;
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  border-left: 3px solid var(--demo-fg);
}

.situation__kicker,
.kpi__label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.situation__state {
  color: var(--demo-fg);
  font-size: 0.9rem;
}

.situation__target {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.situation__badge {
  flex: 1 1 100%;
  display: flex;
  justify-content: flex-end;
  padding: 4px 10px;
  background: var(--surface-2);
}

.kpi {
  flex: 1 1 120px;
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 10px 12px;
  min-width: 0;
}

.kpi__value {
  font-size: 1.15rem;
  font-weight: 750;
  color: var(--text);
  overflow-wrap: anywhere;
}

.kpi__sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.kpi--severe .kpi__value {
  color: var(--st-severe-fg);
}

.kpi--neutral .kpi__value {
  color: var(--st-neutral-fg);
}

/* ---- instrument grid -------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: row dense;
  gap: var(--gap);
  align-items: stretch;
}

.span-1 { grid-column: span 1; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

.instrument {
  container-type: inline-size;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, var(--accent-soft), transparent 70px),
    var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

/* Corner brackets: an instrument-bezel cue. */
.instrument::before,
.instrument::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border-color: var(--accent);
  border-style: solid;
  opacity: 0.55;
  pointer-events: none;
}

.instrument::before {
  top: 5px;
  left: 5px;
  border-width: 1.5px 0 0 1.5px;
}

.instrument::after {
  right: 5px;
  bottom: 5px;
  border-width: 0 1.5px 1.5px 0;
}

.instrument--demo {
  border-top: 2px dashed var(--demo-edge);
}

.instrument--live {
  border-top: 2px solid var(--live-fg);
}

.instrument:hover,
.instrument:focus-within {
  border-color: var(--border-strong);
  box-shadow: var(--shadow), 0 0 0 1px var(--glow), 0 0 24px var(--glow);
}

.instrument__scan {
  position: absolute;
  left: 0;
  right: 0;
  top: -40%;
  height: 40%;
  background: linear-gradient(180deg, transparent, var(--accent-soft), transparent);
  opacity: 0;
  pointer-events: none;
}

.instrument:hover .instrument__scan {
  opacity: 1;
  animation: scan 1.6s ease-in-out 1;
}

@keyframes scan {
  from { transform: translateY(0); }
  to { transform: translateY(350%); }
}

.instrument__head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(var(--pad) - 2px) var(--pad) 8px;
  border-bottom: 1px solid var(--border);
}

.instrument__titles {
  min-width: 0;
  flex: 1 1 180px;
}

.instrument__title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.instrument__question {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.instrument__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.instrument__tools {
  display: inline-flex;
  gap: 2px;
}

/* Narrow instruments: badge left, tools right, on one row under the title. */
@container (max-width: 460px) {
  .instrument__meta {
    flex: 1 1 100%;
    justify-content: space-between;
  }
}

.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.tool:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.tool:disabled {
  opacity: 0.35;
  cursor: default;
}

.tool--detail {
  border-color: var(--border-strong);
  color: var(--text);
}

.tool__text {
  font-size: 0.76rem;
  font-weight: 650;
}

.instrument.is-collapsed .tool--collapse span {
  display: inline-block;
  transform: rotate(-90deg);
}

.instrument__body {
  flex: 1;
  padding: 12px var(--pad) var(--pad);
  min-width: 0;
}

.instrument.is-collapsed {
  align-self: start;
}

/* ---- coverage / donut ------------------------------------------------- */

.coverage {
  display: grid;
  grid-template-columns: minmax(150px, 200px) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.span-1 .coverage {
  grid-template-columns: 1fr;
  justify-items: center;
}

.span-1 .coverage .legend-list {
  width: 100%;
}

.coverage__ring {
  width: 100%;
  max-width: 210px;
}

.donut {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.donut__track {
  fill: none;
  stroke: var(--surface-3);
}

.donut__arc {
  fill: none;
  stroke-linecap: butt;
  transition: opacity 140ms ease, stroke-width 140ms ease;
}

.donut.is-focused .donut__arc {
  opacity: 0.32;
}

.donut.is-focused .donut__arc.is-active {
  opacity: 1;
  filter: drop-shadow(0 0 5px var(--glow));
}

.donut__value {
  fill: var(--text);
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 800;
}

.donut__label {
  fill: var(--text-muted);
  font-size: 11px;
}

/* Colour slots: one custom property, consumed by strokes, fills and swatches. */
.fill-verified { --c: var(--fill-verified); }
.fill-partial { --c: var(--fill-partial); }
.fill-neutral { --c: var(--fill-neutral); }
.fill-muted { --c: var(--fill-muted); }
.fill-severe { --c: var(--fill-severe); }
.series-1 { --c: var(--series-1); }
.series-2 { --c: var(--series-2); }
.series-3 { --c: var(--series-3); }
.series-4 { --c: var(--series-4); }
.series-5 { --c: var(--series-5); }
.series-6 { --c: var(--series-6); }
.series-other { --c: var(--series-other); }

/* Unknown keeps the hatch paint server set as an SVG attribute. */
.donut__arc:not(.series-unknown) { stroke: var(--c); }
.cbar__seg,
.meter__fill { fill: var(--c); }
.meter__track { fill: var(--surface-3); }

.hatch__bg { fill: var(--hatch-bg); }
.hatch__line { fill: var(--hatch-line); }

.legend-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  min-width: 0;
}

.legend-list--cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 12px;
}

.legend-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto 52px;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}

.legend-item:hover,
.legend-item.is-active {
  background: var(--surface-2);
  border-color: var(--border);
}

.legend-item[aria-pressed="true"] {
  border-color: var(--accent);
}

.legend-item__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--c);
}

.legend-item__swatch.series-unknown {
  background: repeating-linear-gradient(45deg, var(--hatch-line) 0 2px, var(--hatch-bg) 2px 5px);
  outline: 1px solid var(--hatch-line);
}

.legend-item__label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.legend-item__count,
.legend-item__pct {
  color: var(--text-muted);
  text-align: right;
}

.unaccounted {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--fill-severe);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.unaccounted__label {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.74rem;
  letter-spacing: 0.12em;
}

.unaccounted__value {
  font-size: 1.3rem;
  font-weight: 800;
}

.unaccounted__note {
  font-size: 0.76rem;
  color: var(--text-muted);
  text-align: right;
}

.unaccounted--nonzero {
  background: var(--st-severe-bg);
  color: var(--st-severe-fg);
}

/* ---- pipeline ---------------------------------------------------------- */

.pipeline {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin: 0;
  padding: 6px 0 0;
  list-style: none;
}

.stage {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 0 4px;
  text-align: center;
}

.stage::before {
  content: "";
  position: absolute;
  top: 9px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--border-strong);
}

.stage:first-child::before {
  display: none;
}

.stage[data-state="done"]::before,
.stage[data-state="current"]::before {
  background: var(--accent);
  box-shadow: 0 0 6px var(--glow);
}

.stage__node {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface-solid);
}

.stage[data-state="done"] .stage__node {
  border-color: var(--accent);
  background: var(--accent);
}

.stage[data-state="current"] .stage__node {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 0 12px var(--glow);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  50% { box-shadow: 0 0 0 7px var(--accent-soft), 0 0 18px var(--glow); }
}

.stage__label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  overflow-wrap: anywhere;
}

.stage__state {
  font-size: 0.7rem;
  color: var(--text-faint);
}

.stage[data-state="current"] .stage__state {
  color: var(--accent);
  font-weight: 700;
}

.stage__detail {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pipeline--vertical {
  grid-template-columns: 1fr;
  gap: 10px;
}

.pipeline--vertical .stage {
  grid-template-columns: 20px minmax(0, 1fr);
  justify-items: start;
  text-align: left;
  column-gap: 10px;
  row-gap: 0;
}

.pipeline--vertical .stage::before {
  display: none;
}

.pipeline--vertical .stage__node {
  grid-row: span 2;
}

.pipeline-wrap {
  display: grid;
  gap: 14px;
}

.stage-readout {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.stage-readout__kicker {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stage-readout__label {
  font-size: 0.95rem;
  color: var(--accent);
}

.stage-readout__detail {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.share {
  margin-top: 12px;
}

.share__title {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.share__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.share__legend li {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.pipeline-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.pipeline-controls .fine {
  margin: 0;
}

/* ---- accounting -------------------------------------------------------- */

.acct-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.acct-stat {
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  min-width: 0;
}

.acct-stat__label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.acct-stat__value {
  font-size: 1.05rem;
  font-weight: 750;
}

.acct-stat--unaccounted {
  border-left: 3px solid var(--fill-severe);
}

.cbar {
  display: block;
  width: 100%;
  height: 22px;
}

.acct-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.equation {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.equation__term {
  display: grid;
  justify-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
}

.equation__term b {
  font-size: 0.95rem;
}

.equation__term small {
  font-size: 0.64rem;
  color: var(--text-muted);
}

.equation__term--whole {
  outline: 1px solid var(--accent);
}

.equation__op {
  color: var(--text-faint);
}

.bars {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bars__row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(80px, 2fr) 40px;
  gap: 10px;
  align-items: center;
  font-size: 0.85rem;
}

.meter {
  display: block;
  width: 100%;
  height: 8px;
}

/* ---- what SAE examined ------------------------------------------------- */

.quads {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quad {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  min-width: 0;
}

.quad__title {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.quad__value {
  margin: 4px 0 6px;
  font-size: 1.25rem;
  font-weight: 800;
}

.quad__value small {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.quad__list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
}

.quad__list li {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.quad__territory {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---- capability states and matrix --------------------------------------- */

.cap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.cap__glyph {
  font-size: 0.75rem;
}

.cap--verified { color: var(--st-verified-fg); background: var(--st-verified-bg); }
.cap--partial { color: var(--st-partial-fg); background: var(--st-partial-bg); }
.cap--gated { color: var(--st-gated-fg); background: var(--st-gated-bg); }
.cap--neutral { color: var(--st-neutral-fg); background: var(--st-neutral-bg); }

.cap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.table-scroll {
  overflow-x: auto;
  max-width: 100%;
}

.matrix,
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

.matrix th,
.matrix td,
.table th,
.table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.matrix thead th,
.table thead th {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.matrix tbody th,
.table tbody th {
  font-weight: 650;
}

.table .num {
  text-align: right;
}

.matrix__cell {
  padding: 2px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.matrix__cell:hover {
  border-color: var(--border-strong);
}

.matrix--full .is-row,
.matrix--full .is-col {
  background: var(--accent-soft);
}

.matrix-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) minmax(260px, 1fr);
  gap: var(--gap);
  align-items: start;
}

.matrix-readout__title {
  margin: 0 0 6px;
}

/* ---- claims ------------------------------------------------------------ */

.claims {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.claims__block {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  min-width: 0;
}

.claims__block--verified {
  border-left: 3px solid var(--fill-verified);
}

.claims__block--neutral {
  border-left: 3px solid var(--fill-neutral);
}

.claims__title {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.claims__count {
  margin-left: auto;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
}

.claims__block ul {
  margin: 0;
  padding-left: 18px;
  font-size: 0.82rem;
}

.claims__block p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.claims__findings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 10px;
  margin-top: 10px;
}

/* ---- callouts, key/value, misc ------------------------------------------- */

.callout {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--fill-neutral);
  background: var(--surface-2);
}

.callout--warn {
  border-left-color: var(--fill-partial);
  background: var(--st-partial-bg);
  color: var(--st-partial-fg);
}

.callout__title {
  display: block;
  font-size: 0.85rem;
}

.callout__text {
  margin: 4px 0 0;
  font-size: 0.82rem;
}

.kv {
  display: grid;
  gap: 6px;
  margin: 0;
}

.kv__row {
  display: grid;
  grid-template-columns: minmax(90px, 130px) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.kv dt {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.kv dd {
  margin: 0;
  min-width: 0;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.kv--compact .kv__row {
  align-items: start;
}

.subhead {
  margin: 14px 0 6px;
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.target-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.target {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--live-fg);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.target__id {
  font-weight: 750;
}

.target__label {
  flex-basis: 100%;
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
  unicode-bidi: isolate;
}

.ticks {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.86rem;
}

.ticks li {
  position: relative;
  padding-left: 18px;
}

.ticks li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.55em;
  width: 7px;
  height: 7px;
  border: 1.5px solid var(--accent);
  transform: rotate(45deg);
}

/* ======================================================================
   Secondary views
   ====================================================================== */

.panel-box {
  position: relative;
  min-width: 0;
  padding: var(--pad);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-box__head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel-box__title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}

.choice-list {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.choice {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  opacity: 0.85;
}

.choice__radio {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
}

.choice--current .choice__radio {
  border-color: var(--accent);
  background: radial-gradient(circle, var(--accent) 0 3px, transparent 3.5px);
}

.choice__main {
  display: grid;
  min-width: 0;
}

.choice__sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.chain {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: chain;
}

.chain__step {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.8rem;
}

.chain__step span {
  color: var(--text-muted);
}

.chain__step:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translate(50%, -50%);
  color: var(--accent);
}

.start-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  padding: 14px var(--pad);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
}

.start-bar__note {
  margin: 0;
  max-width: 70ch;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.start-bar__note strong {
  color: var(--text);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.toolbar .cap-legend {
  margin: 0;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.filter {
  padding: 5px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.filter[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}

.cap-library {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--gap);
}

.cap-card {
  padding: var(--pad);
  border: 1px solid var(--border);
  border-top: 2px dashed var(--demo-edge);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.cap-card__head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cap-card__title {
  margin: 0;
  font-size: 0.95rem;
}

.cap-card__title small {
  font-weight: 500;
  color: var(--text-muted);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

.product-card {
  position: relative;
  padding: 18px var(--pad) var(--pad);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.product-card__index {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.1em;
}

.product-card__title {
  margin: 6px 0 6px;
  font-size: 1.02rem;
}

.product-card p {
  margin: 0;
  color: var(--text-muted);
}

.venn {
  display: grid;
  place-items: center;
  padding: 10px 0;
}

.venn__ring {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 10px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.8rem;
}

.venn__ring > span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.venn__ring--outer {
  width: min(560px, 100%);
  padding: 22px 30px 34px;
  border: 1.5px dashed var(--border-strong);
  background: var(--surface-2);
}

.venn__ring--mid {
  width: 76%;
  padding: 18px 24px 28px;
  border: 1.5px solid var(--fill-neutral);
  background: var(--surface-3);
}

.venn__ring--inner {
  width: 64%;
  padding: 22px 14px;
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 18px var(--glow);
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}

.accordion {
  display: grid;
  gap: 6px;
}

.accordion__item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.accordion__q {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}

.accordion__q::-webkit-details-marker {
  display: none;
}

.accordion__icon {
  flex: none;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
  transition: transform 140ms ease;
}

.accordion__item[open] .accordion__icon {
  transform: rotate(225deg);
}

.accordion__a {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--text-muted);
}

.support-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}

.support-card {
  padding: var(--pad);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.support-card__title {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.support-card--future {
  border-style: dashed;
}

.support-card--future p {
  color: var(--text-muted);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}

.setting {
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.setting__legend {
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 700;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.segmented__option {
  position: relative;
}

.segmented__input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.segmented__label {
  display: block;
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
}

.segmented__input:checked + .segmented__label {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.segmented__input:focus-visible + .segmented__label {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ======================================================================
   Detail workspace (modal drawer)
   ====================================================================== */

.detail {
  width: min(1180px, 100vw);
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--border-strong);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.35);
}

.detail::backdrop {
  background: rgba(2, 6, 4, 0.55);
  backdrop-filter: blur(3px);
}

.detail[open] {
  animation: drawer-in 180ms ease-out;
}

@keyframes drawer-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.detail__frame {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.detail__head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--accent-soft), transparent);
}

.detail__titles {
  flex: 1 1 260px;
  min-width: 0;
}

.detail__kicker {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.detail__title {
  margin: 2px 0 0;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.detail__body {
  flex: 1;
  overflow: auto;
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 18px 22px 28px;
}

.detail-split {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}

.footer {
  position: relative;
  z-index: 1;
  padding: 8px var(--gutter) 22px;
  color: var(--text-faint);
  font-size: 0.75rem;
}

.footer p {
  margin: 0;
}

/* ======================================================================
   Responsive
   ====================================================================== */

@media (max-width: 1599px) {
  .appbar__panel-label {
    display: none;
  }
}

@media (max-width: 1399px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .flow-grid,
  .support-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1239px) {
  .product-grid,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .matrix-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1023px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .span-3 {
    grid-column: span 2;
  }
  .acct-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .chain {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .chain__step::after {
    display: none;
  }
}

@media (max-width: 759px) {
  .grid,
  .flow-grid,
  .support-grid,
  .product-grid,
  .settings-grid,
  .two-col,
  .claims,
  .claims__findings,
  .quads,
  .detail-split {
    grid-template-columns: 1fr;
  }
  .span-2,
  .span-3 {
    grid-column: span 1;
  }
  .situation__evidence {
    flex-basis: 100%;
  }
  .coverage {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .coverage .legend-list {
    width: 100%;
  }
  .pipeline {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .pipeline .stage {
    grid-template-columns: 20px minmax(0, 1fr) auto;
    justify-items: start;
    text-align: left;
    column-gap: 10px;
  }
  .pipeline .stage::before {
    display: none;
  }
  .tool--width {
    display: none;
  }
  /* Run history: one stacked record per run. */
  .table--runs thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .table--runs,
  .table--runs tbody,
  .table--runs tr {
    display: block;
  }
  .table--runs tr {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }
  .table--runs th,
  .table--runs td {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 3px 0;
    border: 0;
  }
  .table--runs th {
    display: block;
  }
  .table--runs td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    color: var(--text-faint);
  }
  .table--runs .chip {
    justify-self: start;
  }
  .table--runs .tool--detail {
    justify-self: start;
  }
  .legend-list--cols-2 {
    grid-template-columns: 1fr;
  }
  .detail__head,
  .detail__body {
    padding-left: 14px;
    padding-right: 14px;
  }
}

@media (max-width: 479px) {
  body {
    font-size: 14px;
  }
  .brand__sub,
  .appbar__panel-label {
    display: none;
  }
  .banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .acct-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .chain {
    grid-template-columns: 1fr;
  }
  .kv__row {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .unaccounted {
    grid-template-columns: auto auto;
  }
  .unaccounted__note {
    grid-column: 1 / -1;
    text-align: left;
  }
  .bars__row {
    grid-template-columns: 1fr 40px;
  }
  .bars__row .meter {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .view-head__title {
    font-size: 1.3rem;
  }
}

/* ======================================================================
   Motion: off when the system asks for reduced motion, or when the panel's
   own motion setting is "reduced".
   ====================================================================== */

:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  transition: none !important;
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .chip,
  .cap,
  .provenance {
    border: 1px solid CanvasText;
  }
}

/* ---------------------------------------------------------------------------
   S7 Round 3B-1B — real-run instruments (runview.mjs)
   ------------------------------------------------------------------------ */

.runview {
  display: grid;
  gap: 10px;
}

.integrity-mismatch {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--fill-severe);
  background: var(--st-severe-bg);
  color: var(--st-severe-fg);
}

.integrity-mismatch__title {
  display: block;
  font-size: 1rem;
  letter-spacing: 0.06em;
}

.integrity-mismatch p {
  margin: 6px 0 0;
  font-size: 0.85rem;
}

.code-list,
.check-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
  font-size: 0.82rem;
}

.check-list li {
  display: flex;
  gap: 8px;
  align-items: center;
}

.text-severe {
  color: var(--st-severe-fg);
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
   S7 Round 3B-1C — diagnostic workflow (docs/22 §22)
   Status is always text + glyph + chip shape; colour only reinforces it.
   --------------------------------------------------------------------------- */

.run-banner-region:empty {
  display: none;
}

.run-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--fill-neutral);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.run-banner--verified { border-left-color: var(--fill-verified); }
.run-banner--partial { border-left-color: var(--fill-partial); }
.run-banner--severe-soft { border-left-color: var(--fill-severe); border-left-style: dashed; }
.run-banner--muted { border-left-color: var(--fill-muted); }

.run-banner--severe {
  border: 2px solid var(--fill-severe);
  border-left-width: 6px;
  background: var(--st-severe-bg);
  color: var(--st-severe-fg);
}

.run-banner__glyph {
  flex: none;
  width: 1.6em;
  font-size: 1.2rem;
  line-height: 1.2;
  text-align: center;
}

.run-banner__text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.run-banner__label {
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.run-banner--severe .run-banner__label {
  letter-spacing: 0.08em;
}

.run-banner__detail {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.run-banner--severe .run-banner__detail {
  color: inherit;
}

.target-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.target-card > .chip {
  grid-column: 2;
  justify-self: start;
}

.target-card__radio {
  width: 14px;
  height: 14px;
  margin-top: 3px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0 3px, transparent 3.5px);
}

.target-card__main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.target-card__id {
  font-weight: 700;
}

.target-card__label {
  font-size: 0.9rem;
}

.target-card__context {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.disclosure {
  margin-top: 10px;
  font-size: 0.85rem;
}

.disclosure__summary {
  cursor: pointer;
  color: var(--text-muted);
}

.disclosure[open] .disclosure__summary {
  margin-bottom: 8px;
}

.start-bar__reason {
  display: inline;
}

.live-run {
  display: grid;
  gap: 12px;
}

.live-run[hidden] {
  display: none;
}

.live-run__phase {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.live-run__phase-text {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.live-run__progress {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.live-run__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.live-run__actions[hidden] {
  display: none;
}

.coverage-lede {
  margin: 4px 0;
  font-size: 0.86rem;
}

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

.situation__code {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.next-step[hidden] {
  display: none;
}

.panel-box[hidden] {
  display: none;
}

.row-tag {
  margin-left: 8px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.table--runs tr.is-current th,
.table--runs tr.is-current td {
  background: var(--accent-soft);
}

@media (max-width: 759px) {
  .run-banner {
    padding: 10px 12px;
  }

  .start-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .start-bar .btn--start {
    justify-content: center;
  }

  .live-run .kv__row {
    grid-template-columns: minmax(0, 1fr);
  }
}

.kv--facts .kv__row {
  grid-template-columns: minmax(0, 1fr) auto;
  padding-bottom: 4px;
  border-bottom: 1px dotted var(--border);
}

.kv--facts dd {
  text-align: right;
}

.stack {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------------
   S7 Round 3B-1D - governed run history (docs/22 section 23)
   Historical runs are framed apart from the current run: a dashed accent edge
   on every historical card and a HISTORICAL banner; state is text + glyph +
   chip shape, never colour alone.
   --------------------------------------------------------------------------- */

.history-box {
  display: grid;
  gap: 12px;
}

.history-live:empty {
  display: none;
}

.history-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  justify-content: space-between;
}

.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  min-width: 0;
}

.history-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.history-field__label {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.history-notes {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-note {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
  font-size: 0.86rem;
}

.history-note--truncated {
  padding: 6px 8px;
  border-left: 3px solid var(--fill-partial);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.table--history td,
.table--history th {
  vertical-align: top;
}

.history-failed {
  display: block;
  margin-top: 4px;
}

.history-inspection {
  display: grid;
  gap: var(--gap);
}

.history-inspection__bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.history-banner {
  border-style: dashed;
  border-left-style: solid;
}

.instrument--history {
  border-top: 2px dashed var(--accent);
}

.history-grid {
  margin: 0;
}

.demo-disclosure {
  border-top: 2px dashed var(--demo-edge);
}

.demo-disclosure__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
}

.demo-disclosure[open] .demo-disclosure__summary {
  margin-bottom: 10px;
}

@media (max-width: 759px) {
  .history-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .history-inspection__bar .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* S7 motor-UI slice (docs/22 section 26): provider cards, the per-file table, pager and actions. */
.provider-card {
  margin-block: 0.75rem;
}

.units__filters {
  display: grid;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.table--units th[scope="row"] .mono {
  white-space: nowrap;
}

.table--units td {
  vertical-align: top;
  overflow-wrap: anywhere;
}

.units__pager,
.units__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* ======================================================================
   S5 UI rebuild — application shell (sidebar, top bar, section bar),
   account views. Presentation only; layout states are data attributes.
   ====================================================================== */

.shell {
  --sb-w: 268px;
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sb-w) minmax(0, 1fr);
  min-height: 100vh;
}

.shell[data-sidebar="collapsed"] {
  --sb-w: 68px;
}

.shell__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.shell__main > .footer {
  margin-top: auto;
}

/* ---- Sidebar ---- */

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--appbar-bg);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index: 30;
  overflow: hidden;
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 12px 14px;
  min-height: 58px;
  border-bottom: 1px solid var(--border);
}

.nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 8px 12px;
}

.sb-group + .sb-group {
  margin-top: 10px;
}

.sb-group__label {
  margin: 8px 10px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.sb-list,
.sb-sub {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sb-row {
  display: flex;
  align-items: stretch;
  gap: 2px;
}

.sb-link {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.sb-link__icon {
  flex: none;
  width: 20px;
  text-align: center;
  font-size: 1rem;
  line-height: 1;
}

.sb-link__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-link:hover,
.sb-sublink:hover,
.sb-toggle:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.sb-item.is-active > .sb-row > .sb-link,
.sb-link[aria-current="page"] {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.sb-toggle {
  flex: none;
  width: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font: inherit;
}

.sb-toggle__chevron {
  display: inline-block;
  font-size: 1.1rem;
  line-height: 1;
  transition: transform 0.15s ease;
}

.sb-item.is-open > .sb-row > .sb-toggle .sb-toggle__chevron {
  transform: rotate(90deg);
}

.sb-sub {
  margin: 2px 0 6px 20px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.sb-sub[hidden] {
  display: none;
}

.sb-sublink {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.83rem;
}

.sb-sublink[aria-current="page"] {
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-weight: 700;
}

.sidebar__status {
  display: grid;
  gap: 4px;
  justify-items: start;
  padding: 10px 14px 0;
  border-top: 1px solid var(--border);
}

.sidebar__status .appbar__panel-label {
  display: block;
}

.sidebar__status + .sidebar__foot {
  border-top: 0;
}

.sidebar__foot {
  margin: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--accent);
}

.icon-btn__bars {
  width: 16px;
  height: 12px;
  background: linear-gradient(var(--text) 0 2px, transparent 2px 5px, var(--text) 5px 7px, transparent 7px 10px, var(--text) 10px 12px);
}

.icon-btn__glyph::before {
  content: "«";
  font-size: 1.2rem;
  line-height: 1;
}

.sidebar__collapse[aria-pressed="true"] .icon-btn__glyph::before {
  content: "»";
}

.topbar__menu,
.sidebar-backdrop {
  display: none;
}

/* Desktop icon-only state */
@media (min-width: 860px) {
  .shell[data-sidebar="collapsed"] .brand__text,
  .shell[data-sidebar="collapsed"] .sb-link__label,
  .shell[data-sidebar="collapsed"] .sb-toggle,
  .shell[data-sidebar="collapsed"] .sb-sub,
  .shell[data-sidebar="collapsed"] .sidebar__foot,
  .shell[data-sidebar="collapsed"] .sidebar__status {
    display: none;
  }
  .shell[data-sidebar="collapsed"] .sidebar__head {
    flex-direction: column;
    padding: 10px 0;
    gap: 10px;
  }
  .shell[data-sidebar="collapsed"] .sb-group__label {
    height: 1px;
    margin: 8px 12px;
    padding: 0;
    overflow: hidden;
    background: var(--border);
    color: transparent;
  }
  .shell[data-sidebar="collapsed"] .sb-link {
    justify-content: center;
    padding: 10px 0;
  }
}

/* Desktop with a real hover pointer: automatic sidebar (data-sidebar-mode="auto", set by shell.mjs).
   The icon rail always keeps its own 68px column, so the content never starts under it. Opening
   (viewport left edge, or keyboard focus) widens the sidebar over the content without changing the
   grid track, so nothing reflows. Closed, the sidebar has no layer outside its 68px column. */
@media (min-width: 860px) and (hover: hover) and (pointer: fine) {
  .shell[data-sidebar-mode="auto"][data-sidebar] {
    --sb-w: 68px;
  }
  .shell[data-sidebar-mode="auto"] .sidebar {
    width: 68px;
    justify-self: start;
    transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1), margin-right 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  }
  @media (prefers-reduced-motion: reduce) {
    .shell[data-sidebar-mode="auto"] .sidebar {
      transition: none;
    }
  }
  .shell[data-sidebar-mode="auto"] .sidebar__collapse {
    display: none;
  }
  .shell[data-sidebar-mode="auto"][data-sidebar="expanded"] .sidebar {
    width: 268px;
    margin-right: -200px;
    background: var(--surface-solid);
    box-shadow: var(--shadow);
  }
}

/* ---- Top bar ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--appbar-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.topbar__row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px var(--gutter);
  min-height: 58px;
}

.topbar__where {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-size: 0.86rem;
}

.topbar__app {
  font-family: var(--font-mono);
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.topbar__sep,
.topbar__page {
  color: var(--text-muted);
}

.topbar__page {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__search {
  flex: 1 1 200px;
  min-width: 160px;
  max-width: 340px;
  margin-left: auto;
}

/* The theme button is an icon in the bar; its state stays in the accessible name and tooltip. */
.topbar .theme-toggle #theme-toggle-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

.tb-btn {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.tb-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.search {
  position: relative;
}

.search__input {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
}

.search__results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.search__results[hidden] {
  display: none;
}

.search__hit {
  width: 100%;
  display: grid;
  gap: 1px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.search__hit:hover,
.search__hit:focus-visible {
  background: var(--accent-soft);
}

.search__hit-label {
  font-weight: 600;
  font-size: 0.88rem;
}

.search__hit-path,
.search__empty {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.search__empty {
  padding: 8px 10px;
}

.acct {
  position: relative;
}

.acct-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px 3px 4px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.acct-button:hover {
  border-color: var(--accent);
}

.acct-button__avatar {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
}

.acct-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  width: min(280px, 90vw);
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.acct-menu[hidden] {
  display: none;
}

.acct-menu__head {
  display: grid;
  gap: 2px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.acct-menu__item {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.acct-menu__item:hover,
.acct-menu__item:focus-visible {
  background: var(--accent-soft);
}

/* ---- Section bar ---- */

.subnav {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 12px var(--gutter) 0;
}

.subnav:empty {
  display: none;
}

.subnav__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 0;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.crumbs__item + .crumbs__item::before {
  content: "›";
  margin: 0 8px;
  color: var(--text-faint);
}

.crumbs__item[aria-current="page"] {
  color: var(--text);
  font-weight: 700;
}

.backlink {
  font-size: 0.82rem;
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 600;
}

.backlink:hover {
  text-decoration: underline;
}

.sectionbar__list {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0 0 2px;
  list-style: none;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}

.sectionbar__link {
  display: block;
  padding: 7px 12px;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.sectionbar__link:hover {
  color: var(--text);
}

.sectionbar__link[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ---- Content ---- */

.view {
  container-type: inline-size;
  container-name: view;
}

.section-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--gap);
}

.section-tile {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.section-tile:hover {
  border-color: var(--accent);
}

.section-tile__title {
  font-weight: 700;
}

.section-tile__lede {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.empty-state {
  max-width: 640px;
}

.empty-state__actions,
.auth-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.auth-card {
  display: grid;
  justify-items: start;
  gap: 10px;
  max-width: 560px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card__mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 1.3rem;
}

.auth-card__title {
  margin: 0;
  font-size: 1.15rem;
}

.auth-card__text {
  margin: 0;
}

.help-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.help-list__item p {
  margin: 4px 0 8px;
}

/* Layout follows the content column, not the window, so the sidebar's width is accounted for. */
@container view (max-width: 1180px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .flow-grid,
  .support-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@container view (max-width: 980px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: span 2; }
  .product-grid,
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .matrix-layout { grid-template-columns: 1fr; }
}

@container view (max-width: 720px) {
  .grid,
  .flow-grid,
  .support-grid,
  .product-grid,
  .settings-grid { grid-template-columns: 1fr; }
  .span-2,
  .span-3 { grid-column: span 1; }
}

/* ---- Tablet and phone: off-canvas sidebar ---- */

@media (max-width: 859px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    height: auto;
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform 0.18s ease, visibility 0s linear 0.18s;
    box-shadow: var(--shadow);
    background: var(--surface-solid);
  }
  .shell[data-mobile-nav="open"] .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 0.18s ease;
  }
  .sidebar__collapse {
    display: none;
  }
  .topbar__menu {
    display: inline-grid;
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    border: 0;
    background: rgba(0, 0, 0, 0.45);
  }
  .sidebar-backdrop[hidden] {
    display: none;
  }
  .topbar__search {
    order: 5;
    flex-basis: 100%;
    max-width: none;
    margin-left: 0;
  }
  .topbar__tools {
    margin-left: auto;
  }
  .acct-button__name,
  .topbar__app,
  .topbar__sep {
    display: none;
  }
}

@media (max-width: 479px) {
  .tb-btn {
    padding: 6px 8px;
  }
  #theme-toggle-label {
    display: none;
  }
}

@media (pointer: coarse) {
  .sb-link,
  .sb-sublink,
  .sb-toggle,
  .sectionbar__link,
  .tb-btn,
  .acct-menu__item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

@media (forced-colors: active) {
  .sb-item.is-active > .sb-row > .sb-link,
  .sb-link[aria-current="page"],
  .sb-sublink[aria-current="page"],
  .sectionbar__link[aria-current="page"] {
    border: 1px solid Highlight;
  }
}

.auth-card .btn:disabled {
  opacity: 0.55;
  filter: grayscale(0.5);
}

/* Account sign-in forms (docs/22 §30) */
.auth-form {
  display: grid;
  gap: 12px;
  width: min(100%, 360px);
}

.field {
  display: grid;
  gap: 4px;
}

.field__label {
  font-size: 0.82rem;
  font-weight: 650;
}

.field__input {
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.field__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field__error {
  margin: 0;
  color: var(--severe, #b3261e);
  font-size: 0.85rem;
  font-weight: 650;
}

.qr-box {
  display: inline-block;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

.idle-warning[hidden] {
  display: none;
}

.idle-warning {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

/* ======================================================================
   Guided flows (registration, plan choice, payment activation) — generic building blocks.
   Every state also carries text and a shape, never colour alone.
   ====================================================================== */

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.82rem;
  counter-increment: step;
}

.steps__item::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
}

.steps__item--done { color: var(--st-verified-fg); border-color: var(--st-verified-fg); }
.steps__item--done::before { content: "✓"; background: var(--st-verified-bg); color: var(--st-verified-fg); }
.steps__item--current { color: var(--text); border-color: var(--accent); font-weight: 700; box-shadow: 0 0 0 2px var(--accent-soft); }
.steps__item--current::before { background: var(--accent); color: var(--accent-ink); }
.steps__item--optional { border-style: dashed; }

.notice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-items: start;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-left-width: 5px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  max-width: 760px;
}

.notice__mark { font-weight: 800; line-height: 1.4; }
.notice__title { margin: 0; font-weight: 700; }
.notice__text { margin: 0; grid-column: 2; }
.notice__actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.notice--ok { border-color: var(--st-verified-fg); background: var(--st-verified-bg); color: var(--st-verified-fg); }
.notice--warn { border-color: var(--st-partial-fg); background: var(--st-partial-bg); color: var(--st-partial-fg); }
.notice--error { border-color: var(--st-severe-fg); background: var(--st-severe-bg); color: var(--st-severe-fg); }
.notice--info { border-color: var(--st-neutral-fg); background: var(--st-neutral-bg); color: var(--st-neutral-fg); }
.notice--progress { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.notice--progress .notice__mark {
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border: 3px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  font-size: 0;
  animation: notice-spin 0.9s linear infinite;
}
@keyframes notice-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .notice--progress .notice__mark { animation: none; border-top-color: var(--accent); } }
:root[data-motion="reduced"] .notice--progress .notice__mark { animation: none; border-top-color: var(--accent); }

.field__hint { margin: 2px 0 0; font-size: 0.8rem; color: var(--text-muted); }
.field__hint--ok { color: var(--st-verified-fg); }
.field__hint--bad { color: var(--st-severe-fg); }
.field--check { display: flex; align-items: center; gap: 8px; }
.field--check label { font-size: 0.88rem; }

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.plan-card {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.plan-card--selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.plan-card__title { margin: 0; font-size: 1.1rem; }
.plan-card__sub { margin: 0; color: var(--text-muted); font-size: 0.88rem; }
.plan-card__list { margin: 0; padding-left: 1.1rem; }
.plan-card__list li { margin: 3px 0; }

@media (max-width: 759px) {
  .plan-grid { grid-template-columns: 1fr; }
  .steps__item { font-size: 0.78rem; }
  .notice { max-width: none; }
}
.field--plain { border: 0; padding: 0; margin: 0; min-width: 0; }

/* ======================================================================
   Customer edition (https): account and subscription flows are single-column tasks. On a wide screen the column is centred in the
   content area instead of hugging the left edge with a large empty area on the right. The Dashboard grid is not touched. (docs/22 §47)
   ====================================================================== */
body[data-tier="web"] .view[data-view="account"] {
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
}
body[data-tier="web"] .view[data-view="account"] .view-head { margin-bottom: 14px; }
body[data-tier="web"] .view[data-view="account"] .steps { justify-content: flex-start; }
body[data-tier="web"] .view[data-view="account"] .auth-card { width: 100%; max-width: 620px; }
body[data-tier="web"] .view[data-view="account"] .auth-form { width: 100%; max-width: 480px; }
body[data-tier="web"] .view[data-view="account"] .notice { width: 100%; }
body[data-tier="web"] .view[data-view="account"] .field__input { width: 100%; box-sizing: border-box; }
body[data-tier="web"] .view[data-view="connector"] { width: 100%; max-width: 1280px; margin-inline: auto; }
@media (max-width: 759px) {
  body[data-tier="web"] .view[data-view="account"] .auth-card { padding: 16px; }
}
.link-row { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 2px 0 0; font-size: 0.88rem; }
.link-button { padding: 0; border: 0; background: none; color: var(--accent-strong, var(--accent)); font: inherit; text-decoration: underline; cursor: pointer; }
.link-button:disabled { opacity: 0.55; cursor: default; text-decoration: none; }
.price-slot { margin: 0; font-weight: 700; }
.price-slot--pending { font-weight: 400; color: var(--text-muted); font-size: 0.88rem; }
