*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #111;
  --bg2: #1c1c1e;
  --bg3: #2c2c2e;
  --text: #e5e5ea;
  --text2: #aeaeb2;
  --text3: #636366;
  --accent: #ff9f0a;
  --danger: #ff453a;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

#views {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}

.view { padding: 16px; }

/* Scanner-Tab füllt genau den sichtbaren Bereich und scrollt nicht:
   nur das Kamerafeld schrumpft, alles andere bleibt fix sichtbar. */
#view-scan {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - var(--tabbar-h));
  overflow: hidden;
}
#view-scan .view-title { flex: 0 0 auto; }
.scan-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.scan-side { flex: 0 0 auto; display: flex; flex-direction: column; min-height: 0; }
.scan-side .sound-toggle { margin-top: 0; }

/* Querformat: Kamera links, Bedienelemente rechts (statt zu blockieren). */
@media (orientation: landscape) and (max-height: 600px) {
  #view-scan > .view-title { display: none; }
  .scan-body { flex-direction: row; gap: 16px; }
  .scan-stage { height: 100%; min-height: 0; min-width: 0; }
  .scan-side { flex: 0 0 280px; width: 280px; overflow-y: auto; }
}

.view-title { font-size: 24px; font-weight: 700; margin-bottom: 12px; }

/* Tab-Leiste */
#tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: var(--bg2);
  border-top: 1px solid #000;
  z-index: 50;
}
.tab {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--text3);
  cursor: pointer;
}
.tab.active { color: var(--accent); }
.tab svg { width: 28px; height: 28px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--bg2); color: var(--text);
  border: none; border-radius: var(--radius);
  padding: 14px 18px; font-size: 18px; font-weight: 600;
  cursor: pointer;
}
.btn-accent { background: var(--accent); color: #000; }
.btn-danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.4; }
.btn svg { width: 20px; height: 20px; }

.scan-stage { position: relative; width: 100%; flex: 1 1 auto; min-height: 140px;
  background: #000; border-radius: var(--radius); overflow: hidden; }
#scan-video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 18% 12%; border: 3px solid var(--accent);
  border-radius: 8px; box-shadow: 0 0 0 9999px rgba(0,0,0,0.25); }
.scan-status { color: var(--text2); margin-top: 12px; text-align: center; }

/* Optisches Treffer-Feedback: grüner Aufblitz + Häkchen über dem Kamerabild */
.scan-flash { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(48, 209, 88, 0.0); color: #fff; opacity: 0; pointer-events: none; }
.scan-flash svg { width: 96px; height: 96px; transform: scale(0.6); }
.scan-flash.show { animation: scan-ok 0.5s ease-out; }
@keyframes scan-ok {
  0% { opacity: 0; background: rgba(48,209,88,0.0); }
  15% { opacity: 1; background: rgba(48,209,88,0.55); }
  100% { opacity: 0; background: rgba(48,209,88,0.0); }
}
.scan-flash.show svg { animation: scan-ok-check 0.5s ease-out; }
@keyframes scan-ok-check { 0% { transform: scale(0.4); } 30% { transform: scale(1.1); } 100% { transform: scale(1); } }

/* Ton-Schalter */
.sound-toggle { display: flex; align-items: center; gap: 10px; margin-top: 14px;
  color: var(--text2); font-size: 16px; cursor: pointer; }
.sound-toggle input { width: 22px; height: 22px; accent-color: var(--accent); }

.scan-last { margin-top: 16px; }
.scan-last-label { color: var(--text3); font-size: 13px; margin-bottom: 8px; }

.liste-head { display: flex; align-items: baseline; justify-content: space-between; }
.liste-total { color: var(--accent); font-weight: 700; }
.liste-empty { color: var(--text3); margin-top: 24px; text-align: center; }
.liste-cards { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 20px; }
.liste-card { display: flex; align-items: center; gap: 12px;
  background: var(--bg2); border-radius: var(--radius); padding: 10px 12px; }
.liste-card-thumb { width: 72px; height: 72px; flex: 0 0 auto; border-radius: 8px;
  object-fit: cover; background: var(--bg3); }
.liste-card-thumb-empty { display: flex; }
.liste-card-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.liste-card-info { min-width: 0; }
.liste-card-code { font-size: 16px; overflow-wrap: anywhere; }
.liste-card-format { font-size: 13px; color: var(--text3); margin-left: 8px; }
.liste-card-qty { display: flex; align-items: center; gap: 8px; }
.liste-card-menge { min-width: 28px; text-align: center; font-weight: 700; font-size: 20px; }
.qctl { position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: none; border-radius: 10px;
  background: var(--bg3); color: var(--text); cursor: pointer; }
.qctl svg { width: 18px; height: 18px; }
.qctl-del { background: transparent; color: var(--danger); }
/* Unsichtbarer nativer Switch über dem Button: behält die native Darstellung
   (opacity statt appearance:none), damit iOS beim Tap die Haptik auslöst. */
.qctl-switch { position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; opacity: 0; cursor: pointer; }
.qctl-ic { pointer-events: none; display: inline-flex; }

.co-hint { color: var(--text2); margin-bottom: 16px; }
.co-start { width: 100%; font-size: 22px; padding: 18px; }
.co-settings { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; }
.co-settings label { display: flex; flex-direction: column; gap: 6px; color: var(--text2); font-size: 14px; }
.co-settings input { background: var(--bg3); color: var(--text); border: none;
  border-radius: var(--radius); padding: 12px; font-size: 18px; }

/* Vollbild-Checkout */
.co-overlay { position: fixed; inset: 0; z-index: 1000; background: #000;
  display: flex; align-items: center; justify-content: center; }
.co-stage { width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; }
.co-countdown { color: #fff; font-size: 120px; font-weight: 800; }
.co-barcode { background: #fff; max-width: 96vw; height: auto; padding: 12px;
  border-radius: 6px; }
.co-progress { position: fixed; bottom: calc(16px + var(--safe-bottom));
  color: #555; font-size: 14px; }
.co-flash { background: #fff !important; }
