/* Tech45 dashboard — e-inkt-afwerking: warm papier, dof inktzwart, scherpe
   1px-lijnen, geen schaduwen/gradiënten/blur. Serif voor koppen en grote
   cijfers (drukwerk), sans voor UI. Monochroom by design: elke grafiek is
   één inktserie, identiteit zit in de karteltitel. Bewust géén dark mode. */
.viz-root {
  color-scheme: light;
  --page:           #eceae2;   /* papier */
  --surface-1:      #f6f4ee;   /* kaart */
  --surface-2:      #e4e1d6;
  --text-primary:   #1a1916;   /* inkt */
  --text-secondary: #4c4a43;
  --text-muted:     #807d73;
  --grid:           #dbd7cb;
  --baseline:       #aeaa9d;
  --border:         #c7c3b6;
  --ink:            #1a1916;
  --paper:          #f6f4ee;
  --series-1:       #1a1916;
  --chart-fill:     rgba(26, 25, 22, 0.08);
  --accent-ink:     #f6f4ee;   /* papieren tekst op inkt */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: #eceae2; }

.viz-root {
  min-height: 100vh;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 14px;
  padding-bottom: 48px;
}
/* full-width: geen max-width, alleen wat ademruimte aan de randen */
.viz-inner { width: 100%; margin: 0; padding: 0 28px; }

/* ---------- header met tabbladen en filterbalk ---------- */
.page-header {
  position: sticky; top: 0; z-index: 15;
  background: var(--page);
  border-bottom: 2px solid var(--ink);
  margin-bottom: 22px;
}
.page-header__inner {
  width: 100%; padding: 12px 28px 0;
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; }
.brand__dot {
  width: 34px; height: 34px; border-radius: 2px;
  background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px; letter-spacing: -0.02em;
}
h1 {
  font-family: var(--serif); font-size: 19px; margin: 0;
  font-weight: 600; letter-spacing: 0;
}
.subtitle { margin: 1px 0 0; color: var(--text-muted); font-size: 12px; }
h2 {
  font-family: var(--serif); font-size: 16px; margin: 0;
  font-weight: 600; letter-spacing: 0;
}
.card-sub { margin: 3px 0 14px; color: var(--text-muted); font-size: 12px; }

.tabs { display: flex; gap: 2px; align-items: flex-end; }
.tab-btn {
  font: inherit; font-size: 13px; font-weight: 550; cursor: pointer;
  background: transparent; color: var(--text-secondary);
  border: 1px solid transparent; border-bottom: 0;
  border-radius: 2px 2px 0 0;
  padding: 9px 18px 11px;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.is-active {
  background: var(--ink); color: var(--accent-ink);
  border-color: var(--ink);
}
.filter-bar {
  width: 100%; padding: 9px 28px 10px;
  border-top: 1px solid var(--border);
  background: var(--surface-1);
  display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap;
}
.filter-bar .flabel {
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--text-muted);
}

/* ---------- knoppen & controls ---------- */
.btn {
  font: inherit; font-size: 13px; font-weight: 550;
  background: var(--paper); color: var(--text-primary);
  border: 1px solid var(--ink); border-radius: 2px;
  padding: 6px 14px; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn--ghost { border-color: var(--border); color: var(--text-secondary); }
.btn--ghost[aria-pressed="true"] {
  background: var(--ink); color: var(--accent-ink); border-color: var(--ink);
}
.btn[disabled] { opacity: .55; cursor: wait; }

.controls { display: flex; gap: 8px; align-items: center; }
.controls--stack { flex-wrap: wrap; justify-content: flex-end; }

.segmented {
  display: inline-flex; background: var(--paper);
  border: 1px solid var(--ink); border-radius: 2px; padding: 0;
}
.seg-btn {
  font: inherit; font-size: 12.5px; font-weight: 550; border: 0;
  background: transparent; color: var(--text-secondary);
  padding: 6px 12px; cursor: pointer; border-radius: 0;
  border-right: 1px solid var(--border);
}
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { color: var(--text-primary); background: var(--surface-2); }
.seg-btn.is-active { background: var(--ink); color: var(--accent-ink); }

.date-inputs { display: flex; gap: 6px; align-items: center; }
.date-inputs label {
  font-size: 12.5px; color: var(--text-secondary);
  display: flex; gap: 5px; align-items: center;
}
.date-inputs input[type="date"], .select, .card-search {
  font: inherit; font-size: 12.5px;
  background: var(--paper); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 2px;
  padding: 6px 10px;
}
.card-search { min-width: 190px; }
.card-search:focus, .select:focus, .date-inputs input:focus {
  outline: none; border-color: var(--ink);
}
.select-label {
  font-size: 12.5px; color: var(--text-secondary);
  display: flex; gap: 6px; align-items: center;
}
.select { max-width: 220px; }

/* snelkeuzes boven de episodetabel */
.chip-btn {
  font: inherit; font-size: 12.5px; font-weight: 550;
  background: var(--paper); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 2px;
  padding: 5px 12px; cursor: pointer;
}
.chip-btn:hover { color: var(--text-primary); background: var(--surface-2); }
.chip-btn.is-active {
  background: var(--ink); color: var(--accent-ink); border-color: var(--ink);
}

/* ---------- pagina's (tabbladen) ---------- */
.page[hidden] { display: none; }

/* ---------- KPI-scorecards ---------- */
.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 12px; margin-bottom: 12px;
}
.stat-tile {
  background: var(--surface-1); border: 1px solid var(--border);
  border-top: 2px solid var(--ink);
  border-radius: 2px; padding: 16px 18px 13px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-label {
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--text-muted); margin: 0 0 8px;
}
.stat-value {
  font-family: var(--serif);
  font-size: 30px; font-weight: 600; letter-spacing: 0; line-height: 1.05;
  font-variant-numeric: lining-nums tabular-nums;
}
.stat-value--hero { font-size: clamp(32px, 3vw, 42px); }
.stat-delta { font-size: 12px; margin-top: 9px; color: var(--text-muted); }
.stat-delta .up, .stat-delta .down {
  color: var(--text-primary); background: transparent;
  border: 1px solid var(--border); border-radius: 2px;
  padding: 2px 8px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.stat-spark { margin-top: 12px; }
.stat-spark svg { display: block; width: 100%; height: 34px; }

/* ---------- kaarten ---------- */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 2px; padding: 18px 20px; margin-bottom: 12px;
}
.card--wide { width: 100%; }
.card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; flex-wrap: wrap;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 1250px) { .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 920px)  { .grid-2 { grid-template-columns: 1fr; } }

.trend-wrap { margin-top: 10px; }
.trend-wrap svg { display: block; width: 100%; height: auto; }
.card { transition: opacity .15s; }
.card.is-loading { opacity: .55; pointer-events: none; }

/* ---------- horizontale balken ---------- */
.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar-row {
  display: grid; grid-template-columns: minmax(90px, 42%) 1fr max-content;
  align-items: center; gap: 10px; font-size: 12.5px;
  padding: 1px 4px;
}
.bar-row:hover { background: var(--surface-2); }
.bar-label {
  color: var(--text-secondary); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-track { height: 14px; display: flex; align-items: center; }
.bar-fill {
  height: 11px; background: var(--ink);
  border-radius: 0 2px 2px 0; min-width: 2px;
}
.bar-value {
  color: var(--text-secondary); font-variant-numeric: tabular-nums;
  text-align: right;
}
.bar-value .pct { color: var(--text-muted); }

/* ---------- tabellen ---------- */
.table-wrap { overflow-x: auto; margin-top: 8px; }
table { border-collapse: collapse; font-size: 13px; width: 100%; }
th, td { text-align: left; padding: 9px 14px 9px 0; border-bottom: 1px solid var(--grid); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th {
  color: var(--text-muted); font-weight: 650; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1px solid var(--baseline);
}

.table-wrap--episodes { margin-top: 6px; }
.ep-table th { white-space: nowrap; cursor: pointer; user-select: none; }
.ep-table th .arrow { color: var(--ink); font-size: 9px; }
.ep-table th:hover { color: var(--text-primary); }
.ep-table tbody tr { cursor: pointer; }
.ep-table tbody tr:hover { background: var(--surface-2); }
.ep-table tbody tr:last-child td { border-bottom: 0; }
.ep-table td { vertical-align: middle; }
.ep-table .cell-rank {
  color: var(--text-muted); font-variant-numeric: tabular-nums;
  font-size: 12px; width: 34px;
}
.ep-table .cell-title { max-width: 420px; font-weight: 550; }
.ep-table .cell-bar { min-width: 160px; }
.ep-table .cell-bar .bar-track { width: 100%; }
.ep-table .cell-bar .bar-fill {
  display: flex; align-items: center; justify-content: flex-end; height: 15px;
}
.ep-table .cell-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ep-table .cell-list { max-width: 300px; }
.bar-inline {
  color: var(--paper); font-size: 11px; padding: 0 7px; font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1;
}
.bar-inline--out { color: var(--text-secondary); padding-left: 7px; font-weight: 500; }

.info-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  font-size: 10px; font-weight: 700; line-height: 1;
  font-family: var(--sans);
  color: var(--text-muted); background: transparent;
  border: 1px solid var(--baseline); cursor: help;
  vertical-align: 2px; margin-left: 4px; padding: 0;
}
.info-dot:hover, .info-dot:focus {
  color: var(--ink); border-color: var(--ink); outline: none;
}
.stat-label .info-dot { vertical-align: -3px; }

.chip {
  display: inline-block; font-size: 11px; font-weight: 550;
  color: var(--text-secondary);
  background: var(--paper);
  border: 1px solid var(--border); border-radius: 2px;
  padding: 2px 8px; margin: 1.5px 3px 1.5px 0; white-space: nowrap;
}

/* ---------- kolomkiezer ---------- */
.col-picker { position: relative; }
.col-picker summary { list-style: none; cursor: pointer; display: inline-block; }
.col-picker summary::-webkit-details-marker { display: none; }
.col-picker__menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 6;
  background: var(--surface-1); border: 1px solid var(--ink);
  border-radius: 2px; padding: 12px 14px; min-width: 200px;
  display: flex; flex-direction: column; gap: 8px;
}
.col-picker__menu label {
  font-size: 12.5px; color: var(--text-secondary);
  display: flex; gap: 8px; align-items: center; cursor: pointer;
}
.col-picker__menu input[type="checkbox"] { accent-color: var(--ink); }

/* ---------- tooltip ---------- */
.tooltip {
  position: fixed; z-index: 30; pointer-events: none;
  background: var(--paper, #f6f4ee);
  color: var(--text-primary, #1a1916);
  border: 1px solid var(--ink, #1a1916); border-radius: 2px;
  padding: 9px 12px; font-size: 12.5px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  max-width: 320px;
}
.tooltip .tt-value {
  font-weight: 700; font-size: 14.5px;
  font-variant-numeric: tabular-nums;
}
.tooltip .tt-label { color: var(--text-secondary, #4c4a43); margin-top: 2px; }
.tooltip .tt-key {
  display: inline-block; width: 12px; height: 2.5px; vertical-align: middle;
  background: var(--ink, #1a1916); margin-right: 6px;
}

/* ---------- modal (episode-detail) ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(26, 25, 22, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--ink); border-radius: 2px;
  padding: 22px 26px; width: min(1040px, 100%);
  max-height: 92vh; overflow-y: auto;
  font-family: var(--sans);
}
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.modal-head h2 { font-size: 19px; }
.modal .kpi-row { margin: 16px 0 12px; }
.modal .stat-tile { padding: 13px 15px 11px; }
.modal .stat-value { font-size: 22px; }
.modal .stat-note { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }
.modal-meta { font-size: 13px; color: var(--text-secondary); margin: 10px 0; line-height: 2; }
.modal-meta a { color: var(--text-primary); }
.modal-loading { color: var(--text-muted); font-size: 13px; padding: 36px 0; text-align: center; }
.modal h3 {
  font-family: var(--serif); font-size: 14.5px; font-weight: 600;
  margin: 18px 0 2px;
}

/* ---------- diversen ---------- */
.page-footer { color: var(--text-muted); font-size: 12px; margin-top: 24px; }
.error-banner {
  background: var(--surface-1); border: 1px solid var(--ink);
  border-left: 3px solid var(--ink); border-radius: 2px;
  padding: 12px 14px; margin-bottom: 12px; font-size: 13.5px;
}
