:root {
  --bg: #f7f3ee;
  --surface: #ffffff;
  --surface-2: #fbf8f5;
  --ink: #2a2124;
  --muted: #7a6d71;
  --line: #e8e0d9;
  --accent: #6b1d2f;
  --accent-ink: #ffffff;
  --accent-soft: #f3e6e9;
  --danger: #b3261e;
  --ok: #2f6b3f;
  --red-wine: #8c2b42;
  --white-wine: #d9c27a;
  --rose-wine: #e39aa8;
  --sparkling: #c9c2a8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(42, 33, 36, .06), 0 4px 16px rgba(42, 33, 36, .06);
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1517;
    --surface: #262022;
    --surface-2: #2d2628;
    --ink: #f2ece8;
    --muted: #a99ea1;
    --line: #3a3134;
    --accent: #d77f95;
    --accent-ink: #1c1517;
    --accent-soft: #3a252b;
    --danger: #ff8a80;
    --ok: #8fd19e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-family: ui-serif, "New York", Georgia, serif; font-size: 28px; font-weight: 600; line-height: 1.15; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
.boot { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ── Grundgerüst ── */
.shell { max-width: 680px; margin: 0 auto; padding: calc(var(--safe-t) + 14px) 16px calc(var(--tabbar-h) + var(--safe-b) + 28px); }
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 12px; margin: 6px 2px 16px; }
.top > div:first-child { flex: 1 1 auto; min-width: 0; }
.top .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.top-actions { display: flex; gap: 8px; flex-shrink: 0; }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); background: none; border: 0; padding: 6px 0; margin: 0 0 4px -4px; font-size: 16px; cursor: pointer; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar nav { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; max-width: 680px; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabbar-h); color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 550; }
.tab .icon { width: 25px; height: 25px; }
.tab.active { color: var(--accent); }
.tab.cta .icon { background: var(--accent); color: var(--accent-ink); border-radius: 9px; padding: 3px; width: 29px; height: 29px; }

/* ── Symbole ── */
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ── Karten und Listen ── */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card, .section + .section { margin-top: 14px; }
.card.pad { padding: 16px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 4px 8px; color: var(--muted); font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.section-title .count { text-transform: none; letter-spacing: 0; font-weight: 550; }

.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; min-height: 56px;
  background: none; border: 0; text-align: left; cursor: pointer; color: inherit; text-decoration: none;
}
.row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--surface-2); }
.row.static { cursor: default; }
.row.static:active { background: none; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 560; overflow-wrap: anywhere; }
.row .meta { color: var(--muted); font-size: 14px; margin-top: 1px; overflow-wrap: anywhere; }
.row .chev { color: var(--muted); width: 18px; height: 18px; }
.row.empty { color: var(--muted); font-style: italic; cursor: default; min-height: 46px; font-size: 15px; }

.qty { min-width: 34px; height: 30px; padding: 0 9px; border-radius: 15px; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.qty.big { height: 36px; min-width: 44px; border-radius: 18px; font-size: 17px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: var(--line); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.dot.R { background: var(--red-wine); }
.dot.W { background: var(--white-wine); }
.dot.RS { background: var(--rose-wine); }
.dot.S { background: var(--sparkling); }

/* Lagerort-Kacheln */
.locs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 360px) { .locs { grid-template-columns: 1fr; } }
.loc {
  display: flex; flex-direction: column; gap: 10px; padding: 16px; min-height: 132px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  color: inherit; text-decoration: none; border: 0; text-align: left; cursor: pointer;
}
.loc:active { transform: scale(.985); }
.loc .icon { width: 28px; height: 28px; color: var(--accent); }
.loc .name { font-weight: 650; font-size: 16px; line-height: 1.25; }
.loc .num { margin-top: auto; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.loc .num small { font-size: 14px; font-weight: 550; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.loc .bars { display: flex; gap: 3px; height: 6px; }
.loc .bars span { flex: 1; border-radius: 3px; background: var(--line); }
.loc .bars span.on { background: var(--accent); opacity: .75; }

/* ── Suche ── */
.searchbar { position: relative; margin-bottom: 16px; }
.searchbar .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.searchbar input[type=search] { padding-left: 42px; }
.hit-where { display: flex; align-items: center; gap: 10px; padding: 9px 14px 9px 36px; width: 100%; background: none; border: 0; border-top: 1px dashed var(--line); text-align: left; cursor: pointer; color: inherit; font-size: 15px; }
.hit-where:active { background: var(--surface-2); }
.hit-where .where { flex: 1; color: var(--muted); }

/* ── Formulare ── */
.field { display: block; margin-bottom: 14px; }
.field > span, .label { display: block; font-size: 13px; font-weight: 650; color: var(--muted); margin: 0 2px 6px; }
input[type=text], input[type=search], input[type=password], input[type=number], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 13px;
  font-size: 16px; /* verhindert Zoom auf iOS */
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; outline: none;
  -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 2px; font-size: 16px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 16px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:active { filter: brightness(.96); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; border-color: transparent; color: var(--accent); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.big { min-height: 54px; font-size: 17px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; background: none; border: 0; color: var(--muted); cursor: pointer; }
.icon-btn:active { background: var(--surface-2); }
.icon-btn[disabled] { opacity: .3; pointer-events: none; }

.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; min-height: 38px; padding: 6px 12px; border: 0; border-radius: 9px; background: none; font-weight: 600; font-size: 15px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 8px 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); font-weight: 560; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .n { font-size: 12px; opacity: .7; font-variant-numeric: tabular-nums; }
.chip[disabled] { opacity: .4; pointer-events: none; }

.stepper { display: flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); width: max-content; }
.stepper button { width: 52px; height: 48px; border: 0; background: none; color: var(--accent); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.stepper button[disabled] { color: var(--line); }
.stepper input { width: 64px; min-height: 48px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0; text-align: center; font-weight: 700; font-size: 18px; padding: 0; box-shadow: none !important; }
.stepper-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stepper-row .hint { color: var(--muted); font-size: 14px; }

.picked { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1.5px solid var(--accent); border-radius: 12px; background: var(--accent-soft); }
.picked .main { flex: 1; min-width: 0; }
.picked .title { font-weight: 650; }
.picked .meta { font-size: 14px; color: var(--muted); }
.pick-list { margin-top: 8px; max-height: 320px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ── Verlauf ── */
.day { margin: 20px 4px 8px; font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ev { display: flex; gap: 12px; padding: 12px 14px; }
.ev + .ev { border-top: 1px solid var(--line); }
.ev .badge { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--surface-2); color: var(--muted); }
.ev .badge .icon { width: 19px; height: 19px; }
.ev.in .badge { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.ev.out .badge { background: var(--accent-soft); color: var(--accent); }
.ev.move .badge { background: color-mix(in srgb, #3a6ea5 14%, transparent); color: #3a6ea5; }
.ev .main { flex: 1; min-width: 0; }
.ev .what { font-weight: 600; }
.ev .wine { overflow-wrap: anywhere; }
.ev .detail, .ev .when { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.ev .note { font-size: 14px; font-style: italic; margin-top: 2px; overflow-wrap: anywhere; }
.ev .btn { margin-top: 8px; }
.ev.reversed .what, .ev.reversed .wine { text-decoration: line-through; text-decoration-color: var(--muted); }
.tag { display: inline-block; font-size: 12px; font-weight: 650; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); vertical-align: 1px; margin-left: 4px; }
.tag.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 14px; max-width: 100%; }
.filter-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-chip button { border: 0; background: none; color: inherit; display: inline-flex; padding: 2px; cursor: pointer; }

/* ── Verwaltung ── */
.admin-loc .head { display: flex; align-items: center; gap: 2px; padding: 10px 6px 10px 14px; border-bottom: 1px solid var(--line); }
.admin-loc .head .icon:first-child { margin-right: 8px; }
.admin-loc .icon-btn { width: 34px; }
.admin-loc .head .main { flex: 1; min-width: 0; }
.admin-loc .shelf { display: flex; align-items: center; gap: 4px; padding: 4px 8px 4px 28px; min-height: 46px; }
.admin-loc .shelf + .shelf { border-top: 1px solid var(--line); }
.admin-loc .shelf .main { flex: 1; min-width: 0; }
.admin-loc .foot { padding: 8px; border-top: 1px solid var(--line); }

/* ── Sheet (Dialog von unten) ── */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(20, 12, 15, .38); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s ease; }
.backdrop.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 680px; max-height: calc(100dvh - var(--safe-t) - 24px); overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 6px 16px calc(var(--safe-b) + 18px);
  transform: translateY(24px); transition: transform .2s ease;
  overscroll-behavior: contain;
}
.backdrop.open .sheet { transform: none; }
@media (min-width: 700px) { .backdrop { align-items: center; } .sheet { border-radius: 20px; max-width: 520px; padding-bottom: 18px; } }
.sheet-head { position: sticky; top: -6px; z-index: 1; display: flex; align-items: flex-start; gap: 8px; padding: 12px 0 10px; background: var(--bg); }
.sheet-head h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-top: 6px; }
.sheet-sub { color: var(--muted); margin: -4px 0 16px; }
.sheet .grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 0; }

/* ── Meldungen ── */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); z-index: 60; display: flex; justify-content: center; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 560px; width: max-content; padding: 11px 12px 11px 16px; border-radius: 14px; background: #2a2124; color: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.25); font-size: 15px; animation: rise .2s ease; }
.toast.error { background: var(--danger); }
.toast button { border: 0; background: rgba(255,255,255,.16); color: #fff; font-weight: 650; border-radius: 9px; padding: 7px 11px; cursor: pointer; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .toast { background: #f2ece8; color: #1c1517; } .toast button { background: rgba(0,0,0,.08); color: #1c1517; } .toast.error { color: #fff; background: #b3261e; } .toast.error button { color: #fff; background: rgba(255,255,255,.16); } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.banner { margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 550; }

/* ── Anmeldung ── */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 18px calc(var(--safe-b) + 24px); }
.login .card { width: 100%; max-width: 380px; padding: 28px 22px 22px; }
.login .logo { width: 64px; height: 64px; border-radius: 16px; display: block; margin: 0 auto 14px; }
.login h1 { text-align: center; margin-bottom: 4px; }
.login p { text-align: center; color: var(--muted); margin: 0 0 22px; }
.error-text { color: var(--danger); font-size: 14px; margin: -4px 2px 12px; min-height: 1em; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mt-s { margin-top: 8px; }
.hint-box { font-size: 14px; color: var(--muted); padding: 12px 14px; border: 1px dashed var(--line); border-radius: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chip .icon { width: 18px; height: 18px; }
