:root {
  /* logokleuren: marineblauw #062F4D, oranje #F68D2D */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #edf1f5;
  --text: #0d1f2e;
  --muted: #5a6b7b;
  --border: #d9e1e8;
  --primary: #062f4d;
  --primary-strong: #041f33;
  --primary-soft: #e4ecf3;
  --on-primary: #ffffff;
  --accent: #f68d2d;
  --accent-strong: #b85d0c;
  --accent-soft: #fef0e2;
  --on-accent: #062f4d;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #1e7b4f;
  --bar: #f68d2d;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #04192a;
    --surface: #0a2438;
    --surface-2: #123049;
    --text: #e8eef4;
    --muted: #9bb0c3;
    --border: #1d3b55;
    --primary: #f68d2d;
    --primary-strong: #f9a95f;
    --primary-soft: #3a2a1c;
    --on-primary: #062f4d;
    --accent: #f68d2d;
    --accent-strong: #f9a95f;
    --accent-soft: #3a2a1c;
    --on-accent: #062f4d;
    --danger: #f27a6e;
    --danger-soft: #3a1f1d;
    --ok: #5cc493;
    --bar: #f68d2d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }

/* ---------- Topbar & navigatie ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--primary); }
.brand img { display: block; width: 34px; height: 33px; }
@media (prefers-color-scheme: dark) { .brand { color: var(--text); } }
.tabs { display: none; gap: 4px; flex: 1; }
.tabs a, .bottomnav a {
  color: var(--muted); text-decoration: none; border-radius: 8px;
}
.tabs a { padding: 6px 12px; font-weight: 500; }
.tabs a:hover { background: var(--surface-2); color: var(--text); }
.tabs a.active { background: var(--primary-soft); color: var(--primary-strong); box-shadow: inset 0 -2px 0 var(--accent); }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--muted); min-width: 0; }
.user .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.user a { color: var(--primary); text-decoration: none; white-space: nowrap; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav:empty { display: none; }
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 2px; font-size: .72rem;
}
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a.active { color: var(--primary); font-weight: 600; }
.bottomnav a.active svg { color: var(--accent); }

@media (min-width: 800px) {
  body { padding-bottom: 24px; }
  .tabs { display: flex; }
  .bottomnav { display: none; }
}

/* ---------- Layout ---------- */
.main { max-width: 960px; margin: 0 auto; padding: var(--gutter); }
.loading, .empty { color: var(--muted); padding: 32px 0; text-align: center; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card h2 { margin-bottom: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Maand-navigatie & totaal ---------- */
.monthnav { display: flex; align-items: center; gap: 6px; }
.monthnav .label { min-width: 150px; text-align: center; font-weight: 600; }
.total { display: flex; align-items: baseline; gap: 8px; }
.total .big { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Projectsamenvatting ---------- */
.proj { padding: 6px 0; border-top: 1px solid var(--border); font-size: .9rem; }
.proj:first-of-type { border-top: 0; }
.proj-line { display: flex; justify-content: space-between; gap: 12px; }
.proj-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-name .klant { color: var(--muted); }
.proj-hours { font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--bar); border-radius: 2px; }

/* ---------- Registraties ---------- */
.day { margin-top: 14px; }
.day:first-child { margin-top: 0; }
.day-head { display: flex; justify-content: space-between; font-size: .9rem; color: var(--text); font-weight: 700; padding: 0 2px 6px; }
.entry {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%;
  text-align: left; background: var(--surface-2); border: 0; border-radius: 10px;
  padding: 8px 12px; margin-bottom: 6px; cursor: pointer; font-size: .9rem;
}
.entry:hover { outline: 1px solid var(--border); }
.entry .t { font-weight: 400; }
.entry .s { color: var(--muted); overflow-wrap: anywhere; }
.entry .h { font-weight: 400; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Lijsten (beheer) ---------- */
.list { display: flex; flex-direction: column; gap: 6px; }
.item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%;
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; cursor: pointer;
}
.item:hover { border-color: var(--primary); }
.item .t { font-weight: 550; overflow-wrap: anywhere; }
.item .s { font-size: .82rem; color: var(--muted); }
.badge {
  display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.admin { background: var(--accent-soft); color: var(--accent-strong); }
.badge.off { background: var(--danger-soft); color: var(--danger); }

/* ---------- Knoppen ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 550; text-decoration: none;
  min-height: 40px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-strong); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.icon { padding: 8px; min-width: 40px; }
.btn:disabled { opacity: .55; cursor: default; }

.fab {
  position: fixed; right: var(--gutter); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 11;
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--on-accent); font-weight: 700; box-shadow: 0 4px 12px rgba(0,0,0,.25);
  font-size: 28px; line-height: 1; cursor: pointer;
}
@media (min-width: 800px) { .fab { display: none; } }
.desktop-only { display: none; }
@media (min-width: 800px) { .desktop-only { display: inline-flex; } }

/* ---------- Formulieren ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 10px 12px; min-height: 44px;
}
textarea.input { min-height: 72px; resize: vertical; }
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-weight: 500; }
.check input { width: 20px; height: 20px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 99px;
  padding: 4px 12px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.chip:hover { border-color: var(--accent); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .input { width: auto; flex: 1 1 180px; }
.error { color: var(--danger); font-size: .9rem; margin: 0 0 10px; }

/* ---------- Dialoog ---------- */
.dialog {
  border: 0; padding: 0; border-radius: 16px; width: min(520px, calc(100vw - 2 * var(--gutter)));
  background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.3);
  max-height: calc(100dvh - 32px);
}
.dialog::backdrop { background: rgba(10, 16, 22, .45); }
.dialog form { padding: 18px; }
.dialog h2 { margin-bottom: 14px; font-size: 1.15rem; }
.dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }
.dialog .actions .spacer { flex: 1; }
@media (max-width: 520px) {
  .dialog { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 16px 16px 0 0; }
  .dialog form { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; }
@media (min-width: 800px) { .toast { bottom: 32px; } }

.notice { max-width: 460px; margin: 48px auto; text-align: center; }
.notice p { color: var(--muted); }

/* ---------- Meerdere dagen ---------- */
[hidden] { display: none !important; }
.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 12px;
  background: var(--surface-2); border-radius: 10px;
}
.seg button {
  border: 0; background: transparent; border-radius: 8px; padding: 8px; cursor: pointer;
  font-weight: 550; color: var(--muted); min-height: 38px;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.weekdagen { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wd {
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  min-height: 40px; cursor: pointer; font-weight: 600; color: var(--muted);
}
.wd[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.voorbeeld { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 12px; }
.voorbeeld-kop { font-size: .9rem; margin-bottom: 8px; }
.dagen {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px;
  max-height: 210px; overflow-y: auto;
}
.dag {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: var(--surface-2); border-radius: 8px; padding: 6px 8px; font-size: .85rem; cursor: pointer;
}
.dag input { margin: 0; accent-color: var(--accent); }
.dag small { flex-basis: 100%; color: var(--muted); font-size: .72rem; margin-top: -2px; padding-left: 22px; }
.dag.uit { opacity: .6; }
.dag:has(input:disabled) { cursor: default; }

/* dag met minder dan 8 u (Mijn uren) */
.day-head.onder { color: var(--bar); }
