/* Chrome + palette (reference dataviz palette, light & dark selected). */
:root {
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6; --series-2: #1baf7a; --series-3: #eda100; --series-4: #008300;
  --series-5: #4a3aa7; --series-6: #e34948; --series-7: #e87ba4; --series-8: #eb6834;
  --status-good: #0ca30c; --status-warning: #fab219;
  --status-serious: #ec835a; --status-critical: #d03b3b;
  --meter-track: #cde2fb;
  --seq-lo: #cde2fb; --seq-hi: #0d366b;   /* sequential blue, near-zero recedes to surface */
  --accent: var(--series-1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5; --series-2: #199e70; --series-3: #c98500; --series-4: #008300;
    --series-5: #9085e9; --series-6: #e66767; --series-7: #d55181; --series-8: #d95926;
    --meter-track: #184f95;
    --seq-lo: #104281; --seq-hi: #b7d3f6;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.ar { unicode-bidi: plaintext; }

/* ---- nav ---- */
.topnav {
  display: flex; align-items: baseline; gap: 22px;
  padding: 12px 22px; border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}
.topnav .brand { font-weight: 650; font-size: 15px; margin-right: 8px; }
.topnav a { color: var(--text-secondary); text-decoration: none; padding-bottom: 2px; }
.topnav a:hover { color: var(--text-primary); }
.topnav a.active { color: var(--text-primary); border-bottom: 2px solid var(--accent); }

main { max-width: 1100px; margin: 0 auto; padding: 18px 22px 40px; }
footer.note { max-width: 1100px; margin: 0 auto; padding: 0 22px 30px; color: var(--text-muted); font-size: 12px; }

/* ---- filter row (one row, above the charts, scopes everything below) ---- */
.filters {
  display: flex; flex-wrap: wrap; align-items: end; gap: 14px;
  margin: 6px 0 16px;
}
.filters .field { display: flex; flex-direction: column; gap: 4px; }
.filters label { font-size: 12px; color: var(--text-muted); }
select, input[type="date"], input[type="text"] {
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--baseline); border-radius: 6px;
  padding: 6px 9px; font: inherit;
}
input[type="text"] { min-width: 220px; }
.hidden { display: none !important; }
.checks { display: flex; gap: 14px; align-items: center; min-height: 33px; }
.check {
  display: inline-flex; gap: 6px; align-items: center;
  color: var(--text-secondary); font-size: 13px; cursor: pointer; white-space: nowrap;
}
.check input { accent-color: var(--accent); }

/* product picker */
.picker { position: relative; }
.picker .drop {
  position: absolute; top: 100%; left: 0; z-index: 30; margin-top: 4px;
  min-width: 280px; max-height: 300px; overflow-y: auto;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.12);
}
.picker .drop div { padding: 7px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 14px; }
.picker .drop div:hover { background: var(--grid); }
.picker .drop .meta { color: var(--text-muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 14px; padding: 4px 11px;
}
.chip .swatch { width: 14px; height: 3px; border-radius: 2px; }
.chip button {
  border: 0; background: none; color: var(--text-muted); cursor: pointer;
  font-size: 14px; padding: 0 1px; line-height: 1;
}
.chip button:hover { color: var(--text-primary); }

/* ---- cards ---- */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px 12px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-head h2 { font-size: 15px; font-weight: 650; margin: 0 0 2px; }
.card-head .sub { color: var(--text-muted); font-size: 12px; margin: 0 0 10px; }
.btn {
  background: var(--surface-1); color: var(--text-secondary);
  border: 1px solid var(--baseline); border-radius: 6px;
  padding: 6px 13px; font: inherit; cursor: pointer;
}
.btn:hover:not(:disabled) { color: var(--text-primary); border-color: var(--text-muted); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); color: #fff; }

/* ---- chart anatomy ---- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; }
.chart .refetching { opacity: 0.45; }
svg .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
svg .axis text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg .axis line, svg .axis path { stroke: var(--baseline); stroke-width: 1; shape-rendering: crispEdges; }
svg .axis-title { fill: var(--text-muted); font-size: 11px; }
svg .crosshair { stroke: var(--baseline); stroke-width: 1; }
svg .direct-label { fill: var(--text-secondary); font-size: 11px; }
.empty-msg { color: var(--text-muted); padding: 60px 0; text-align: center; }
.empty-msg a { color: var(--accent); }

/* legend (always present for >=2 series) */
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 8px 2px 2px; }
.legend .item { display: inline-flex; align-items: center; gap: 7px; color: var(--text-secondary); font-size: 12.5px; }
.legend .key-line { width: 16px; height: 2px; border-radius: 1px; }
.legend .key-dot { width: 9px; height: 9px; border-radius: 50%; }

/* tooltip: values lead, labels follow; line keys not boxes */
#tooltip {
  position: fixed; z-index: 100; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.16);
  padding: 9px 12px; font-size: 12.5px; max-width: 320px;
}
#tooltip .tip-title { color: var(--text-muted); margin-bottom: 5px; }
#tooltip .tip-row { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
#tooltip .tip-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
#tooltip .tip-val { font-weight: 650; font-variant-numeric: tabular-nums; }
#tooltip .tip-label { color: var(--text-secondary); }

/* table view (the WCAG-clean twin of every chart) */
.tablewrap { overflow-x: auto; margin-top: 8px; }
table.data { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.data th, table.data td { padding: 5px 10px; text-align: right; border-bottom: 1px solid var(--grid); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--text-muted); font-weight: 500; }
table.data td { font-variant-numeric: tabular-nums; }

/* ---- scraper monitor ---- */
.statusline { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); }
.status-dot.running { background: var(--status-good); }
.meter { height: 10px; border-radius: 5px; background: var(--meter-track); overflow: hidden; margin: 12px 0 4px; }
.meter .fill { height: 100%; background: var(--accent); border-radius: 5px; width: 0; transition: width 0.4s; }
.meter-caption { color: var(--text-muted); font-size: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 14px 0 4px; }
.tile { border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; }
.tile .label { color: var(--text-muted); font-size: 12px; }
.tile .value { font-size: 19px; font-weight: 650; margin-top: 2px; }
.tile .value.small { font-size: 14px; }
.errors { margin-top: 10px; color: var(--text-secondary); font-size: 12px; }
.errors .err { color: var(--status-critical); }
.errors ul { margin: 4px 0 0; padding-left: 18px; }
.controls-row { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; margin-top: 14px; }
.current-window { color: var(--text-muted); font-size: 12px; margin-top: 6px; min-height: 16px; }

/* coverage heatmap: 2px surface gaps between cells */
.heatmap { display: grid; gap: 2px; margin-top: 10px; width: fit-content; }
.heatmap .hcell { width: 26px; height: 20px; border-radius: 3px; background: var(--page); }
.heatmap .hlabel {
  font-size: 11px; color: var(--text-muted); display: flex; align-items: center;
  padding-right: 6px; font-variant-numeric: tabular-nums;
}
.heatmap .hmonth { font-size: 11px; color: var(--text-muted); display: flex; align-items: end; justify-content: center; }
.ramp-legend { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--text-muted); font-size: 11px; }
.ramp-legend .ramp { width: 120px; height: 8px; border-radius: 4px; background: linear-gradient(to right, var(--seq-lo), var(--seq-hi)); }
