:root {
  --bg: #10151a;
  --bg2: #1a222b;
  --card: #202b36;
  --text: #f2f5f7;
  --muted: #8fa1b0;
  --orange: #ffa500;
  --blue: #2e93b8;
  --grad: linear-gradient(135deg, #ffa500 0%, #ff7846 45%, #b45cc7 100%);
  --green: #3ecf8e;
  --red: #ff5c5c;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Poppins, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  padding-bottom: 76px;
  min-height: 100vh;
}
button { font-family: inherit; }

/* ---------- Header ---------- */
header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(16,21,26,.92); backdrop-filter: blur(8px);
  padding: 12px 16px calc(10px);
  padding-top: calc(12px + env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #2a3540;
}
header h1 {
  margin: 0; font-size: 18px; font-weight: 700; letter-spacing: 2px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
header .sub { font-size: 11px; color: var(--muted); letter-spacing: 1px; }
#offlineBadge {
  display: none; font-size: 11px; font-weight: 600; color: #10151a;
  background: var(--orange); padding: 3px 10px; border-radius: 20px;
}
#offlineBadge.show { display: inline-block; }
#eventChip {
  font-size: 12px; color: var(--text); background: var(--bg2);
  border: 1px solid #34424f; padding: 4px 12px; border-radius: 20px;
  max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Bottom-Nav ---------- */
nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: rgba(16,21,26,.97); backdrop-filter: blur(10px);
  border-top: 1px solid #2a3540;
  padding-bottom: env(safe-area-inset-bottom);
}
nav button {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 9px 0 7px; font-size: 10.5px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
nav button svg { width: 22px; height: 22px; }
nav button.active { color: var(--orange); }

/* ---------- Allgemein ---------- */
main { padding: 14px; max-width: 1100px; margin: 0 auto; }
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
h2 { font-size: 16px; margin: 4px 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; }
.btn {
  background: var(--grad); color: #14100a; border: none; font-weight: 700;
  padding: 12px 18px; border-radius: 12px; font-size: 15px; cursor: pointer;
  width: 100%;
}
.btn:disabled { opacity: .45; }
.btn.secondary { background: var(--bg2); color: var(--text); border: 1px solid #34424f; }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; }
.btn.danger { background: var(--red); color: #fff; }
input, select {
  background: var(--bg2); border: 1px solid #34424f; color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 15px; width: 100%;
  font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--orange); border-color: transparent; }
label { font-size: 12px; color: var(--muted); display: block; margin: 10px 0 4px; }
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--card); color: var(--text); border: 1px solid #3a4854;
  padding: 10px 18px; border-radius: 12px; z-index: 100; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5); white-space: nowrap;
  max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--red); }

/* ---------- Login ---------- */
#loginView {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 80vh; padding: 24px; gap: 8px;
}
#loginView .logo { font-size: 30px; font-weight: 800; letter-spacing: 5px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; }
#loginView form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- Kasse ---------- */
.catbar { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.catbar::-webkit-scrollbar { display: none; }
.catbar button {
  background: var(--bg2); border: 1px solid #34424f; color: var(--muted);
  border-radius: 20px; padding: 7px 14px; font-size: 13px; white-space: nowrap; cursor: pointer;
}
.catbar button.active { background: var(--grad); color: #14100a; font-weight: 700; border-color: transparent; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ptile {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; border: 1px solid transparent; position: relative;
}
.ptile:active { border-color: var(--orange); }
.ptile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #0c1014; }
.ptile .pname { font-size: 12.5px; font-weight: 600; padding: 8px 10px 2px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 34px; }
.ptile .pprice { padding: 0 10px 10px; font-size: 13px; color: var(--orange); font-weight: 700; }
.ptile .pstock { position: absolute; top: 8px; right: 8px; font-size: 11px; font-weight: 700;
  background: rgba(16,21,26,.85); padding: 3px 8px; border-radius: 12px; }
.ptile .pstock.low { color: var(--red); }
.ptile .pstock.ok { color: var(--green); }

/* Warenkorb-Leiste */
#cartBar {
  position: fixed; bottom: calc(58px + env(safe-area-inset-bottom)); left: 0; right: 0; z-index: 25;
  background: var(--grad); color: #14100a; display: none;
  padding: 12px 18px; font-weight: 700; cursor: pointer;
  align-items: center; justify-content: space-between; font-size: 15px;
}
#cartBar.show { display: flex; }

/* ---------- Sheets (Modal von unten) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; display: none;
}
.sheet-backdrop.show { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--bg2); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .22s ease; max-height: 86vh; overflow-y: auto;
}
.sheet.show { transform: translateY(0); }
.sheet h2 { margin-top: 0; }
.opt-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.opt-grid button {
  background: var(--card); border: 1.5px solid #34424f; color: var(--text);
  border-radius: 10px; padding: 12px 16px; font-size: 15px; font-weight: 600; cursor: pointer;
  min-width: 62px;
}
.opt-grid button .st { display: block; font-size: 10.5px; font-weight: 400; color: var(--muted); }
.opt-grid button.sel { border-color: var(--orange); background: rgba(255,165,0,.12); }
.opt-grid button.empty { opacity: .4; }
.qty-row { display: flex; align-items: center; gap: 14px; justify-content: center; margin: 12px 0; }
.qty-row button {
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid #34424f;
  background: var(--card); color: var(--text); font-size: 24px; cursor: pointer;
}
.qty-row span { font-size: 26px; font-weight: 700; min-width: 40px; text-align: center; }

/* Warenkorb-Liste */
.cart-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #2a3540; }
.cart-item .ci-name { flex: 1; font-size: 14px; }
.cart-item .ci-name small { color: var(--muted); display: block; }
.cart-item button { background: none; border: none; color: var(--red); font-size: 20px; cursor: pointer; padding: 4px 8px; }
.pay-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 14px 0; }
.pay-grid button {
  background: var(--card); border: 1.5px solid #34424f; color: var(--text);
  border-radius: 10px; padding: 13px 6px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.pay-grid button.sel { border-color: var(--orange); background: rgba(255,165,0,.12); }

/* ---------- Bestand ---------- */
.inv-prod { margin-bottom: 6px; }
.inv-head { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 10px 0; }
.inv-head img { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: #0c1014; }
.inv-head .iname { flex: 1; font-size: 14px; font-weight: 600; }
.inv-head .iname small { display: block; color: var(--muted); font-weight: 400; }
.inv-total { font-weight: 700; font-size: 15px; }
.inv-total.low { color: var(--red); }
.inv-vars { display: none; padding: 4px 0 8px; }
.inv-prod.open .inv-vars { display: block; }
.inv-var { display: flex; align-items: center; gap: 8px; padding: 7px 0 7px 56px; }
.inv-var .vlabel { flex: 1; font-size: 14px; }
.inv-var .vstock { font-weight: 700; min-width: 34px; text-align: center; }
.inv-var .vstock.low { color: var(--red); }
.inv-var button {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid #34424f;
  background: var(--card); color: var(--text); font-size: 18px; cursor: pointer;
}

/* ---------- Verkäufe / Statistik ---------- */
.sale-row { padding: 12px 0; border-bottom: 1px solid #2a3540; }
.sale-row .sr-top { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; }
.sale-row .sr-top .neg { color: var(--red); }
.sale-row .sr-items { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.sale-row .sr-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 10px; align-items: center; }
.chip { background: var(--bg2); border-radius: 10px; padding: 2px 8px; font-size: 11px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 14px; }
.stat-card .big { font-size: 22px; font-weight: 800; margin-top: 2px; }
.stat-card .big.accent { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
table.mini { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.mini td { padding: 7px 4px; border-bottom: 1px solid #2a3540; }
table.mini td:last-child { text-align: right; font-weight: 600; }
.warn-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13.5px; border-bottom: 1px solid #2a3540; }
.warn-row .stk { color: var(--red); font-weight: 700; }

/* ---------- Einstellungen ---------- */
.set-status { font-size: 13px; padding: 8px 12px; border-radius: 10px; background: var(--bg2); margin: 8px 0; }
.set-status.ok { color: var(--green); }
.set-status.warn { color: var(--orange); }

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .sheet { max-width: 520px; left: 50%; transform: translate(-50%, 105%); border-radius: 20px; bottom: 20px; }
  .sheet.show { transform: translate(-50%, 0); }
}
