:root {
  --bg: #f7f1e8;
  --surface: #fffdf9;
  --text: #2b211c;
  --muted: #7a6a5f;
  --line: #e4d8c9;
  --brand: #7a2e22;
  --brand-ink: #ffffff;
  --accent: #c8902e;
  --ok-bg: #e7f2ea;
  --ok-text: #24563a;
  --err-bg: #f9e3df;
  --err-text: #8f2a1b;
  --info-bg: #f2ebdf;
  --radius: 12px;
  --tabs-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1714;
    --surface: #26201c;
    --text: #f1e8de;
    --muted: #b3a294;
    --line: #3d332d;
    --brand: #c4614d;
    --brand-ink: #1c1714;
    --accent: #e0aa4c;
    --ok-bg: #1f3428;
    --ok-text: #a6d9b6;
    --err-bg: #43231d;
    --err-text: #f4b3a6;
    --info-bg: #2f2822;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* Geen vertraging of zoom bij dubbel tikken op knoppen. */
button, .btn, input, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
/* Zichtbare reactie: hover alleen met een muis, :active ook bij tikken. */
@media (hover: hover) {
  .btn:not(:disabled):hover, .chip:not(:disabled):hover, .wd:hover, .seg button:hover, button.week-row:hover {
    border-color: var(--muted);
    background-color: color-mix(in srgb, var(--text) 6%, var(--surface));
  }
  .btn.primary:not(:disabled):hover, .seg button.on:hover { background-color: color-mix(in srgb, var(--brand) 85%, var(--text)); }
  .btn.link:hover { background: none; text-decoration: underline; }
  .tabs button:hover { color: var(--text); }
}
.btn:not(:disabled):active, .chip:not(:disabled):active, .wd:active, .tabs button:active, button.week-row:active { opacity: 0.7; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; margin-top: 20px; }
p { margin: 0 0 12px; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.center-text { text-align: center; }
.invisible { visibility: hidden; }

/* ---------- opbouw ---------- */
#app { min-height: 100vh; min-height: 100dvh; }

.test-banner {
  background: #f2c94c;
  color: #3a2d00;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 16px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 14px 16px 6px;
  max-width: 760px;
  margin: 0 auto;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--brand); letter-spacing: 0.02em; }
.who { color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 16px calc(var(--tabs-h) + 32px + env(safe-area-inset-bottom));
}

main.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-top: 8vh;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
  /* Even breed als de inhoud, ook op een groot scherm. */
  max-width: 760px;
  margin: 0 auto;
}
@media (min-width: 761px) {
  .tabs { border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
}
.tabs button {
  flex: 1;
  height: var(--tabs-h);
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.tabs button.on { color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 16px;
}

/* ---------- formulieren ---------- */
label { display: block; font-weight: 600; font-size: 0.9rem; margin: 10px 0 4px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
  max-width: 100%;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input[type="color"] { padding: 4px; width: 64px; }
form input:not([type="checkbox"]):not([type="color"]), form select { width: 100%; }

.login { width: 100%; max-width: 380px; }
.brand-big { color: var(--brand); text-align: center; font-size: 2rem; margin-bottom: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.wide { width: 100%; margin-top: 16px; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: 0.875rem; }
.btn.icon { width: 44px; padding: 0; font-size: 1.4rem; }
.btn.icon.small { width: 36px; font-size: 1rem; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 4px 0; min-height: 0; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button {
  border: 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 8px 16px;
  min-height: 40px;
  cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand); color: var(--brand-ink); }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; align-items: flex-end; }
.row input { flex: 1; min-width: 0; }
.field { margin-bottom: 4px; }
.sub-form { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 4px; }
.sub-form .row { margin-top: 12px; }

.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 0; margin-top: 2px; flex: none; }

.msg { border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.msg-error { background: var(--err-bg); color: var(--err-text); }
.msg-ok { background: var(--ok-bg); color: var(--ok-text); }
.msg-info { background: var(--info-bg); }

.credentials dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.credentials dt { font-weight: 600; }
.credentials dd { margin: 0; font-size: 1.1rem; word-break: break-all; }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 8px;
  margin-left: 6px;
  border-radius: 99px;
  background: var(--info-bg);
  color: var(--muted);
  vertical-align: middle;
}
.badge.warn { background: var(--err-bg); color: var(--err-text); }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--act, var(--muted));
  margin-right: 6px;
}

/* ---------- invullen ---------- */
.day-head { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 16px; }
.date-nav { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 460px; }
.date-label { flex: 1; text-align: center; display: flex; flex-direction: column; }
.today-link { margin-left: 10px; font-size: inherit; }
.top { align-items: center; }
.who-select { min-height: 36px; padding: 4px 8px; font-size: 0.9rem; }

/* Telefoon: datumkop compact, zodat de tijdlijn de ruimte krijgt. */
@media (max-width: 600px) {
  .day-head { gap: 6px; margin-bottom: 10px; }
  .day-head .btn.icon { width: 36px; min-height: 36px; font-size: 1.2rem; }
  .day-head .date-label { line-height: 1.2; }
  .day-head .date-label strong { font-size: 0.95rem; }
  .day-head .date-label .muted { font-size: 0.8rem; }
  .day-head .today-link { padding: 0; }
  .week-strip .wd { padding: 3px 0; line-height: 1.2; font-size: 0.7rem; }
  .week-strip .wd .wd-num { font-size: 0.95rem; }
  main .timeline { max-height: calc(100dvh - 310px); }
}

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; width: 100%; }
.wd {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}
.wd .wd-num { font-size: 1rem; font-weight: 700; color: var(--text); }
.wd .wd-hours { font-weight: 600; }
.wd.today .wd-num { color: var(--brand); }
.wd.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }

.timeline {
  height: 60vh;
  height: 60dvh;
  overflow-y: auto;
  /* Op de telefoon samen met kop, weekstrook en tabbalk binnen één scherm. */
  max-height: calc(100dvh - 380px);
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  touch-action: pan-y;
  overscroll-behavior: contain; /* scrollen in de tijdlijn schuift de pagina niet mee */
}
.tl-grid { position: relative; margin: 12px 8px 12px 48px; }
.tl-hour { position: absolute; left: -48px; right: 0; border-top: 1px solid var(--line); }
.tl-hour span {
  display: block;
  width: 36px;
  text-align: right;
  font-size: 0.75rem;
  color: var(--muted);
  transform: translateY(-50%);
}
.tl-blocks { position: absolute; inset: 0; }
.tl-block {
  position: absolute;
  left: 4px;
  right: 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  overflow: hidden;
  padding: 4px 8px;
  border: 0;
  border-left: 4px solid var(--act, var(--muted));
  border-radius: 8px;
  background: color-mix(in srgb, var(--act, var(--muted)) 22%, var(--surface));
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}
.tl-block span { color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-block.short { flex-direction: row; align-items: center; gap: 8px; padding-top: 0; padding-bottom: 0; white-space: nowrap; }
/* Overlappende blokken iets inspringen, zodat beide aan te tikken blijven. */
.tl-block.invalid { left: 28px; z-index: 1; background: var(--err-bg); border-left-color: var(--err-text); }
.tl-block.sel { z-index: 2; box-shadow: 0 0 0 2px var(--accent); touch-action: none; cursor: grab; }
.tl-handle { position: absolute; left: 0; right: 0; height: 16px; cursor: ns-resize; }
.tl-handle.top { top: 0; }
.tl-handle.bottom { bottom: 0; }
.tl-handle::after {
  content: '';
  position: absolute;
  left: 50%;
  width: 28px;
  height: 4px;
  margin-left: -14px;
  border-radius: 2px;
  background: var(--accent);
}
.tl-handle.top::after { top: 3px; }
.tl-handle.bottom::after { bottom: 3px; }
.add-block { margin-top: 10px; }
.note-input { width: 100%; }

.panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 20px rgb(0 0 0 / 0.15);
  overscroll-behavior: contain;
}
.panel[hidden] { display: none; }
.panel:focus { outline: none; }
.panel .msg { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.chip.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); font-weight: 700; }
.chip:disabled { cursor: default; }
/* Begin en eind naast elkaar, ook op een smalle telefoon (anders loopt het eind door naar een tweede regel). */
.panel-times { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel-time { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.panel-time-row { display: flex; align-items: center; gap: 4px; }
.panel-time .time { flex: 1; min-width: 0; width: auto; padding: 8px 2px; text-align: center; font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.panel-time .time::-webkit-date-and-time-value { text-align: center; }
.panel-actions { display: flex; gap: 8px; }
.panel-actions .primary { margin-left: auto; }

.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: center;
  margin-top: 16px;
  padding: 12px 4px;
}
.totals > div { display: flex; flex-direction: column; }
.totals strong { font-size: 1.25rem; }
.save-status { margin-left: auto; font-size: 0.9rem; color: var(--muted); }
.save-status.saved { color: var(--ok-text); }
.save-status.error { color: var(--err-text); }

/* ---------- overzicht ---------- */
.report-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-bottom: 16px; }
.report-head .date-nav { max-width: none; }
.actions { display: flex; gap: 8px; }

.table-wrap { overflow-x: auto; margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.grid { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.grid thead th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.grid tbody th { font-weight: 600; }
.grid tfoot th { border-bottom: 0; border-top: 2px solid var(--line); }
.grid tbody tr:last-child td, .grid tbody tr:last-child th { border-bottom: 0; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }

.week-total { display: flex; flex-direction: column; align-items: center; margin: 4px 0 16px; }
.week-total strong { font-size: 2rem; }
.week-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr 3rem;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 6px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
button.week-row { cursor: pointer; }
.week-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-row .num { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.week-row.axis { padding: 0; }
.clock-bar { position: relative; height: 18px; overflow: hidden; border-radius: 4px; background: var(--info-bg); }
.clock-seg { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: var(--act, var(--muted)); }
.clock-axis { position: relative; height: 1rem; font-size: 0.75rem; color: var(--muted); }
.clock-axis span { position: absolute; transform: translateX(-50%); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0; font-size: 0.9rem; }
/* Elke dag een eigen kaartje, zodat de dagen niet in elkaar overlopen. */
.roster-day {
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.roster-day.today { border-color: var(--brand); }
.week-row.axis:has(+ .roster-day) { padding: 0 13px; } /* klokas gelijk met de balken in de kaartjes */
.roster-day h3 { display: flex; justify-content: space-between; margin: 0 0 2px; font-size: 0.95rem; }
.roster-day h3 .num { color: var(--muted); font-variant-numeric: tabular-nums; }
.roster-day > .muted { margin: 0; }
/* Eén medewerker: een lijntje tussen de dagen. */
.week-row:not(.axis) + .week-row { border-top: 1px solid var(--line); }

.notes { padding-left: 18px; }
.notes li { margin-bottom: 4px; }

/* ---------- beheer ---------- */
.list { list-style: none; margin: 0 0 12px; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); padding: 10px 0; }
.list > li.off .item > div:first-child { opacity: 0.6; }
.item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.item .row { flex-wrap: wrap; }

.log { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; }
.log li { padding: 6px 0; border-bottom: 1px solid var(--line); }

/* ---------- afdrukken ---------- */
.print-only { display: none; }

@media print {
  .tabs, .top, .test-banner, .no-print { display: none !important; }
  .print-only { display: block; }
  html, body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .table-wrap { border: 0; overflow: visible; }
  .grid th, .grid td { border-bottom: 1px solid #ccc; }
}
