/* Tokens: reference data-viz palette. Series: human = slot 1 (blue), agent = slot 2 (orange),
   unknown = slot 3 (aqua); the first three slots validate all-pairs in both modes.
   Status colours are reserved for outcomes and always paired with an icon and a label. */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --raised: #ffffff;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #6f6d68; --axis: #898781;
  --grid: #e1e0d9; --baseline: #c3c2b7; --border: rgba(11,11,11,0.10);
  --accent: #2a78d6; --accent-ink: #ffffff;
  --s-human: #2a78d6; --s-agent: #eb6834; --s-unknown: #1baf7a; --s-single: #2a78d6;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b; --neutral: #c3c2b7;
  --good-ink: #006300; --critical-ink: #b12a2a; --warning-ink: #8a5a00;
  --suppressed: #e1e0d9;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --raised: #222221;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #a3a197; --axis: #898781;
    --grid: #2c2c2a; --baseline: #383835; --border: rgba(255,255,255,0.10);
    --accent: #3987e5;
    --s-human: #3987e5; --s-agent: #d95926; --s-unknown: #199e70; --s-single: #3987e5;
    --good-ink: #0ca30c; --critical-ink: #e66767; --warning-ink: #fab219;
    --suppressed: #2c2c2a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.45 var(--sans); }
h1 { font-size: 24px; margin: 0 0 8px; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
code, pre { font-family: var(--mono); font-size: 12.5px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: block; }
button, .button { font: inherit; border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); padding: 6px 12px; border-radius: 6px; cursor: pointer; text-decoration: none; display: inline-block; }
button.ghost, .button.ghost { background: transparent; color: var(--ink); border-color: var(--border); }
button.ghost:hover, .button.ghost:hover { background: var(--grid); }
.small { font-size: 12.5px; padding: 3px 9px; }
input, select { font: inherit; color: var(--ink); background: var(--raised); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; max-width: 100%; }
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.error { color: var(--critical-ink); }

/* login */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; width: 100%; max-width: 400px; }
.login-card form { display: grid; gap: 12px; margin-top: 16px; }
.login-card label { display: grid; gap: 4px; color: var(--ink-2); }

/* shell */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand strong { font-size: 16px; }
.who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tags { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11.5px; border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; color: var(--ink-2); background: var(--raised); }
.tabs { display: flex; gap: 2px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { background: none; color: var(--ink-2); border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 12px; white-space: nowrap; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.controls, .filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px; }
.filters { padding: 0 0 12px; }
.spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { background: var(--raised); color: var(--ink-2); border-radius: 0; border: none; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--accent); color: var(--accent-ink); }
main { padding: 0 20px 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.grid2 .card { margin-bottom: 0; }
.grid2 { margin-bottom: 16px; }
.note { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; color: var(--ink-2); }
.foot { padding: 8px 20px 24px; font-size: 12px; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.tile .label { color: var(--ink-2); font-size: 12.5px; }
.tile .value { font-size: 26px; font-weight: 600; margin-top: 2px; }
.tile .sub { color: var(--muted); font-size: 12px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--ink-2); border-bottom: 1px solid var(--baseline); padding: 6px 8px; white-space: nowrap; }
td { border-bottom: 1px solid var(--grid); padding: 6px 8px; vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--grid); }
.mono { font-family: var(--mono); font-size: 12px; }
.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more { display: flex; gap: 12px; align-items: center; padding-top: 10px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; border-radius: 4px; padding: 1px 6px; border: 1px solid var(--border); white-space: nowrap; color: var(--ink); background: var(--raised); }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.human { background: var(--s-human); } .dot.agent { background: var(--s-agent); } .dot.unknown { background: var(--s-unknown); }
.st-approved { color: var(--good-ink); } .st-rejected { color: var(--critical-ink); } .st-bypassed { color: var(--warning-ink); } .st-abandoned, .st-open { color: var(--ink-2); }
.src { font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
.src.client, .src.provider { font-style: italic; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--baseline); margin-left: 6px; padding: 6px 0 10px 16px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--axis); }
.timeline li.decision::before { border-color: var(--ink); background: var(--ink); }
.timeline .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; cursor: pointer; }
.timeline .t { font-family: var(--mono); font-size: 12px; color: var(--ink-2); min-width: 84px; }
.timeline .ty { font-weight: 600; }
.timeline pre { display: none; margin: 8px 0 0; }
.timeline li.open pre { display: block; }
pre.json { background: var(--raised); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; max-height: 520px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; overflow-wrap: anywhere; }

/* charts */
.chart { width: 100%; min-height: 220px; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--axis); font-size: 11px; font-family: var(--sans); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--baseline); stroke-width: 1; }
.chart .seg-human { fill: var(--s-human); } .chart .seg-agent { fill: var(--s-agent); } .chart .seg-unknown { fill: var(--s-unknown); }
.chart .seg-suppressed { fill: var(--suppressed); }
.chart .hit { fill: transparent; }
.chart .hit:hover + g rect, .chart g.col:hover rect { opacity: .85; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend i.human { background: var(--s-human); } .legend i.agent { background: var(--s-agent); } .legend i.unknown { background: var(--s-unknown); } .legend i.suppressed { background: var(--suppressed); }
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar .name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar svg { width: 100%; height: 14px; display: block; }
.hbar .val { font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.bar-fill { fill: var(--s-single); } .bar-track { fill: var(--grid); }
.out-approved { fill: var(--good); } .out-rejected { fill: var(--critical); } .out-bypassed { fill: var(--warning); } .out-abandoned { fill: var(--neutral); }
.tooltip { position: fixed; z-index: 10; pointer-events: none; background: var(--raised); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 4px 16px rgba(0,0,0,.12); min-width: 150px; }
.tooltip .tt-title { font-weight: 600; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 12px; }
.tooltip .tt-row span:first-child { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); }
.prose p { max-width: 900px; color: var(--ink-2); }
@media (max-width: 640px) { main, .controls { padding-left: 16px; padding-right: 16px; } .topbar { padding: 10px 16px; } }

#ov-table td:first-child { min-width: 190px; }
#ev-table td:first-child { white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand .logo { border-radius: 6px; }
