/* Lager-App – mobil zuerst, große Bedienelemente */
:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #1d4ed8;
  --primary-ink: #ffffff;
  --muster: #7c3aed;
  --muster-bg: #ede9fe;
  --ware: #0369a1;
  --ware-bg: #e0f2fe;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 6px rgba(0,0,0,.05);
  --nav-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --card: #151e2e;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --line: #263247;
    --primary: #3b82f6;
    --muster: #a78bfa;
    --muster-bg: #2e1f5e;
    --ware: #38bdf8;
    --ware-bg: #0c3350;
    --ok: #4ade80;
    --ok-bg: #12351f;
    --bad: #f87171;
    --bad-bg: #451a1a;
    --warn: #fbbf24;
    --warn-bg: #42300c;
    --info: #60a5fa;
    --info-bg: #172a4d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
body.has-nav main { padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
main { padding: 16px; max-width: 900px; margin: 0 auto; outline: none; }
a { color: var(--primary); }
h2 { font-size: 20px; margin: 24px 0 10px; }
h2:first-child { margin-top: 4px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }
svg.i { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px; padding-top: calc(6px + env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; gap: 4px; }
.icon-btn {
  width: 48px; height: 48px; border: 0; border-radius: 12px; background: transparent; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:active { background: var(--line); }
.icon-btn:disabled { opacity: .35; }

.banner { padding: 10px 16px; font-size: 15px; background: var(--warn-bg); color: var(--warn); text-align: center; }

/* ---------- Untere Navigation ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--nav-h); font-size: 12px; color: var(--muted); text-decoration: none;
}
.bottomnav a.active { color: var(--primary); font-weight: 600; }
.bottomnav a.scan span {
  width: 52px; height: 52px; margin-top: -18px; border-radius: 50%; background: var(--primary); color: var(--primary-ink);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(29,78,216,.35);
}
.bottomnav a.scan svg.i { width: 28px; height: 28px; }

/* ---------- Startseite ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  min-height: 112px; padding: 16px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; font-weight: 650; font-size: 18px; border: 0; text-align: left; cursor: pointer;
}
.tile svg.i { width: 34px; height: 34px; }
.tile:active { transform: scale(.98); }
.tile.in { background: var(--ok-bg); color: var(--ok); }
.tile.out { background: var(--bad-bg); color: var(--bad); }
.tile.new { background: var(--primary); color: var(--primary-ink); }
.tile .badge { position: absolute; top: 12px; right: 12px; }

.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; padding: 0 9px;
  border-radius: 999px; font-size: 15px; font-weight: 700; background: var(--line); color: var(--text);
}
.badge.bad { background: var(--bad); color: #fff; }
.badge.ok { background: var(--ok); color: #fff; }

/* ---------- Buttons & Formulare ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.in { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.out { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.big { min-height: 64px; font-size: 19px; width: 100%; }
.btn.block { width: 100%; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 15px; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btns.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.btns.three .btn { padding: 0 6px; gap: 6px; font-size: 15px; min-width: 0; }
.btns.three .btn svg.i { width: 20px; height: 20px; }

label.field { display: block; }
label.field > span { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; min-height: 52px; padding: 12px 14px; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; outline: none;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
input.upper { text-transform: uppercase; }
.checkbox { display: flex; gap: 12px; align-items: center; min-height: 52px; font-weight: 600; }
.checkbox input { width: 26px; height: 26px; min-height: 0; accent-color: var(--primary); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg button {
  min-height: 56px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 700; cursor: pointer;
}
.seg button.on { border-color: var(--primary); background: var(--info-bg); color: var(--primary); }
.seg button.on.muster { border-color: var(--muster); background: var(--muster-bg); color: var(--muster); }
.seg button.on.ware { border-color: var(--ware); background: var(--ware-bg); color: var(--ware); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--text); color: var(--card); border-color: var(--text); }
select.chip { width: auto; min-height: 40px; padding: 0 30px 0 14px; }

/* Mengen-Stepper */
.stepper { display: grid; grid-template-columns: 72px 1fr 72px; gap: 10px; }
.stepper button { height: 72px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.stepper button svg.i { width: 32px; height: 32px; }
.stepper input { height: 72px; text-align: center; font-size: 32px; font-weight: 800; }
.quick { display: flex; gap: 8px; margin-top: 8px; }
.quick button { flex: 1; min-height: 44px; }

/* ---------- Karten & Listen ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list-item {
  display: flex; gap: 12px; align-items: center; padding: 12px 14px; min-height: 64px;
  border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.list-item:last-child { border-bottom: 0; }
.list-item .thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--line); flex: none; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.list-item .main { flex: 1; min-width: 0; }
.list-item .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .s { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .end { text-align: right; flex: none; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* Artikel-Kacheln */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 800px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.itile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; color: var(--text); text-decoration: none; display: flex; flex-direction: column; position: relative; }
.itile.low { outline: 3px solid var(--bad); outline-offset: -3px; }
.itile .ph { aspect-ratio: 1; background: var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.itile .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.itile .ph svg.i { width: 40px; height: 40px; opacity: .5; }
.itile .body { padding: 8px 10px 10px; }
.itile .name { font-weight: 650; font-size: 15px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.itile .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 13px; color: var(--muted); gap: 4px; }
.itile .qty { position: absolute; top: 8px; right: 8px; background: rgba(17,24,39,.82); color: #fff; font-weight: 800; border-radius: 10px; padding: 3px 9px; font-size: 16px; }
.itile.low .qty { background: var(--bad); }
.itile .num { position: absolute; top: 8px; left: 8px; }

.tag { display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: .03em; padding: 3px 8px; border-radius: 8px; }
.tag.M { background: var(--muster-bg); color: var(--muster); }
.tag.W { background: var(--ware-bg); color: var(--ware); }
.tag.loc { background: var(--line); color: var(--text); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.info { background: var(--info-bg); color: var(--info); }
.tag.muted { background: var(--line); color: var(--muted); }

/* Artikel-Detail */
.hero-photo { width: 100%; max-height: 50vh; object-fit: contain; background: var(--line); border-radius: var(--radius); display: block; }
.hero-placeholder { aspect-ratio: 16/9; border-radius: var(--radius); background: var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.qty-big { font-size: 56px; font-weight: 850; line-height: 1; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.alert { padding: 12px 14px; border-radius: 12px; font-weight: 650; display: flex; gap: 10px; align-items: center; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.info { background: var(--info-bg); color: var(--info); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

/* Verlauf */
.mv-delta { font-weight: 800; font-size: 18px; }
.mv-delta.pos { color: var(--ok); }
.mv-delta.neg { color: var(--bad); }

/* Foto-Auswahl */
.photo-pick {
  width: 100%; aspect-ratio: 4/3; border-radius: var(--radius); border: 2px dashed var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted);
  font-weight: 600; cursor: pointer; overflow: hidden; position: relative;
}
.photo-pick img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.photo-pick svg.i { width: 48px; height: 48px; }
.photo-pick input { display: none; }

/* Sendungen */
.ship { border-left: 6px solid transparent; }
.ship.delivered { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok-bg) 60%, var(--card)); }
.ship .desc { font-weight: 700; font-size: 17px; }

/* Scanner */
.scanner { position: relative; width: 100%; aspect-ratio: 3/4; max-height: 65vh; background: #000; border-radius: var(--radius); overflow: hidden; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 18%; border: 4px solid rgba(255,255,255,.9); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }

/* Login */
.login { max-width: 380px; margin: 10vh auto 0; }
.login .logo { width: 72px; height: 72px; margin: 0 auto 12px; display: block; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #111827; color: #fff; padding: 14px 20px; border-radius: 14px; font-weight: 600; max-width: calc(100% - 32px);
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

.sticky-search { position: sticky; top: 61px; z-index: 5; background: var(--bg); padding: 4px 0 10px; margin: -4px 0 0; }
.searchbox { position: relative; }
.searchbox svg.i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.searchbox input { padding-left: 46px; font-size: 18px; }

.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
