/* Inhoud. Style: pastel consumer (pale tints with the dark of their own hue as ink, one large radius).
   Grid: phone 16px gutters, one column. Desktop: 56px rail + canvas, content 1152 max,
   product view 2 columns: 1fr 1fr with a 24px gap (564 + 24 + 564 = 1152). */
:root {
  --ground: #f3f5f7;
  --surface: #ffffff;
  --raised: #f2f8fd;
  --border: #e6e6e6;
  --rule: #f0f1f2;
  --control: #d6d9dd;
  --text: #1b1d1f;
  --muted: #5c6064;
  --primary: #1b1d1f;
  --accent: #1d5fd6;
  --accent-soft: #dcf1ff;
  --accent-ink: #0a3a80;
  --positive: #2f7a45;
  --negative: #c41c29;

  /* score tiers: pale fill, ink of the same hue, a solid mark */
  --top-bg: #dcfae5;   --top-ink: #04250e;   --top-mark: #2f7a45;
  --goed-bg: #ebf6d6;  --goed-ink: #263f07;  --goed-mark: #5e8a1c;
  --matig-bg: #fff0d9; --matig-ink: #6e3600; --matig-mark: #b45309;
  --slecht-bg: #ffedea; --slecht-ink: #831c1e; --slecht-mark: #c41c29;
  --none-bg: #eef1f4;  --none-ink: #3a3d40;  --none-mark: #8a8f94;

  /* people: one hue each, at least 60 degrees apart */
  --blauw-bg: #dcf1ff;  --blauw-ink: #0a3a80;
  --roze-bg: #fde4ee;   --roze-ink: #82163f;
  --groen-bg: #d8f3ec;  --groen-ink: #0d4d42;
  --oranje-bg: #ffe9d6; --oranje-ink: #7a3300;

  --radius-card: 20px;
  --radius-inner: 10px;
  --radius-control: 10px;
  --gap: 24px;
  --pad: 24px;
  --rail: 56px;
  --control-height: 44px;
  --font: "Manrope", Inter, system-ui, sans-serif;
  --fs-title: 28px;
  --fs-section: 20px;
  --fs-kpi: 34px;
  --fs-body: 16px;
  --fs-small: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 400 var(--fs-body)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
.num, .score-num, td.num { font-variant-numeric: tabular-nums; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* shell */
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 0; background: var(--ground); border-right: 1px solid var(--border); z-index: 10;
}
.rail-mark svg { width: 32px; height: 32px; display: block; margin-bottom: 18px; }
.rail-item {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--radius-inner);
  color: var(--muted); text-decoration: none; transition: background .15s, color .15s;
}
.rail-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rail-item span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.rail-item:hover { background: #e9ecef; color: var(--text); }
.rail-item[aria-current="page"] { color: var(--accent); background: #e7edf5; }
.canvas { margin-left: var(--rail); padding: 32px var(--pad) 64px; outline: none; }
.page { max-width: 1152px; margin: 0 auto; }

/* title row */
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
h1 { font-size: var(--fs-title); line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.sub { color: var(--muted); margin: 6px 0 0; font-size: var(--fs-body); }
h2 { font-size: var(--fs-section); font-weight: 600; margin: 0; line-height: 1.3; }
h3 { font-size: var(--fs-body); font-weight: 600; margin: 0; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: var(--fs-small); margin-bottom: 12px; min-height: 32px; }
.back:hover { color: var(--text); }
.back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--pad); }
.stack > * + * { margin-top: var(--gap); }
[hidden] { display: none !important; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head .meta { color: var(--muted); font-size: var(--fs-small); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: start; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-small); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control-height); padding: 0 18px; border-radius: var(--radius-control);
  border: 1px solid var(--control); background: var(--surface); font-weight: 500; cursor: pointer;
  text-decoration: none; transition: background .15s, transform .1s;
}
.btn:hover { background: #f5f6f7; }
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #33363a; }
.btn-text { border: 0; background: none; padding: 0 4px; min-height: 32px; color: var(--accent-ink); font-weight: 500; }
.btn-text:hover { background: none; text-decoration: underline; }
.btn-danger { color: var(--negative); border-color: #f0c4c6; }
.btn:disabled { opacity: 1; color: var(--muted); cursor: default; }

/* fields */
.field { display: grid; gap: 8px; }
.field label { font-size: var(--fs-small); font-weight: 500; }
.input {
  height: var(--control-height); border: 1px solid #e3e5e8; border-radius: var(--radius-control);
  padding: 0 14px; background: #fff; width: 100%;
}
.input::placeholder { color: #6b6b6b; }

/* pills and chips */
.pill { display: inline-flex; align-items: center; gap: 6px; flex: none; white-space: nowrap; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 500; }
.t-top { background: var(--top-bg); color: var(--top-ink); }
.t-goed { background: var(--goed-bg); color: var(--goed-ink); }
.t-matig { background: var(--matig-bg); color: var(--matig-ink); }
.t-slecht { background: var(--slecht-bg); color: var(--slecht-ink); }
.t-none { background: var(--none-bg); color: var(--none-ink); }
.ev { height: 22px; font-size: 12px; padding: 0 8px; }
.ev-bewezen { background: #e3ecfb; color: #0a3a80; }
.ev-aanwijzing { background: #f1eee6; color: #5a4a1e; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--control); background: #fff; cursor: pointer; font-size: 15px; transition: background .15s, border-color .15s;
}
.chip:hover { border-color: #b9bdc2; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent-ink); font-weight: 500; }
.chip[aria-pressed="true"]::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* avatars */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 600; font-size: 14px; flex: none; }
.h-blauw { background: var(--blauw-bg); color: var(--blauw-ink); }
.h-roze { background: var(--roze-bg); color: var(--roze-ink); }
.h-groen { background: var(--groen-bg); color: var(--groen-ink); }
.h-oranje { background: var(--oranje-bg); color: var(--oranje-ink); }

/* scan screen */
.scan-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.viewfinder { position: relative; aspect-ratio: 4 / 3; background: #15171a; border-radius: var(--radius-inner); overflow: hidden; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder .aim { position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%; border: 2px solid rgba(255, 255, 255, .85); border-radius: 12px; pointer-events: none; }
.viewfinder .vf-msg { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 14px; color: #fff; text-align: center; padding: 24px; }
.viewfinder .vf-msg p { margin: 0; color: #d6d9dd; max-width: 30ch; }
.viewfinder .vf-msg .btn { background: #fff; color: var(--text); border-color: #fff; }
.scan-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.code-form { display: flex; gap: 8px; margin-top: 16px; }
.code-form .input { flex: 1; }
.notice { margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-inner); background: #fffbeb; border: 1px solid #fde68a; color: #92400e; font-size: var(--fs-small); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--rule); }
.prow { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 0; text-decoration: none; min-height: 72px; }
.prow:hover .prow-name { text-decoration: underline; }
.thumb { width: 48px; height: 48px; border-radius: 8px; background: #f2f3f5; object-fit: contain; }
.thumb-empty { display: grid; place-items: center; color: var(--muted); font-size: 12px; font-weight: 600; }
.prow-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow-meta { color: var(--muted); font-size: var(--fs-small); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day { color: var(--muted); font-size: var(--fs-small); font-weight: 500; margin: 20px 0 4px; }
.day:first-child { margin-top: 0; }
.empty { border: 1px dashed var(--control); border-radius: var(--radius-inner); padding: 14px 16px; color: var(--muted); font-size: var(--fs-small); }

/* product */
.prod-head { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 20px; align-items: center; }
.prod-img { width: 112px; height: 112px; border-radius: 12px; background: #f2f3f5; object-fit: contain; }
.prod-head h1 { font-size: 26px; }
.score-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: center; margin-top: 20px; padding: 20px; border-radius: 16px; }
.score-num { font-size: var(--fs-kpi); line-height: 1; font-weight: 600; letter-spacing: -0.02em; }
.score-num small { font-size: 16px; font-weight: 500; opacity: .75; letter-spacing: 0; }
.score-label { font-size: 18px; font-weight: 600; }
.score-for { font-size: var(--fs-small); margin-top: 2px; opacity: .85; }
.meter { position: relative; height: 8px; border-radius: 999px; background: rgba(0, 0, 0, .08); margin-top: 12px; overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; border-radius: 999px; }
.alert { margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-inner); font-size: 15px; }
.alert-bad { background: var(--slecht-bg); color: var(--slecht-ink); }
.alert-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert strong { display: block; }
.people-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.person-btn { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 14px 6px 6px; border-radius: 999px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.person-btn[aria-pressed="true"] { border-color: var(--text); }
.person-btn .pill { height: 22px; }

.why { list-style: none; margin: 0; padding: 0; }
.why li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding: 10px 0; }
.why li + li { border-top: 1px solid var(--rule); }
.why .dir { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 15px; line-height: 1; margin-top: 1px; }
.dir-plus { background: var(--top-bg); color: var(--top-ink); }
.dir-min { background: var(--slecht-bg); color: var(--slecht-ink); }
.dir-zero { background: var(--none-bg); color: var(--none-ink); }
.why .tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.ntable { width: 100%; border-collapse: collapse; }
.ntable th { text-align: left; font-weight: 400; color: var(--muted); font-size: 13px; padding: 0 0 8px; }
.ntable th.num { text-align: right; }
.ntable td { padding: 10px 0; border-top: 1px solid var(--rule); }
.ntable td.num { text-align: right; white-space: nowrap; }
.ntable td.lvl { width: 108px; text-align: right; padding-left: 12px; }
.unit { color: var(--muted); font-size: 13px; margin-left: 2px; }

.nova { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 4px 0 14px; }
.nova span { height: 8px; border-radius: 999px; background: var(--rule); }
.nova span.on { background: var(--text); }
.nova-labels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; font-size: 12px; color: var(--muted); margin-top: -8px; margin-bottom: 14px; }
.nova-labels .on { color: var(--text); font-weight: 600; }

.add { padding: 12px 0; }
.add + .add { border-top: 1px solid var(--rule); }
.add-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.add-name { font-weight: 500; }
.add-class { color: var(--muted); font-size: var(--fs-small); }
.add p { margin: 6px 0 0; font-size: 15px; }
.lvl-3 { background: var(--slecht-bg); color: var(--slecht-ink); }
.lvl-2 { background: var(--matig-bg); color: var(--matig-ink); }
.lvl-1 { background: #fffbeb; color: #92400e; }
.lvl-0 { background: var(--top-bg); color: var(--top-ink); }

.ingredients { margin: 0; font-size: 15px; color: var(--text); }
.source { margin-top: 24px; color: var(--muted); font-size: var(--fs-small); display: flex; gap: 16px; flex-wrap: wrap; }
.source a { color: var(--accent-ink); }
.iarc li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; padding: 10px 0; align-items: start; }
.iarc li + li { border-top: 1px solid var(--rule); }

/* loading: final layout with grey bars, no shimmer */
.sk { display: block; background: #eceef1; border-radius: 6px; }

/* profiles */
.person-card .card-head { align-items: center; }
.person-name { display: flex; align-items: center; gap: 12px; }
.person-name .input { max-width: 260px; font-weight: 600; }
.section-label { font-size: var(--fs-small); font-weight: 500; margin: 20px 0 10px; }
.hue-row { display: flex; gap: 8px; }
.hue { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.hue[aria-pressed="true"] { border-color: var(--text); }
.settings-row { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: var(--gap); padding: 28px 0; border-top: 1px solid var(--border); }
.settings-row:first-of-type { border-top: 0; padding-top: 0; }
.settings-row p { margin: 6px 0 0; }
.explain p { margin: 0 0 12px; }
.explain p:last-child { margin-bottom: 0; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-small); }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--none-mark); }
.status.on i { background: var(--positive); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: #fff;
  padding: 12px 18px; border-radius: 12px; font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); z-index: 20; max-width: calc(100vw - 32px);
}

.history-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--gap); align-items: start; }

@media (max-width: 960px) {
  .scan-layout, .grid-2, .history-layout { grid-template-columns: 1fr; }
  .product-grid { gap: var(--gap); }
  .product-grid > .stack { display: contents; }
  .o-1 { order: 1; margin-top: 0 !important; }
  .o-2 { order: 2; margin-top: 0 !important; }
  .o-3 { order: 3; margin-top: 0 !important; }
  .o-4 { order: 4; margin-top: 0 !important; }
  .o-5 { order: 5; margin-top: 0 !important; }
  .o-6 { order: 6; margin-top: 0 !important; }
  .o-7 { order: 7; margin-top: 0 !important; }
  .o-8 { order: 8; margin-top: 0 !important; }
  .o-9 { order: 9; margin-top: 0 !important; }
  .o-10 { order: 10; margin-top: 0 !important; }

  .settings-row { grid-template-columns: 1fr; gap: 12px; }
}

/* phone: the rail becomes a bottom bar with labels */
@media (max-width: 720px) {
  :root { --pad: 20px; --gap: 16px; --fs-title: 24px; --fs-section: 18px; }
  .canvas { margin-left: 0; padding: calc(16px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom)); }
  .rail {
    inset: auto 0 0 0; width: auto; height: calc(64px + env(safe-area-inset-bottom)); flex-direction: row; justify-content: space-around;
    padding: 6px 8px env(safe-area-inset-bottom); border-right: 0; border-top: 1px solid var(--border); background: #fff;
  }
  .rail-mark { display: none; }
  .rail-item { width: auto; flex: 1; height: 52px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 500; }
  .rail-item span { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .rail-item[aria-current="page"] { background: none; }
  .rail-item svg { width: 22px; height: 22px; }
  .title-row { margin-bottom: 16px; flex-wrap: wrap; align-items: flex-start; }
  .title-row .btn { width: 100%; }
  .person-name .input { max-width: none; }
  .person-card .card-head { flex-wrap: wrap; }
  .viewfinder { aspect-ratio: 1 / 1; }
  .prod-head { grid-template-columns: 80px minmax(0, 1fr); gap: 14px; }
  .prod-img { width: 80px; height: 80px; }
  .prod-head h1 { font-size: 22px; }
  .score-card { padding: 16px; gap: 16px; }
  .ntable td.lvl { width: 96px; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
.list > li.day, .list > li.day + li { border-top: 0; }
