:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #eef2f1;
  --text: #17201e;
  --muted: #5f6b68;
  --line: #dde3e1;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #d7efec;
  --plus: #15803d;
  --minus: #b42318;
  --warn-bg: #fff4e0;
  --warn: #8a5300;
  --radius: 14px;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1413;
    --surface: #182120;
    --surface-2: #212c2a;
    --text: #e8eeec;
    --muted: #9aa8a4;
    --line: #2c3936;
    --brand: #2bb3a5;
    --brand-ink: #062522;
    --brand-soft: #173d39;
    --plus: #4ade80;
    --minus: #f87171;
    --warn-bg: #3a2a10;
    --warn: #f5c272;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}
button, input, select { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.35rem; margin: 0; flex: 1; }
.badge { font-size: .75rem; padding: 3px 8px; border-radius: 99px; background: var(--warn-bg); color: var(--warn); font-weight: 600; }

main { padding: 12px 16px; max-width: 720px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar button {
  border: 0; background: none; font-size: .72rem; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tabbar button .ico { font-size: 1.3rem; filter: grayscale(1); opacity: .7; }
.tabbar button.active { color: var(--brand); font-weight: 600; }
.tabbar button.active .ico { filter: none; opacity: 1; }

/* Bausteine */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface);
  padding: 7px 14px; border-radius: 99px; font-size: .92rem;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 10px 16px; min-height: 44px; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--minus); }
.btn.big { width: 100%; min-height: 56px; font-size: 1.1rem; }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: .88rem; }
.btn:disabled { opacity: .45; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 10px; }

.input {
  width: 100%; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); min-height: 44px;
}
.input:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
label.field { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
label.field .input { color: var(--text); font-size: 1rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 4px 8px; font-weight: 700; }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li.tap { cursor: pointer; }
.thumb {
  width: 44px; height: 44px; flex: none; border-radius: 10px; background: var(--surface-2);
  object-fit: contain; display: grid; place-items: center; font-size: 1.3rem;
}
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qty { font-weight: 700; font-size: 1.15rem; min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }
.qty.zero { color: var(--minus); }
.locqty { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill { font-size: .78rem; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill b { font-size: .9rem; }
.plus { color: var(--plus); }
.minus { color: var(--minus); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { border: 0; background: var(--surface-2); width: 36px; height: 36px; font-size: 1.2rem; }
.stepper span { min-width: 34px; text-align: center; font-weight: 700; }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.empty .big { font-size: 2.4rem; }
.hint { font-size: .85rem; color: var(--muted); margin: 6px 4px; }
.warnbox { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: .9rem; }

/* Modal (Bottom-Sheet) */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.modal h2 { margin: 0 0 12px; font-size: 1.2rem; }
.modal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; flex: 1; }
.product-hero { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.product-hero img, .product-hero .thumb { width: 72px; height: 72px; }

/* Scanner */
.scanner { position: fixed; inset: 0; z-index: 40; background: #000; color: #fff; display: flex; flex-direction: column; }
.scanner-head { display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 10px) 12px 10px; }
.scanner-head h2 { flex: 1; margin: 0; font-size: 1.05rem; }
.scanner-head .btn { background: rgba(255,255,255,.15); border-color: transparent; color: #fff; }
#reader { flex: 1; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; }
#reader video { width: 100% !important; height: auto !important; max-height: 100%; object-fit: cover; }
.scanner-foot { background: #111; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: grid; gap: 8px; max-height: 40vh; overflow-y: auto; }
.scanner-foot .input { background: #222; border-color: #333; color: #fff; }
.feed { display: grid; gap: 6px; }
.feed-item { display: flex; align-items: center; gap: 8px; background: #1d1d1d; border-radius: 10px; padding: 8px 10px; font-size: .92rem; }
.feed-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item .btn { background: #333; border-color: #333; color: #fff; }
.scanner-flash { animation: flash .35s ease-out; }
@keyframes flash { from { box-shadow: inset 0 0 0 6px #22c55e; } to { box-shadow: inset 0 0 0 0 transparent; } }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  background: #17201e; color: #fff; padding: 10px 16px; border-radius: 12px;
  max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: .95rem;
}
.toast.err { background: #b42318; }

.login { max-width: 380px; margin: 10vh auto 0; }
.login h2 { margin-top: 0; }
.cart-total { display: flex; justify-content: space-between; font-weight: 700; padding: 10px 4px; }
.price-input { width: 84px; text-align: right; padding: 6px 8px; min-height: 36px; }
.day { font-size: .82rem; color: var(--muted); font-weight: 700; margin: 16px 4px 6px; }
