:root {
  --bg: #EAF3FC;
  --card: #FFFFFF;
  --card2: #F1F7FD;
  --line: #DCE8F5;
  --ink: #16325B;
  --dim: #64799B;
  --blue: #2563EB;
  --blue-deep: #1D4ED8;
  --blue-soft: #E5EEFF;
  --pink: #EC4899;
  --pink-soft: #FDE7F1;
  --yellow: #FFC93C;
  --yellow-soft: #FFF6DA;
  --orange: #FB923C;
  --green: #34D399;
  --lime: #A3E635;
  --amber: #FBBF24;
  --red: #F87171;
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { color-scheme: light; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  font-size: 16px;
  line-height: 1.45;
}
#app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }
::placeholder { color: var(--dim); opacity: 0.7; }

/* datumveld: iOS laat het anders uitlopen of gek uitlijnen */
input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
  min-width: 0;
  max-width: 100%;
  min-height: 50px;
  display: flex;
  align-items: center;
  text-align: left;
}
input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
  margin: 0;
}

/* header */
.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(12px);
  padding: calc(12px + env(safe-area-inset-top)) 0 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--line);
  margin: 0 -16px 16px; padding-left: 16px; padding-right: 16px;
}
.top h1 { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.top h1 .accent { color: var(--pink); }
.userchip { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.avatar.con { background: #F9A8D4; color: #831843; }
.avatar.niek { background: #93C5FD; color: #1E3A8A; }
.iconbtn { padding: 8px; border-radius: 10px; color: var(--dim); font-size: 18px; line-height: 1; }
.iconbtn:active { background: var(--card2); }

/* tabbar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; max-width: 160px; text-align: center; text-decoration: none; color: var(--dim);
  font-size: 11px; font-weight: 600; padding: 6px 0 4px; border-radius: 12px;
}
.tabbar a .ti { display: block; font-size: 22px; margin-bottom: 2px; }
.tabbar a.active { color: var(--blue); background: var(--blue-soft); }

/* cards & general */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(22, 50, 91, 0.05);
}
.h2 { font-size: 15px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
.btn {
  display: block; width: 100%; text-align: center;
  background: var(--pink); color: #fff; font-weight: 800;
  padding: 14px; border-radius: 14px; font-size: 16px;
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.3);
}
.btn:active { transform: scale(0.985); }
.btn.secondary { background: var(--card); color: var(--blue); border: 1px solid var(--line); font-weight: 700; box-shadow: none; }
.btn.danger { background: var(--card); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.45); box-shadow: none; }
.btn[disabled] { opacity: 0.5; }
.muted { color: var(--dim); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }

/* login */
.login-wrap { min-height: 88dvh; display: flex; flex-direction: column; justify-content: center; }
.login-logo { font-size: 52px; text-align: center; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--dim); margin-bottom: 24px; }
.who { display: flex; gap: 12px; margin-bottom: 16px; }
.who button {
  flex: 1; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-weight: 700; font-size: 16px;
}
.who button.sel { border-color: var(--blue); background: var(--blue-soft); }
.who .avatar { width: 44px; height: 44px; font-size: 18px; }
.err { color: var(--red); font-size: 14px; margin-top: 10px; text-align: center; font-weight: 600; }

/* segmented */
.seg { display: flex; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; padding: 10px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--dim); }
.seg button.active { background: var(--blue); color: #fff; }

/* nieuw formulier */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--dim); margin-bottom: 6px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 14px; max-height: 260px; overflow-y: auto; }
.pick-list button {
  text-align: left; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
}
.pick-list button .muted { display: block; }
.sel-chip {
  display: flex; align-items: center; gap: 10px; background: var(--blue-soft);
  border: 1px solid var(--blue); border-radius: 12px; padding: 10px 14px; margin-top: 8px;
}
.sel-chip b { flex: 1; }
.slider-row { margin-bottom: 14px; }
.slider-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.slider-head .w { font-size: 11px; color: var(--dim); background: var(--card2); border: 1px solid var(--line); border-radius: 20px; padding: 2px 8px; }
.slider-head .val { margin-left: auto; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 34px; padding: 0; background: transparent; border: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 8px; border-radius: 6px; background: #E0EBF7; border: 1px solid var(--line); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--blue); margin-top: -11px; border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(22, 50, 91, 0.3);
}
/* elk cijfer z'n eigen kleurtje */
input[data-cat="eten"]::-webkit-slider-thumb { background: var(--orange); }
input[data-cat="sfeer"]::-webkit-slider-thumb { background: var(--pink); }
input[data-cat="personeel"]::-webkit-slider-thumb { background: var(--blue); }
input[data-cat="prijs"]::-webkit-slider-thumb { background: var(--yellow); }
.total-preview {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--yellow-soft); border: 1px solid var(--yellow); border-radius: 14px; padding: 12px 16px; margin: 6px 0 14px;
}
.total-preview b { font-size: 28px; font-variant-numeric: tabular-nums; }

/* lijst */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters .full { grid-column: 1 / -1; display: flex; gap: 8px; }
.filters select { padding: 10px 12px; font-size: 14px; }
.sortdir { width: 48px; flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 12px; font-size: 18px; color: var(--blue); }
.rlist { display: flex; flex-direction: column; gap: 8px; }
.ritem {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  box-shadow: 0 2px 10px rgba(22, 50, 91, 0.05);
}
.ritem:active { background: var(--card2); }
.rank { width: 28px; text-align: center; font-weight: 800; color: var(--dim); font-size: 14px; flex: none; }
.rank.medal { font-size: 20px; }
.ritem .info { flex: 1; min-width: 0; }
.ritem .info b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  flex: none; min-width: 52px; text-align: center; font-weight: 800; font-size: 16px;
  padding: 8px 10px; border-radius: 12px; color: #14290B; font-variant-numeric: tabular-nums;
}
.badge.s-top { background: var(--green); }
.badge.s-good { background: var(--lime); }
.badge.s-ok { background: var(--amber); }
.badge.s-meh { background: var(--red); color: #47110D; }
.badge.s-none { background: var(--card2); color: var(--dim); }

/* detail */
.back { color: var(--blue); font-size: 15px; font-weight: 600; padding: 8px 0; display: inline-block; text-decoration: none; }
.hero { text-align: center; padding: 20px 16px 18px; }
.hero h2 { font-size: 24px; letter-spacing: -0.02em; }
.hero .muted { margin-bottom: 12px; }
.hero .big { font-size: 56px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; color: var(--blue-deep); }
.cat-bars { margin-top: 6px; }
.cat-bar { margin-bottom: 10px; }
.cat-bar .row { font-size: 13px; margin-bottom: 4px; }
.cat-bar .row b { font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: #E0EBF7; border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--blue); border-radius: 6px; }
.visit { margin-bottom: 12px; }
.visit-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.visit-head b { font-size: 15px; }
.delta { font-size: 13px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.delta.up { color: #067647; background: #D8F5E7; }
.delta.down { color: #B42318; background: #FDE5E2; }
.entry { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.entry .avatar { width: 30px; height: 30px; font-size: 13px; flex: none; }
.avatar.import { background: var(--card2); color: var(--dim); }
.entry .body { flex: 1; min-width: 0; }
.entry .cats { color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.entry .note { font-size: 14px; color: var(--ink); opacity: 0.85; margin-top: 4px; font-style: italic; }
.entry .etotal { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.entry .acts { display: flex; gap: 4px; margin-top: 4px; }
.entry .acts button { font-size: 12px; color: var(--blue); padding: 4px 8px; border-radius: 8px; background: var(--blue-soft); font-weight: 600; }
.entry .acts button.del { color: #B42318; background: #FDE5E2; }

/* logs */
.log { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.log:last-child { border-bottom: none; }
.log .body { flex: 1; min-width: 0; font-size: 14px; }
.log .when { font-size: 12px; color: var(--dim); margin-top: 2px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; font-weight: 700; padding: 12px 20px; border-radius: 14px;
  z-index: 50; box-shadow: 0 8px 30px rgba(22, 50, 91, 0.3); max-width: 90vw; text-align: center;
}
.toast.error { background: #D92D20; color: #fff; }

.empty { text-align: center; color: var(--dim); padding: 32px 16px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
