:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7686;
  --line: #dde3ea;
  --brand: #1f4e79;
  --brand-ink: #ffffff;
  --accent: #f8cbad;
  --work: #dbe8f6;
  --home: #e6eef0;
  --holiday: #fbe3d3;
  --vacation: #e3f1dc;
  --sick: #f7dede;
  --error: #b42318;
  --ok: #217a3c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --card: #1b2129;
    --text: #e7ecf2;
    --muted: #93a0b0;
    --line: #2c3540;
    --brand: #5b9bd5;
    --brand-ink: #0d1520;
    --accent: #8a5a3c;
    --work: #1f3248;
    --home: #26323a;
    --holiday: #4a3326;
    --vacation: #24392a;
    --sick: #472828;
    --error: #ff8a80;
    --ok: #7bd389;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: env(safe-area-inset-bottom); }
button, input, select { font: inherit; color: inherit; }
h1 { font-size: 1.3rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 .6rem; }
.card h2:first-child { margin-top: 0; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--brand); color: var(--brand-ink);
}
.topbar nav { display: flex; gap: 4px; }
.topbar nav button {
  background: transparent; border: 0; color: inherit; opacity: .75;
  padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: .9rem;
}
.topbar nav button.active { opacity: 1; background: rgba(255,255,255,.18); }

main { max-width: 760px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 380px; margin: 40px auto; }
label { display: block; margin: 0 0 12px; font-size: .9rem; color: var(--muted); }
label input, label select { display: block; width: 100%; margin-top: 4px; }
input, select {
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; padding: 10px 12px 0; }
legend { font-size: .9rem; color: var(--muted); padding: 0 4px; }
button {
  padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); cursor: pointer;
}
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button:disabled { opacity: .5; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.span2 { grid-column: span 2; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--error); min-height: 1em; }
.ok { color: var(--ok); min-height: 1em; margin: 8px 0 0; }

.monthbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.monthbar h1 { text-transform: capitalize; }
.monthbar button { font-size: 1.4rem; line-height: 1; padding: 4px 14px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.stats span { display: block; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats small { color: var(--muted); font-size: .75rem; }
.actions { display: flex; gap: 8px; }
.actions .primary { flex: 1; }

.days { list-style: none; margin: 0; padding: 0; }
.days li {
  display: grid; grid-template-columns: 2.6rem 1fr auto auto; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: 8px; margin-bottom: 4px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line);
}
.days li.weekend { opacity: .55; }
.days li.t-gewerkt { background: var(--work); }
.days li.t-thuis { background: var(--home); }
.days li.t-feestdag { background: var(--holiday); }
.days li.t-vakantie { background: var(--vacation); }
.days li.t-ziek { background: var(--sick); }
.days li.edited { box-shadow: inset 4px 0 0 var(--brand); }
.days .d { font-weight: 700; font-variant-numeric: tabular-nums; }
.days .d small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; }
.days .what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.days .what small { color: var(--muted); }
.days .h, .days .km { font-variant-numeric: tabular-nums; text-align: right; min-width: 3.2rem; }
.days .km { font-weight: 600; }

.list { list-style: none; padding: 0; margin: 0 0 16px; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.weekgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.weekgrid label { text-align: center; margin: 0; }
.weekgrid input { text-align: center; padding: 8px 2px; }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 18px; width: min(420px, calc(100vw - 32px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin-top: 0; text-transform: capitalize; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; }
.dlg-actions #day-reset { margin-right: auto; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: calc(100vw - 32px);
}

@media (max-width: 520px) {
  .topbar strong { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}
.rate { display: grid; grid-template-columns: 5.5rem 1fr auto; gap: 8px; margin-bottom: 8px; }
.rate button { padding: 6px 10px; }
.rate input { width: 100%; min-width: 0; }
fieldset { min-width: 0; }
[hidden] { display: none !important; }
a { color: var(--brand); }
.filebtn { display: inline-block; margin: 8px 0 0 8px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); cursor: pointer; }
.filebtn input { display: none; }
