.viz-root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-pos: #2a78d6;
  --series-neg: #e34948;
  --series-2: #eb6834;
  --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  .viz-root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-pos: #3987e5;
    --series-neg: #e66767;
    --series-2: #d95926;
    --accent: #3987e5;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); }

.viz-root {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--page);
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  min-height: 100vh;
}

h1 { font-size: 24px; margin: 0 0 4px; }
.subtitle { color: var(--text-secondary); margin: 0 0 20px; font-size: 14px; }

.demo-note {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--series-neg);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-secondary);
}
.demo-note code { color: var(--text-primary); }

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 8px;
  flex-wrap: wrap;
}
.controls label { font-size: 14px; color: var(--text-secondary); }
.controls select {
  font: inherit;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
}
.view-toggle { display: flex; gap: 12px; border: none; margin: 0 0 0 auto; padding: 0; }
.view-toggle label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-secondary); }

.breadcrumb { font-size: 15px; margin: 10px 0 16px; color: var(--text-secondary); }
.breadcrumb span { color: var(--text-primary); font-weight: 600; }
.crumb {
  font: inherit;
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.crumb-hint { margin-left: 12px; color: var(--text-muted) !important; font-weight: 400 !important; font-size: 13px; }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi span { font-size: 13px; color: var(--text-secondary); }
.kpi strong { font-size: 22px; font-weight: 600; }

.status { color: var(--text-secondary); font-size: 14px; min-height: 1em; margin: 0 0 8px; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.chart { position: relative; }
.chart.is-loading { opacity: 0.5; }
.chart svg { display: block; width: 100%; }
.chart-gridline { stroke: var(--gridline); stroke-width: 1; }
.chart-baseline { stroke: var(--baseline); stroke-width: 1; }
.chart-tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-extreme { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
.chart-bar { fill: var(--series-pos); }
.chart-bar-negative { fill: var(--series-neg); }
.chart-range { fill: var(--series-pos); opacity: 0.35; }
.chart-avg { fill: var(--series-pos); }
.chart-avg-negative { fill: var(--series-neg); }
.chart-seg-0 { fill: var(--series-pos); }
.chart-seg-1 { fill: var(--series-2); }
.chart-hit { fill: transparent; }
.chart-mark { outline-offset: 2px; }
.chart-mark:hover, .chart-mark:focus-visible { opacity: 0.8; }
.chart-mark-selectable { cursor: pointer; }

.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.card-unit { color: var(--text-muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
.card + .card { margin-top: 16px; }

.chart-legend { display: flex; gap: 16px; margin-bottom: 8px; font-size: 13px; color: var(--text-secondary); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.legend-swatch-0 { background: var(--series-pos); }
.legend-swatch-1 { background: var(--series-2); }
.tooltip-row { display: inline-flex; align-items: center; gap: 6px; }

.chart-tooltip[hidden] { display: none; }
.chart-tooltip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  font-size: 13px;
}
.chart-tooltip strong { font-size: 14px; }
.chart-tooltip span { color: var(--text-secondary); }

.table-view { max-height: 420px; overflow-y: auto; }
.table-view table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-view th, .table-view td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--gridline);
}
.table-view td:not(:first-child), .table-view th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.table-view th { color: var(--text-secondary); font-weight: 600; position: sticky; top: 0; background: var(--surface-1); }

footer p { color: var(--text-muted); font-size: 12px; margin-top: 24px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
