:root {
  --font-sans: "Avenir Next", "Segoe UI Variable", "Helvetica Neue", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius-xs: 7px;
  --radius-sm: 11px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

/* ---- Dusk (dark): kept close to the original, well-contrasting aesthetic ---- */
html[data-theme="dusk"] {
  --shadow: 0 18px 54px oklch(0.12 0.02 255 / .22);
  --bg: oklch(0.27 0.026 255);
  --rail: oklch(0.235 0.027 255);
  --surface: oklch(0.325 0.025 255);
  --surface-2: oklch(0.37 0.026 255);
  --surface-3: oklch(0.405 0.025 255);
  --text: oklch(0.955 0.012 245);
  --muted: oklch(0.74 0.025 250);
  --faint: oklch(0.74 0.025 250);
  --line: oklch(0.92 0.01 250 / .12);
  --line-strong: oklch(0.92 0.01 250 / .22);
  --glass: oklch(0.31 0.025 255 / .88);
  --ink-on-accent: oklch(0.18 0.02 255);

  /* fill / background tones (used for bars, chart segments, buttons) */
  --accent: oklch(0.78 0.14 166);
  --blue: oklch(0.79 0.13 252);
  --coral: oklch(0.76 0.14 42);
  --amber: oklch(0.82 0.13 84);
  --red: oklch(0.78 0.17 20);
  --violet: oklch(0.78 0.13 305);
  --success: oklch(0.76 0.14 155);

  /* text / icon / indicator tones -- verified >= 4.5:1 against surface/surface-2 */
  --accent-ink: var(--accent);
  --blue-ink: var(--blue);
  --coral-ink: var(--coral);
  --amber-ink: var(--amber);
  --red-ink: var(--red);
  --violet-ink: var(--violet);
  --success-ink: var(--success);
}

/* ---- Mist (light): same structure, re-tuned tones so text/icons clear WCAG AA ---- */
html[data-theme="mist"] {
  --shadow: 0 18px 54px oklch(0.34 0.04 255 / .12);
  --bg: oklch(0.94 0.012 244);
  --rail: oklch(0.985 0.006 246);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.965 0.008 245);
  --surface-3: oklch(0.925 0.012 246);
  --text: oklch(0.22 0.03 254);
  --muted: oklch(0.42 0.035 252);
  --faint: oklch(0.48 0.03 250);
  --line: oklch(0.31 0.035 255 / .16);
  --line-strong: oklch(0.31 0.035 255 / .28);
  --glass: oklch(0.99 0.004 244 / .9);
  --ink-on-accent: oklch(0.14 0.02 255);

  /* fill / background tones -- unchanged bright hues (fine for large blocks / dark-text buttons) */
  --accent: oklch(0.72 0.14 166);
  --blue: oklch(0.62 0.15 252);
  --coral: oklch(0.66 0.16 42);
  --amber: oklch(0.68 0.15 84);
  --red: oklch(0.62 0.19 20);
  --violet: oklch(0.6 0.15 305);
  --success: oklch(0.62 0.15 155);

  /* text / icon / indicator tones -- darkened variants, each checked >= 4.5:1 on surface/surface-2 */
  --accent-ink: oklch(0.4 0.13 166);
  --blue-ink: oklch(0.42 0.15 252);
  --coral-ink: oklch(0.46 0.15 42);
  --amber-ink: oklch(0.42 0.13 84);
  --red-ink: oklch(0.48 0.18 20);
  --violet-ink: oklch(0.44 0.15 305);
  --success-ink: oklch(0.4 0.13 155);
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 82% -10%, color-mix(in oklch, var(--blue) 15%, transparent), transparent 32rem),
    radial-gradient(circle at 58% 110%, color-mix(in oklch, var(--accent) 10%, transparent), transparent 38rem),
    var(--bg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; z-index: 999; left: 16px; top: -80px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--ink-on-accent); background: var(--accent);
  font-weight: 750; text-decoration: none;
}
.skip-link:focus { top: 16px; }
:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; }

.app-shell { display: grid; grid-template-columns: 246px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30;
  width: 246px;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in oklch, var(--blue) 6%, transparent), transparent 30%),
    var(--rail);
  padding: 24px 18px 18px;
}
.brand { display: flex; align-items: center; gap: 12px; min-height: 46px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 13px;
  color: var(--ink-on-accent);
  background: linear-gradient(145deg, var(--accent), var(--blue));
  box-shadow: 0 12px 28px color-mix(in oklch, var(--accent) 45%, transparent);
}
.brand-mark svg { width: 23px; height: 23px; }
.brand-copy { display: grid; line-height: 1.05; letter-spacing: -.025em; }
.brand-copy b { color: var(--muted); font-size: 12px; font-weight: 620; }
.brand-copy strong { font-size: 18px; font-weight: 780; }
.source-state {
  display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 11px;
  margin: 26px 0 20px; padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--surface) 78%, transparent);
}
.source-state.stale { border-color: color-mix(in oklch, var(--amber) 55%, var(--line)); }
.pulse {
  width: 8px; height: 8px; margin-top: 4px; border-radius: 50%;
  background: var(--accent-ink);
  box-shadow: 0 0 0 5px color-mix(in oklch, var(--accent-ink) 18%, transparent);
}
.source-state.stale .pulse { background: var(--amber-ink); box-shadow: 0 0 0 5px color-mix(in oklch, var(--amber-ink) 18%, transparent); }
.source-state b { display: block; font-size: 11px; }
.source-state span:not(.pulse) { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.nav-list { display: grid; gap: 4px; }
.nav-item {
  width: 100%; min-height: 44px;
  display: grid; grid-template-columns: 30px 1fr; align-items: center;
  border: 0; border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--muted); background: transparent;
  text-align: left; cursor: pointer;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}
.nav-item:hover { color: var(--text); background: color-mix(in oklch, var(--surface) 74%, transparent); transform: translateX(2px); }
.nav-item.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--accent-ink) 30%, transparent); }
.nav-index { color: var(--faint); font-family: var(--font-mono); font-size: 9px; }
.nav-item.active .nav-index { color: var(--accent-ink); }
.nav-item span:last-child { font-size: 12px; font-weight: 660; }
.sidebar-foot { margin-top: auto; color: var(--muted); font-size: 9px; line-height: 1.45; }
.privacy-note { margin-bottom: 15px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.privacy-note > span { color: var(--accent-ink); font-family: var(--font-mono); font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.privacy-note p { margin: 7px 0 0; }

.main-column { grid-column: 2; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  min-height: 82px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 16px clamp(22px, 4vw, 52px);
  border-bottom: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(120%);
}
.kicker { margin: 0 0 4px; color: var(--muted); font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.button, .window-select {
  appearance: none; -webkit-appearance: none;
  min-height: 39px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--text); background: var(--surface);
  font-size: 10px; font-weight: 700; text-decoration: none;
}
.button { cursor: pointer; transition: transform .18s ease, border-color .18s ease, background .18s ease; }
.button:hover { transform: translateY(-1px); border-color: color-mix(in oklch, var(--accent-ink) 55%, transparent); }
.button:disabled {
  cursor: not-allowed; transform: none;
  opacity: .6;
  background-color: var(--surface-2) !important;
  color: var(--muted) !important;
  border-color: var(--line) !important;
}
.button.primary { color: var(--ink-on-accent); border-color: transparent; background: var(--accent); }
.button.ghost { background: color-mix(in oklch, var(--surface) 70%, transparent); }
.window-select { gap: 6px; padding-right: 7px; color: var(--muted); }
.window-select span { font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.window-select select { border: 0; color: var(--text); background: transparent; font-size: 10px; font-weight: 700; cursor: pointer; }
.theme-swatch { width: 11px; height: 11px; border-radius: 50%; background: linear-gradient(135deg, var(--blue-ink), var(--accent-ink)); }

main { width: min(100%, 1600px); margin: 0 auto; padding: 26px clamp(22px, 4vw, 52px) 72px; }
.status-banner {
  display: flex; align-items: center; gap: 10px;
  min-height: 42px; margin-bottom: 16px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--muted); background: var(--surface);
  font-size: 11px;
}
.status-banner.ready { display: none; }
.status-banner.error { color: var(--red-ink); border-color: color-mix(in oklch, var(--red) 35%, transparent); background: color-mix(in oklch, var(--red) 7%, var(--surface)); }
.status-banner.error .status-retry { margin-left: auto; }
.status-spinner {
  width: 12px; height: 12px; border: 2px solid var(--line-strong); border-top-color: var(--accent-ink);
  border-radius: 50%; animation: spin .8s linear infinite; flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.view { display: none; animation: view-in .24s ease both; }
.view.active { display: block; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }

.hero-card {
  position: relative; overflow: hidden;
  min-height: 286px;
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(260px, .75fr);
  gap: 28px; align-items: end;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(28px, 5vw, 60px);
  background:
    linear-gradient(110deg, color-mix(in oklch, var(--accent) 10%, transparent), transparent 40%),
    linear-gradient(155deg, var(--surface), color-mix(in oklch, var(--surface-2) 76%, var(--blue)));
  box-shadow: var(--shadow);
}
.hero-card::after {
  content: ""; position: absolute; width: 420px; height: 420px; right: -170px; top: -210px;
  border-radius: 50%; border: 1px solid color-mix(in oklch, var(--blue) 22%, transparent);
  box-shadow: inset 0 0 0 56px color-mix(in oklch, var(--blue) 2.5%, transparent), inset 0 0 0 112px color-mix(in oklch, var(--accent) 2.5%, transparent);
}
.eyebrow, .section-label {
  margin: 0;
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em;
}
.hero-copy, .hero-value { position: relative; z-index: 1; }
.hero-copy h2, .audit-hero h2, .factory-hero h2, .provider-hero h2 {
  margin: 13px 0 15px;
  max-width: 760px;
  font-family: var(--font-display);
  font-size: clamp(38px, 5.5vw, 72px);
  font-weight: 600; line-height: .98; letter-spacing: -.045em;
}
.hero-copy > p:not(.eyebrow) { max-width: 700px; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.65; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 24px; color: var(--faint); font-family: var(--font-mono); font-size: 9px; }
.hero-value { align-self: end; text-align: right; }
.hero-value span, .hero-value small { display: block; color: var(--muted); font-size: 10px; }
.hero-value strong { display: block; margin: 10px 0 8px; font-size: clamp(52px, 7vw, 90px); line-height: .85; letter-spacing: -.07em; }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.metric-card {
  min-height: 130px;
  display: flex; flex-direction: column; justify-content: space-between;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 17px;
  background: var(--surface);
}
.metric-card .metric-top { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.metric-card strong { display: block; margin-top: 14px; font-size: clamp(23px, 2.8vw, 34px); letter-spacing: -.05em; }
.metric-card small { display: block; margin-top: 6px; color: var(--faint); font-size: 9px; line-height: 1.4; }
.metric-card.featured { background: linear-gradient(145deg, color-mix(in oklch, var(--accent) 14%, transparent), var(--surface)); border-color: color-mix(in oklch, var(--accent) 28%, transparent); }

.dashboard-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.panel {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 23px;
  background: var(--surface);
  box-shadow: 0 12px 30px color-mix(in oklch, var(--text) 6%, transparent);
}
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.panel-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 21px; }
.panel-head.wrap { flex-wrap: wrap; align-items: end; }
.panel-head h2, .panel-head h3 { margin: 6px 0 0; font-size: 19px; letter-spacing: -.025em; }
.panel-copy { margin: 8px 0 0; max-width: 760px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.evidence-tag, .maturity-level {
  flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 27px;
  border: 1px solid var(--line); border-radius: 999px; padding: 0 9px;
  color: var(--muted); background: var(--surface-2);
  font-family: var(--font-mono); font-size: 8px; text-transform: uppercase; letter-spacing: .07em;
}
.maturity-level { color: var(--accent-ink); font-size: 11px; font-weight: 800; }

/* ---- chart primitives (SVG/canvas-first, no inline style attributes ever) ---- */
.chart-frame { width: 100%; height: auto; overflow: visible; }
.chart-frame text { font-family: var(--font-mono); fill: var(--muted); }
.chart-frame .value-label { fill: var(--text); font-weight: 700; }
.chart-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 16px; align-items: center; }
.chart-legend { display: grid; gap: 8px; margin-top: 14px; }
.legend-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; min-width: 0; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.legend-row span:nth-child(2) { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.legend-row b { font-family: var(--font-mono); font-size: 9px; }
.chart-empty { padding: 30px 10px; text-align: center; color: var(--faint); font-size: 11px; }
.gauge-wrap { display: flex; align-items: center; gap: 18px; }
.gauge-copy strong { display: block; font-size: 28px; letter-spacing: -.04em; }
.gauge-copy span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.4; max-width: 220px; }
.two-col-chart { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(0,1fr); gap: 20px; align-items: center; }
.two-col-chart.spaced { margin-top: 20px; }

/* native progress/meter used for ratio bars: attribute-driven, CSP-safe, themeable */
progress.ratio-bar { appearance: none; -webkit-appearance: none; width: 100%; height: 8px; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface-3); vertical-align: middle; }
progress.ratio-bar::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
progress.ratio-bar::-webkit-progress-value { background: linear-gradient(90deg, var(--blue), var(--accent)); border-radius: 999px; }
progress.ratio-bar::-moz-progress-bar { background: linear-gradient(90deg, var(--blue), var(--accent)); border-radius: 999px; }
progress.ratio-bar.warn::-webkit-progress-value { background: linear-gradient(90deg, var(--amber), var(--coral)); }
progress.ratio-bar.warn::-moz-progress-bar { background: linear-gradient(90deg, var(--amber), var(--coral)); }
td progress.ratio-bar { width: 88px; }
.microbar-cell { display: flex; align-items: center; gap: 8px; }
.microbar-cell .mono { min-width: 42px; text-align: right; }

.domain-list { display: grid; gap: 9px; margin-top: 18px; }
.domain-row { display: grid; grid-template-columns: auto 1fr; gap: 9px; align-items: start; }
.domain-dot { width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: var(--amber-ink); }
.domain-dot.strong { background: var(--accent-ink); }
.domain-row b { display: block; font-size: 10px; }
.domain-row span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.4; }

.split-chart { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.split-block { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 18px; background: var(--surface-2); }
.split-block span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .07em; }
.split-block strong { display: block; margin: 12px 0 7px; font-size: 29px; letter-spacing: -.05em; }
.split-block small { color: var(--faint); font-family: var(--font-mono); font-size: 9px; }
.attention-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.attention-item { border-top: 1px solid var(--line); padding-top: 13px; }
.attention-item strong { display: block; font-size: 24px; letter-spacing: -.04em; }
.attention-item span { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.35; }

.session-list { display: grid; gap: 8px; }
.session-row {
  display: grid; grid-template-columns: minmax(180px, 1.8fr) repeat(4, minmax(80px, .7fr));
  gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 15px; background: var(--surface-2);
}
.session-title b { display: block; font-size: 11px; }
.session-title span { display: block; margin-top: 4px; color: var(--faint); font-family: var(--font-mono); font-size: 8px; }
.session-stat { text-align: right; }
.session-stat b { display: block; font-family: var(--font-mono); font-size: 11px; }
.session-stat span { display: block; margin-top: 3px; color: var(--faint); font-size: 8px; text-transform: uppercase; letter-spacing: .05em; }

.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; min-width: 930px; border-collapse: collapse; }
th { padding: 11px 12px; border-bottom: 1px solid var(--line-strong); color: var(--faint); font-size: 8px; text-align: left; text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; }
td { padding: 14px 12px; border-bottom: 1px solid var(--line); font-size: 10px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in oklch, var(--surface-2) 72%, transparent); }
.model-name, .tool-name { display: flex; align-items: center; gap: 9px; min-width: 180px; font-weight: 720; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.status-cell { display: inline-flex; gap: 6px; align-items: center; }
.status-cell i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-ink); }
.status-cell.fail i { background: var(--red-ink); }
.search-box input {
  min-width: 230px; min-height: 40px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 0 12px; color: var(--text); background: var(--surface-2);
}

.fleet-summary, .tool-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.summary-block { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 18px; background: var(--surface); }
.summary-block span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.summary-block strong { display: block; margin-top: 13px; font-size: 30px; letter-spacing: -.05em; }
.summary-block small { display: block; margin-top: 5px; color: var(--faint); font-size: 9px; }
.agent-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.agent-card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; background: var(--surface); }
.agent-card header { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.agent-card h3 { margin: 0; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.agent-card .agent-id { margin-top: 5px; color: var(--faint); font-family: var(--font-mono); font-size: 8px; overflow-wrap: anywhere; }
.agent-card .completion { color: var(--accent-ink); font-family: var(--font-mono); font-size: 9px; white-space: nowrap; }
.agent-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 20px; }
.agent-metrics div { border-top: 1px solid var(--line); padding-top: 11px; }
.agent-metrics b { display: block; font-size: 14px; }
.agent-metrics span { display: block; margin-top: 3px; color: var(--faint); font-size: 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 15px; }
.chip { border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 5px 7px; color: var(--muted); background: var(--surface-2); font-family: var(--font-mono); font-size: 8px; }

.audit-hero, .factory-hero, .provider-hero {
  display: flex; justify-content: space-between; gap: 30px; align-items: end;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  margin-bottom: 14px; padding: clamp(26px, 4vw, 46px);
  background: linear-gradient(140deg, var(--surface), color-mix(in oklch, var(--surface-2) 83%, var(--coral)));
}
.audit-hero h2, .factory-hero h2, .provider-hero h2 { font-size: clamp(34px, 4vw, 58px); }
.audit-hero > div > p:last-child, .factory-hero > p:last-child, .provider-hero > div > p:last-child { max-width: 760px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.audit-badge { flex: 0 0 auto; width: 170px; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 17px; background: var(--surface-2); text-align: right; }
.audit-badge span { display: block; color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .08em; }
.audit-badge b { display: block; margin-top: 10px; color: var(--accent-ink); font-size: 40px; letter-spacing: -.06em; }
.audit-badge strong { display: block; margin-top: 4px; font-size: 10px; }
.audit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.finding-card { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 20px; background: var(--surface); }
.finding-card header { display: flex; justify-content: space-between; gap: 12px; }
.finding-card h3 { margin: 0; font-size: 14px; }
.finding-severity { flex: 0 0 auto; border-radius: 999px; padding: 5px 8px; font-family: var(--font-mono); font-size: 8px; text-transform: uppercase; letter-spacing: .06em; background: color-mix(in oklch, var(--accent) 16%, var(--surface)); color: var(--accent-ink); }
.finding-severity.watch { color: var(--amber-ink); background: color-mix(in oklch, var(--amber) 18%, var(--surface)); }
.finding-severity.info { color: var(--blue-ink); background: color-mix(in oklch, var(--blue) 16%, var(--surface)); }
.finding-card p { margin: 13px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.finding-action { margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--text) !important; }
.lineage-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.lineage-block { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 15px; background: var(--surface-2); }
.lineage-block strong { display: block; font-size: 26px; letter-spacing: -.04em; }
.lineage-block span { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }
.audit-note { display: grid; grid-template-columns: 120px 1fr; gap: 16px; margin-top: 16px; padding: 16px; border: 1px solid color-mix(in oklch, var(--coral) 30%, transparent); border-radius: var(--radius-sm); background: var(--surface-2); }
.audit-note strong { font-size: 11px; }
.audit-note p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.6; }

.factory-hero { display: block; background: linear-gradient(145deg, var(--surface), color-mix(in oklch, var(--surface-2) 84%, var(--blue))); }
.control-plane { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.control-node { position: relative; min-height: 106px; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px; background: var(--surface); }
.control-node::after { content: ""; position: absolute; right: -9px; top: 50%; width: 8px; height: 1px; background: var(--line-strong); }
.control-node:last-child::after { display: none; }
.control-node span { color: var(--accent-ink); font-family: var(--font-mono); font-size: 8px; }
.control-node b { display: block; margin-top: 16px; font-size: 11px; line-height: 1.4; }
.factory-flow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.team-cell { min-height: 200px; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 19px; background: var(--surface); }
.team-cell .team-number { color: var(--faint); font-family: var(--font-mono); font-size: 8px; }
.team-cell h3 { margin: 14px 0 8px; font-family: var(--font-display); font-size: 24px; font-weight: 600; }
.team-cell p { min-height: 42px; margin: 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.team-cell .team-outcome { display: block; margin-top: 17px; padding-top: 13px; border-top: 1px solid var(--line); color: var(--accent-ink); font-size: 9px; }
.gate-track { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.gate { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; background: var(--surface-2); }
.gate b { display: block; color: var(--coral-ink); font-family: var(--font-mono); font-size: 10px; }
.gate span { display: block; margin-top: 7px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.attention-hook { display: grid; grid-template-columns: 1fr 1.35fr; gap: 24px; margin-top: 14px; background: linear-gradient(135deg, var(--surface), color-mix(in oklch, var(--surface-2) 88%, var(--accent))); }
.attention-hook h2 { margin: 7px 0 9px; font-size: 25px; }
.attention-hook p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.hook-detail { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.hook-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; background: var(--surface-2); }
.hook-item b { display: block; font-size: 10px; }
.hook-item span { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; line-height: 1.4; }

.provider-hero { align-items: center; background: linear-gradient(140deg, var(--surface), color-mix(in oklch, var(--surface-2) 83%, var(--violet))); }
.provider-legend { flex: 0 0 auto; display: grid; grid-template-columns: repeat(2, auto); gap: 9px 14px; color: var(--muted); font-size: 9px; }
.provider-legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.dot.live { background: var(--accent-ink); }
.dot.ready { background: var(--blue-ink); }
.dot.config { background: var(--amber-ink); }
.dot.import { background: var(--violet-ink); }
.provider-summary { display: flex; align-items: center; gap: 20px; margin-bottom: 14px; }
.provider-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.provider-card { display: flex; flex-direction: column; min-height: 250px; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; background: var(--surface); }
.provider-card header { display: flex; justify-content: space-between; gap: 12px; }
.provider-card h3 { margin: 0; font-size: 14px; }
.provider-status { border-radius: 999px; padding: 5px 8px; color: var(--muted); background: var(--surface-2); font-family: var(--font-mono); font-size: 8px; text-transform: uppercase; }
.provider-status.live { color: var(--accent-ink); }
.provider-status.ready { color: var(--blue-ink); }
.provider-status.not-configured { color: var(--amber-ink); }
.provider-status.import-only { color: var(--violet-ink); }
.provider-note { margin: 11px 0 15px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.capability-list { display: grid; gap: 7px; }
.capability { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 9px; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--surface-2); text-decoration: none; }
.capability span { font-size: 9px; }
.capability b { color: var(--faint); font-family: var(--font-mono); font-size: 7px; text-transform: uppercase; }
.provider-actions { display: flex; gap: 7px; margin-top: auto; padding-top: 16px; }
.provider-actions .button { min-height: 34px; font-size: 9px; }
.provider-actions button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.provider-sync-result { margin-top: 10px; }
.provider-sync-result .audit-note { grid-template-columns: 1fr; padding: 10px; margin-top: 0; }
.provider-sync-result .audit-note.fail { border-color: color-mix(in oklch, var(--red) 40%, transparent); }

.operation-list { display: grid; gap: 9px; }
.operation-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px; background: var(--surface-2); }
.operation-item b { display: block; font-size: 11px; }
.operation-item span, .operation-item p { display: block; margin: 5px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.operation-item .operation-meta { color: var(--accent-ink); font-family: var(--font-mono); font-size: 8px; text-transform: uppercase; }
.mapping-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mapping-form label { display: grid; gap: 5px; color: var(--muted); font-size: 9px; }
.mapping-form input, .mapping-form select { min-height: 38px; border: 1px solid var(--line-strong); border-radius: var(--radius-xs); padding: 0 9px; color: var(--text); background: var(--surface-2); }
.mapping-form .button { grid-column: 1 / -1; }
dialog { width: min(680px, calc(100% - 28px)); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); padding: 0; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
dialog::backdrop { background: oklch(0.12 0.02 255 / .7); backdrop-filter: blur(5px); }
.discovery-dialog { padding: clamp(22px, 4vw, 38px); }
.discovery-dialog h2 { margin: 10px 0; font-family: var(--font-display); font-size: clamp(30px, 5vw, 48px); line-height: 1; }
.discovery-dialog > p:not(.eyebrow) { color: var(--muted); font-size: 11px; line-height: 1.6; }
.discovery-list { display: grid; gap: 8px; margin-top: 20px; }
.discovery-choice { display: grid; grid-template-columns: auto 1fr; gap: 11px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; }
.discovery-choice input { margin-top: 2px; accent-color: var(--accent-ink); }
.discovery-choice b { display: block; font-size: 11px; }
.discovery-choice span { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.empty-state { border: 1px dashed var(--line-strong); border-radius: var(--radius-md); padding: 26px; text-align: center; color: var(--muted); }
.empty-state strong, .empty-state span { display: block; }
.empty-state span { margin-top: 6px; font-size: 10px; }

@media (max-width: 1260px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .agent-grid, .provider-grid { grid-template-columns: repeat(2, 1fr); }
  .control-plane, .factory-flow { grid-template-columns: repeat(3, 1fr); }
  .control-node::after { display: none; }
  .gate-track { grid-template-columns: repeat(3, 1fr); }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .two-col-chart { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .app-shell { display: block; }
  .sidebar {
    position: sticky; top: 0; width: 100%; height: auto;
    display: grid; grid-template-columns: auto 1fr auto; align-items: center;
    padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand-copy, .source-state, .sidebar-foot { display: none; }
  .brand-mark { width: 36px; height: 36px; }
  .nav-list { display: flex; justify-content: center; overflow-x: auto; }
  .nav-item { width: auto; min-height: 36px; grid-template-columns: auto; padding: 0 10px; white-space: nowrap; }
  .nav-index { display: none; }
  .main-column { grid-column: auto; }
  .topbar { position: static; }
  .hero-card { grid-template-columns: 1fr; }
  .hero-value { text-align: left; }
  .dashboard-grid { display: block; }
  .panel { margin-bottom: 12px; }
  .fleet-summary, .tool-summary { grid-template-columns: repeat(2, 1fr); }
  .session-row { grid-template-columns: minmax(180px, 1fr) repeat(2, 80px); }
  .session-row .session-stat:nth-last-child(-n+2) { display: none; }
}

@media (max-width: 720px) {
  .sidebar { display: block; overflow-x: auto; }
  .brand { display: none; }
  .nav-list { justify-content: flex-start; }
  .topbar { align-items: flex-start; padding: 14px; }
  .topbar > div:first-child { display: none; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .window-select { order: -1; }
  .button, .window-select { flex: 1 0 auto; }
  main { padding: 14px 10px 50px; }
  .hero-card { min-height: auto; padding: 25px 20px; border-radius: 19px; }
  .hero-copy h2, .audit-hero h2, .factory-hero h2, .provider-hero h2 { font-size: 39px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card { min-height: 118px; }
  .panel { border-radius: 18px; padding: 18px; }
  .chart-legend, .audit-grid, .agent-grid, .provider-grid, .attention-hook { grid-template-columns: 1fr; }
  .two-col-chart { grid-template-columns: 1fr; }
  .audit-hero, .provider-hero { display: block; }
  .audit-badge, .provider-legend { margin-top: 18px; }
  .lineage-grid { grid-template-columns: repeat(2, 1fr); }
  .audit-note { grid-template-columns: 1fr; }
  .mapping-form { grid-template-columns: 1fr; }
  .control-plane, .factory-flow { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .control-node, .team-cell { flex: 0 0 78%; scroll-snap-align: start; }
  .gate-track { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 440px) {
  .metric-grid, .fleet-summary, .tool-summary, .split-chart, .attention-grid, .lineage-grid, .gate-track { grid-template-columns: 1fr; }
  .top-actions { flex-wrap: wrap; }
  .top-actions .button, .top-actions .window-select { flex: 1 1 auto; }
  .hero-value strong { font-size: 56px; }
  .session-row { grid-template-columns: 1fr 75px; }
  .session-row .session-stat:not(:first-of-type) { display: none; }
}

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

@media print {
  html { color-scheme: light; }
  html[data-theme] {
    --bg: #f3f5f8; --rail: #ffffff; --surface: #ffffff; --surface-2: #f4f6f9; --surface-3: #e9edf2;
    --text: #16202b; --muted: #46505c; --faint: #57616c;
    --line: #d7dde4; --line-strong: #c3cbd5; --glass: #ffffff; --ink-on-accent: #10161d;
    --accent-ink: #1c7a54; --blue-ink: #1d5fae; --coral-ink: #a6431c; --amber-ink: #8a6512; --red-ink: #a3271c; --violet-ink: #6a3b9e; --success-ink: #1c7a54;
  }
  .sidebar, .topbar, .status-banner, .provider-actions, .search-box { display: none !important; }
  .app-shell, .main-column { display: block; }
  body { color: #16202b; background: #f3f5f8; }
  main { width: 100%; max-width: none; padding: 0; }
  .view { display: block !important; margin-bottom: 18px; break-before: page; }
  .view:first-of-type { break-before: auto; }
  .hero-card, .panel, .metric-card, .audit-hero, .factory-hero, .provider-hero, .agent-card, .provider-card { box-shadow: none; break-inside: avoid; }
}
