:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #efeeea;
  --border: #dddcd6;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7973;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --danger: #c8322f;
  --good: #0a7f3f;
  --warning: #b86e00;
  --series-1: #2a78d6;  /* Infozorg */
  --series-2: #eb6834;  /* Direct */
  --series-3: #1baf7a;  /* Abonnementen */
  --grid: #e6e5e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #242422;
    --border: #34332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --accent: #3987e5;
    --danger: #e66767;
    --good: #3cbf6e;
    --warning: #e0a030;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --grid: #2c2b28;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 1rem; font-weight: 650; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .7rem; font-weight: 650; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.boot { padding: 3rem; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.hidden { display: none !important; }

/* ---------- formulieren */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: .5rem .65rem; min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--text-2); }
label.check { flex-direction: row; align-items: center; gap: .45rem; color: var(--text); font-size: .95rem; }
.btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: .5rem .9rem; cursor: pointer; white-space: nowrap;
}
a.btn { text-decoration: none; color: var(--text); display: inline-block; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: .25rem .55rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: .6rem; align-items: end; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.full { grid-column: 1 / -1; }
.error { color: var(--danger); font-size: .9rem; min-height: 1.2em; }

/* ---------- auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 2rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 1rem; }
.auth-card h1 { margin: 0; }
.auth-card .btn { width: 100%; padding: .65rem; }
.code-input { font-size: 1.6rem; letter-spacing: .35em; text-align: center; font-family: ui-monospace, Consolas, monospace; }
.qr { display: grid; place-items: center; background: #fff; border-radius: 8px; padding: .5rem; }
.qr svg { width: 200px; height: 200px; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; background: var(--surface-2);
  padding: .6rem; border-radius: 8px; text-align: center; word-break: break-all; user-select: all; }
.recovery { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; font-family: ui-monospace, Consolas, monospace;
  background: var(--surface-2); padding: .8rem; border-radius: 8px; }

/* ---------- layout */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.nav { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .7rem; display: flex;
  flex-direction: column; gap: .15rem; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; padding: .3rem .6rem 1rem; display: flex; align-items: center; gap: .5rem; }
.brand img { width: 22px; height: 22px; }
.nav a { color: var(--text-2); text-decoration: none; padding: .5rem .7rem; border-radius: 8px; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.nav .sep { height: 1px; background: var(--border); margin: .6rem .4rem; }
.nav .spacer { flex: 1; }
.nav .user { font-size: .85rem; color: var(--muted); padding: .3rem .7rem; }
.content { min-width: 0; }
main { padding: 1.5rem 2rem 4rem; max-width: 1200px; }

/* ---------- timerbalk */
.timerbar { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border);
  padding: .7rem 2rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.timerbar #t-desc { flex: 1 1 260px; font-size: 1rem; }
.timerbar select { max-width: 260px; }
.timerbar .elapsed { font-variant-numeric: tabular-nums; font-size: 1.25rem; font-weight: 600; min-width: 6.5ch; text-align: right; }
.timerbar.running { box-shadow: inset 4px 0 0 var(--accent); }
.timerbar .btn { min-width: 84px; }

/* ---------- kaarten & tabellen */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .grow { flex: 1; }
.period-nav { display: inline-flex; align-items: center; gap: .3rem; }
.period-nav .label { min-width: 10ch; text-align: center; font-weight: 600; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .55rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr.total td { font-weight: 650; border-top: 2px solid var(--border); border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
td.actions { white-space: nowrap; text-align: right; width: 1%; }
.tablewrap { overflow-x: auto; }

.day { margin-bottom: 1rem; }
.day-head { display: flex; justify-content: space-between; padding: .4rem .2rem; color: var(--text-2); font-weight: 600; font-size: .9rem; }
.entry { display: grid; grid-template-columns: 1fr auto auto auto auto; gap: .8rem; align-items: center;
  padding: .55rem .8rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.entry:first-of-type { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.entry:last-child { border-bottom: none; }
.entries { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.entry .desc { min-width: 0; }
.entry .desc .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .desc .meta { font-size: .82rem; color: var(--muted); display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; margin-top: .15rem; }
.entry .time { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.entry .dur { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 5ch; text-align: right; }

.badge { display: inline-block; font-size: .72rem; font-weight: 650; padding: .08rem .45rem; border-radius: 99px;
  border: 1px solid var(--border); color: var(--text-2); letter-spacing: .02em; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.infozorg { background: var(--series-1); }
.dot.direct { background: var(--series-2); }
.dot.abonnement { background: var(--series-3); }
.dot.eigen { background: var(--muted); }

/* ---------- KPI's */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.kpi .k { font-size: .8rem; color: var(--muted); }
.kpi .v { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: .25rem; }
.kpi .s { font-size: .8rem; color: var(--text-2); margin-top: .2rem; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.cols > .card + .card { margin-top: 0; }

/* ---------- verbruik */
.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; position: relative; }
.meter > span { display: block; height: 100%; background: var(--series-3); border-radius: 99px; }
.meter.over > span { background: var(--warning); }
.usage { display: grid; grid-template-columns: minmax(140px, 1.3fr) 2fr auto; gap: .9rem; align-items: center;
  padding: .55rem 0; border-bottom: 1px solid var(--border); }
.usage:last-child { border-bottom: none; }
.status-over { color: var(--warning); font-weight: 600; }

/* ---------- grafiek */
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--text-2); margin-bottom: .5rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: var(--text); fill-opacity: .04; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem; font-size: .85rem; box-shadow: 0 6px 24px rgba(0,0,0,.15); min-width: 180px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.tooltip .tt-row span:first-child { display: inline-flex; align-items: center; gap: .35rem; color: var(--text-2); }

/* ---------- modal & toast */
dialog { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text);
  padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog form { padding: 1.3rem 1.4rem; display: flex; flex-direction: column; gap: .9rem; }
dialog .foot { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .4rem; }
dialog .foot .left { margin-right: auto; }
#toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: .65rem 1rem; border-radius: 8px; font-size: .9rem; max-width: 380px; box-shadow: var(--shadow); }
.toast.err { background: var(--danger); color: #fff; }

.tabs { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tabs button { border: none; background: var(--surface); padding: .4rem .8rem; cursor: pointer; }
.tabs button.on { background: var(--surface-2); font-weight: 600; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--border); }
  .nav .spacer, .nav .sep { display: none; }
  main { padding: 1rem; }
  .timerbar { padding: .6rem 1rem; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .cols, .grid3 { grid-template-columns: 1fr; }
  .entry { grid-template-columns: 1fr auto auto; }
  .entry .time, .entry .rev { display: none; }
}
@media print {
  .nav, .timerbar, .toolbar .btn, td.actions { display: none !important; }
  .layout { display: block; }
  .card, .kpi { box-shadow: none; }
}
