:root {
  --bg: #f1f5f9; --karte: #ffffff; --text: #0f172a; --matt: #64748b; --rand: #e2e8f0; --feld: #ffffff; --feldrand: #cbd5e1;
  --akzent: #dc2626; --akzent2: #b91c1c; --navi: #0f172a; --navitext: #94a3b8; --blau: #2563eb;
  --p0h: #dcfce7; --p0t: #15803d; --p1h: #fef3c7; --p1t: #b45309; --p2h: #fee2e2; --p2t: #b91c1c;
  --p3h: #f1f5f9; --p3t: #475569; --p4h: #dbeafe; --p4t: #1d4ed8;
  --schatten: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --karte: #111827; --text: #e5e7eb; --matt: #94a3b8; --rand: #1f2937; --feld: #0f172a; --feldrand: #334155;
    --navi: #020617; --p0h: #052e16; --p0t: #4ade80; --p1h: #3b2a05; --p1t: #fbbf24; --p2h: #3f0d0d; --p2t: #f87171;
    --p3h: #1e293b; --p3t: #cbd5e1; --p4h: #172554; --p4t: #93c5fd; --schatten: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Kopf ---------- */
.kopf { position: sticky; top: 0; z-index: 10; background: var(--navi); color: #fff;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 12px; display: flex; align-items: center; gap: 12px; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--akzent); position: relative; flex: none; }
.logo::before, .logo::after { content: ""; position: absolute; background: #fff; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.logo::before { width: 6px; height: 19px; } .logo::after { width: 19px; height: 6px; }
.kopf h1 { font-size: 18px; margin: 0; font-weight: 650; line-height: 1.1; }
.kopf .wer { font-size: 12.5px; color: var(--navitext); }
.kopf .titel { flex: 1; min-width: 0; }
.sync { border: 0; border-radius: 999px; padding: 6px 11px; font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.sync.ok { background: rgba(34,197,94,.18); color: #4ade80; }
.sync.warte { background: rgba(245,158,11,.2); color: #fbbf24; }
.sync.aus { background: rgba(148,163,184,.18); color: #cbd5e1; }
.sync.laeuft::before { animation: puls 1s infinite; }
@keyframes puls { 50% { opacity: .25; } }

/* ---------- Inhalt ---------- */
main { padding: 14px 14px calc(env(safe-area-inset-bottom) + 160px); max-width: 760px; margin: 0 auto; }
.suche { position: relative; margin-bottom: 10px; }
.suche input { width: 100%; padding: 12px 14px 12px 40px; border-radius: 12px; border: 1px solid var(--feldrand); background: var(--feld); outline: none; }
.suche input:focus { border-color: var(--blau); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.suche svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--matt); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -14px; padding-left: 14px; padding-right: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--rand); background: var(--karte); border-radius: 999px; padding: 7px 13px; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.chip.aktiv { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.chip .punkt { width: 8px; height: 8px; border-radius: 50%; }
.chip .n { font-size: 11.5px; font-weight: 700; color: #fff; background: var(--akzent); border-radius: 999px; padding: 1px 6px; }
.chip .n.gelb { background: #d97706; }

.kacheln { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.kachel { background: var(--karte); border: 1px solid var(--rand); border-radius: 14px; padding: 10px 12px; text-align: left; box-shadow: var(--schatten); }
.kachel b { display: block; font-size: 22px; line-height: 1.1; }
.kachel span { font-size: 12px; color: var(--matt); }
.kachel.aktiv { outline: 2px solid var(--blau); }
.kachel.k2 b { color: var(--p2t); } .kachel.k1 b { color: var(--p1t); }

.liste { display: flex; flex-direction: column; gap: 8px; }
.karte { background: var(--karte); border: 1px solid var(--rand); border-radius: 14px; box-shadow: var(--schatten); }
.prod { padding: 12px 14px; display: flex; gap: 12px; align-items: center; text-align: left; width: 100%; position: relative; overflow: hidden; }
.prod:active { transform: scale(.99); }
.prod .balken { position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; }
.prod .info { flex: 1; min-width: 0; }
.prod .name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prod .sub { font-size: 13px; color: var(--matt); display: flex; align-items: center; gap: 6px; margin-top: 2px; flex-wrap: wrap; }
.prod .menge { text-align: right; flex: none; }
.prod .menge b { font-size: 20px; display: block; line-height: 1.1; }
.prod .menge span { font-size: 12px; color: var(--matt); }
.prod .menge.rot b { color: var(--p2t); }
.punkt { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.p0 { background: var(--p0h); color: var(--p0t); } .p1 { background: var(--p1h); color: var(--p1t); } .p2 { background: var(--p2h); color: var(--p2t); }
.p3 { background: var(--p3h); color: var(--p3t); } .p4 { background: var(--p4h); color: var(--p4t); }

h2 { font-size: 15px; margin: 18px 4px 8px; color: var(--matt); font-weight: 650; text-transform: uppercase; letter-spacing: .03em; }
h2:first-child { margin-top: 4px; }
.leer { text-align: center; color: var(--matt); padding: 28px 12px; font-size: 15px; }
.zeile { padding: 12px 14px; display: flex; gap: 10px; align-items: center; }
.zeile + .zeile { border-top: 1px solid var(--rand); }
.zeile .info { flex: 1; min-width: 0; }
.zeile .klein { font-size: 13px; color: var(--matt); }

.bst { padding: 13px 14px; }
.bst .oben { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bst .pos { margin: 8px 0 0; padding: 0; list-style: none; font-size: 15px; }
.bst .pos li { padding: 2px 0; }
.bst .klein { font-size: 13px; color: var(--matt); margin-top: 6px; }
.bst .knoepfe { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- Knöpfe & Felder ---------- */
.btn { border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 650; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.btn:active { filter: brightness(.92); }
.btn:disabled { opacity: .45; }
.btn.primaer { background: var(--akzent); color: #fff; }
.btn.blau { background: var(--blau); color: #fff; }
.btn.sek { background: var(--karte); color: var(--text); border: 1px solid var(--feldrand); }
.btn.geist { background: transparent; color: var(--matt); }
.btn.voll { width: 100%; }
.btn.klein { padding: 9px 13px; font-size: 14.5px; border-radius: 10px; flex: 1; }
.feld { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--feldrand); background: var(--feld); outline: none; }
.feld:focus { border-color: var(--blau); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
label.lbl { display: block; font-size: 13.5px; font-weight: 650; color: var(--matt); margin: 14px 0 6px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 52px; height: 52px; border-radius: 14px; border: 1px solid var(--feldrand); background: var(--karte); font-size: 26px; line-height: 1; }
.stepper input { flex: 1; text-align: center; font-size: 24px; font-weight: 700; padding: 9px; border-radius: 14px; border: 1px solid var(--feldrand); background: var(--feld); min-width: 0; }
.mini { display: flex; align-items: center; gap: 6px; }
.mini button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--feldrand); background: var(--karte); font-size: 20px; line-height: 1; }
.mini b { min-width: 30px; text-align: center; }

/* ---------- Navigation unten ---------- */
nav.unten { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--karte); border-top: 1px solid var(--rand);
  display: flex; padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px); }
nav.unten button { flex: 1; border: 0; background: none; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; color: var(--matt); position: relative; }
nav.unten button.aktiv { color: var(--akzent); font-weight: 650; }
nav.unten .badge { position: absolute; top: 0; left: calc(50% + 6px); background: var(--akzent); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 0 6px; min-width: 18px; line-height: 18px; }
nav.unten .badge.gelb { background: #d97706; }

/* ---------- Bottom-Sheet ---------- */
#sheet-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 40; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--karte); border-radius: 20px 20px 0 0;
  padding: 10px 18px calc(env(safe-area-inset-bottom) + 18px); max-height: 92vh; overflow-y: auto; max-width: 760px; margin: 0 auto;
  animation: hoch .18s ease-out; }
@keyframes hoch { from { transform: translateY(40px); opacity: .4; } }
#sheet .griff { width: 40px; height: 5px; border-radius: 3px; background: var(--rand); margin: 0 auto 10px; }
#sheet h3 { margin: 4px 0 2px; font-size: 20px; }
#sheet .unter { color: var(--matt); font-size: 14px; }
.daten { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 4px; }
.daten div { background: var(--bg); border-radius: 12px; padding: 9px 12px; }
.daten div > span:first-child { font-size: 12px; color: var(--matt); display: block; margin-bottom: 2px; }
.daten b { font-size: 17px; }
.aktionen { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 60; max-width: 520px; margin: 0 auto;
  background: #0f172a; color: #fff; border-radius: 14px; padding: 13px 16px; font-size: 15px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  display: flex; gap: 10px; align-items: flex-start; animation: hoch .18s ease-out; }
#toast::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: #22c55e; }
#toast.warn::before { background: #f59e0b; } #toast.err::before { background: #ef4444; } #toast.info::before { background: #3b82f6; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 22px calc(env(safe-area-inset-bottom) + 24px); max-width: 440px; margin: 0 auto; }
.login .logo { width: 58px; height: 58px; border-radius: 16px; margin-bottom: 18px; }
.login .logo::before { width: 10px; height: 32px; } .login .logo::after { width: 32px; height: 10px; }
.login h1 { margin: 0 0 4px; font-size: 26px; }
.login p { margin: 0 0 18px; color: var(--matt); }
.fehler { color: var(--p2t); font-weight: 600; margin-top: 12px; min-height: 1.4em; }
.hinweis { background: var(--p4h); color: var(--p4t); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.hinweis.gelb { background: var(--p1h); color: var(--p1t); }

/* ---------- Neues Produkt (schwebender Knopf) ---------- */
.fab { position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 86px); z-index: 15; width: 58px; height: 58px; border-radius: 18px;
  border: 0; background: var(--akzent); color: #fff; font-size: 34px; line-height: 1; box-shadow: 0 8px 22px rgba(220,38,38,.38); }
.fab:active { transform: scale(.95); }
select.feld { -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--matt) 50%), linear-gradient(135deg, var(--matt) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }