/* ============================================================
   Balans: historie (grafiek per metriek en de vergelijkingstabel)
   De kleur komt uit --a, het accent van het scherm.
   ============================================================ */

/* ── Periodekiezer ───────────────────────────────────────────── */
.seg.wide { width: 100%; margin-bottom: var(--sp-4); }
.seg.wide button { flex: 1 1 0; min-height: 38px; }

/* ── Kop van de grafiekkaart ─────────────────────────────────── */
.hist-headline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.hist-value {
  display: block;
  font-size: var(--fs-hero);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.02;
  font-variant-numeric: tabular-nums;
  font-variation-settings: "opsz" 96;
}
.hist-sub { display: block; margin-top: 4px; font-size: var(--fs-sm); color: var(--ink-3); }

/* ── De grafiek ──────────────────────────────────────────────── */
.hist-chart { width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.hist-chart .grid { stroke: rgba(255, 255, 255, 0.07); stroke-width: 1; }
.hist-chart .tick { fill: var(--ink-3); font-family: var(--mono); font-size: 11px; }
.hist-chart .hist-bar { fill: var(--a); opacity: 0.9; }
.hist-chart .hist-line { fill: none; stroke: var(--a); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.hist-chart .hist-dot { fill: var(--a); }
/* De vorige periode ligt er als schaduw achter: zichtbaar, maar nooit de hoofdrol. */
.hist-chart .hist-ghost { fill: var(--ink-3); opacity: 0.22; }
.hist-chart .hist-ghost-line {
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
  opacity: 0.55;
}
.hist-chart .crosshair { stroke: rgba(255, 255, 255, 0.32); stroke-width: 1; }
.hist-chart .hover-dot { fill: var(--a); stroke: var(--bg); stroke-width: 2; }

/* Legenda onder de grafiek: zonder dit weet niemand wat de grijze staven zijn. */
.hist-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.hist-legend .swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--a); }
.hist-legend .swatch.before { margin-left: var(--sp-3); background: var(--ink-3); opacity: 0.45; }

/* ── Snelkeuze ───────────────────────────────────────────────── */
.hist-quick { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.chip.pick { cursor: pointer; min-height: 32px; }
.chip.pick[aria-pressed="true"] { border-color: var(--a); color: var(--ink); background: var(--glass-hover); }

/* ── Vergelijkingstabel ──────────────────────────────────────── */
.hist-group { margin-top: var(--sp-4); }
.hist-group h3 {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.hist-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.hist-table thead th {
  padding: 0 var(--sp-2) 6px;
  text-align: right;
  font-weight: 500;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}
.hist-table thead th:first-child { text-align: left; }
.hist-table tbody tr { border-bottom: 1px solid var(--line); cursor: pointer; }
.hist-table tbody tr:last-child { border-bottom: 0; }
.hist-table tbody tr:hover { background: var(--glass); }
.hist-table tbody tr[aria-current="true"] { background: var(--glass-hover); }
.hist-table tbody tr.leeg { opacity: 0.55; }
.hist-table th[scope="row"] {
  padding: 9px var(--sp-2);
  text-align: left;
  font-weight: 500;
  color: var(--ink);
}
.hist-table td {
  padding: 9px var(--sp-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hist-unit { display: block; font-size: var(--fs-xs); color: var(--ink-3); font-weight: 400; }
.hist-table .chip { font-variant-numeric: tabular-nums; }
.chip .pct { margin-left: 5px; opacity: 0.75; }

/* ── Breakpoints ─────────────────────────────────────────────── */
@media (max-width: 980px) {
  .hist-value { font-size: 38px; }
}

@media (max-width: 640px) {
  /* Het SVG schaalt sterk terug, dus tekst en lijnen groter in SVG-eenheden. */
  .hist-chart .tick { font-size: 17px; }
  .hist-chart .tick.x { transform: translateY(5px); }
  .hist-chart .hist-line { stroke-width: 3; }
  .hist-value { font-size: 32px; }
  .hist-headline { align-items: center; }
  /* Vier cijfers naast elkaar passen niet meer: twee rijen van twee lezen prettiger dan
     drie plus een die eronder valt. */
  .hist-main .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hist-table { font-size: var(--fs-xs); }
  .hist-table th[scope="row"], .hist-table td { padding: 8px 4px; }
  .hist-table .chip { padding: 0 7px; min-height: 24px; }
  .seg.wide button { font-size: var(--fs-xs); padding: 0 6px; }
}

@media (max-width: 420px) {
  .hist-chart .tick { font-size: 20px; }
  .hist-value { font-size: 28px; }
  /* Op de smalste telefoons past het percentage er niet meer bij; het verschil zelf wel. */
  .hist-table .chip .pct { display: none; }
  .hist-table thead th { font-size: 10px; }
}
