/* Fluitje Dashboard */
.viz-root {
  color-scheme: light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --accent: #2a78d6;
  --grid: #e8e7e2;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95;
  --good: #0ca30c; --good-text: #006300; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-bg: #e6f4e6; --warning-bg: #fdf3dc; --critical-bg: #fbe8e8; --info-bg: #e7f0fb;
}
@media (prefers-color-scheme: dark) {
  .viz-root {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #262624;
    --border: #33332f;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #9a998f;
    --accent: #3987e5;
    --grid: #2c2c29;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --seq-1: #104281; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #2a78d6; --seq-5: #5598e7; --seq-6: #86b6ef;
    --good-text: #4cc44c;
    --good-bg: #16301a; --warning-bg: #3a2f12; --critical-bg: #3a1a1a; --info-bg: #15263c;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: #f4f4f2; }
@media (prefers-color-scheme: dark) { body { background: #121211; } }
.viz-root {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text-primary);
  background: var(--surface-0);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-word; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 13px; margin: 16px 0 8px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.muted, small.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }

/* ---------- top bar */
header.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--surface-1); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; white-space: nowrap; }
.logo { color: var(--series-2); }
header.top nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
header.top nav a { padding: 6px 10px; border-radius: 6px; color: var(--text-secondary); }
header.top nav a:hover { background: var(--surface-2); text-decoration: none; }
header.top nav a.active { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
.logout { display: flex; align-items: center; gap: 8px; }
.who { color: var(--text-muted); }
button {
  font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-primary); padding: 6px 12px; border-radius: 6px;
}
button:hover { border-color: var(--text-muted); }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
form.inline { display: inline; }

main { padding: 20px 24px 40px; max-width: 1600px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.filters { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-1); }
.filters a { padding: 6px 12px; color: var(--text-secondary); border-right: 1px solid var(--border); }
.filters a:last-child { border-right: none; }
.filters a.active { background: var(--accent); color: #fff; }
.filters a:hover { text-decoration: none; }

footer { padding: 16px 24px 32px; color: var(--text-muted); font-size: 12px; text-align: center; }

/* ---------- layout */
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } main { padding: 12px; } }

.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; margin-bottom: 16px; min-width: 0;
}
.grid > .card { margin-bottom: 0; }
.card > header { margin-bottom: 12px; }
.card .sub { margin: 4px 0 0; color: var(--text-muted); font-size: 12px; }

/* ---------- stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card .stats { margin-bottom: 8px; }
.stat { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.stat-label { color: var(--text-secondary); font-size: 12px; }
.stat-value { font-size: 26px; font-weight: 650; margin: 2px 0; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--text-muted); font-size: 12px; }
.stat-warning { border-left: 4px solid var(--warning); }
.stat-critical { border-left: 4px solid var(--critical); }
.delta.up { color: var(--good-text); }
.delta.down { color: var(--critical); }

/* ---------- bars */
ul.bars { list-style: none; margin: 0; padding: 0; }
ul.bars li {
  display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center;
  gap: 10px; padding: 3px 0;
}
ul.bars li:hover { background: var(--surface-2); }
ul.bars li.other .bar-fill { background: var(--text-muted); opacity: .5; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.bar-track { height: 12px; position: relative; }
.bar-fill { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-value { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.bar-value small { color: var(--text-muted); }

/* ---------- meter */
.meter { display: inline-block; width: 80px; height: 8px; background: var(--surface-2); border-radius: 4px; vertical-align: middle; overflow: hidden; }
td.w50 .meter { width: 100%; }
.meter > span { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.meter-low > span { background: var(--serious); }
.meter-high > span { background: var(--good); }

/* ---------- charts */
.chart-wrap { width: 100%; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .axis { fill: var(--text-muted); font-size: 11px; }
svg.chart .stroke { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .series-1.stroke { stroke: var(--series-1); }
svg.chart .series-2.stroke { stroke: var(--series-2); }
svg.chart .series-3.stroke { stroke: var(--series-3); }
svg.chart .series-4.stroke { stroke: var(--series-4); }
svg.chart .series-1.fill { fill: var(--series-1); }
svg.chart .series-2.fill { fill: var(--series-2); }
svg.chart .hit { fill: transparent; }
svg.chart .hit:hover { fill: var(--text-primary); fill-opacity: .06; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.swatch.series-1 { background: var(--series-1); }
.swatch.series-2 { background: var(--series-2); }
.swatch.series-3 { background: var(--series-3); }
.swatch.series-4 { background: var(--series-4); }
.seq-legend { align-items: center; margin-top: 8px; gap: 3px; }
.seq-legend span { margin: 0 6px; }
details.data-table { margin-top: 6px; font-size: 12px; }
details.data-table summary { cursor: pointer; color: var(--text-muted); }
details.data-table .table-wrap { max-height: 260px; overflow: auto; }

/* ---------- heatmap */
table.heatmap { border-collapse: separate; border-spacing: 2px; width: 100%; }
table.heatmap th { font-weight: 500; color: var(--text-muted); font-size: 11px; padding: 2px 4px; text-align: center; }
table.heatmap td { height: 28px; min-width: 28px; text-align: center; font-size: 11px; border-radius: 4px; background: var(--surface-2); padding: 0; }
table.heatmap td span { visibility: hidden; }
table.heatmap td:hover span { visibility: visible; }
.seq-1 { background: var(--seq-1) !important; color: var(--text-primary); }
.seq-2 { background: var(--seq-2) !important; color: var(--text-primary); }
.seq-3 { background: var(--seq-3) !important; color: #fff; }
.seq-4 { background: var(--seq-4) !important; color: #fff; }
.seq-5 { background: var(--seq-5) !important; color: #fff; }
.seq-6 { background: var(--seq-6) !important; color: #fff; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--text-secondary); border-bottom: 1px solid var(--border); padding: 6px 8px; white-space: nowrap; }
td { border-bottom: 1px solid var(--grid); padding: 6px 8px; vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
table.small td { font-size: 12px; }
td details summary { cursor: pointer; color: var(--accent); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 4px 0; }

/* ---------- badges & insights */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; white-space: nowrap; color: var(--text-primary); vertical-align: middle; }
.badge-good { background: var(--good-bg); }
.badge-good span { color: var(--good-text); }
.badge-info { background: var(--info-bg); }
.badge-info span { color: var(--accent); }
.badge-warning { background: var(--warning-bg); }
.badge-warning span { color: #a36a00; }
.badge-critical { background: var(--critical-bg); }
.badge-critical span { color: var(--critical); }
.err { margin: 0 0 8px; }
.empty { color: var(--text-muted); font-style: italic; margin: 8px 0; }

ul.insights { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
ul.insights li { border: 1px solid var(--border); border-left-width: 4px; border-radius: 8px; padding: 10px 14px; }
ul.insights li p { margin: 6px 0; color: var(--text-secondary); }
ul.insights.compact li { padding: 8px 12px; }
.ins-critical { border-left-color: var(--critical) !important; }
.ins-warning { border-left-color: var(--warning) !important; }
.ins-info { border-left-color: var(--accent) !important; }
.ins-good { border-left-color: var(--good) !important; }

/* ---------- tooltip */
#tip {
  position: fixed; z-index: 100; pointer-events: none; max-width: 360px;
  background: var(--text-primary); color: var(--surface-1); font-size: 12px;
  padding: 6px 9px; border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.2);
}

/* ---------- login */
.login-body .viz-root { display: flex; align-items: center; justify-content: center; }
main.login { width: 100%; max-width: 360px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 28px; margin: 40px auto; }
main.login h1 { font-size: 18px; margin-bottom: 18px; }
main.login label { display: block; margin-bottom: 14px; color: var(--text-secondary); font-size: 13px; }
main.login input {
  display: block; width: 100%; margin-top: 4px; font: inherit; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface-0); color: var(--text-primary);
}
main.login button { width: 100%; background: var(--accent); color: #fff; border: none; padding: 10px; font-weight: 600; }

/* ---------- opzoeken */
.top-search input { font: inherit; padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-0); color: var(--text-primary); width: 220px; }
.lookup-form label { display: block; font-weight: 600; margin-bottom: 6px; }
.lookup-row { display: flex; gap: 8px; }
.lookup-row input { flex: 1; font: inherit; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-0); color: var(--text-primary); }
.lookup-row button { background: var(--accent); color: #fff; border: none; font-weight: 600; padding: 8px 18px; }
h2.subject { font-size: 20px; margin: 8px 0 12px; }
h2.subject small { font-weight: 400; font-size: 14px; }
table.kv th { width: 40%; color: var(--text-secondary); font-weight: 500; white-space: normal; border-bottom: 1px solid var(--grid); }
tr.row-err td { background: var(--critical-bg); }
tr.gap td { text-align: center; color: var(--text-muted); font-size: 11px; background: var(--surface-2); padding: 3px; }
table.timeline td { vertical-align: top; }
pre { font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 8px; border-radius: 6px; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 4px 0; }
.small-filters { display: inline-flex; margin-bottom: 10px; font-size: 12px; }
@media (max-width: 1100px) { .top-search input { width: 140px; } }
.table-wrap.scroll { max-height: 520px; overflow: auto; }
.lookup-row select { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-0); color: var(--text-primary); }
.lookup-form .sub { margin: 0 0 8px; }

/* ---------- beoordelen */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; }
.flash-ok { background: var(--good-bg); color: var(--good-text); }
.flash-err { background: var(--critical-bg); color: var(--critical); }
.rv-item { border-top: 1px solid var(--grid); padding: 14px 0; }
.rv-item:first-of-type { border-top: none; padding-top: 4px; }
.rv-head { margin-bottom: 4px; }
.rv-meta { font-size: 12px; margin-bottom: 6px; }
.rv-fields { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
.rv-fields-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 640px; }
.rv-fields label { font-size: 12px; color: var(--text-secondary); }
.rv-fields input, .rv-merge select { display: block; width: 100%; font: inherit; font-size: 13px; padding: 6px 8px; margin-top: 3px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-0); color: var(--text-primary); }
.rv-merge select { display: inline-block; width: auto; max-width: 280px; margin-top: 0; }
.rv-tr { font-size: 11px; margin-left: 4px; }
.rv-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rv-merge { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--critical); }
@media (max-width: 900px) { .rv-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } .rv-merge { margin-left: 0; } }
