:root {
  --bg: #f6f7f5; --card: #fff; --text: #17201c; --muted: #66706b; --line: #e3e6e2;
  --accent: #0f766e; --accent-soft: #ccfbf1; --deal: #dc2626; --ok: #16a34a;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1412; --card: #18201d; --text: #e8eeeb; --muted: #95a29c; --line: #26302c;
          --accent: #2dd4bf; --accent-soft: #134e4a; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
h2 { margin: .2em 0 .3em; } h3 { margin: 1.4em 0 .3em; }
.muted { color: var(--muted); } .small { font-size: 13px; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.week-select { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 6px 8px; }
.banner { background: #fef3c7; color: #78350f; padding: 8px 16px; font-size: 13px; }

main { max-width: 1100px; margin: 0 auto; padding: 12px 16px; }
.view { display: none; } .view.active { display: block; }

.toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.toolbar input { flex: 1; min-width: 0; }
input, select {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 12px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

.chips { display: flex; gap: 6px; margin-bottom: 8px; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap; font-size: 14px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .chip.on { color: #04201c; } }
.chip.store.on { background: var(--c); border-color: var(--c); color: var(--t); }
.chip .n { opacity: .7; font-size: 12px; margin-left: 4px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.group-title { grid-column: 1 / -1; margin: 10px 0 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card {
  position: relative; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 4px; cursor: pointer;
}
.card .img {
  height: 96px; border-radius: 10px; background: var(--bg); display: grid; place-items: center; font-size: 40px;
  overflow: hidden;
}
.card .img img { width: 100%; height: 100%; object-fit: contain; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  background: var(--c); color: var(--t); letter-spacing: .2px;
}
.badge.demo { background: #fde68a; color: #78350f; margin-left: 4px; }
.card .title { font-weight: 600; line-height: 1.25; }
.card .unit, .card .bp, .card .when { font-size: 12px; color: var(--muted); }
.price-row { display: flex; align-items: baseline; gap: 6px; margin-top: auto; flex-wrap: wrap; }
.price { font-size: 20px; font-weight: 800; }
.old { text-decoration: line-through; color: var(--muted); font-size: 13px; }
.pct { position: absolute; top: 8px; right: 8px; background: var(--deal); color: #fff; font-weight: 800;
       font-size: 12px; padding: 3px 7px; border-radius: 8px; }
.add {
  margin-top: 6px; border: 0; border-radius: 10px; padding: 8px; background: var(--accent-soft); color: var(--accent);
  font-weight: 700; cursor: pointer;
}
.add.in { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .add.in { color: #04201c; } }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 9px 14px; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { color: var(--deal); }

/* Liste */
.list-group { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.list-group header { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; }
.list-item .info { flex: 1; min-width: 0; }
.list-item .info .t { font-weight: 600; }
.list-item .info .s { font-size: 12px; color: var(--muted); }
.list-item.done .t { text-decoration: line-through; color: var(--muted); }
.list-item .warn { color: var(--deal); }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.qty span { min-width: 18px; text-align: center; }
.line-price { min-width: 64px; text-align: right; font-weight: 700; }
.summary { padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.summary .row { display: flex; justify-content: space-between; }
.summary .save { color: var(--ok); font-weight: 600; }
.list-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.suggest { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin: -4px 0 10px; overflow: hidden; }
.suggest button { display: flex; width: 100%; justify-content: space-between; gap: 8px; border: 0; background: none;
                  padding: 9px 12px; cursor: pointer; text-align: left; border-bottom: 1px solid var(--line); }
.suggest button:last-child { border-bottom: 0; }

/* Laeden */
.store-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.store { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--card); border: 2px solid var(--line);
         border-radius: var(--radius); cursor: pointer; }
.store.on { border-color: var(--c); }
.store .logo { width: 42px; height: 42px; border-radius: 10px; background: var(--c); color: var(--t); display: grid; place-items: center; font-weight: 800; }
.store .meta { flex: 1; } .store .meta small { display: block; color: var(--muted); }
.store input { width: 22px; height: 22px; accent-color: var(--accent); }

/* Tabs */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { flex: 1; border: 0; background: none; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center;
               font-size: 12px; color: var(--muted); cursor: pointer; position: relative; }
.tabs button span { font-size: 20px; }
.tabs button.active { color: var(--accent); font-weight: 700; }
.tabs b { position: absolute; top: 4px; left: calc(50% + 8px); background: var(--deal); color: #fff; border-radius: 999px;
          font-size: 11px; padding: 1px 6px; }

/* Detail */
dialog { border: 0; padding: 0; background: transparent; max-width: 560px; width: 100%; }
dialog::backdrop { background: rgba(0,0,0,.45); }
.sheet { background: var(--card); color: var(--text); border-radius: 18px; padding: 18px; position: relative; max-height: 85vh; overflow: auto; }
.sheet .close { position: absolute; top: 10px; right: 10px; border: 0; background: var(--bg); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.cmp { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cmp .info { flex: 1; } .cmp .best { color: var(--ok); font-weight: 700; font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .2s;
         background: #17201c; color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 14px; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (min-width: 900px) {
  .tabs { top: 0; bottom: auto; left: auto; right: 16px; width: 360px; background: none; border: 0; height: 60px; }
  .tabs button { flex-direction: row; gap: 6px; font-size: 14px; justify-content: center; }
  .tabs button span { font-size: 16px; }
  .top { padding-right: 400px; }
  body { padding-bottom: 20px; }
  .toast { bottom: 24px; }
}

.more { grid-column: 1 / -1; margin: 8px auto 16px; padding: 12px 20px; border: 1px solid var(--accent); border-radius: 999px; background: transparent; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }

.upload { display: grid; gap: 8px; margin: 8px 0; }
.upload select, .upload input, .upload button { font: inherit; padding: 10px; border-radius: 10px; border: 1px solid #ccc; }
.upload button { background: var(--accent); color: #fff; border: 0; font-weight: 600; }
