/* Voxi LLM Bench dashboard. Colors are role tokens; dark mode is its own selected set. */
:root {
  color-scheme: light;
  --surface-0: #f5f5f3;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --line: #e2e1dc;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #686762;
  --btn-bg: #256abf;
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --baseline: #52514e;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --track: #ecebe6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #242422;
    --line: #33332f;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --baseline: #c3c2b7;
    --track: #2b2b28;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #242422;
  --line: #33332f;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8e86;
  --accent: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --baseline: #c3c2b7;
  --track: #2b2b28;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--surface-0);
  color: var(--text-primary);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }

/* ── Shell ───────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px; background: var(--surface-1); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 10px; border-radius: 6px; color: var(--text-secondary); }
.nav a.active, .nav a:hover { background: var(--surface-2); color: var(--text-primary); text-decoration: none; }
.spacer { flex: 1; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface-1); border-radius: 8px;
  padding: 6px 10px; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
main { max-width: 1280px; margin: 0 auto; padding: 24px; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.015em; }
h2 { font-size: 15px; margin: 0 0 12px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .spacer { min-width: 8px; }

/* ── Cards / tiles ───────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); min-width: 0;
}
.tile .label { font-size: 12px; color: var(--text-secondary); }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; }
.tile .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.section-gap { margin-top: 16px; }

/* ── Status chips (icon + label, never color alone) ──────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.ready .dot { background: var(--good); }
.chip.notready .dot { background: var(--critical); }
.chip.base { font-weight: 500; color: var(--text-secondary); }
.delta { font-size: 12px; margin-left: 4px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--critical); }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; background: var(--surface-1); position: sticky; top: 0; }
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text-primary); }
td.num, th.num { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
.score-cell { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.mini-bar { width: 44px; height: 6px; background: var(--track); border-radius: 3px; overflow: hidden; }
.mini-bar > span { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }

/* ── Filters ─────────────────────────────────────────────── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type="search"], .filters select {
  border: 1px solid var(--line); background: var(--surface-1); border-radius: 8px; padding: 6px 10px; min-width: 0;
}
.filters input[type="search"] { width: 240px; max-width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface-1); padding: 6px 10px; cursor: pointer; }
.seg button.on { background: var(--surface-2); font-weight: 600; }
.btn {
  border: 1px solid var(--btn-bg); background: var(--btn-bg); color: #fff; border-radius: 8px;
  padding: 7px 14px; cursor: pointer; font-weight: 600;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); }

/* ── Bars (horizontal score bars with baseline tick) ─────── */
.hbar { display: grid; grid-template-columns: minmax(110px, 180px) 1fr 64px; gap: 12px; align-items: center; margin: 10px 0; }
.hbar .name { color: var(--text-secondary); }
.hbar .name small { color: var(--text-muted); margin-left: 4px; }
.hbar .track { position: relative; height: 12px; background: var(--track); border-radius: 4px; }
.hbar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--series-1); }
.hbar .tick { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--baseline); border-radius: 1px; }
.hbar .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.hbar .val small { display: block; font-weight: 500; font-size: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend i.tick { width: 2px; height: 12px; border-radius: 1px; background: var(--baseline); }

/* Grouped bars (compare) */
.gbar { display: grid; grid-template-columns: minmax(110px, 180px) 1fr; gap: 12px; align-items: center; margin: 12px 0; }
.gbar .stack { display: grid; gap: 2px; }
.gbar .row { display: grid; grid-template-columns: 1fr 52px; gap: 8px; align-items: center; }
.gbar .row .track { height: 9px; background: var(--track); border-radius: 3px; position: relative; }
.gbar .row .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 3px 3px 0; }
.gbar .row .v { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }

/* ── SVG chart ───────────────────────────────────────────── */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--text-muted); font-size: 11px; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .marker { stroke: var(--surface-1); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: crosshair; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; padding: 8px 10px; border-radius: 8px;
  background: var(--surface-1); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.14);
  font-size: 12px; max-width: 280px;
}
.tooltip b { font-weight: 650; }

/* ── Gates ───────────────────────────────────────────────── */
.gate-ok, .gate-fail { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 12px; }
.gate-ok { color: var(--good); }
.gate-fail { color: var(--critical); }

/* ── Turn detail ─────────────────────────────────────────── */
details.turn { border-top: 1px solid var(--line); padding: 8px 0; }
details.turn summary { cursor: pointer; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
details.turn summary::-webkit-details-marker { display: none; }
.turn-body { padding: 8px 0 4px 18px; display: grid; gap: 6px; }
.bubble { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; word-break: break-word; }
.bubble.agent { border-left: 3px solid var(--series-1); }
.kv { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
ul.checks { margin: 0; padding-left: 18px; font-size: 12.5px; }
ul.checks li.fail { color: var(--critical); }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--line); }

/* ── Login ───────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { margin-bottom: 4px; }
.field { display: grid; gap: 4px; margin: 14px 0; }
.field label { font-size: 12px; color: var(--text-secondary); }
.field input { border: 1px solid var(--line); background: var(--surface-1); border-radius: 8px; padding: 9px 11px; }
.field input:focus, .filters input:focus, .filters select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.error { color: var(--critical); font-size: 13px; min-height: 20px; }
.empty { padding: 40px 16px; text-align: center; color: var(--text-muted); }
.loading { padding: 40px 16px; text-align: center; color: var(--text-muted); }

@media (max-width: 900px) {
  .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.k3, .grid.k2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  main { padding: 16px; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .grid.k4 { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 1fr 56px; }
  .hbar .track { grid-column: 1 / -1; order: 3; }
  .gbar { grid-template-columns: 1fr; }
}
