/* ===================================================================
   112 STAT — design tokens
   Palette: #F5F5F5 (bg) · #EA5C1F (accent) · #D6D7D7 (line) ·
            #4F5D75 (slate) · #212431 (ink)
   Type: Space Grotesk (display/UI) · Inter (body) · JetBrains Mono (data)
   =================================================================== */

:root{
  --bg: #F5F5F5;
  --panel: #FFFFFF;
  --line: #D6D7D7;
  --accent: #EA5C1F;
  --accent-ink: #FFFFFF;
  --slate: #4F5D75;
  --ink: #212431;
  --ink-soft: rgba(33,36,49,.60);
  --ink-faint: rgba(33,36,49,.38);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', monospace;

  --shadow-card: 0 1px 2px rgba(33,36,49,.04), 0 8px 24px -12px rgba(33,36,49,.18);
  --tabbar-h: 68px;
  --topbar-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*, *::before, *::after{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, textarea{ font-family: inherit; color: inherit; }
button{ background: none; border: 0; cursor: pointer; }
input, textarea{ background: var(--panel); }
h1,h2,h3,p{ margin: 0; }
svg{ width: 22px; height: 22px; }
::selection{ background: var(--accent); color: var(--accent-ink); }

/* ---------------- app shell ---------------- */
#app{
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.topbar{
  height: calc(var(--topbar-h) + var(--safe-t));
  padding-top: var(--safe-t);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 20px;
  padding-right: 20px;
  background: var(--ink);
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand{ display: flex; align-items: baseline; gap: 6px; font-family: var(--font-display); }
.brand-mark{ color: var(--accent); font-weight: 700; font-size: 20px; letter-spacing: .01em; }
.brand-word{ color: #fff; font-weight: 500; font-size: 13px; letter-spacing: .18em; }
.topbar-date{
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(255,255,255,.55);
  text-transform: capitalize;
}

main{
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 16px calc(28px + var(--tabbar-h) + var(--safe-b));
  -webkit-overflow-scrolling: touch;
}

.view{ display: none; animation: viewIn .22s ease; }
.view.active{ display: block; }
@keyframes viewIn{ from{ opacity: 0; transform: translateY(4px); } to{ opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce){
  .view{ animation: none; }
}

.tabbar{
  position: sticky;
  bottom: 0;
  z-index: 20;
  flex: 0 0 auto;
  display: flex;
  background: var(--ink);
  padding-bottom: var(--safe-b);
  height: calc(var(--tabbar-h) + var(--safe-b));
  box-shadow: 0 -1px 0 rgba(255,255,255,.06);
}
.tab{
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: rgba(255,255,255,.45);
  transition: color .15s ease;
  min-width: 0;
}
.tab svg{ width: 21px; height: 21px; flex-shrink: 0; }
.tab span{ font-family: var(--font-display); font-size: 10.5px; letter-spacing: .02em; font-weight: 500; white-space: nowrap; }
.tab.active{ color: var(--accent); }

/* ---------------- stat tiles ---------------- */
.stat-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.stat-tile{
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-tile--wide{ grid-column: 1 / -1; margin-bottom: 10px; }
.stat-label{
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 500;
}
.stat-value{
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

/* ---------------- panels / foldouts ---------------- */
.panel{
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: 10px;
}
.panel-header{ display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.eyebrow{
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--slate);
  font-weight: 600;
}
.panel-sub{ font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); }

.foldout-trigger{
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
}
.chevron{ width: 18px; height: 18px; color: var(--ink-faint); transition: transform .2s ease; flex-shrink: 0; }
.foldout.open .chevron{ transform: rotate(180deg); }
.foldout-body{
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .22s ease;
}
.foldout.open .foldout-body{ grid-template-rows: 1fr; margin-top: 12px; }
.foldout:not(.open) .foldout-body{ margin-top: 0; }
.foldout-inner{ overflow: hidden; min-height: 0; }

.freq-row{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--bg);
  font-size: 13.5px;
}
.freq-row:last-child{ border-bottom: 0; }
.freq-name{ flex: 1; font-weight: 500; }
.freq-bar-track{ width: 64px; height: 5px; border-radius: 3px; background: var(--bg); overflow: hidden; }
.freq-bar-fill{ height: 100%; background: var(--accent); border-radius: 3px; }
.freq-count{ font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); min-width: 18px; text-align: right; }
.empty-note{ color: var(--ink-faint); font-size: 13px; padding: 4px 0; }

/* ---------------- calendar grid (signature element) ---------------- */
.cal-panel .panel-header{ margin-bottom: 10px; }
.cal-weekdays{
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.cal-weekdays span{
  text-align: center;
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .03em;
  color: var(--ink-faint);
  text-transform: uppercase;
}
.cal-week{
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.cal-cell{
  aspect-ratio: 1 / 0.82;
  border-radius: 8px;
  background: var(--bg);
  padding: 5px 6px;
  position: relative;
}
.cal-cell--pad{ background: transparent; }
.cal-daynum{
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  font-weight: 500;
}
.cal-cell.has-entries{
  background: rgba(234,92,31,.10);
  cursor: pointer;
}
.cal-cell.has-entries .cal-daynum{ color: var(--ink); font-weight: 600; }
.cal-cell--today{ box-shadow: inset 0 0 0 1.5px var(--slate); }
.cal-pips{ position: absolute; left: 6px; bottom: 5px; display: flex; gap: 2px; }
.cal-pip{ width: 5px; height: 5px; border-radius: 1.5px; background: var(--accent); display: inline-block; }
.cal-pip--legend{ position: static; }
.cal-legend{
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--ink-faint);
}
.cal-legend span{ display: inline-flex; align-items: center; gap: 5px; }

/* calendar "page" cards used in Historiek (per month / per year) */
.cal-card{
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-bottom: 10px;
}
.cal-card-header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.cal-card-title{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  text-transform: capitalize;
  color: var(--ink);
}
.hist-metrics{ display: flex; gap: 12px; align-items: center; flex-shrink: 0; }
.hist-metric{ text-align: right; }
.hist-metric-value{ font-family: var(--font-mono); font-weight: 600; font-size: 14px; display: block; }
.hist-metric-label{ font-size: 9px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .03em; }

/* year group: header (always visible) + mini grid (always visible) + foldout of full month cards */
.year-card{ padding-bottom: 14px; }
.year-header{
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.year-header .chevron{ margin-top: 4px; }
.year-mini-grid{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.year-mini-tile{
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
  opacity: .45;
}
.year-mini-tile.has-data{ opacity: 1; background: rgba(234,92,31,.10); }
.year-mini-label{
  display: block;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink);
}
.year-mini-hours{
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.year-card .foldout-body{ margin-top: 0; }
.year-card.open .foldout-body{ margin-top: 12px; }
.year-card .foldout-inner > .cal-card:last-child{ margin-bottom: 0; }

/* ---------------- forms ---------------- */
.field{ display: block; margin-bottom: 14px; }
.field-row{ display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-label{
  display: block;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--slate);
  font-weight: 600;
  margin-bottom: 6px;
}
.field-label--sm{ margin-bottom: 8px; margin-top: 2px; }
input[type="date"], input[type="time"], input[type="text"], textarea{
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  font-size: 15px;
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}
textarea{ resize: vertical; min-height: 56px; font-family: var(--font-body); }
input:focus-visible, textarea:focus-visible, button:focus-visible{
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.hint{ font-size: 12.5px; color: var(--ink-faint); margin: -6px 0 14px; }
.hint--center{ text-align: center; }
.hint--empty{ text-align: center; padding: 18px 0; }

.chip-row{ display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chip{
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg);
  border: 1.5px solid var(--line);
  color: var(--ink);
}
.chip.selected{ background: var(--accent); border-color: var(--accent); color: #fff; }

.chip-row--scroll{ flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; margin-bottom: 0; -webkit-overflow-scrolling: touch; }
.chip-row--scroll .chip{ flex-shrink: 0; }

.filtered-header{ display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 10px; }
.filtered-title{ font-family: var(--font-display); font-weight: 700; font-size: 15px; text-transform: none; }
.month-group-label{
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--slate);
  padding: 10px 4px 4px;
}
.month-group-label:first-child{ padding-top: 2px; }

/* horizontal tag picker (intervention cards) */
.tag-picker{ display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tag-chip{ font-size: 12px; padding: 5px 11px; }
.chip--add{ background: transparent; border-style: dashed; color: var(--slate); }
.tag-add-input{
  width: auto;
  min-width: 90px;
  flex: 1 0 90px;
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: 999px;
}
.tag-pill{
  display: inline-block;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(234,92,31,.12);
  color: var(--accent);
  margin: 0 5px 5px 0;
}

.interventions-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.btn--icon{
  width: 30px; height: 30px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.intervention-card{
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
  position: relative;
}
.intervention-card-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.intervention-index{
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--slate);
  font-weight: 600;
}
.btn--remove{
  color: var(--ink-faint);
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
}
.intervention-card textarea{ font-size: 14px; }

.entry-actions{ display: flex; gap: 10px; margin-top: 18px; }
.btn{
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .02em;
  border-radius: var(--radius-md);
  padding: 13px 18px;
  text-align: center;
}
.btn--primary{ background: var(--ink); color: #fff; flex: 1; }
.btn--primary:active{ background: var(--accent); }
.btn--ghost{ background: var(--bg); color: var(--ink); border: 1.5px solid var(--line); }
.link-btn{ color: var(--accent); font-weight: 600; text-decoration: underline; padding: 0; font-size: inherit; }
.backup-actions{ display: flex; gap: 10px; }
.backup-actions .btn{ flex: 1; padding: 10px 12px; font-size: 13px; }

/* ---------------- historiek shift list (used inside day sheet) ---------------- */
.shift-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 4px;
  border-top: 1px solid var(--bg);
  cursor: pointer;
}
.shift-row:first-child{ border-top: 0; }
.shift-row-main{ display: flex; flex-direction: column; gap: 2px; }
.shift-date{ font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; }
.shift-dienst{ font-size: 11.5px; color: var(--ink-soft); }
.shift-metrics{ font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); text-align: right; }

/* ---------------- Instellingen (settings) ---------------- */
.manage-row{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--bg);
}
.manage-row:last-child{ border-bottom: 0; }
.manage-name{ flex: 1; font-size: 14px; font-weight: 500; }
.manage-count{ font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-faint); }
.icon-btn{
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--ink-soft);
  flex-shrink: 0;
}
.icon-btn:active{ background: var(--bg); }
.manage-add-row{ display: flex; gap: 8px; margin-top: 12px; }
.manage-add-row input{ flex: 1; padding: 9px 12px; font-size: 13.5px; }

.setting-row{ display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.segmented{ display: flex; background: var(--bg); border-radius: 999px; padding: 3px; }
.seg-btn{
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--ink-soft);
}
.seg-btn.active{ background: var(--ink); color: #fff; }

/* ---------------- sheet (entry detail / day list) ---------------- */
.sheet-backdrop{
  position: fixed; inset: 0;
  background: rgba(33,36,49,.45);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
  z-index: 50;
}
.sheet-backdrop.show{ opacity: 1; pointer-events: auto; }
.sheet{
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: 480px;
  max-height: 82vh;
  background: var(--panel);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 40px rgba(33,36,49,.25);
  z-index: 51;
  transition: transform .26s cubic-bezier(.32,.72,0,1);
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-b);
}
.sheet.open{ transform: translate(-50%, 0); }
.sheet-handle{ width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 10px auto 4px; flex-shrink: 0; }
.sheet-header{
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 18px 12px;
  flex-shrink: 0;
}
.sheet-header h3{ font-family: var(--font-display); font-size: 16px; font-weight: 700; text-transform: capitalize; }
.sheet-close{ font-size: 22px; color: var(--ink-faint); line-height: 1; padding: 2px 6px; }
.sheet-body{ overflow-y: auto; padding: 0 18px 8px; flex: 1 1 auto; }
.sheet-actions{ display: flex; gap: 10px; padding: 12px 18px 18px; flex-shrink: 0; }
.sheet-actions .btn{ flex: 1; }

.detail-meta{ margin-bottom: 14px; }
.detail-meta-row{
  display: flex; justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg);
  font-size: 13.5px;
}
.detail-meta-row span{ color: var(--ink-soft); }
.detail-int{
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  margin-bottom: 8px;
}
.detail-int-head{
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--slate);
  margin-bottom: 6px;
}
.detail-tags{ margin-bottom: 4px; }
.detail-desc{ font-size: 13.5px; line-height: 1.45; }

/* ---------------- toast ---------------- */
.toast{
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 60;
  white-space: nowrap;
}
.toast.show{ opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- misc ---------------- */
@media (min-width: 481px){
  body{ background: var(--line); }
  #app{ box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(33,36,49,.15); min-height: 100vh; }
}
