:root {
  color-scheme: dark;
  --ink: #e9eee9;
  --muted: #8b9690;
  --line: #2b3430;
  --panel: #151a18;
  --panel-raised: #1b211e;
  --base: #0e1210;
  --green: #21d391;
  --green-dim: #123d2e;
  --amber: #f0af4e;
  --danger: #ee6a62;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--base); color: var(--ink); min-width: 320px; }
button, input { font: inherit; }
button { color: inherit; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 72px minmax(0, 1fr); }
.rail { position: sticky; top: 0; height: 100vh; padding: 20px 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; background: #0b0f0d; z-index: 3; }
.mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--green); color: #07140e; font: 800 14px/1 ui-monospace, monospace; }
.rail nav { margin-top: 72px; display: grid; gap: 8px; }
.rail-link { width: 40px; height: 40px; display: grid; place-items: center; color: #66706b; text-decoration: none; font: 700 10px/1 ui-monospace, monospace; border-left: 2px solid transparent; }
.rail-link:hover, .rail-link.active { color: var(--ink); border-color: var(--green); background: #151b18; }
.rail-foot { margin-top: auto; color: #56605b; font: 700 10px/1.4 ui-monospace, monospace; text-align: center; }
main { width: min(1600px, 100%); margin: 0 auto; padding: 32px 36px 48px; }
.topbar { min-height: 82px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 9px; color: var(--green); font: 700 10px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .16em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 24px; font-size: clamp(28px, 3.2vw, 46px); line-height: 1; letter-spacing: -.045em; font-weight: 650; }
h2 { margin-bottom: 0; font-size: 21px; letter-spacing: -.025em; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.logout-form { margin: 0; }
.live { height: 38px; padding: 0 13px; border: 1px solid var(--line); display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font: 700 10px/1 ui-monospace, monospace; letter-spacing: .08em; }
.live i { width: 7px; height: 7px; background: var(--green); box-shadow: 0 0 0 4px rgba(33,211,145,.11); }
.live.failed i { background: var(--danger); box-shadow: none; }
.button { height: 38px; padding: 0 16px; border: 1px solid var(--green); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; }
.button[href] { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; white-space: nowrap; }
.button:hover { background: var(--green); color: #07140e; }
.button[href]:hover { color: #07140e; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-top: 0; }
.metric { min-height: 148px; padding: 23px; border-right: 1px solid var(--line); background: var(--panel); }
.metric:last-child { border-right: 0; }
.metric span, .metric small { display: block; color: var(--muted); }
.metric span { font-size: 12px; }
.metric strong { display: block; margin: 14px 0 9px; font: 560 clamp(28px, 3vw, 42px)/1 ui-monospace, monospace; letter-spacing: -.06em; }
.metric small { font-size: 10px; }
.metric.accent { background: var(--green); color: #07140e; }
.metric.accent span, .metric.accent small { color: #174a38; }
.pipeline { margin-top: 22px; border: 1px solid var(--line); background: var(--panel); }
.pipeline-head, .section-head { padding: 21px 23px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.source { max-width: 45%; margin: 0; color: var(--muted); text-align: right; font: 10px/1.4 ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipeline-flow { display: grid; grid-template-columns: 1fr 28px 1fr 28px 1fr 28px 1fr; align-items: center; padding: 22px; }
.pipeline-flow > i { height: 1px; background: var(--line); position: relative; }
.pipeline-flow > i::after { content: ""; position: absolute; right: 0; top: -3px; width: 6px; height: 6px; border-top: 1px solid var(--muted); border-right: 1px solid var(--muted); transform: rotate(45deg); }
.stage { min-height: 74px; padding: 13px; background: #111613; border: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; align-items: center; }
.stage b { color: #53605a; font: 700 9px/1 ui-monospace, monospace; }
.stage span { color: var(--muted); font-size: 11px; }
.stage strong { grid-column: 1 / -1; font: 650 20px/1 ui-monospace, monospace; }
.stage.final { border-color: #2d7055; }
.progress-track { height: 3px; background: #242c28; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--green); transition: width .3s ease; }
.workspace { margin-top: 22px; display: grid; grid-template-columns: minmax(520px, 1.15fr) minmax(390px, .85fr); border: 1px solid var(--line); min-height: 650px; }
.event-panel { min-width: 0; border-right: 1px solid var(--line); background: var(--panel); }
.filters { display: flex; gap: 4px; }
.filter { padding: 7px 9px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; font-size: 10px; }
.filter:hover, .filter.active { color: var(--ink); border-color: var(--line); background: #202723; }
.search { display: flex; align-items: center; gap: 14px; margin: 16px 20px 4px; padding: 0 13px; height: 42px; border: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: 12px/1 ui-monospace, monospace; }
.event-list { padding: 12px 20px 22px; display: grid; gap: 7px; max-height: 560px; overflow: auto; }
.event-item { width: 100%; display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 10px; border: 1px solid var(--line); background: #111613; text-align: left; cursor: pointer; }
.event-item:hover, .event-item.selected { border-color: #3b725d; background: #18211d; }
.event-thumb { width: 72px; height: 48px; object-fit: cover; background: #080b09; }
.event-main { min-width: 0; }
.event-main strong { display: block; font: 650 16px/1.2 ui-monospace, monospace; letter-spacing: .04em; }
.event-main span { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-score { text-align: right; }
.event-score strong { display: block; font: 700 12px/1 ui-monospace, monospace; }
.event-score span { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }
.unknown .event-main strong, .unknown .event-score strong { color: var(--amber); }
.inspector { min-width: 0; padding: 23px; background: #101512; }
.inspector-empty { min-height: 600px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.inspector-empty span { font: 700 11px/1 ui-monospace, monospace; letter-spacing: .13em; color: #59645f; }
.inspector-empty p { max-width: 320px; margin: 14px 0 0; font-size: 12px; line-height: 1.6; }
.inspector-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 17px; }
.inspector-head h2 { font: 650 30px/1 ui-monospace, monospace; letter-spacing: .05em; }
.status-pill { padding: 6px 8px; color: var(--green); border: 1px solid #2d7055; font: 700 9px/1 ui-monospace, monospace; }
.status-pill.unknown { color: var(--amber); border-color: #765c31; }
.frame-view { margin: 0; border: 1px solid var(--line); background: #090c0a; }
.frame-view img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.frame-view figcaption { display: flex; justify-content: space-between; padding: 9px 11px; color: var(--muted); font: 9px/1 ui-monospace, monospace; }
.plate-row { margin-top: 12px; display: grid; grid-template-columns: minmax(150px, 1.3fr) 1fr; gap: 12px; }
.plate-row img { width: 100%; height: 78px; object-fit: contain; background: #080b09; border: 1px solid var(--line); }
.plate-row div { border-left: 2px solid var(--green); padding: 12px; background: var(--panel-raised); }
.plate-row span { color: var(--muted); font-size: 9px; }
.plate-row strong { display: block; margin-top: 8px; font: 700 21px/1 ui-monospace, monospace; }
.evidence { margin-top: 18px; }
.evidence h3 { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }
.candidate { display: grid; grid-template-columns: 1fr 80px 55px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font: 11px/1 ui-monospace, monospace; }
.candidate-bar { height: 3px; background: #2a332f; }
.candidate-bar i { display: block; height: 100%; background: var(--green); }
.candidate small { color: var(--muted); text-align: right; }
.sheet-link { display: inline-block; margin-top: 14px; color: var(--green); font-size: 11px; text-decoration: none; }
.system-strip { margin-top: 22px; display: grid; grid-template-columns: 1.5fr repeat(4, 1fr); border: 1px solid var(--line); background: var(--panel); }
.system-strip div { padding: 16px 18px; border-right: 1px solid var(--line); }
.system-strip div:last-child { border-right: 0; }
.system-strip span { display: block; color: var(--muted); font-size: 9px; }
.system-strip strong { display: block; margin-top: 7px; font: 650 11px/1.3 ui-monospace, monospace; }
.empty { padding: 36px 14px; color: var(--muted); text-align: center; font-size: 12px; border: 1px dashed var(--line); }
@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .workspace { grid-template-columns: 1fr; }
  .event-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .event-list { max-height: 440px; }
  .system-strip { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  main { padding: 22px 14px 36px; }
  .topbar, .pipeline-head, .section-head { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; justify-content: space-between; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric { min-height: 125px; border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .pipeline-flow { grid-template-columns: 1fr; gap: 7px; }
  .pipeline-flow > i { height: 12px; width: 1px; margin-left: 24px; }
  .source { max-width: 100%; text-align: left; }
  .filters { width: 100%; flex-wrap: wrap; }
  .event-item { grid-template-columns: 58px minmax(0, 1fr); }
  .event-thumb { width: 58px; }
  .event-score { grid-column: 2; text-align: left; display: flex; gap: 8px; }
  .system-strip { grid-template-columns: 1fr 1fr; }
  .system-strip div { border-bottom: 1px solid var(--line); }
}
