:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --text: #23231f;
  --muted: #6b6b64;
  --faint: #94948c;
  --border: #e3e1d9;
  --border-strong: #cfcdc3;
  --accent: #185fa5;
  --accent-bg: #e6f1fb;
  --wouter: #534ab7;
  --faculteit: #1d9e75;
  --danger: #a32d2d;
  --ok: #3b6d11;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a18; --surface: #232320; --surface-2: #2c2c28;
    --text: #ececE6; --muted: #a5a49c; --faint: #77776f;
    --border: #38382f; --border-strong: #4a4a40;
    --accent: #7fb2ee; --accent-bg: #16324d;
    --wouter: #9a92f0; --faculteit: #63cba5;
    --danger: #e88; --ok: #a7cf6f;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3 { font-weight: 500; margin: 0; }
button { font-family: inherit; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 18px; }
.brand .sub { margin: 0; font-size: 12px; color: var(--faint); }
.dot { width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--wouter), var(--faculteit)); }
.save-state {
  font-size: 12px; color: var(--muted); padding: 4px 10px;
  border: 1px solid var(--border); border-radius: 20px; background: var(--surface-2);
}
.save-state.saving { color: var(--accent); }
.save-state.error { color: var(--danger); border-color: var(--danger); }
.topright { display: flex; align-items: center; gap: 8px; }
#undoBtn { display: none; font-size: 12px; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px; cursor: pointer; }
#undoBtn:hover { color: var(--text); border-color: var(--border-strong); }

.tabs {
  display: flex; gap: 4px; padding: 10px 16px 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 57px; z-index: 9; overflow-x: auto;
}
.tabs button {
  background: none; border: none; padding: 10px 14px; font-size: 14px;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

main { max-width: 860px; margin: 0 auto; padding: 20px 16px 80px; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 12px; margin-bottom: 22px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.card .label { font-size: 12px; color: var(--faint); display: flex; align-items: center; gap: 6px; }
.card .value { font-size: 26px; font-weight: 500; margin-top: 4px; }
.card .value small { font-size: 14px; color: var(--muted); font-weight: 400; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 20px; box-shadow: var(--shadow); }
.panel > h2 { font-size: 16px; margin-bottom: 4px; }
.panel .hint { font-size: 12px; color: var(--faint); margin: 0 0 14px; }

.swatch { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* month chart (pure CSS) */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart .stack { width: 100%; max-width: 34px; display: flex; flex-direction: column-reverse; justify-content: flex-start; height: 150px; }
.chart .seg { width: 100%; }
.chart .seg.w { background: var(--wouter); }
.chart .seg.f { background: var(--faculteit); }
.chart .seg.top { border-radius: 4px 4px 0 0; }
.chart .xlabel { font-size: 10px; color: var(--faint); white-space: nowrap; }
.legend { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], textarea, select {
  width: 100%; padding: 9px 11px; font-size: 14px; font-family: inherit;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
}
textarea { min-height: 72px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 120px; }

.btn { padding: 9px 14px; font-size: 14px; border-radius: var(--radius); cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }

/* client toggle */
.seg-toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.seg-toggle button { background: var(--surface); border: none; padding: 9px 14px; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg-toggle button + button { border-left: 1px solid var(--border); }
.seg-toggle button.on[data-c=wouter] { background: var(--wouter); color: #fff; }
.seg-toggle button.on[data-c=faculteit] { background: var(--faculteit); color: #fff; }

/* tag chips */
.tagpick { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); user-select: none; }
.chip.on { color: #fff; border-color: transparent; }
.tag-badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; color: #fff; white-space: nowrap; }

/* lists */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=text] { flex: 1; min-width: 160px; }
.filters select { width: auto; }

.entry { border-top: 1px solid var(--border); padding: 12px 0; display: flex; gap: 12px; }
.entry:first-child { border-top: none; }
.entry .meta { min-width: 96px; }
.entry .date { font-size: 13px; font-weight: 500; }
.entry .cli { font-size: 11px; }
.entry .cli.wouter { color: var(--wouter); }
.entry .cli.faculteit { color: var(--faculteit); }
.entry .body { flex: 1; min-width: 0; }
.entry .txt { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.entry .tags { margin-top: 6px; display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.entry .hrs { font-weight: 500; white-space: nowrap; }
.entry .actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.badge-guess { font-size: 10px; color: var(--faint); border: 1px dashed var(--border-strong); border-radius: 20px; padding: 1px 7px; cursor: help; }
.pill-entered { font-size: 11px; color: var(--ok); }
.mut { color: var(--muted); }
.faint { color: var(--faint); }

/* invoerhulp day rows */
.inv-day { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-top: 1px solid var(--border); cursor: pointer; }
.inv-day:first-child { border-top: none; }
.inv-day input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--accent); flex: 0 0 auto; }
.inv-main { font-size: 15px; }
.inv-split { margin-left: auto; font-size: 13px; color: var(--muted); }

table.months { width: 100%; border-collapse: collapse; font-size: 13px; }
table.months th, table.months td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.months th:first-child, table.months td:first-child { text-align: left; }
table.months th { color: var(--muted); font-weight: 500; }
table.months tr.tot td { font-weight: 500; border-top: 2px solid var(--border-strong); }
table.months tr.cur td { background: var(--surface-2); font-weight: 500; }
table.months th .swatch { margin-right: 5px; }
.panel .chart + .legend + table.months { margin-top: 18px; }

/* todos */
.todo-cols { display: flex; flex-direction: column; gap: 12px; }
.todo-group { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px 12px; box-shadow: var(--shadow); }
.todo-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.todo-group h3 { font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 9px; }
.todo-group h3 .swatch { width: 10px; height: 10px; flex: 0 0 auto; }
.cat-grip { opacity: 0; cursor: grab; color: var(--faint); font-size: 13px; line-height: 1; user-select: none; margin-right: -2px; }
.todo-group:hover .cat-grip { opacity: .5; }
.cat-del { opacity: 0; border: none; background: none; color: var(--faint); font-size: 17px; cursor: pointer; line-height: 1; padding: 0 2px; }
.todo-group:hover .cat-del { opacity: .6; }
.cat-del:hover { opacity: 1; color: var(--danger); }
.todo-list { min-height: 6px; }
.todo { display: flex; gap: 10px; align-items: flex-start; padding: 7px 2px; border-radius: 6px; }
.todo .grip { opacity: 0; cursor: grab; color: var(--faint); font-size: 12px; line-height: 1.7; user-select: none; }
.todo:hover .grip { opacity: .55; }
.todo input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; flex: 0 0 auto; cursor: pointer; }
.todo .t { flex: 1; font-size: 15px; line-height: 1.5; word-break: break-word; cursor: text; }
.todo.done .t { color: var(--faint); text-decoration: line-through; }
.cat-label { cursor: text; }
.inline-edit { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--accent, #534ab7); border-radius: 6px; padding: 2px 6px; margin: -3px 0; flex: 1; min-width: 60px; }
.inline-edit:focus { outline: none; }
.todo.done .grip { visibility: hidden; }
.todo .x { opacity: 0; cursor: pointer; color: var(--faint); border: none; background: none; font-size: 16px; line-height: 1; }
.todo:hover .x { opacity: .6; }
.todo .x:hover { opacity: 1; color: var(--danger); }
.todo-add { width: 100%; border: none; background: none; padding: 8px 2px 2px; font-size: 15px; color: var(--text); border-radius: 0; margin-top: 4px; }
.todo-add:focus { outline: none; box-shadow: none; }
.todo-add::placeholder { color: var(--faint); }
.addcat-wrap { margin-top: 12px; }
.todo-group.addcat { border-style: dashed; box-shadow: none; display: flex; align-items: center; padding: 12px 16px; }
.todo-group.addcat input { width: 100%; border: none; background: none; font-size: 15px; color: var(--text); padding: 4px 2px; }
.todo-group.addcat input:focus { outline: none; box-shadow: none; }
.todo-group.addcat input::placeholder { color: var(--faint); }

/* drag (SortableJS) */
.drag-ghost { opacity: .35; }
.todo.drag-ghost { background: var(--surface-2); }
.todo-group.drag-ghost { background: var(--surface-2); border-style: dashed; }
.drag-chosen { cursor: grabbing; }
.todo-group.drag-active, .todo.drag-active { box-shadow: 0 6px 20px rgba(0,0,0,.18); }

.empty { color: var(--faint); font-size: 14px; padding: 20px 0; text-align: center; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 20px; font-size: 13px;
  opacity: 0; transition: .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
