:root {
  --accent: #ef4444;
  --accent-2: #f97316;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(15, 23, 42, .08);
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #dc2626;
  --warn-bg: #fef2f2;
  --low: #b45309;
  --low-bg: #fef3c7;
  --on-low: #ffffff;
  --dock: rgba(15, 23, 42, .92);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
  --r: 18px;
  --r-sm: 12px;
  color-scheme: light;
}
/* Dunkel: automatisch nach Systemeinstellung oder fest per Umschalter (data-theme am <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d12;
    --surface: #151821;
    --surface-2: #1e222d;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --line: rgba(255, 255, 255, .08);
    --ok: #34d399;
    --ok-bg: rgba(16, 185, 129, .12);
    --warn: #f87171;
    --warn-bg: rgba(239, 68, 68, .12);
    --low: #fbbf24;
    --low-bg: rgba(245, 158, 11, .16);
    --on-low: #1c1917;
    --dock: rgba(30, 34, 45, .92);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d12;
  --surface: #151821;
  --surface-2: #1e222d;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --line: rgba(255, 255, 255, .08);
  --ok: #34d399;
  --ok-bg: rgba(16, 185, 129, .12);
  --warn: #f87171;
  --warn-bg: rgba(239, 68, 68, .12);
  --low: #fbbf24;
  --low-bg: rgba(245, 158, 11, .16);
  --on-low: #1c1917;
  --dock: rgba(30, 34, 45, .92);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
.theme-btn svg { display: none; }
.theme-btn[data-mode="auto"] .i-auto, .theme-btn[data-mode="light"] .i-light, .theme-btn[data-mode="dark"] .i-dark { display: block; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }
h1, h2 { letter-spacing: -.02em; }
h2 { font-size: 1.25rem; margin: 8px 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; background: var(--surface); box-shadow: var(--shadow);
  border-radius: var(--r-sm); padding: 14px 18px; font-weight: 650; min-height: 52px;
  transition: transform .12s ease, opacity .15s ease;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(239, 68, 68, .35); }
.btn:disabled { opacity: .4; box-shadow: none; }
.btn.ghost { background: var(--surface-2); box-shadow: none; }
.btn.big { width: 100%; font-size: 1.1rem; min-height: 60px; border-radius: var(--r); }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 0; background: var(--surface-2); font-size: 1.2rem; font-weight: 700;
}
.icon-btn:active { transform: scale(.94); }

.screen { min-height: 100%; display: flex; flex-direction: column; }

/* Login */
#login { justify-content: center; padding: 24px 16px; }
.login-box { max-width: 360px; width: 100%; margin: 0 auto; text-align: center; }
.login-box .logo { filter: drop-shadow(0 10px 24px rgba(239, 68, 68, .35)); }
.login-box h1 { margin: 18px 0 4px; font-size: 2rem; }
.login-box p { color: var(--muted); margin: 0 0 24px; }
.login-box input {
  width: 100%; padding: 16px; font-size: 1.15rem; border-radius: var(--r);
  border: 2px solid transparent; background: var(--surface); box-shadow: var(--shadow);
  margin-bottom: 12px; text-align: center; outline: none; transition: border-color .15s;
}
.login-box input:focus { border-color: var(--accent); }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { flex: none; border-radius: 11px; }
.topbar .event { font-weight: 750; font-size: 1.05rem; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { background: none; border: 0; padding: 0; color: var(--muted); font-size: .85rem; }
.who::after { content: " · wechseln"; opacity: .6; }
.link { background: none; border: 0; padding: 0; color: var(--muted); font-size: .9rem; text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
/* Verbindung: gleicher Stil wie die anderen Symbol-Buttons oben */
.conn { position: relative; cursor: default; color: var(--muted); }
.conn svg { display: none; }
.conn.on .i-on, .conn.off .i-off { display: block; }
.conn.on::after {
  content: ""; position: absolute; right: 6px; bottom: 6px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 0 2px var(--surface-2);
}
.conn.off { color: var(--low); background: var(--low-bg); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--low) 25%, transparent); } }
.conn .queue {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px;
  background: var(--low); color: var(--on-low); font-size: .72rem; font-weight: 800; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--bg);
}

/* Admin-Hinweise (nur auf dem Admin-Handy) */
.alerts { display: grid; gap: 8px; margin: 4px 16px 10px; }
.alert {
  display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 12px; border-radius: var(--r-sm);
  font-weight: 650; font-size: .9rem; cursor: pointer; animation: up .25s ease;
}
.alert.error { background: #dc2626; color: #fff; box-shadow: 0 6px 18px rgba(220, 38, 38, .3); }
.alert.warn { background: var(--low-bg); color: var(--low); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--low) 45%, transparent); }
.alert-icon {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; font-size: .85rem; background: rgba(255, 255, 255, .25);
}
.alert.warn .alert-icon { background: var(--low); color: var(--on-low); }
.alert-text { flex: 1; min-width: 0; line-height: 1.3; }
.alert-hide { flex: none; width: 32px; height: 32px; border: 0; border-radius: 8px; background: rgba(0, 0, 0, .12); color: inherit; font-weight: 700; }

.admin-box { margin-top: 18px; }
.admin-on, .admin-enable {
  display: grid; gap: 12px; padding: 14px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow);
}
.admin-on small, .admin-enable small { display: block; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.admin-actions { display: flex; gap: 8px; }
.admin-actions .btn { flex: 1; min-height: 48px; text-decoration: none; }
.admin-actions input {
  flex: 1; min-width: 0; padding: 12px; border-radius: var(--r-sm); border: 0; background: var(--surface-2);
  font-size: 1rem; outline: none;
}
.admin-actions input:focus { box-shadow: 0 0 0 2px var(--accent); }

/* Tisch */
.table-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 4px 16px 0; padding: 8px 8px 8px 16px; background: var(--surface);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.table-row { cursor: text; transition: box-shadow .15s; }
.table-row:focus-within { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.table-row span { font-weight: 650; color: var(--muted); }
.table-row.missing { box-shadow: 0 0 0 2px var(--warn), var(--shadow); animation: shake .4s ease; }
.table-row.missing span { color: var(--warn); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.table-row input {
  width: 96px; padding: 10px; font-size: 1.2rem; font-weight: 750; text-align: center;
  border: 0; border-radius: var(--r-sm); background: var(--surface-2); outline: none;
}

/* Kategorien */
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 14px 16px 10px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats button {
  flex: none; border: 0; border-radius: 99px; padding: 10px 18px; font-weight: 650;
  background: var(--surface); color: var(--muted); box-shadow: var(--shadow);
  transition: background .15s, color .15s;
}
.cats button.active { background: var(--c); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 40%, transparent); }

/* Artikel */
.products {
  flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; padding: 4px 16px 120px; align-content: start;
}
.prod {
  position: relative; min-height: 104px; padding: 14px; text-align: left; border: 0;
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow);
  transition: transform .12s ease;
  overflow: hidden;
}
.prod::before {
  content: ""; position: absolute; inset: 0 auto auto 0; width: 100%; height: 4px; background: var(--c); opacity: .9;
}
.prod { cursor: pointer; user-select: none; -webkit-user-select: none; }
.prod:active:not(:has(.minus:active)) { transform: scale(.95); }
.prod.selected { box-shadow: 0 0 0 2px var(--c), var(--shadow); }
.prod-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.prod .minus {
  width: 40px; height: 40px; margin: -6px -6px -6px 0; border: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--text); font-size: 1.4rem; font-weight: 700; line-height: 1;
  display: grid; place-items: center;
}
.prod .minus:active { transform: scale(.9); background: var(--warn-bg); color: var(--warn); }
.prod .name { font-weight: 650; line-height: 1.25; }
.prod .qty + .name { padding-right: 30px; }
/* Kontingent: gut sichtbares Badge auf der Kachel */
.prod .stock {
  align-self: flex-start; display: inline-flex; align-items: baseline; gap: 4px;
  margin-top: -2px; padding: 4px 10px; border-radius: 8px;
  font-size: .85rem; font-weight: 700; line-height: 1.2;
  background: var(--surface-2); color: var(--text);
}
.prod .stock b { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.prod .stock.low { background: var(--low-bg); color: var(--low); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--low) 45%, transparent); }
.prod .stock.out { background: #dc2626; color: #fff; text-transform: uppercase; letter-spacing: .06em; padding: 6px 12px; }
.prod.soldout { cursor: not-allowed; box-shadow: none; background: var(--surface-2); }
.prod.soldout::before { opacity: .25; }
.prod.soldout .name, .prod.soldout .price { opacity: .45; }
.prod.soldout:active { transform: none; }
.prod .price {
  align-self: flex-start; font-size: .85rem; font-weight: 650; font-variant-numeric: tabular-nums;
  padding: 4px 10px; border-radius: 99px;
  background: color-mix(in srgb, var(--c) 12%, transparent); color: color-mix(in srgb, var(--c) 80%, var(--text));
}
.prod .qty {
  position: absolute; top: 10px; right: 10px; min-width: 28px; height: 28px; padding: 0 8px;
  border-radius: 99px; background: var(--grad); color: #fff; font-weight: 750; font-size: .9rem;
  display: grid; place-items: center; animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.4); } }

/* Schwebende Warenkorb-Leiste */
.cartbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 6;
  display: flex; align-items: stretch; gap: 8px; padding: 8px;   /* stretch: Bestellung und Kassieren immer gleich hoch */
  background: var(--dock); color: #fff; border-radius: 22px; box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  max-width: 640px; margin: 0 auto;
}
/* Linke Hälfte: klar als Button erkennbar – öffnet die Bestellung */
.cart-sum {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 8px;
  background: rgba(255, 255, 255, .09); border: 1px solid rgba(255, 255, 255, .14); border-radius: 16px; color: #fff;
  text-align: left; transition: background .15s, transform .12s;
}
.cart-sum:active { transform: scale(.97); background: rgba(255, 255, 255, .16); }
.cart-icon {
  position: relative; flex: none; display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: 12px; background: rgba(255, 255, 255, .12);
}
.cart-badge {
  position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px;
  background: var(--grad); color: #fff; font-size: .78rem; font-weight: 800; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--dock);
}
.cart-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cart-text span { opacity: .75; font-size: .78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-text strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.cart-chev { flex: none; width: 26px; height: 26px; padding: 4px; border-radius: 50%; background: rgba(255, 255, 255, .14); }
.cart-sum:disabled { opacity: .55; }
.cart-sum.bump { animation: bump .45s cubic-bezier(.3, 1.6, .5, 1); }
.cart-sum.bump .cart-badge { animation: pop .3s ease; }
@keyframes bump { 30% { transform: translateY(-6px) scale(1.03); } }
.cartbar .btn { flex: none; min-width: 0; padding: 0 16px; min-height: 60px; border-radius: 16px; box-shadow: none; }

/* Bottom-Sheets */
.sheet {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end;
  background: rgba(15, 23, 42, .4); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade .2s ease;
}
.sheet-body {
  width: 100%; max-width: 640px; margin: 0 auto; max-height: 85vh; overflow-y: auto; background: var(--bg);
  border-radius: 28px 28px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  animation: up .25s cubic-bezier(.2, .9, .3, 1);
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40%); } }
.grabber { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 4px auto 6px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-foot { display: flex; gap: 10px; margin-top: 14px; }
.sheet-foot .btn { flex: 1; }
.cart-list, .mine-list, .prints { list-style: none; margin: 0; padding: 0; }
.cart-list li, .mine-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface); border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow);
}
.cart-list li > div:first-child { font-weight: 600; }
.cart-list small, .mine-list small { display: block; color: var(--muted); font-weight: 400; }
.empty { justify-content: center !important; color: var(--muted); box-shadow: none !important; background: none !important; }
.stepper { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.stepper button { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--surface); font-size: 1.25rem; font-weight: 700; box-shadow: var(--shadow); }
.stepper span { min-width: 26px; text-align: center; font-weight: 750; }

/* Notizen */
.line-main { min-width: 0; }
.note-btn {
  display: inline-block; max-width: 100%; margin-top: 6px; padding: 5px 10px; border: 0; border-radius: 8px;
  background: var(--surface-2); color: var(--muted); font-size: .8rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left;
}
.note-btn.set { background: var(--low-bg); color: var(--low); font-style: italic; }
.prod .has-note { align-self: flex-start; font-size: .72rem; font-weight: 700; color: var(--low); }
.note-form { display: grid; gap: 12px; }
.note-form input {
  width: 100%; padding: 14px; font-size: 1.05rem; border-radius: var(--r-sm);
  border: 2px solid transparent; background: var(--surface); box-shadow: var(--shadow); outline: none;
}
.note-form input:focus { border-color: var(--accent); }
.note-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.note-chips .chip {
  border: 0; border-radius: 99px; padding: 8px 12px; font-size: .85rem; font-weight: 600;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.note-chips .chip:active { transform: scale(.95); }
.note-scope { display: flex; gap: 8px; }
.note-scope label {
  flex: 1; display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: var(--r-sm);
  background: var(--surface); box-shadow: var(--shadow); font-weight: 600;
}
.note-scope input { accent-color: var(--accent); width: 18px; height: 18px; }
.sheet-head h2 span { color: var(--muted); font-weight: 600; }

/* Bezahlung */
.pay { padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 12px; max-width: 520px; width: 100%; margin: 0 auto; }
.pay-total { text-align: center; padding: 18px 0 8px; }
.pay-total span { display: block; color: var(--muted); font-weight: 600; }
.pay-total strong { display: block; font-size: 3rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.pay-given, .pay-change {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border-radius: var(--r); padding: 14px 18px; box-shadow: var(--shadow);
}
.pay-given span, .pay-change span { color: var(--muted); font-weight: 600; }
.pay-note {
  display: grid; gap: 6px; background: var(--surface); border-radius: var(--r); padding: 12px 18px; box-shadow: var(--shadow);
  cursor: text; transition: box-shadow .15s;
}
.pay-note span { color: var(--muted); font-weight: 600; font-size: .9rem; }
.pay-note input { border: 0; background: none; font-size: 1rem; outline: none; padding: 2px 0; }
.pay-note:focus-within { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.pay-given { cursor: text; transition: box-shadow .15s; }
.pay-given:focus-within { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.pay-given input {
  width: 55%; text-align: right; font-size: 1.8rem; font-weight: 750; border: 0; background: none;
  font-variant-numeric: tabular-nums; outline: none;
}
.bills { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bills .btn { padding: 10px 4px; font-size: 1.05rem; min-height: 56px; }
.pay-change { transition: background .2s, color .2s; }
.pay-change strong { font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.pay-change.ok { background: var(--ok-bg); box-shadow: none; }
.pay-change.ok span, .pay-change.ok strong { color: var(--ok); }
.pay-change.missing { background: var(--warn-bg); box-shadow: none; }
.pay-change.missing span, .pay-change.missing strong { color: var(--warn); }

/* Ergebnis */
#done { justify-content: center; padding: 24px 16px; }
.done { max-width: 420px; width: 100%; margin: 0 auto; text-align: center; }
.done-check {
  width: 84px; height: 84px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ok-bg); color: var(--ok); animation: pop .35s cubic-bezier(.2, 1.6, .4, 1);
}
.done-label { color: var(--muted); font-weight: 600; }
.done-change { font-size: 3.8rem; font-weight: 800; letter-spacing: -.03em; color: var(--ok); font-variant-numeric: tabular-nums; margin: 0 0 8px; }
.done-info { color: var(--muted); margin-bottom: 16px; }
.done-info.warn, .warn { color: var(--warn); font-weight: 600; }
.prints { margin-bottom: 20px; text-align: left; }
.prints li { padding: 12px 14px; border-radius: var(--r-sm); margin-bottom: 8px; background: var(--surface); box-shadow: var(--shadow); }
.prints li.ok { background: var(--ok-bg); color: var(--ok); box-shadow: none; }
.prints li.error { background: var(--warn-bg); color: var(--warn); box-shadow: none; }

/* Abrechnung */
.mine-sum {
  display: flex; justify-content: space-between; align-items: center; color: #fff;
  background: var(--grad); border-radius: var(--r); padding: 18px; margin-bottom: 12px;
}
.mine-sum span { opacity: .85; }
.mine-sum strong { font-size: 1.7rem; font-weight: 800; }
.mine-list li.storno { opacity: .5; text-decoration: line-through; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 480px; margin: 0 auto;
  background: var(--dock); color: #fff; padding: 12px 16px; border-radius: 14px; text-align: center;
  box-shadow: var(--shadow-lg); animation: up .2s ease;
}
