:root {
  color-scheme: dark;
  --bg: #0b0c0e;
  --surface: #131416;
  --surface-2: #1a1b1e;
  --surface-3: #222327;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, 0.14);
  --orange: #d95926;
  --aqua: #199e70;
  --violet: #9085e9;
  --critical: #d03b3b;
  --elevated: #fab219;
  --safe: #0ca30c;
  --critical-soft: rgba(208, 59, 59, 0.14);
  --elevated-soft: rgba(250, 178, 25, 0.13);
  --safe-soft: rgba(12, 163, 12, 0.14);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --nav-w: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
small { color: var(--muted); }
.num, td.num, .mono { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.nav {
  position: sticky; top: 0; height: 100vh; width: var(--nav-w); flex: none;
  display: flex; flex-direction: column; gap: 8px;
  padding: 18px 12px; border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #101114, #0b0c0e);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; color: var(--ink); font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; color: var(--ink); }
.links { display: flex; flex-direction: column; gap: 2px; }
.links a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--ink-2); font-weight: 500;
}
.links a svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.links a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.links a.active { background: var(--accent-soft); color: var(--ink); }
.links a.active svg { color: var(--accent); opacity: 1; }
.links .count { margin-left: auto; font-size: 11px; font-family: var(--mono); color: var(--muted); }
.links a.active .count { color: var(--ink-2); }
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 4px; }
.nav-note { font-size: 12px; color: var(--muted); line-height: 1.45; }

.seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  flex: 1; border: 0; background: transparent; padding: 6px 8px; border-radius: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.seg button small { font-weight: 500; }
.seg button[aria-checked="true"] { background: var(--surface-3); color: var(--ink); box-shadow: 0 0 0 1px var(--border-strong); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 28px; border-bottom: 1px solid var(--border);
  background: rgba(11, 12, 14, 0.82); backdrop-filter: blur(10px);
}
.crumbs { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs b { color: var(--ink); font-weight: 600; }
.jump { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; height: 34px; width: 230px; }
.jump:focus-within { border-color: var(--accent); }
.jump svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.jump input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--ink); font: inherit; }
kbd { font: 11px var(--mono); color: var(--muted); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; }
.icon-btn { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; display: block; }

#view { padding: 24px 28px 64px; outline: none; max-width: 1480px; width: 100%; }
.loading { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 80px 0; justify-content: center; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- page layout ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { color: var(--ink-2); max-width: 760px; margin-top: 6px; }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mt { margin-top: 16px; } .mt-l { margin-top: 28px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; min-width: 0;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head p, .card .sub { color: var(--muted); font-size: 12.5px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 16px 18px 0; }
.note { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.5; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; }
.tile .label { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin-top: 4px; line-height: 1.15; }
.tile .value small { font-size: 14px; font-weight: 500; }
.tile .foot { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tile.feature { background: linear-gradient(135deg, rgba(57,135,229,0.18), rgba(57,135,229,0.04) 60%), var(--surface); border-color: rgba(57,135,229,0.35); }
.tile .bar-mini { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }

/* tier badges: icon + label, never color alone */
.tier { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; padding: 2px 9px 2px 7px; border-radius: 999px; white-space: nowrap; }
.tier::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tier.Critical { color: #ff8d8d; background: var(--critical-soft); }
.tier.Critical::before { background: var(--critical); box-shadow: 0 0 0 3px rgba(208,59,59,0.25); }
.tier.Elevated { color: #ffd27a; background: var(--elevated-soft); }
.tier.Elevated::before { background: var(--elevated); border-radius: 2px; transform: rotate(45deg); width: 7px; height: 7px; }
.tier.Safe { color: #7fd97f; background: var(--safe-soft); }
.tier.Safe::before { background: var(--safe); border-radius: 2px; }
.tier.lg { font-size: 15px; padding: 5px 13px 5px 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.chip.review { background: rgba(144,133,233,0.16); color: #c4bdff; }
.chip.clear { background: var(--safe-soft); color: #7fd97f; }
.chip.queue { background: var(--surface-3); }
.chip.accent { background: var(--accent-soft); color: #a7cbf5; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4a94ea; }
.btn.act { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn.watch { background: #3a2f12; border-color: var(--elevated); color: #ffd27a; }
.btn.clear { background: #0f2a10; border-color: var(--safe); color: #8fe38f; }
.btn.ghost { background: transparent; }
.btn svg { width: 16px; height: 16px; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.input, select.input { height: 34px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; color: var(--ink); padding: 0 10px; font: inherit; outline: none; }
.input:focus { border-color: var(--accent); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--ink-2); user-select: none; }
.toggle input { appearance: none; width: 32px; height: 18px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; cursor: pointer; margin: 0; transition: background .15s; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ink-2); transition: transform .15s; }
.toggle input:checked { background: var(--accent); border-color: var(--accent); }
.toggle input:checked::after { transform: translateX(14px); background: #fff; }
.pillset { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.pill { border: 1px solid var(--border-strong); background: transparent; border-radius: 999px; padding: 4px 11px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; }
.pill[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); border-color: var(--ink-2); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; }

/* table */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--surface); cursor: default; }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--ink); }
table.data th .arrow { color: var(--accent); margin-left: 4px; }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td.num, table.data th.num { text-align: right; }
table.data tbody tr { cursor: pointer; transition: background .1s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.sel { background: var(--accent-soft); }
table.data.static tbody tr { cursor: default; }
.pbar { display: flex; width: 120px; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--surface-3); }
.pbar span { display: block; height: 100%; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.delta-up { color: #ff8d8d; } .delta-down { color: #7fd97f; } .delta-eq { color: var(--muted); }

/* charts */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font: 11px var(--sans); }
.chart text:not([fill]) { fill: var(--muted); }
.chart .axis path, .chart .axis line { stroke: var(--axis); }
.chart .grid line { stroke: var(--grid); }
.chart .grid path { display: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.legend i.dot { width: 9px; height: 9px; border-radius: 50%; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important; height: 2px; }
.tooltip {
  position: fixed; pointer-events: none; z-index: 100; opacity: 0; transition: opacity .1s;
  background: rgba(20, 21, 24, 0.96); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; color: var(--ink); max-width: 280px; box-shadow: 0 8px 28px rgba(0,0,0,0.45);
}
.tooltip .tt-title { font-weight: 600; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-2); }
.tooltip .tt-row b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* 3D */
.scene { position: relative; width: 100%; border-radius: var(--radius); overflow: hidden; background: radial-gradient(ellipse at 50% 40%, #12161f, #08090b 75%); }
.scene canvas { display: block; width: 100% !important; }
.scene-ui { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; pointer-events: none; }
.scene-ui > * { pointer-events: auto; }
.scene-tag { position: absolute; top: 12px; left: 12px; font-size: 11.5px; color: var(--ink-2); background: rgba(10,11,13,0.7); border: 1px solid var(--border); padding: 4px 9px; border-radius: 6px; max-width: calc(100% - 24px); }
.scene-legend { position: absolute; top: 12px; right: 12px; font-size: 11.5px; color: var(--ink-2); background: rgba(10,11,13,0.7); border: 1px solid var(--border); padding: 7px 10px; border-radius: 6px; display: flex; flex-direction: column; gap: 3px; }
.scene-legend span { display: flex; align-items: center; gap: 7px; }
.scene-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.range { flex: 1; min-width: 160px; accent-color: var(--accent); }
.scene-readout { font: 12px var(--mono); background: rgba(10,11,13,0.78); border: 1px solid var(--border); padding: 5px 9px; border-radius: 6px; color: var(--ink-2); }

/* hero */
.hero { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); background: #07080a; min-height: 340px; margin-bottom: 16px; }
.hero .scene { position: absolute; inset: 0; border-radius: 0; background: radial-gradient(ellipse at 70% 50%, #111827 0%, #07080a 70%); }
.hero-copy { position: relative; z-index: 2; padding: 32px 32px 28px; max-width: 560px; pointer-events: none; }
.hero-copy h1 { font-size: 32px; line-height: 1.12; letter-spacing: -0.03em; }
.hero-copy h1 em { font-style: normal; color: var(--accent); }
.hero-copy p { color: var(--ink-2); margin-top: 10px; font-size: 15px; }
.hero-stats { display: flex; gap: 26px; margin-top: 22px; flex-wrap: wrap; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats b { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
.hero-stats span { font-size: 12px; color: var(--muted); }
.hero .scene-tag { top: auto; bottom: 12px; left: auto; right: 12px; }

/* threat list */
.threats { display: flex; flex-direction: column; gap: 8px; }
.threat { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; color: var(--ink); }
.threat:hover { border-color: var(--border-strong); text-decoration: none; background: var(--surface-3); }
.threat .t-main { min-width: 0; }
.threat .t-main b { font-weight: 600; }
.threat .t-main div { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.threat .t-p { text-align: right; font: 600 15px var(--mono); }
.threat .t-p small { display: block; font: 11px var(--sans); color: var(--muted); }

/* event detail */
.ev-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.ev-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ev-title h1 { font-size: 26px; }
.ev-arrow { color: var(--muted); font-size: 18px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px 16px; }
.kv div { display: flex; flex-direction: column; gap: 2px; }
.kv span { font-size: 11.5px; color: var(--muted); }
.kv b { font: 600 15px var(--mono); }
.trace { display: flex; flex-direction: column; gap: 0; }
.trace-step { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.trace-step:last-child { border-bottom: 0; }
.trace-step .n { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font: 600 11px var(--mono); color: var(--ink-2); }
.trace-step .what { font-weight: 600; font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.trace-step .why { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; font-family: var(--mono); word-break: break-word; }
.brief { border-left: 3px solid var(--accent); padding: 4px 0 4px 14px; font-size: 14.5px; line-height: 1.6; color: var(--ink); }
.brief-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.suggest { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding: 12px; background: var(--surface-2); border-radius: 10px; }
.suggest .what { font-weight: 650; }
.decision-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.decision-log { margin-top: 12px; font-size: 12.5px; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
.whatif-out { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.whatif-out div { background: var(--surface-2); border-radius: 8px; padding: 10px; }
.whatif-out span { font-size: 11.5px; color: var(--muted); display: block; }
.whatif-out b { font: 600 16px var(--mono); }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--ink-2); }
.callout.warn { border-color: rgba(250,178,25,0.35); background: rgba(250,178,25,0.06); }
.callout.bad { border-color: rgba(208,59,59,0.4); background: rgba(208,59,59,0.07); }
.callout.good { border-color: rgba(12,163,12,0.4); background: rgba(12,163,12,0.06); }
.callout b { color: var(--ink); }
.insights { display: flex; flex-direction: column; gap: 10px; }
.insight { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; padding: 12px; border-radius: 10px; background: var(--surface-2); font-size: 13.5px; color: var(--ink-2); }
.insight .ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; }

/* about / pipeline */
.pipeline { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.pipe { position: relative; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.pipe .who { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 4px; }
.pipe .who.code { color: var(--accent); } .pipe .who.ml { color: var(--violet); } .pipe .who.llm { color: var(--orange); } .pipe .who.human { color: var(--safe); }
.pipe b { display: block; font-size: 13.5px; }
.pipe p { font-size: 12px; color: var(--muted); margin-top: 4px; }
.prose { max-width: 820px; color: var(--ink-2); }
.prose h3 { color: var(--ink); margin: 20px 0 8px; }
.prose ul { padding-left: 18px; margin: 0; }
.prose li { margin: 5px 0; }
.prose code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: var(--ink); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--ink); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: all .2s; z-index: 120; font-size: 13px; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .span-4, .span-5, .span-7, .span-8 { grid-column: span 12; }
  .span-6 { grid-column: span 12; }
  .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .nav { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,0.6); }
  .nav.open { transform: none; }
  .icon-btn { display: block; }
  .topbar { padding: 10px 16px; }
  #view { padding: 16px 16px 48px; }
  .jump { width: 150px; }
  .jump kbd { display: none; }
  .g-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .hero-copy { padding: 22px 18px; }
  .hero-copy h1 { font-size: 24px; }
  .pipeline { grid-template-columns: minmax(0, 1fr); }
  .whatif-out { grid-template-columns: minmax(0, 1fr); }
  .crumbs { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
