:root {
  color-scheme: dark;
  --bg: #101010; --surface-1: #191919; --surface-2: #222222; --border: #2e2e2e;
  --text-primary: #efefef; --text-secondary: #9c9c9c; --grid: #2a2a2a;
  --series-1: #338ced; --series-2: #e76624;
  --good: #0aac23; --bad: #eb6263;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f4f4; --surface-1: #ffffff; --surface-2: #f0f0f0; --border: #e2e2e2;
    --text-primary: #191919; --text-secondary: #666666; --grid: #ececec;
    --series-1: #257de0; --series-2: #f47230;
    --good: #006c10; --bad: #c62f30;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input { font: inherit; color: var(--text-primary); }
select, input[type=password], input[type=search], .btn {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; }
.btn { cursor: pointer; }
.btn:hover { border-color: var(--text-secondary); }
.btn.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn.small { padding: 2px 8px; font-size: 12px; }

/* nav */
nav.top { display: flex; align-items: center; gap: 6px; padding: 10px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface-1); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
nav.top .brand { font-weight: 700; margin-right: 14px; letter-spacing: -0.01em; }
nav.top a.tab { color: var(--text-secondary); padding: 6px 10px; border-radius: 6px; }
nav.top a.tab:hover { text-decoration: none; color: var(--text-primary); }
nav.top a.tab.active { color: var(--text-primary); background: var(--surface-2); }
nav.top .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
#queue-badge { font-size: 11px; background: var(--series-2); color: #fff; border-radius: 9px; padding: 0 6px; margin-left: 4px; }

main { max-width: 1280px; margin: 0 auto; padding: 0 24px 64px; }
header.page { padding: 22px 0 4px; }
h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.sub { color: var(--text-secondary); margin-top: 4px; }
.filters { position: sticky; top: 53px; z-index: 5; display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  padding: 10px 0; background: var(--bg); border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.filters label { color: var(--text-secondary); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.seg { display: inline-flex; }
.seg button { background: var(--surface-1); border: 1px solid var(--border); padding: 6px 10px; cursor: pointer; border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button[aria-pressed="true"] { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.count { margin-left: auto; color: var(--text-secondary); font-size: 12px; }
section { margin: 26px 0; }
h2 { font-size: 16px; margin: 0 0 4px; }
.desc { color: var(--text-secondary); font-size: 12px; margin: 0 0 12px; }
.grid { display: grid; gap: 12px; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); }
.three { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.tile .lbl { color: var(--text-secondary); font-size: 12px; display: flex; justify-content: space-between; gap: 6px; }
.tile .val { font-size: 25px; font-weight: 600; margin: 2px 0; font-variant-numeric: tabular-nums; }
.tile .cmp { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.tile .cmp b { font-weight: 600; }
.up { color: var(--good); } .down { color: var(--bad); }
.info { cursor: help; border: 1px solid var(--border); border-radius: 50%; width: 16px; height: 16px; font-size: 10px;
  display: inline-flex; align-items: center; justify-content: center; flex: none; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
td.l, th.l { text-align: left; }
th { color: var(--text-secondary); font-weight: 500; font-size: 12px; cursor: pointer; user-select: none; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tr.me td { background: color-mix(in srgb, var(--series-1) 12%, transparent); }
.tablewrap { overflow-x: auto; }
.minibar { display: inline-block; height: 6px; border-radius: 0 3px 3px 0; background: var(--series-1); vertical-align: middle; margin-right: 6px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--text-secondary); font-size: 11px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.dot { width: 8px; height: 8px; border-radius: 50%; }
#tip { position: fixed; pointer-events: none; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 9px; font-size: 12px; display: none; z-index: 50; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.insights ul { margin: 6px 0 0; padding-left: 0; list-style: none; }
.insights li { padding: 5px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; }
.insights li:last-child { border-bottom: 0; }
.res-W { color: var(--good); font-weight: 600; } .res-L { color: var(--bad); font-weight: 600; }
.ok { color: var(--good); } .no { color: var(--bad); } .muted { color: var(--text-secondary); }
.empty { color: var(--text-secondary); padding: 40px 0; text-align: center; }

/* heatmap */
.heatwrap { position: relative; width: 100%; max-width: 860px; aspect-ratio: 1; margin: 0 auto; }
.heatwrap img, .heatwrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.heatwrap img { opacity: .9; border-radius: 8px; }
.heat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .heat-layout { grid-template-columns: 1fr; } }
.side-panel .row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 13px; }

/* upload */
.drop { border: 2px dashed var(--border); border-radius: 12px; padding: 36px; text-align: center; color: var(--text-secondary); cursor: pointer; }
.drop.over { border-color: var(--series-1); color: var(--text-primary); }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.progress > div { height: 100%; background: var(--series-1); width: 0; transition: width .2s; }
.status { font-size: 12px; padding: 1px 8px; border-radius: 9px; border: 1px solid var(--border); }
.status.done { color: var(--good); } .status.error { color: var(--bad); } .status.parsing { color: var(--series-1); }

/* login */
.login-box { max-width: 360px; margin: 14vh auto; padding: 28px; }
.login-box h1 { margin-bottom: 6px; }
.login-box input { width: 100%; margin: 14px 0 10px; padding: 10px 12px; }
.login-box button { width: 100%; padding: 10px; }
.login-box .err { color: var(--bad); min-height: 20px; font-size: 13px; margin-top: 8px; }
