:root {
  --bg: #0f172a;
  --surface: #1f2937;
  --surface-2: #273244;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --danger: #ef4444;
  --ok: #10b981;
  --warn: #f59e0b;
  --pause: #facc15;
  --pause-fg: #422006;
  --row-alt: #1a2433;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  /* Combined height of sticky topbar + day-tabs. The grid-wrap pins below this
     so its time header stays visible when the page scrolls. */
  --top-stack: 106px;
}
@media (max-width: 640px) {
  :root { --top-stack: 96px; }
}

:root[data-theme="light"] {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #d8dee8;
  --text: #0f172a;
  --muted: #64748b;
  --row-alt: #f1f5f9;
  --shadow: 0 4px 14px rgba(15, 23, 42, 0.07);
}
:root[data-theme="light"] .grid td.slot-empty {
  background-image:
    linear-gradient(135deg, transparent 45%, rgba(15, 23, 42, 0.04) 45%,
                    rgba(15, 23, 42, 0.04) 55%, transparent 55%);
}
:root[data-theme="light"] .chip-time {
  background: rgba(241, 245, 249, 0.9);
}
:root[data-theme="light"] .now-indicator .now-label,
:root[data-theme="light"] .now-indicator { color: #fff; }

* { box-sizing: border-box; }

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

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Login === */
#login {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card {
  background: var(--surface);
  padding: 28px 24px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card h1 {
  margin: 0;
  font-size: 22px;
  text-align: center;
}

.muted { color: var(--muted); margin: 0; text-align: center; font-size: 14px; }
.error { color: var(--danger); min-height: 18px; margin: 0; text-align: center; font-size: 14px; }

input[type="password"], input[type="text"], textarea {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  width: 100%;
  font-family: inherit;
}

input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

button:hover { background: var(--accent-2); }
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.ghost:hover { background: var(--surface-2); }
button.danger { background: var(--danger); }

/* === Topbar === */
.topbar {
  background: var(--surface);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: max(10px, env(safe-area-inset-top));
}

.brand { font-weight: 700; font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.badge.admin { background: var(--ok); color: #062d22; }
.badge.viewer { background: var(--accent); color: #fff; }

#logoutBtn, #themeBtn { padding: 6px 12px; min-height: auto; font-size: 14px; }
#themeBtn { padding: 6px 10px; font-size: 16px; line-height: 1; }

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.history-main { flex: 1; min-width: 0; }
.history-time {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-stats {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.history-item button {
  flex-shrink: 0;
  font-size: 13px;
  padding: 8px 14px;
  min-height: auto;
}

/* === Day tabs === */
.day-tabs {
  background: var(--surface);
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 9;
  -webkit-overflow-scrolling: touch;
}

.day-tabs button {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 14px 18px;
  color: var(--muted);
  font-weight: 600;
  font-size: 15px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  flex: 0 0 auto;
}

.day-tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* === Content === */
main {
  flex: 1;
  padding: 12px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar input[type="search"] {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  flex: 1 1 200px;
  min-width: 200px;
}

.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  align-items: center;
}
.stat {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.stat-toggle {
  cursor: pointer;
  font-family: inherit;
  min-height: auto;
}
.stat-toggle.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.day-overview {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
}
.overview-piece {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.overview-lbl {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  font-size: 11px;
}
.overview-val {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* === Statistieken === */
.stats-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.stats-section h2 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
}
.stats-section p.small {
  margin: -4px 0 12px;
  font-size: 12px;
}

/* Hours list (Section A) */
.hours-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hours-row {
  display: grid;
  grid-template-columns: 140px 1fr 64px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.hours-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hours-bar {
  height: 14px;
  background: var(--surface-2);
  border-radius: 7px;
  overflow: hidden;
}
.hours-bar-fill {
  height: 100%;
  border-radius: 7px;
  min-width: 4px;
  transition: width 0.2s;
}
.hours-total {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.hours-breakdown {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--muted);
  margin-left: 150px;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 640px) {
  .hours-row { grid-template-columns: 110px 1fr 58px; }
  .hours-breakdown { margin-left: 0; }
}

/* Heatmap (Sections B, C) */
.heat-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.heat-table {
  border-collapse: separate;
  border-spacing: 1px;
  font-size: 11px;
}
.heat-day {
  font-weight: 600;
  padding: 4px 8px;
  white-space: nowrap;
  background: var(--surface-2);
  border-radius: 4px;
  min-width: 80px;
}
.heat-th {
  font-size: 9px;
  color: var(--muted);
  font-weight: 500;
  padding: 2px 0;
  text-align: center;
  width: 22px;
  min-width: 22px;
}
.heat-th-hour {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}
.heat-cell {
  width: 22px;
  min-width: 22px;
  height: 26px;
  text-align: center;
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  font-weight: 600;
}

.admin-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.admin-bar button {
  font-size: 13px;
  padding: 8px 14px;
  min-height: auto;
}

.badge-empty {
  display: inline-block;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  white-space: nowrap;
}
.badge-empty.inline { margin-top: 4px; align-self: flex-start; }

.view-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.view-toggle::-webkit-scrollbar { display: none; }
.view-toggle button {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--muted);
  min-height: auto;
}
.view-toggle button.active {
  background: var(--accent);
  color: #fff;
}

/* === Card list view (mobile-first) === */
.cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.task-card.row-empty {
  opacity: 0.65;
  border-style: dashed;
}
.task-head {
  flex-wrap: wrap;
}

.task-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 6px;
}

.task-fn {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
  flex: 1;
}

.task-shift {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.task-people {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip-name {
  font-weight: 600;
}
.chip-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  background: rgba(15, 23, 42, 0.35);
  padding: 1px 6px;
  border-radius: 999px;
}
.chip.pause .chip-time {
  background: rgba(66, 32, 6, 0.2);
  color: var(--pause-fg);
}
.chip-pauze {
  font-size: 11px;
  color: #fbbf24;
  background: rgba(250, 204, 21, 0.15);
  padding: 1px 8px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
:root[data-theme="light"] .chip-pauze {
  color: #92400e;
  background: rgba(250, 204, 21, 0.32);
}

.chip.pause {
  background: var(--pause);
  color: var(--pause-fg);
  border-color: var(--pause);
}
.chip.empty {
  background: transparent;
  color: var(--muted);
  font-style: italic;
}

.task-notes {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.note {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: baseline;
  line-height: 1.35;
}
.note-time {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.note-text {
  font-style: italic;
  color: var(--text);
  font-weight: 400;
}

.row-notes {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.row-note {
  display: flex;
  gap: 5px;
  align-items: baseline;
  font-size: 11px;
  font-style: italic;
  color: var(--muted);
  white-space: normal;
  line-height: 1.3;
}
.row-note .note-time {
  font-size: 10px;
  padding: 0 4px;
}
.row-note .note-text {
  font-size: 11px;
  font-style: italic;
}

.task-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}
.task-actions button {
  font-size: 13px;
  padding: 6px 12px;
  min-height: auto;
}

/* === Grid view (table) === */
.grid-wrap {
  /* Pin the grid below the topbar+day-tabs so the time header stays visible
     while scrolling — both vertically (within the grid) and horizontally. */
  position: sticky;
  top: var(--top-stack);
  max-height: calc(100vh - var(--top-stack) - 16px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

.hour-guide {
  position: absolute;
  top: 0;
  width: 0;
  /* Sits between tbody cells (z-index 0) and the sticky thead (z-index 2)
     so it shows over rows but is hidden behind the time-header. */
  z-index: 1;
  pointer-events: none;
  border-left: 1px dashed rgba(148, 163, 184, 0.45);
}

.now-indicator {
  position: absolute;
  top: 0;
  width: 2px;
  background: var(--danger);
  z-index: 4;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}
.now-indicator .now-label {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.grid tr.row-empty td.sticky-col {
  opacity: 0.65;
  border-left: 3px dashed var(--border);
}
/* Sub-tracks for rows with overlapping shifts share the same logical row;
   suppress the bottom border between them in the time grid (slot cells), but
   leave the sticky-col alone — its rowspan already spans all sub-tracks, so
   its bottom border serves as the function separator. */
.grid tr.row-track-extra > td.slot { border-top: 1px dashed rgba(148, 163, 184, 0.18); }
.grid tr:has(+ tr.row-track-extra) > td.slot { border-bottom: none; }
.grid tr.row-empty td.slot-empty {
  background-image:
    linear-gradient(135deg, transparent 45%, rgba(148, 163, 184, 0.04) 45%, rgba(148, 163, 184, 0.04) 55%, transparent 55%);
}
table.grid {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  width: max-content;
  min-width: 100%;
}
.grid th, .grid td {
  border-right: 1px solid var(--border);
  border-bottom: 2px dashed rgba(148, 163, 184, 0.6);
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
}
/* Solid borders inside the time header (not dashed) so it reads as a block. */
.grid thead th { border-bottom: 1px solid var(--border); }
.grid thead th {
  background: var(--surface-2);
  position: sticky;
  z-index: 2;
  font-weight: 600;
  white-space: nowrap;
  text-align: center;
}
.grid thead tr:first-child th { top: 0; }
.grid thead tr:nth-child(2) th { top: 32px; }

.grid th.hour-th {
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--text);
  background: var(--surface-2);
  border-left: 2px solid var(--border);
  padding: 6px 4px;
}
.grid th.hour-th:first-of-type { border-left: none; }
.grid th.half-th {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  padding: 3px 2px;
  min-width: 30px;
  background: var(--surface-2);
}
.grid th.half-th.half-th-start {
  border-left: 2px solid var(--border);
}

.grid th.sticky-col, .grid td.sticky-col {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
  min-width: 170px;
  max-width: 220px;
  font-weight: 600;
  border-right: 2px solid var(--border);
}
.grid thead th.sticky-col {
  background: var(--surface-2);
  z-index: 3;
  text-align: left;
}
.grid tbody tr:nth-child(even) td.sticky-col { background: var(--row-alt); }

.grid td.slot {
  min-width: 30px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  padding: 0;
  height: 38px;
}
.grid td.slot.slot-hour-start {
  border-left: 2px solid var(--border);
}

.grid td.slot-empty {
  background-image:
    linear-gradient(135deg, transparent 45%, rgba(148, 163, 184, 0.06) 45%, rgba(148, 163, 184, 0.06) 55%, transparent 55%);
  background-size: 8px 8px;
}

.grid td.slot-shift {
  background: #3b82f6;
  color: #fff;
  font-weight: 600;
  border-radius: 0;
}
.grid td.slot-shift.slot-merged {
  box-shadow: inset 1px 0 0 rgba(255,255,255,0.25), inset -1px 0 0 rgba(255,255,255,0.25);
}

.grid td.slot-pause {
  background: var(--pause) !important;
  color: var(--pause-fg);
  font-weight: 700;
}

.grid td .slot-label {
  display: inline-block;
  padding: 0 8px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.2;
}
.grid td.slot-pause .slot-label {
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
  padding: 0 4px;
}

.grid td .fn-title {
  font-size: 13px;
  line-height: 1.25;
  white-space: normal;
}

.grid td.person-cell .fn-title {
  font-size: 14px;
  font-weight: 700;
}

.grid td .shift-cell {
  color: var(--muted);
  font-size: 11px;
  white-space: normal;
  margin-top: 2px;
}

/* Toggle bar between cards & grid */
.section-title {
  margin: 18px 0 8px;
  font-size: 14px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.6px;
}

/* === Modal === */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 18px;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0; font-size: 18px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#editBody { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
#editBody label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.slot-edit-row {
  display: grid;
  grid-template-columns: 70px 1fr 90px;
  gap: 8px;
  align-items: center;
}

.slot-edit-row .time {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.slot-edit-row select, .slot-edit-row input[type=text] {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}

.row-meta { display: grid; gap: 8px; margin-bottom: 6px; }
.row-meta input { font-size: 15px; }

.edit-section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.edit-section h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.muted.small { font-size: 12px; margin: 0; text-align: left; }
.muted.italic { font-style: italic; }

#editNotesList {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-edit-row {
  display: grid;
  grid-template-columns: 80px 1fr 36px;
  gap: 6px;
  align-items: center;
}

/* === Persons view (mobile) === */
.persons-mobile-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.person-mobile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.person-mobile-name {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  min-height: auto;
  font-family: inherit;
  width: auto;
}
.person-mobile-name:hover { color: var(--accent); }
.person-mobile-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.person-mobile-timeline {
  position: relative;
  margin-top: 10px;
}
.person-mobile-timeline .timeline-axis {
  position: relative;
  height: 14px;
  font-size: 9px;
  color: var(--muted);
}
.person-mobile-timeline .timeline-tick {
  position: absolute;
  transform: translateX(-50%);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 600;
}
.person-mobile-timeline .timeline-track {
  position: relative;
  height: 28px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.person-mobile-timeline .timeline-block {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.18);
}
.person-mobile-timeline .timeline-block.timeline-pause {
  background: var(--pause);
  color: var(--pause-fg);
}
.person-mobile-timeline .timeline-label {
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
}

/* === Mijn rooster name picker === */
.me-hint {
  margin: 4px 0 12px;
  text-align: left;
  font-size: 13px;
}
.name-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.name-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  min-height: 48px;
  transition: background 0.1s, border-color 0.1s, transform 0.1s;
  font-family: inherit;
}
.name-btn:hover {
  background: var(--surface-2);
  border-color: var(--accent);
}
.name-btn:active {
  transform: scale(0.98);
}
.name-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.name-btn-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 640px) {
  .name-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
  }
  .name-btn { padding: 12px; font-size: 14px; }
}

/* === Person schedule modal ("Mijn rooster") === */
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-head button {
  padding: 4px 10px;
  font-size: 16px;
  min-height: auto;
}
.person-name-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  text-align: left;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
  border-radius: 0;
  min-height: auto;
}
.person-name-btn:hover {
  color: var(--accent);
  background: transparent;
  text-decoration: underline;
}
.person-day {
  margin-bottom: 14px;
}
.person-day h3 {
  margin: 0 0 6px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.person-day-hours {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}
.person-shifts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.person-shift-item {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 10px;
}
.person-shift-item .shift-swatch {
  width: 10px;
  height: 28px;
  border-radius: 3px;
  flex-shrink: 0;
  border: none;
}
.person-shift-main { flex: 1; min-width: 0; }
.person-shift-fn { font-weight: 600; font-size: 14px; }
.person-shift-range {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.person-shift-pauze {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.person-total {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  text-align: right;
  font-weight: 700;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

/* === Openstaand state === */
.chip.open .chip-name {
  font-style: italic;
  color: var(--muted);
}
.chip.open {
  border-style: dashed;
  background: transparent;
}
.grid td.slot-shift.slot-open {
  background-image:
    linear-gradient(135deg, transparent 25%, rgba(255,255,255,0.08) 25%,
                    rgba(255,255,255,0.08) 50%, transparent 50%,
                    transparent 75%, rgba(255,255,255,0.08) 75%);
  background-size: 8px 8px;
  font-style: italic;
}
.manage-shift.open .manage-shift-person {
  font-style: italic;
  color: var(--muted);
}
.shift-edit-card.open {
  border-style: dashed;
  border-color: var(--muted);
}
.shift-edit-card.open input[type="text"] {
  font-style: italic;
}
.open-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.open-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* === Manage tabs === */
.manage-tabs {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
  gap: 2px;
}
.manage-tab {
  background: transparent;
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 7px;
  min-height: auto;
  cursor: pointer;
}
.manage-tab.active {
  background: var(--accent);
  color: #fff;
}

/* === Openstaand list (admin) === */
.open-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.open-day-head {
  margin: 8px 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 700;
}
.open-row {
  display: grid;
  grid-template-columns: 1fr 200px auto;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.open-row-main { min-width: 0; }
.open-row-fn {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.open-row-time {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.open-row-input {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
.open-row-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: auto;
}
.open-row-btn:hover:not(:disabled) { background: var(--accent-2); }
.open-row-btn:disabled { opacity: 0.6; cursor: default; }
@media (max-width: 640px) {
  .open-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .open-row-input { width: 100%; }
}

/* === Manage view (admin) === */
.manage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.manage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.manage-card:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}
.manage-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.manage-card-fn {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  line-height: 1.25;
}
.manage-card-shifts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 2px;
}
.manage-shift {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding: 3px 0;
  flex-wrap: wrap;
}
.manage-shift .shift-swatch {
  width: 10px;
  height: 18px;
  border-radius: 3px;
  flex-shrink: 0;
  border: none;
}
.manage-shift-person {
  font-weight: 600;
  color: var(--text);
}
.manage-shift-time {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 13px;
}
.manage-shift-pauze {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  background: rgba(250, 204, 21, 0.12);
  padding: 1px 6px;
  border-radius: 999px;
}
@media (max-width: 640px) {
  .manage-card-fn { font-size: 16px; }
}

/* Shift editor */
.shift-edit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shift-edit-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.shift-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.shift-edit-top input[type="text"] {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 10px;
}
.shift-edit-time, .pauze-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.shift-arrow {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.shift-arrow.small { font-size: 12px; }
.pauze-lbl {
  background: var(--pause);
  color: var(--pause-fg);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}
.time-input {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  flex: 1;
  max-width: 130px;
}
.time-input::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(0.6);
  cursor: pointer;
}
.shift-add-pauze {
  font-size: 12px;
  padding: 4px 10px;
  align-self: flex-start;
  min-height: auto;
  margin-left: 4px;
}
.shift-add {
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  margin-top: 4px;
  width: 100%;
  cursor: pointer;
}
.shift-add:hover { background: var(--accent-2); }
.note-edit-row .note-time-select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 13px;
  font-family: inherit;
}
.note-edit-row input[type="text"] {
  padding: 8px 10px;
  font-size: 14px;
}
.note-edit-row .note-del {
  padding: 6px 0;
  min-height: auto;
  font-size: 14px;
  color: var(--danger);
  border-color: var(--border);
}
.note-edit-row .note-del:hover {
  background: rgba(239, 68, 68, 0.12);
}

.edit-advanced {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.edit-advanced summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  padding: 4px 0;
  user-select: none;
}
.edit-advanced summary:hover { color: var(--text); }
.edit-advanced[open] summary {
  margin-bottom: 8px;
  color: var(--text);
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 200;
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }

/* === Mobile tweaks === */
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; }
  .brand { font-size: 15px; }
  main { padding: 10px; }
  .day-tabs { top: 50px; }
  .day-tabs button { padding: 12px 14px; font-size: 14px; }
  .task-card { padding: 10px 12px; }
  .task-fn { font-size: 15px; }
  .grid th, .grid td { padding: 4px 6px; font-size: 11px; }
  .grid th.sticky-col, .grid td.sticky-col { min-width: 140px; max-width: 170px; }
  .grid th.half-th { min-width: 24px; }
  .grid td.slot { height: 36px; }
  .grid td .slot-label { font-size: 11px; padding: 0 4px; }
  .grid thead tr:nth-child(2) th { top: 28px; }
  .slot-edit-row { grid-template-columns: 60px 1fr 80px; }
}

@media (min-width: 900px) {
  .cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}
