/* TR.AI.N.-huisstijl, afgeleid van de Canva-presentatie: blush-wit, roest-oranje, bijna-zwart.
   Eén lettertype (Archivo, variabel in breedte): breed voor titels, smal en vet voor kopjes in hoofdletters. */
@font-face {
  font-family: 'Archivo'; src: url('/fonts/archivo.woff2') format('woff2');
  font-weight: 100 900; font-stretch: 62% 125%; font-display: swap;
}

:root {
  --paper: #fff8f6; --panel: #ffffff; --panel-2: #fbf1ee; --ink: #1c0c06; --ink-2: #4a3a33; --muted: #7a6a63; --line: #efe2dd; --line-2: #e2d2cc;
  --rust: #c3542b; --rust-hover: #a9461f; --rust-ink: #ffffff; --rust-wash: #fbe6de;
  --night: #121212; --night-2: #1e1b1a; --night-ink: #f4ece8; --night-muted: #9b8f8a;
  --s-uit: #c3542b; --s-in: #1f72a3;
  --ok: #1f6b45; --ok-bg: #e3f2e9; --warn: #8a5300; --warn-bg: #fdf0d9; --bad: #a3271f; --bad-bg: #fbe5e3;
  --shadow: 0 1px 2px rgba(28, 12, 6, .04), 0 8px 24px -12px rgba(28, 12, 6, .10);
  --r: 6px; --side: 248px;
  color-scheme: light;
  font-family: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 15px; line-height: 1.5; color: var(--ink);
  font-stretch: 100%;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121212; --panel: #1b1716; --panel-2: #231e1c; --ink: #f4ece8; --ink-2: #d2c5bf; --muted: #a3958f; --line: #2c2523; --line-2: #3a312e;
    --rust: #e06a3d; --rust-hover: #ec7d52; --rust-ink: #1c0c06; --rust-wash: #3a2219;
    --night: #0b0b0b; --night-2: #1a1716;
    --s-uit: #e06a3d; --s-in: #3d96d6;
    --ok: #7fcf9f; --ok-bg: #16301f; --warn: #f0b45a; --warn-bg: #3a2c12; --bad: #f2948a; --bad-bg: #3b1a17;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121212; --panel: #1b1716; --panel-2: #231e1c; --ink: #f4ece8; --ink-2: #d2c5bf; --muted: #a3958f; --line: #2c2523; --line-2: #3a312e;
  --rust: #e06a3d; --rust-hover: #ec7d52; --rust-ink: #1c0c06; --rust-wash: #3a2219;
  --night: #0b0b0b; --night-2: #1a1716;
  --s-uit: #e06a3d; --s-in: #3d96d6;
  --ok: #7fcf9f; --ok-bg: #16301f; --warn: #f0b45a; --warn-bg: #3a2c12; --bad: #f2948a; --bad-bg: #3b1a17;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--rust); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; border-radius: 3px; }

/* ---------- zijbalk ---------- */
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--night); color: var(--night-ink); display: flex; flex-direction: column; z-index: 20; }
.side-head { display: flex; align-items: center; padding: 26px 24px 18px; }
.brand { color: var(--rust); font-weight: 800; font-stretch: 75%; font-size: 21px; letter-spacing: .06em; text-transform: uppercase; display: flex; flex-direction: column; line-height: 1.1; }
.brand:hover { text-decoration: none; }
.brand span { color: var(--night-muted); font-weight: 500; font-stretch: 100%; font-size: 12px; letter-spacing: .02em; text-transform: none; margin-top: 4px; }
.side-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.side nav { flex: 1; overflow-y: auto; padding: 0 12px 16px; }
.nav-group { margin: 18px 12px 6px; font-size: 11px; font-weight: 700; font-stretch: 75%; letter-spacing: .12em; text-transform: uppercase; color: var(--night-muted); }
.side nav a { display: block; position: relative; padding: 7px 12px; border-radius: 4px; color: #d9cfca; font-size: 14.5px; }
.side nav a:hover { background: var(--night-2); color: #fff; text-decoration: none; }
.side nav a.active { background: var(--night-2); color: #fff; font-weight: 600; }
.side nav a.active::before { content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 2px; background: var(--rust); }
.side-foot { border-top: 1px solid #2a2523; padding: 14px 20px 18px; display: grid; gap: 10px; }
.side .user { color: var(--night-muted); font-size: 12px; display: grid; gap: 4px; }
.side .user select { background: var(--night-2); color: var(--night-ink); border-color: #332c29; font-size: 13px; }
.side-actions { display: flex; gap: 6px; }
button.ghost { background: transparent; color: #d9cfca; border: 1px solid #332c29; padding: 5px 10px; font-size: 12.5px; }
button.ghost:hover, .menu-toggle:hover { background: var(--night-2); color: #fff; }
.menu-toggle { display: none; margin-left: auto; background: none; border: 1px solid #332c29; border-radius: 4px; padding: 9px 8px; width: 40px; flex-direction: column; align-items: stretch; gap: 4px; }
.menu-toggle span { display: block; height: 2px; background: var(--night-ink); border-radius: 1px; }

/* ---------- pagina ---------- */
.page { margin-left: var(--side); min-height: 100vh; border-top: 6px solid var(--rust); }
main { max-width: 1240px; margin: 0 auto; padding: 40px 40px 80px; }
h1 { font-size: 38px; font-weight: 400; font-stretch: 112%; letter-spacing: -.015em; line-height: 1.1; margin: 0 0 10px; }
h2 { font-size: 13px; font-weight: 700; font-stretch: 75%; letter-spacing: .1em; text-transform: uppercase; margin: 36px 0 12px; color: var(--ink); }
h3 { font-size: 15px; font-weight: 650; margin: 0 0 10px; }
.sub { color: var(--ink-2); margin: 0 0 28px; max-width: 72ch; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list.card { padding: 4px 20px; }
details > summary { cursor: pointer; color: var(--ink-2); margin-top: 8px; }
details[open] > summary { margin-bottom: 10px; }
pre.msg { white-space: pre-wrap; background: var(--panel-2); padding: 14px 16px; border-radius: 4px; font-family: inherit; margin: 10px 0; border-left: 3px solid var(--rust); }

/* ---------- tabellen ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
.table-wrap > table { border: 0; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; font-weight: 700; font-stretch: 75%; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); background: var(--panel-2); position: sticky; top: 0; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--ink); }
th[aria-sort="descending"]::after { content: ' ↓'; color: var(--rust); }
th[aria-sort="ascending"]::after { content: ' ↑'; color: var(--rust); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .12s; }
tbody tr:hover { background: var(--panel-2); }
td a { color: var(--ink); font-weight: 600; }
td a:hover { color: var(--rust); }

/* ---------- labels ---------- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; line-height: 1.5; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; vertical-align: 1px; }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.demo { background: transparent; border: 1px dashed var(--line-2); color: var(--muted); font-size: 11px; }

/* ---------- knoppen en velden ---------- */
button, .btn { display: inline-flex; align-items: center; gap: 6px; background: var(--rust); color: var(--rust-ink); border: 1px solid transparent; border-radius: 4px; padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: background-color .12s, border-color .12s, color .12s; }
button:hover, .btn:hover { background: var(--rust-hover); text-decoration: none; }
button.secondary { background: var(--panel); color: var(--ink); border-color: var(--line-2); font-weight: 500; }
button.secondary:hover { border-color: var(--ink-2); background: var(--panel); }
button.danger { background: var(--bad); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea { font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--panel); color: var(--ink); width: 100%; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--rust); box-shadow: 0 0 0 3px var(--rust-wash); }
input[type="checkbox"] { accent-color: var(--rust); width: auto; }
textarea { min-height: 120px; }
label.f { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label.f > input, label.f > select, label.f > textarea { margin-top: 4px; color: var(--ink); }

/* ---------- meldingen ---------- */
.banner { background: var(--warn-bg); color: var(--warn); padding: 10px 40px; font-weight: 600; }
.toast { position: fixed; bottom: 24px; left: calc(50% + var(--side) / 2); transform: translateX(-50%); background: var(--night); color: var(--night-ink); padding: 12px 18px; border-radius: 4px; border-left: 3px solid var(--rust); max-width: min(560px, 90vw); z-index: 30; box-shadow: 0 12px 32px -12px rgba(0, 0, 0, .5); animation: toast-in .18s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- kansenbord ---------- */
.funnel { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.funnel .col { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; min-height: 140px; }
.funnel .col h4 { margin: 0 0 10px; font-size: 11px; font-weight: 700; font-stretch: 75%; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.mini { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 10px; margin-bottom: 8px; font-size: 13px; box-shadow: var(--shadow); }

/* ---------- overzicht: cijfers en grafieken ---------- */
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.live.loading::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head-row .sub { margin-bottom: 28px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi .k-label { font-size: 13px; color: var(--muted); }
.kpi .k-value { font-size: 34px; font-weight: 500; font-stretch: 112%; letter-spacing: -.01em; line-height: 1.15; margin: 6px 0 4px; }
.kpi .k-note { font-size: 12.5px; color: var(--ink-2); }
.kpi .up { color: var(--ok); } .kpi .down { color: var(--bad); }
.charts { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.charts .wide { grid-column: 1 / -1; }
.chart-card { min-width: 0; }
.chart-card .c-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-card .c-head h3 { margin: 0; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .axis-t { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .val-t { fill: var(--ink-2); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .cat-t { fill: var(--ink-2); font-size: 12.5px; }
.chart .mark { transition: opacity .15s; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .mark, .chart g.on .mark { opacity: .78; }
.chart.loading { opacity: .55; }
.tip { position: fixed; z-index: 40; pointer-events: none; background: var(--night); color: var(--night-ink); border-radius: 4px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 8px 24px -8px rgba(0, 0, 0, .5); min-width: 120px; }
.tip .t-h { color: var(--night-muted); margin-bottom: 4px; }
.tip .t-r { display: flex; align-items: center; gap: 8px; }
.tip .t-r b { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2ch; }
.tip .t-r i { width: 12px; height: 2px; border-radius: 1px; display: inline-block; }

/* segmentbalk boven de pipeline: elk deel is ook een filter */
.segbar { display: flex; gap: 2px; height: 28px; margin: 4px 0 14px; }
.segbar button { flex: var(--n) 1 0; min-width: 0; padding: 0 8px; border-radius: 4px; border: 0; font-size: 12px; font-weight: 700; justify-content: flex-start; overflow: hidden; white-space: nowrap; color: #fff; }
.segbar button[data-c="none"] { background: #8c7d77; }
.segbar button[data-c="warn"] { background: #b7791f; color: #1c0c06; }
.segbar button[data-c="bad"] { background: #b3402f; }
.segbar button[data-c="ok"] { background: #2f7d55; }
.segbar button[data-c="stop"] { background: #4a3a33; }
.segbar button.dim { opacity: .35; }
.segbar button:hover { filter: brightness(1.08); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- tablet en telefoon ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .side { position: sticky; top: 0; inset: auto; width: auto; height: auto; }
  .side-head { padding: 12px 16px; }
  .brand { flex-direction: row; align-items: baseline; gap: 10px; font-size: 19px; }
  .brand span { margin: 0; }
  .menu-toggle { display: flex; }
  .side-body { display: none; max-height: calc(100vh - 64px); overflow-y: auto; }
  .side-body.open { display: flex; }
  .side nav { columns: 2; column-gap: 8px; padding-bottom: 8px; }
  .nav-group { break-after: avoid; }
  .side nav a { break-inside: avoid; }
  .page { margin-left: 0; border-top-width: 4px; }
  main { padding: 24px 16px 64px; }
  h1 { font-size: 30px; }
  .banner { padding: 10px 16px; }
  .toast { left: 50%; bottom: 16px; }
  th.hide-sm, td.hide-sm { display: none; }
  .grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .k-value { font-size: 26px; }
  .side nav { columns: 1; }
}
.eval { max-width: 560px; }
.scores { border: 0; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.scores legend { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.scores label { position: relative; }
.scores input { position: absolute; opacity: 0; }
.scores span { display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.scores input:checked + span { background: var(--rust); color: var(--rust-ink); border-color: var(--rust); }
.scores input:focus-visible + span { outline: 2px solid var(--rust); outline-offset: 2px; }
label.check { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
label.check input { width: auto; margin-top: 3px; }
.qr { background: #fff; display: inline-block; padding: 8px; border-radius: 8px; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--rust); }
a.btn { display: inline-block; text-decoration: none; }
a.btn.secondary { background: var(--panel); color: var(--ink); border-color: var(--line-2); font-weight: 500; }
a.btn.secondary:hover { border-color: var(--ink-2); background: var(--panel); }
.btn.small { padding: 4px 10px; font-size: 13px; }
