:root {
  --bg: #f2f4f7;
  --flaeche: #ffffff;
  --flaeche-2: #f7f8fa;
  --linie: #dde1e7;
  --text: #1c2430;
  --text-2: #5b6573;
  --primaer: #1f6feb;
  --primaer-dunkel: #1958bd;
  --gruen: #1a8a4a;
  --gruen-hell: #e3f5ea;
  --rot: #c62828;
  --rot-hell: #fdecea;
  --gelb-hell: #fff6dc;
  --radius: 14px;
  --schatten: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --oben: env(safe-area-inset-top, 0px);
  --unten: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, select { -webkit-user-select: text; user-select: text; font: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
#app { height: 100%; }
.laden { display: grid; place-items: center; height: 100%; color: var(--text-2); }
[hidden] { display: none !important; }

/* ---------- Buttons & Formulare ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--linie); background: var(--flaeche); font-weight: 600;
  text-decoration: none; color: var(--text); white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primaer { background: var(--primaer); border-color: var(--primaer); color: #fff; }
.btn.gruen { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.btn.rot { background: var(--rot); border-color: var(--rot); color: #fff; }
.btn.rot-rand { color: var(--rot); border-color: #f0b4b4; }
.btn.gross { min-height: 60px; font-size: 20px; border-radius: 12px; }
.btn.klein { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.leise { background: transparent; border-color: transparent; color: var(--primaer); }
.btn.voll { width: 100%; }

.feld { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.feld > span { font-size: 14px; font-weight: 600; color: var(--text-2); }
.feld input, .feld textarea, .feld select {
  min-height: 44px; padding: 10px 12px; border: 1px solid var(--linie); border-radius: 10px;
  background: var(--flaeche); color: var(--text); font-size: 16px; width: 100%;
}
.feld textarea { min-height: 80px; resize: vertical; }
.feld input:focus, .feld textarea:focus, .feld select:focus { outline: 2px solid var(--primaer); outline-offset: -1px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.check input { width: 22px; height: 22px; }
.reihe { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.reihe > .feld { flex: 1 1 140px; }
.fehlertext { color: var(--rot); font-weight: 600; margin: 8px 0; min-height: 1.2em; }

/* ---------- Login / Öffnen ---------- */
.mitte { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.karte {
  background: var(--flaeche); border-radius: 20px; box-shadow: var(--schatten);
  padding: 28px; width: 100%; max-width: 420px;
}
.karte h1 { margin: 0 0 6px; font-size: 26px; }
.karte p.unter { margin: 0 0 22px; color: var(--text-2); }
.logo { font-size: 44px; margin-bottom: 6px; }

/* ---------- Kopfzeile ---------- */
.kopf {
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + var(--oben)) 14px 8px; background: var(--flaeche);
  border-bottom: 1px solid var(--linie); min-height: 60px;
}
.kopf .titel { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.kopf .luecke { flex: 1; }
.punkt { width: 10px; height: 10px; border-radius: 50%; background: var(--gruen); display: inline-block; }
.punkt.aus { background: var(--rot); }
.admin-chip {
  background: var(--gelb-hell); border: 1px solid #f0d58a; color: #7a5b00;
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700;
}
.offline-banner {
  background: var(--rot); color: #fff; text-align: center; font-weight: 700; padding: 10px;
}

/* ---------- Kassen-Layout ---------- */
.kasse { display: flex; flex-direction: column; height: 100%; }
.kasse-inhalt { flex: 1; display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
.sortiment { display: flex; flex-direction: column; min-height: 0; }
.reiter {
  display: flex; gap: 8px; padding: 12px 14px; overflow-x: auto; flex-shrink: 0;
  scrollbar-width: none;
}
.reiter::-webkit-scrollbar { display: none; }
.reiter button {
  min-height: 48px; padding: 0 22px; border-radius: 999px; border: 1px solid var(--linie);
  background: var(--flaeche); font-weight: 700; font-size: 16px; white-space: nowrap;
}
.reiter button.aktiv { background: var(--text); color: #fff; border-color: var(--text); }

.kacheln {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; padding: 0 14px 14px; align-content: start;
}
.kachel {
  position: relative; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius);
  overflow: hidden; padding: 0; text-align: left; box-shadow: var(--schatten);
  display: flex; flex-direction: column;
}
.kachel:active { transform: scale(.97); }
.kachel .bild { aspect-ratio: 4 / 3; width: 100%; object-fit: cover; display: block; background: var(--flaeche-2); }
.kachel .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.kachel .name { font-weight: 700; font-size: 16px; line-height: 1.2; }
.kachel .beschr {
  font-size: 12.5px; color: var(--text-2); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.kachel .preis { font-weight: 800; font-size: 17px; margin-top: auto; padding-top: 4px; }
.kachel .plus {
  position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,.92); border-radius: 999px;
  font-size: 12px; font-weight: 700; padding: 4px 8px; color: var(--text-2);
}
.kachel .im-korb {
  position: absolute; top: 8px; left: 8px; background: var(--primaer); color: #fff; border-radius: 999px;
  min-width: 28px; height: 28px; display: grid; place-items: center; font-weight: 800; font-size: 14px; padding: 0 8px;
}
.bild-platzhalter { display: grid; place-items: center; font-size: 40px; font-weight: 800; color: #aab2bf; }

/* ---------- Warenkorb ---------- */
.korb {
  background: var(--flaeche); border-left: 1px solid var(--linie);
  display: flex; flex-direction: column; min-height: 0;
}
.korb-kopf { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.korb-kopf h2 { margin: 0; font-size: 20px; }
.korb-liste { flex: 1; overflow-y: auto; padding: 0 10px; }
.korb-leer { color: var(--text-2); text-align: center; padding: 40px 16px; }
.pos {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
  padding: 12px 8px; border-bottom: 1px solid var(--linie);
}
.pos.ungueltig { background: var(--rot-hell); border-radius: 10px; }
.pos .pname { font-weight: 700; }
.pos .ptoppings { font-size: 13px; color: var(--text-2); grid-column: 1; }
.pos .psumme { font-weight: 800; text-align: right; }
.pos .paktionen { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.menge { display: inline-flex; align-items: center; border: 1px solid var(--linie); border-radius: 10px; overflow: hidden; }
.menge button { width: 44px; height: 40px; border: 0; background: var(--flaeche-2); font-size: 22px; font-weight: 700; }
.menge span { min-width: 40px; text-align: center; font-weight: 800; font-size: 17px; }
.korb-fuss { padding: 12px 16px calc(14px + var(--unten)); border-top: 1px solid var(--linie); }
.summe-zeile { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.summe-zeile .betrag { font-size: 30px; font-weight: 800; }
.mwst-zeile { font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
.korb-knoepfe { display: grid; grid-template-columns: auto 1fr; gap: 10px; }

/* ---------- Dialoge ---------- */
.hintergrund {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50;
  display: grid; place-items: center; padding: 16px; animation: einblenden .12s ease-out;
}
@keyframes einblenden { from { opacity: 0; } }
.dialog {
  background: var(--flaeche); border-radius: 20px; width: 100%; max-width: 560px;
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.dialog.breit { max-width: 860px; }
.dialog.schmal { max-width: 400px; }
.dialog-kopf { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--linie); }
.dialog-kopf h2 { margin: 0; font-size: 20px; flex: 1; }
.dialog-inhalt { padding: 18px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.dialog-fuss { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--linie); flex-wrap: wrap; }
.schliessen { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--flaeche-2); font-size: 22px; }

/* Topping-Auswahl */
.artikel-kopf { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.artikel-kopf img, .artikel-kopf .bild-platzhalter { width: 110px; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; background: var(--flaeche-2); }
.artikel-kopf .beschr { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.topping-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.topping {
  position: relative; border: 2px solid var(--linie); border-radius: 12px; background: var(--flaeche);
  padding: 0; overflow: hidden; text-align: center;
}
.topping img, .topping .bild-platzhalter { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--flaeche-2); }
.topping .tname { font-weight: 700; font-size: 14px; padding: 6px 6px 0; }
.topping .tpreis { font-size: 13px; color: var(--text-2); padding: 0 6px 8px; }
.topping.an { border-color: var(--primaer); background: #eef4ff; }
.topping.an::after {
  content: "✓"; position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--primaer); color: #fff; display: grid; place-items: center; font-weight: 800;
}
.abschnitt-titel { font-weight: 700; color: var(--text-2); font-size: 14px; margin: 18px 0 10px; text-transform: uppercase; letter-spacing: .04em; }

/* Bezahlen */
.bezahlen { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.anzeige { background: var(--flaeche-2); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; }
.anzeige .label { font-size: 14px; color: var(--text-2); font-weight: 600; }
.anzeige .wert { font-size: 30px; font-weight: 800; }
.anzeige.rueckgeld { background: var(--gruen-hell); }
.anzeige.rueckgeld .wert { color: var(--gruen); font-size: 40px; }
.anzeige.fehlt { background: var(--rot-hell); }
.anzeige.fehlt .wert { color: var(--rot); }
.stueckelung { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.stueckelung span { background: #fff; border: 1px solid #b9e2c8; border-radius: 8px; padding: 4px 8px; font-size: 14px; font-weight: 700; }
.schnell { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.schnell .btn { min-height: 52px; font-size: 17px; }
.tastatur { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tastatur button {
  height: 60px; border-radius: 12px; border: 1px solid var(--linie); background: var(--flaeche);
  font-size: 24px; font-weight: 700;
}
.tastatur button:active { background: var(--flaeche-2); }

.erfolg { text-align: center; }
.erfolg .haken { width: 72px; height: 72px; border-radius: 50%; background: var(--gruen); color: #fff; font-size: 40px; display: grid; place-items: center; margin: 4px auto 10px; }
.erfolg .rueckgeld-gross { font-size: 64px; font-weight: 800; color: var(--gruen); line-height: 1.1; margin: 6px 0; }
.erfolg .stueckelung { justify-content: center; }
.erfolg .stueckelung span { font-size: 18px; padding: 6px 12px; }

/* PIN */
.pin-punkte { display: flex; justify-content: center; gap: 14px; margin: 6px 0 16px; }
.pin-punkte span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--text-2); }
.pin-punkte span.voll { background: var(--text); border-color: var(--text); }

/* ---------- Tabellen / Verwaltung ---------- */
.verwaltung { display: flex; flex-direction: column; height: 100%; }
.verwaltung .reiter { background: var(--flaeche); border-bottom: 1px solid var(--linie); }
.verwaltung-inhalt { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.panel { background: var(--flaeche); border-radius: var(--radius); box-shadow: var(--schatten); padding: 16px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 12px; }
.leiste { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.leiste .luecke { flex: 1; }
.tabelle-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--linie); vertical-align: middle; }
th { font-size: 13px; color: var(--text-2); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.klickbar { cursor: pointer; }
tr.klickbar:active { background: var(--flaeche-2); }
tr.inaktiv td { color: #9aa3af; }
tr.storniert td { text-decoration: line-through; color: #9aa3af; }
.mini { width: 56px; height: 42px; object-fit: cover; border-radius: 8px; background: var(--flaeche-2); display: block; }
.mini.bild-platzhalter { font-size: 18px; }
.marke { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; background: var(--flaeche-2); color: var(--text-2); }
.marke.gruen { background: var(--gruen-hell); color: var(--gruen); }
.marke.rot { background: var(--rot-hell); color: var(--rot); }
.marke.gelb { background: var(--gelb-hell); color: #7a5b00; }
.kennzahlen { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kennzahl { background: var(--flaeche-2); border-radius: 12px; padding: 12px 14px; }
.kennzahl .label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.kennzahl .wert { font-size: 22px; font-weight: 800; }
.kennzahl.betont { background: #eef4ff; }
.kennzahl.gut .wert { color: var(--gruen); }
.kennzahl.schlecht .wert { color: var(--rot); }
.bild-wahl { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.bild-wahl img, .bild-wahl .bild-platzhalter { width: 120px; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; background: var(--flaeche-2); }
.bild-wahl .knoepfe { display: flex; flex-direction: column; gap: 8px; }
.check-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 12px; }
.hinweis { color: var(--text-2); font-size: 14px; }

.meldung {
  position: fixed; left: 50%; bottom: calc(24px + var(--unten)); transform: translateX(-50%); z-index: 100;
  background: var(--text); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100% - 32px);
}
.meldung.fehler { background: var(--rot); }

/* Hochformat / kleine Breiten */
@media (max-width: 900px) {
  .kasse-inhalt { grid-template-columns: 1fr 320px; }
  .kacheln { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
@media (max-width: 700px) {
  .kasse-inhalt { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .korb { border-left: 0; border-top: 1px solid var(--linie); max-height: 45vh; }
  .bezahlen { grid-template-columns: 1fr; }
  .kopf .text-optional { display: none; }
}
