:root {
  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --ink: #1F1D1A;
  --muted: #6B665D;
  --line: #E3DED3;
  --accent: #D9482B;
  --accent-ink: #FFFFFF;
  --werk: #2563C9;
  --zzp: #B26A00;
  --prive: #23794A;
  --danger: #B3261E;
  --note-bg: #FFF1CC;
  --note-ink: #5B4300;
  --radius: 12px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #22201D;
    --ink: #EDE9E1;
    --muted: #A8A297;
    --line: #37342F;
    --accent: #F0683F;
    --accent-ink: #1A0E0A;
    --werk: #7FB0FF;
    --zzp: #EDB04C;
    --prive: #6FCF9A;
    --danger: #FF8A80;
    --note-bg: #3A3118;
    --note-ink: #F3DFA3;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 16px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior-y: none;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.7rem; letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
h3 { font-size: 1rem; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.boot { padding: 48px 24px; text-align: center; color: var(--muted); }

/* ---------- indeling ---------- */

.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100dvh; }

.nav {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 2px;
  padding: 20px 12px;
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 1.1rem; }
.brand img { width: 28px; height: 28px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.nav a[aria-current="page"] .ic { color: var(--accent); }
.count {
  margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 99px;
  background: var(--accent); color: var(--accent-ink); font-size: 0.75rem; font-weight: 700; text-align: center;
}

.main { width: 100%; max-width: 780px; padding: 32px clamp(16px, 4vw, 44px) 80px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.head .sub { color: var(--muted); margin-top: 2px; }
.section { margin-top: 26px; }
.section > h2 { margin-bottom: 8px; padding: 0 2px; display: flex; align-items: center; gap: 8px; }
.section > h2.late { color: var(--danger); }

@media (max-width: 760px) {
  .shell { display: block; }
  .nav {
    position: fixed; inset: auto 0 0 0; height: auto; z-index: 5;
    flex-direction: row; justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-right: 0; border-top: 1px solid var(--line);
  }
  .brand { display: none; }
  .nav a { position: relative; flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 0.7rem; min-width: 0; }
  .nav a[aria-current="page"] { background: none; box-shadow: none; }
  .nav a .count { position: absolute; top: 0; left: 52%; min-width: 18px; padding: 0 5px; font-size: 0.65rem; }
  .main { padding: calc(20px + env(safe-area-inset-top)) 16px calc(110px + env(safe-area-inset-bottom)); }
  .item.proposal { flex-wrap: wrap; }
  .item.proposal .body { flex-basis: 100%; }
  .item.proposal .side { justify-content: flex-start; }
  h1 { font-size: 1.45rem; }
}

/* ---------- knoppen en velden ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-weight: 600; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: 0.875rem; }
.btn:disabled { opacity: 0.5; cursor: default; }

input[type="text"], input[type="password"], input[type="url"], input[type="email"], input[type="date"],
input[type="time"], input[type="datetime-local"], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface);
}
textarea { resize: vertical; min-height: 84px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--accent); }

.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; min-height: 42px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.form { display: grid; gap: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions .spacer { flex: 1; }

/* ---------- snel toevoegen ---------- */

.quick {
  display: flex; gap: 8px; align-items: center;
  padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
}
.quick:focus-within { border-color: var(--accent); }
.quick input[type="text"] { flex: 1; min-width: 0; border: 0; background: none; outline: none; }
.quick select { width: auto; min-height: 36px; padding: 4px 8px; border-radius: 8px; background: var(--bg); }
.quick .btn { min-height: 36px; padding: 6px 12px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 14px; border: 1px solid var(--line); border-radius: 99px;
  background: none; font-size: 0.875rem; font-weight: 600; color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ---------- lijsten ---------- */

.list { margin: 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .body { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0; }
.item .title { display: block; overflow-wrap: anywhere; }
.item .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; font-size: 0.8125rem; color: var(--muted); }
.item .meta .late { color: var(--danger); font-weight: 600; }
.item.done .title { text-decoration: line-through; color: var(--muted); }
.item .side { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.tick {
  width: 24px; height: 24px; margin-top: 1px; flex: none; padding: 0;
  display: grid; place-items: center;
  border: 2px solid var(--muted); border-radius: 50%; background: none; color: transparent;
}
.tick:hover { border-color: var(--accent); color: var(--accent); }
.tick .ic { width: 14px; height: 14px; stroke-width: 3; }
.item.done .tick { background: var(--muted); color: var(--surface); }
.item.prio .tick { border-color: var(--accent); }

.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tag.werk { color: var(--werk); }
.tag.zzp { color: var(--zzp); }
.tag.prive { color: var(--prive); }
.tag.alle { color: var(--muted); }
.flag { color: var(--accent); font-weight: 700; }

.empty { padding: 28px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

.note {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--note-bg); color: var(--note-ink); margin-bottom: 16px;
}
.note strong { font-weight: 700; }

.time { flex: none; width: 92px; font-variant-numeric: tabular-nums; font-size: 0.875rem; color: var(--muted); padding-top: 1px; }
.day-head { display: flex; align-items: baseline; gap: 8px; }
.day-head.today { color: var(--accent); }

/* ---------- kaarten (instellingen, afwezig) ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.card p { color: var(--muted); font-size: 0.9rem; }
.copy { display: flex; gap: 8px; }
.copy input { font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem; }
.status { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status.on::before { background: var(--prive); }
ol.steps { margin: 0; padding-left: 20px; color: var(--muted); font-size: 0.9rem; display: grid; gap: 4px; }

/* ---------- venster, login, melding ---------- */

dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 20px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--bg); color: var(--ink);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h3 { font-size: 1.15rem; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login form { width: min(380px, 100%); display: grid; gap: 14px; text-align: center; }
.login img { width: 64px; height: 64px; margin: 0 auto; }
.login input { text-align: center; letter-spacing: 0.12em; font-size: 1.1rem; text-transform: uppercase; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: 0.9rem;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 20;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}
