/* ============ Onze Clean Maand — styles ============ */

:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --card-soft: #faf8f3;
  --ink: #26302b;
  --muted: #6f7a72;
  --line: #e6e2d8;
  --accent: #2f7d5c;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe8;
  --warn: #b7791f;
  --warn-soft: #f7ecd8;
  --ok: #2f7d5c;
  --danger: #b5493a;
  --danger-soft: #f6e3df;
  --shadow: 0 1px 3px rgba(38, 48, 43, .08), 0 4px 16px rgba(38, 48, 43, .06);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141715;
    --card: #1e2320;
    --card-soft: #232925;
    --ink: #e9ece7;
    --muted: #9aa69e;
    --line: #313833;
    --accent: #58b98d;
    --accent-ink: #10241b;
    --accent-soft: #24352c;
    --warn: #d9a441;
    --warn-soft: #37301f;
    --ok: #58b98d;
    --danger: #d97a6c;
    --danger-soft: #3a2723;
    --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  overflow-x: hidden;
}

body.sheet-open { overflow: hidden; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font: inherit; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
}
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; max-width: 720px; margin: 0 auto; }
.app-title { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.week-label { font-size: 13px; color: var(--muted); margin-top: 1px; }
.header-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; font-size: 19px;
  display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow);
}
.icon-btn:active { transform: scale(.94); }

/* ---------- Layout ---------- */
#main { max-width: 720px; margin: 0 auto; padding: 14px 14px calc(env(safe-area-inset-bottom) + 92px); }
.view[hidden] { display: none; }

h2.section-title { font-size: 17px; font-weight: 700; margin: 18px 2px 8px; }
.sub { color: var(--muted); font-size: 14px; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
}

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 11px; font-weight: 600; color: var(--muted);
  padding: 5px 0 3px; border-radius: 12px; max-width: 120px;
}
.tab-icon { font-size: 21px; line-height: 1.2; }
.tab.active { color: var(--accent); background: var(--accent-soft); }
.tab:active { transform: scale(.95); }

/* ---------- Knoppen ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: 13px; font-weight: 700; font-size: 15px;
  background: var(--card-soft); border: 1px solid var(--line); color: var(--ink);
  min-height: 44px;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn.small { padding: 7px 12px; min-height: 36px; font-size: 13.5px; border-radius: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.btn-row .btn { flex: 1 1 auto; }

/* ---------- Weekplanner ---------- */
.day-card { padding: 10px 12px 6px; }
.day-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.day-name { font-weight: 800; font-size: 15px; text-transform: capitalize; }
.day-date { color: var(--muted); font-size: 12.5px; }
.day-kcal { margin-left: auto; color: var(--muted); font-size: 12px; }
.day-card.today { outline: 2px solid var(--accent); outline-offset: -1px; }
.today-chip { font-size: 10.5px; font-weight: 800; background: var(--accent); color: var(--accent-ink); border-radius: 20px; padding: 1.5px 8px; }

.slot-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--line); min-height: 48px;
}
.slot-row:first-of-type { border-top: none; }
.slot-label { width: 58px; flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--muted); }
.slot-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.slot-recipe {
  flex: 1; min-width: 0; text-align: left; display: flex; align-items: center; gap: 8px;
  padding: 4px 2px; border-radius: 8px;
}
.slot-recipe .r-em { font-size: 19px; flex-shrink: 0; }
.slot-recipe .slot-txt { display: block; min-width: 0; flex: 1; }
.slot-recipe .r-name {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; font-weight: 600; font-size: 14.5px; line-height: 1.25;
}
.slot-recipe .r-meta { display: block; font-size: 11.5px; color: var(--muted); }
.slot-empty {
  flex: 1; text-align: left; color: var(--muted); font-size: 14px; font-weight: 600;
  padding: 8px 10px; border: 1.5px dashed var(--line); border-radius: 11px;
}
.slot-btns { display: flex; gap: 2px; flex-shrink: 0; }
.mini-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 9px; font-size: 14px; color: var(--muted); background: var(--card-soft);
}
.mini-btn:active { transform: scale(.9); }

/* Weekcheck */
.check-row { display: flex; gap: 9px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; align-items: flex-start; }
.check-row:first-of-type { border-top: none; }
.check-ico { flex-shrink: 0; font-size: 15px; line-height: 1.4; }
.check-ok .check-ico { color: var(--ok); }
.check-warn { color: inherit; }
.check-text b { font-weight: 700; }
.check-detail { display: block; font-size: 12.5px; color: var(--muted); }

/* ---------- Chips / filters ---------- */
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 2px 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 7px 13px; border-radius: 20px; font-size: 13.5px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); color: var(--ink); white-space: nowrap;
}
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.search-box {
  width: 100%; padding: 11px 14px; font-size: 16px; border-radius: 13px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  margin-bottom: 8px; -webkit-appearance: none;
}
.search-box:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* ---------- Receptkaarten ---------- */
.recipe-card {
  width: 100%; text-align: left; display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 11px 12px; margin-bottom: 9px;
}
.recipe-card:active { transform: scale(.985); }
.recipe-em { font-size: 30px; flex-shrink: 0; width: 44px; height: 44px; display: grid; place-items: center; background: var(--card-soft); border-radius: 12px; }
.recipe-info { flex: 1; min-width: 0; }
.recipe-name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.recipe-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.fav-star { font-size: 20px; flex-shrink: 0; padding: 6px; color: var(--muted); }
.fav-star.is-fav { color: #e0a83c; }
.badge { font-size: 10.5px; font-weight: 700; padding: 1.5px 7px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); }
.badge.recent { background: var(--warn-soft); color: var(--warn); }
.badge.gepland { background: var(--accent); color: var(--accent-ink); }
.group-title { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 16px 2px 8px; }

/* ---------- Sheet (modal) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(15, 20, 17, .45);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-height: calc(100dvh - 40px);
  background: var(--bg); border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column;
  animation: sheet-up .22s ease-out;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .25);
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet[hidden], .sheet-backdrop[hidden] { display: none !important; }
.sheet-handle { width: 40px; height: 4.5px; background: var(--line); border-radius: 4px; margin: 9px auto 2px; flex-shrink: 0; }
.sheet-content { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px calc(env(safe-area-inset-bottom) + 24px); }
.sheet-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; position: sticky; top: 0; background: var(--bg); padding: 6px 0 8px; z-index: 2; }
.sheet-title { font-size: 19px; font-weight: 800; line-height: 1.25; flex: 1; }
.sheet-close { width: 34px; height: 34px; border-radius: 50%; background: var(--card); font-size: 15px; display: grid; place-items: center; flex-shrink: 0; box-shadow: var(--shadow); }

/* Receptdetail */
.detail-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.meta-pill { font-size: 13px; font-weight: 600; background: var(--card); border: 1px solid var(--line); padding: 5px 11px; border-radius: 20px; }
.portion-stepper { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 13px; padding: 9px 12px; margin-bottom: 12px; box-shadow: var(--shadow); }
.stepper-btn { width: 38px; height: 38px; border-radius: 11px; background: var(--card-soft); border: 1px solid var(--line); font-size: 19px; font-weight: 700; }
.stepper-val { font-weight: 800; font-size: 15px; flex: 1; text-align: center; }
.ing-list { list-style: none; }
.ing-list li { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.ing-list li:first-child { border-top: none; }
.ing-qty { min-width: 84px; font-weight: 700; flex-shrink: 0; }
.step-list { list-style: none; counter-reset: step; }
.step-list li { display: flex; gap: 11px; padding: 8px 0; font-size: 14.5px; }
.step-list li::before {
  counter-increment: step; content: counter(step);
  width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12.5px; font-weight: 800; display: grid; place-items: center; margin-top: 1px;
}
.tip-box { background: var(--warn-soft); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; margin-top: 10px; }
.plan-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 8px; }
.plan-grid .btn.small { flex: none; }
.day-btn { padding: 9px 4px; border-radius: 11px; background: var(--card); border: 1px solid var(--line); font-weight: 700; font-size: 13px; text-align: center; }
.day-btn:active { background: var(--accent); color: var(--accent-ink); }

/* ---------- Boodschappenlijst ---------- */
.list-cat { margin-bottom: 14px; }
.list-cat-title { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 2px 6px; }
.list-item {
  width: 100%; display: flex; align-items: center; gap: 11px; text-align: left;
  background: var(--card); padding: 10px 12px; border-radius: 12px; margin-bottom: 6px;
  box-shadow: var(--shadow); min-height: 48px;
}
.list-check {
  width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%;
  border: 2px solid var(--line); display: grid; place-items: center; font-size: 13px; color: transparent;
}
.list-item.checked .list-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.list-item.checked .list-name { text-decoration: line-through; color: var(--muted); }
.list-name { flex: 1; font-size: 14.5px; font-weight: 600; min-width: 0; }
.list-qty { font-size: 13.5px; color: var(--muted); font-weight: 600; text-align: right; flex-shrink: 0; }
.list-advice { display: block; font-size: 11.5px; color: var(--accent); font-weight: 700; }
.progress-bar { height: 7px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 8px 0 2px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width .25s; }
.extra-row { display: flex; gap: 8px; margin-top: 8px; }
.extra-row input { flex: 1; }

/* ---------- Gids ---------- */
details.gids-sec { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px; overflow: hidden; }
details.gids-sec summary {
  list-style: none; cursor: pointer; padding: 14px; font-weight: 800; font-size: 15.5px;
  display: flex; align-items: center; gap: 10px;
}
details.gids-sec summary::-webkit-details-marker { display: none; }
details.gids-sec summary::after { content: '›'; margin-left: auto; font-size: 20px; color: var(--muted); transform: rotate(90deg); transition: transform .15s; }
details.gids-sec[open] summary::after { transform: rotate(-90deg); }
.gids-body { padding: 0 14px 14px; }
.gids-body ul { list-style: none; }
.gids-body ul li { padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.gids-body ul li:first-child { border-top: none; }
.prod-item { padding: 9px 0; border-top: 1px solid var(--line); }
.prod-item:first-child { border-top: none; }
.prod-name { font-weight: 700; font-size: 14.5px; }
.prod-why { font-size: 13px; color: var(--muted); margin-top: 2px; }
.prod-ruil { font-size: 13px; margin-top: 3px; color: var(--accent); font-weight: 600; }
.data-badge { text-align: center; font-size: 12.5px; color: var(--muted); padding: 10px 0 2px; }

/* ---------- Instellingen ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: none; }
.set-label { font-weight: 700; font-size: 14.5px; }
.set-sub { font-size: 12.5px; color: var(--muted); font-weight: 400; display: block; }
.seg { display: flex; background: var(--card-soft); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.seg button.active { background: var(--accent); color: var(--accent-ink); }
.switch { width: 52px; height: 31px; border-radius: 20px; background: var(--line); position: relative; transition: background .18s; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 25px; height: 25px; border-radius: 50%; background: #fff; transition: left .18s; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.switch.on { background: var(--accent); }
.switch.on::after { left: 24px; }

/* ---------- Macro's ---------- */
.macro-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.macro-box {
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow);
  text-align: center; padding: 10px 4px;
}
.macro-box b { display: block; font-size: 16px; font-weight: 800; }
.macro-box span { font-size: 10.5px; color: var(--muted); }
.macro-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.macro-table th {
  text-align: right; font-size: 10.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; padding: 4px 6px;
}
.macro-table td { text-align: right; padding: 6px; border-top: 1px solid var(--line); }
.macro-table th:first-child, .macro-table td:first-child { text-align: left; font-weight: 700; text-transform: capitalize; }
.macro-table tr.avg td { font-weight: 800; border-top: 2px solid var(--ink); }
.nutri-details summary {
  list-style: none; cursor: pointer; font-size: 13px; font-weight: 700;
  color: var(--accent); padding: 10px 0 2px;
}
.nutri-details summary::-webkit-details-marker { display: none; }
.nutri-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
.nutri-table th {
  text-align: right; color: var(--muted); font-weight: 700; padding: 3px 4px;
  font-size: 10px; text-transform: uppercase; letter-spacing: .03em;
}
.nutri-table td { text-align: right; padding: 3.5px 4px; border-top: 1px solid var(--line); }
.nutri-table th:first-child, .nutri-table td:first-child { text-align: left; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 100px);
  transform: translateX(-50%); z-index: 90;
  background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600;
  padding: 11px 18px; border-radius: 24px; max-width: 88vw; text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.3);
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.empty-state { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty-state .big { font-size: 44px; margin-bottom: 8px; }

/* ---------- Print ---------- */
#print-root { display: none; }

@media print {
  body { background: #fff; color: #111; font-size: 12px; }
  .app-header, #main, .tabbar, .sheet, .sheet-backdrop, .toast { display: none !important; }
  #print-root { display: block; padding: 0; }
  .p-page { page-break-after: always; }
  .p-page:last-child { page-break-after: auto; }
  .p-title { font-size: 20px; font-weight: 800; margin-bottom: 2px; }
  .p-sub { font-size: 11px; color: #555; margin-bottom: 12px; }
  table.p-menu { width: 100%; border-collapse: collapse; }
  table.p-menu th, table.p-menu td { border: 1px solid #bbb; padding: 6px 7px; text-align: left; vertical-align: top; }
  table.p-menu th { background: #eef3ef; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
  table.p-menu td .p-r { font-weight: 700; }
  table.p-menu td .p-t { color: #666; font-size: 10.5px; }
  .p-day { font-weight: 800; white-space: nowrap; }
  .p-cols { column-count: 2; column-gap: 26px; }
  .p-cat { break-inside: avoid; margin-bottom: 12px; }
  .p-cat h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1.5px solid #333; padding-bottom: 3px; margin-bottom: 5px; }
  .p-item { display: flex; gap: 7px; padding: 2.5px 0; font-size: 11.5px; align-items: baseline; }
  .p-item .box { width: 10px; height: 10px; border: 1.2px solid #333; border-radius: 3px; flex-shrink: 0; position: relative; top: 1px; }
  .p-item .q { color: #444; margin-left: auto; white-space: nowrap; padding-left: 8px; }
  .p-recipe { break-inside: avoid; border: 1px solid #ccc; border-radius: 8px; padding: 9px 11px; margin-bottom: 10px; }
  .p-recipe h3 { font-size: 13px; margin-bottom: 2px; }
  .p-recipe .p-meta { font-size: 10px; color: #666; margin-bottom: 5px; }
  .p-recipe .p-ing { font-size: 10.5px; color: #333; margin-bottom: 5px; }
  .p-recipe ol { margin-left: 16px; font-size: 10.5px; }
  .p-recipe ol li { margin-bottom: 2px; }
  .p-note { font-size: 10px; color: #777; margin-top: 8px; }
}

@media (min-width: 700px) {
  .plan-grid { grid-template-columns: repeat(7, 1fr); }
}
