/* Portaal: rustig grijs met teal, veel witruimte, mobiel eerst */
@font-face { font-family: "Inter"; src: url("/fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("/fonts/plus-jakarta-sans.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  --ink: #14181F; --muted: #4A5360; --line: #DDE1E7; --line-soft: #EEF0F3; --bg: #F3F5F7; --surface: #fff;
  --accent: #0E7C7B; --accent-dark: #0A6665; --accent-ink: #0A5F5E; --accent-soft: #DDF1F0; --accent-mid: #6CC3C1; --accent-line: #9DD6D4;
  --danger: #B42318; --danger-soft: #FDECEA; --ok-soft: #DDF3E6; --ok-ink: #14532D;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; }
a { color: var(--accent-ink); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent-mid); outline-offset: 2px; }

/* ---------- indeling ---------- */
.app { display: flex; min-height: 100vh; }
.side { width: 256px; flex: none; background: var(--surface); border-right: 1px solid var(--line); padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; position: sticky; top: 0; z-index: 5; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); }
.content { width: 100%; max-width: 1080px; margin: 0 auto; padding: 44px 40px 72px; outline: none; }
.bottomnav { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(8px + env(safe-area-inset-bottom, 0px)); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brandlogo { display: block; flex: none; border-radius: 22%; }
.brandmark { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: #fff; flex: none; }
.brandname { display: flex; flex-direction: column; gap: 2px; }
.brandname b { font: 700 17px/1.1 var(--font-head); }
.brandname span { font-size: 13px; color: var(--muted); }
.sidefoot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }

/* ---------- typografie ---------- */
.h1 { font: 700 30px/1.15 var(--font-head); letter-spacing: -.02em; margin: 0; overflow-wrap: anywhere; }
.h2 { font: 700 18px/1.3 var(--font-head); letter-spacing: -.01em; margin: 0; }
.sub { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.pagehead > div:first-child { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- knoppen ---------- */
.btn, .btn2 { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 12px; font: 600 15px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn2 { border: 1px solid #CFE0EE; background: var(--surface); color: #0A5F5E; }
.btn2:hover { background: #EEF7F7; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn2.danger { color: var(--danger); border-color: #F1C4BF; }
.btn2.danger:hover { background: var(--danger-soft); }
.btn:disabled, .btn2:disabled { opacity: .6; cursor: default; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.iconbtn:hover { background: #F0F6FB; color: var(--accent-ink); }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px 0 4px; margin-left: -4px; border: 0; background: transparent; color: #0A5F5E; font: 600 14px/1 var(--font); cursor: pointer; border-radius: 10px; text-decoration: none; }
.back:hover { background: var(--accent-soft); }

/* ---------- navigatie ---------- */
.navbtn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 12px; background: transparent; color: #4A5360; font: 500 15px/1 var(--font); cursor: pointer; text-align: left; text-decoration: none; }
.navbtn:hover { background: #F0F6FB; }
.navbtn.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; padding: 4px 0; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font: 500 11px/1.1 var(--font); text-decoration: none; }
.tab.on { color: var(--accent-ink); font-weight: 600; }
.tab.on .tabicon { background: var(--accent-soft); }
.tabicon { display: flex; align-items: center; justify-content: center; width: 44px; height: 28px; border-radius: 999px; }

/* ---------- onderdelen ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.pill { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font: 600 12px/1 var(--font); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok-ink); }
.pill.grey { background: #EEF0F3; color: #4A5360; }
.chip { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid #D5DDE3; background: var(--surface); color: #2C3743; font: 500 14px/1 var(--font); cursor: pointer; }
.chip:hover { background: #EEF7F7; }
.chip.on { background: var(--accent-soft); border-color: var(--accent-mid); color: var(--accent-ink); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.daychip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 60px; min-height: 64px; padding: 6px 8px; border-radius: 14px; border: 1px solid #D5DDE3; background: var(--surface); color: #2C3743; font: 500 12px/1 var(--font); cursor: pointer; }
.daychip b { font: 700 18px/1 var(--font-head); }
.daychip small { font-size: 11px; max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.daychip:hover { background: #EEF7F7; }
.daychip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg { display: inline-flex; padding: 4px; border-radius: 14px; background: #E9F0F6; gap: 2px; max-width: 100%; flex-wrap: wrap; }
.seg button, .seg label { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 0; border-radius: 11px; background: transparent; color: #4A5360; font: 500 14px/1 var(--font); cursor: pointer; }
.seg button.on, .seg label.on { background: var(--surface); color: var(--accent-ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16,32,47,.12); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--accent-mid); }

.rowwrap { border-bottom: 1px solid var(--line-soft); }
.rowwrap:last-child { border-bottom: 0; }
.rowbtn { display: flex; align-items: center; gap: 16px; width: 100%; padding: 14px 20px; border: 0; background: transparent; cursor: pointer; font: inherit; color: inherit; text-align: left; min-height: 64px; text-decoration: none; }
.rowbtn:hover { background: #F6FAFA; }
.datebox { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; flex: none; width: 56px; height: 56px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-ink); }
.datebox span { font: 600 12px/1 var(--font); }
.datebox b { font: 700 20px/1 var(--font-head); }
.rowtext { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 auto; }
.rowtext b { font-weight: 600; font-size: 16px; }
.empty { padding: 32px 24px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); overflow: hidden; margin-bottom: 8px; }
.stats > div { display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; border-right: 1px solid var(--line-soft); }
.stats span:first-child { font-size: 13px; color: var(--muted); }
.stats b { font: 700 22px/1.1 var(--font-head); font-variant-numeric: tabular-nums; }
.statnote { margin: 0 0 24px; font-size: 13px; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.tile { display: flex; align-items: center; gap: 16px; padding: 20px; color: inherit; text-decoration: none; }
.tile:hover { border-color: var(--accent-line); background: #FAFDFD; }
.tileicon { display: flex; align-items: center; justify-content: center; flex: none; width: 48px; height: 48px; border-radius: 14px; background: var(--accent-soft); color: #0A5F5E; }
.tile b { display: block; font: 700 32px/1 var(--font-head); font-variant-numeric: tabular-nums; }
.tile span.lbl { font-size: 14px; color: var(--muted); }
.cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.cta { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; padding: 24px; border-radius: 16px; background: var(--accent-soft); border: 1px solid #BFDDF3; }
.cta p { margin: 0; font-size: 15px; line-height: 1.55; color: #2C3743; }

/* accordeon */
.meals { display: flex; flex-direction: column; gap: 12px; }
.meal { overflow: hidden; }
.mealhead { min-height: 72px; }
.chev { transition: transform .2s ease; flex: none; color: var(--muted); }
.chev.up { transform: rotate(180deg); }
.mealbody { padding: 0 20px 16px; border-top: 1px solid var(--line-soft); }
.line { display: flex; align-items: center; gap: 12px; padding: 6px 0 6px; border-bottom: 1px solid #F1F5F9; min-height: 56px; }
.line:last-of-type { border-bottom: 0; }
.line .name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 15px; overflow-wrap: anywhere; }
.line .amt { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mealfoot { padding-top: 12px; }
.btn2.small { min-height: 44px; padding: 0 14px; font-size: 14px; }

/* recepten */
.search { position: relative; max-width: 520px; }
.search svg { position: absolute; left: 15px; top: 14px; pointer-events: none; color: var(--muted); }
.field { width: 100%; height: 48px; border: 1px solid #D5DDE3; border-radius: 12px; padding: 0 16px; font: 400 15px var(--font); background: var(--surface); color: var(--ink); }
.search .field { padding-left: 46px; }
.field::placeholder { color: #6B7C8D; }
.field:focus { border-color: var(--accent); }
textarea.field { height: auto; padding: 12px 16px; line-height: 1.5; resize: vertical; }
select.field { appearance: auto; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.rcard { display: flex; flex-direction: column; gap: 14px; padding: 20px; color: inherit; text-decoration: none; min-height: 176px; }
.rcard:hover { border-color: var(--accent-line); background: #FAFDFD; }
.rcard .name { font: 700 17px/1.3 var(--font-head); letter-spacing: -.01em; overflow-wrap: anywhere; }
.rcard .meta { display: flex; flex-direction: column; gap: 4px; margin-top: auto; }
.twocol { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.twocol > .left { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.twocol > .right { flex: 1.3 1 420px; min-width: 0; }
.pad { padding: 20px; }
.kv { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid #F1F5F9; font-size: 15px; }
.kv:last-child { border-bottom: 0; }
.kv .amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 8px; border-radius: 999px; background: #EAF1F7; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; }
.prep { margin: 12px 0 0; font-size: 16px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }

/* tabel (ingrediënten) */
.tablewrap { overflow-x: auto; }
.trow { display: grid; grid-template-columns: minmax(200px, 2.2fr) repeat(4, minmax(90px, 1fr)) 52px; align-items: center; gap: 8px; padding: 8px 12px 8px 20px; border-bottom: 1px solid var(--line-soft); font-size: 15px; min-width: 700px; }
.trow.th { background: var(--bg); font: 600 12px/1.2 var(--font); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding-top: 12px; padding-bottom: 12px; }
.trow:not(.th):hover { background: #F6FAFA; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* boodschappen */
.check { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 8px 20px; border: 0; background: transparent; cursor: pointer; font: 400 16px/1.3 var(--font); color: var(--ink); text-align: left; }
.check:hover { background: #F6FAFA; }
.box { display: flex; align-items: center; justify-content: center; flex: none; width: 24px; height: 24px; border-radius: 8px; border: 2px solid #9DB5CA; background: var(--surface); color: #fff; }
.box svg { opacity: 0; stroke-width: 3; }
.check.on .box { background: var(--accent); border-color: var(--accent); }
.check.on .box svg { opacity: 1; }
.check.on .lbl { color: #6B7C8D; text-decoration: line-through; }
.weeknav { display: flex; align-items: center; gap: 4px; }
.weeknav b { font: 600 15px/1.2 var(--font); min-width: 0; padding: 0 8px; text-align: center; }

/* ---------- formulieren en dialogen ---------- */
.dlg { border: 0; border-radius: 20px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); color: var(--ink); background: var(--surface); box-shadow: 0 24px 64px rgba(16,32,47,.28); }
.dlg.wide { width: min(760px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(16,32,47,.45); }
.dlgform { display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
.dlghead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 12px 8px 24px; }
.dlgbody { padding: 8px 24px 16px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.dlgfoot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 24px 20px; border-top: 1px solid var(--line-soft); }
.dlgextra, .dlgmain { display: flex; flex-wrap: wrap; gap: 10px; }
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fld > label, .fld > .lab { font-size: 14px; font-weight: 600; color: #2C3743; }
.hint { font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.checkrow { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 15px; }
.checkrow input { width: 22px; height: 22px; accent-color: var(--accent); }
.err { margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px; line-height: 1.4; }
.irow { display: grid; grid-template-columns: minmax(0, 1fr) 96px 120px 44px; gap: 8px; align-items: center; }
.irows { display: flex; flex-direction: column; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 24px); z-index: 50; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px; background: #10202F; color: #fff; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* inlogscherm */
.loginwrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.logincard { width: min(420px, 100%); padding: 32px 28px; display: flex; flex-direction: column; gap: 20px; }
.loading { padding: 48px 0; text-align: center; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { .chev, .toast { transition: none; } }
@media (max-width: 600px) { .grid2.stack { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 820px) {
  .side { display: none; }
  .topbar { display: flex; }
  .bottomnav { display: grid; }
  .content { padding: 24px 16px calc(120px + env(safe-area-inset-bottom, 0px)); }
  .h1 { font-size: 26px; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .irow { grid-template-columns: minmax(0, 1fr) 80px 44px; }
  .irow .eenheid { grid-column: 1 / 3; grid-row: 2; }
  .irow .rm { grid-column: 3; grid-row: 1 / 3; }
  .dlghead { padding-left: 20px; }
  .dlgbody { padding-left: 20px; padding-right: 20px; }
  .dlgfoot { padding-left: 20px; padding-right: 20px; }
}

/* Importeren */
.codebox { font: 400 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; overflow: auto; }
textarea.codebox[readonly] { background: #F6FAFA; }

/* Schema-knoppen zijn links: geen onderstreping. Schakelaars en onderste navigatie passen op smalle schermen. */
a.chip { text-decoration: none; }
@media (max-width: 600px) {
  .seg[aria-label="Periode"] { display: flex; }
  .seg[aria-label="Periode"] button { flex: 1 1 0; justify-content: center; padding: 0 6px; white-space: nowrap; font-size: 13px; }
  .tab { font-size: 10.5px; }
}

/* Logboek */
.logrow { display: grid; grid-template-columns: 140px 160px 120px minmax(0, 1fr) 180px; gap: 12px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.logrow:last-child { border-bottom: 0; }
.logtijd { color: var(--muted); font-variant-numeric: tabular-nums; }
.logip { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.logip code { font: 500 13px ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: #FFF1D6; color: #7A4B00; }
@media (max-width: 820px) {
  .logrow { grid-template-columns: 1fr auto; row-gap: 4px; padding: 12px 16px; }
  .logtijd { order: 1; } .logrow > span:nth-child(2) { order: 2; justify-self: end; }
  .logsite { order: 3; grid-column: 1 / -1; } .logwie { order: 4; grid-column: 1 / -1; } .logip { order: 5; grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  #log-tegels { grid-template-columns: 1fr 1fr; gap: 10px; }
  #log-tegels .tile { padding: 12px 14px !important; }
  #log-tegels .tile b { font-size: 24px; }
  #log-tegels .lbl { font-size: 13px; }
}

/* Portaal: bovenbalk en apptegels */
.ptop { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 40px; padding-top: calc(14px + env(safe-area-inset-top, 0px)); background: var(--surface); border-bottom: 1px solid var(--line); }
.pnav { display: flex; gap: 6px; flex-wrap: wrap; }
.pnav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 15px; }
.pnav a:hover { background: #F3F5F7; }
.pnav a.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.puser { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.apptiles { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 32px; }
.apptile { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 16px; padding: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; text-decoration: none; color: inherit; }
.apptile:hover { border-color: var(--accent-line); box-shadow: 0 6px 24px rgba(20,24,31,.06); }
.appicon { width: 56px; height: 56px; border-radius: 14px; color: #fff; display: flex; align-items: center; justify-content: center; font: 800 26px/1 var(--font-head); flex: none; }
.apptile b { font: 800 22px/1.2 var(--font-head); letter-spacing: -.01em; }
.notice { padding: 14px 18px; border-radius: 14px; background: #FFF1D6; color: #7A4B00; margin-bottom: 24px; font-size: 15px; line-height: 1.5; }
.keybox { font: 600 15px ui-monospace, Menlo, Consolas, monospace; word-break: break-all; user-select: all; padding: 12px 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
@media (max-width: 820px) {
  .ptop { padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  .pnav { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; }
  .pnav a { white-space: nowrap; }
  .content { padding: 28px 16px 56px; }
}
