:root {
  --bg: #f6f5f1; --surface: #ffffff; --text: #1f2a24; --muted: #66726b; --border: #dcdad2;
  --accent: #2f7d4f; --accent-text: #ffffff; --accent-soft: #e3f1e8;
  --red: #b3261e; --red-soft: #fbe4e2; --orange: #a55a00; --orange-soft: #fdeccf; --green: #2f7d4f; --green-soft: #e3f1e8; --blue-soft: #e1ecf7; --blue: #25598f;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181a; --surface: #1d2326; --text: #e8ece9; --muted: #98a59d; --border: #333c40;
    --accent: #4aa873; --accent-text: #0c1a12; --accent-soft: #1d3326;
    --red: #f2776f; --red-soft: #3a1f1d; --orange: #f0b35a; --orange-soft: #3a2c15; --green: #4aa873; --green-soft: #1d3326; --blue-soft: #1c2b3b; --blue: #7db4ea;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; } h2 { font-size: 1.15rem; margin: 1.5rem 0 .6rem; } h3 { font-size: 1rem; margin: 0 0 .4rem; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.hidden { display: none !important; }

header.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.top-inner { max-width: 1100px; margin: 0 auto; padding: .5rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
nav a { padding: .4rem .7rem; border-radius: 8px; text-decoration: none; color: var(--muted); }
nav a:hover { background: var(--bg); } nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.user { display: flex; align-items: center; gap: .5rem; }
main { max-width: 1100px; margin: 0 auto; padding: 1rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stat { font-size: 2rem; font-weight: 700; line-height: 1.1; }

button, .btn { font: inherit; cursor: pointer; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); min-height: 40px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--red); } button.small { min-height: 32px; padding: .2rem .6rem; font-size: .85rem; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; width: 100%; padding: .5rem .6rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); min-height: 40px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.field { margin-bottom: .8rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 160px; } .row > button { flex: 0 0 auto; }
.form-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.toolbar > div { flex: 1 1 170px; }
.tabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.tabs button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--bg); }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; } td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.red { background: var(--red-soft); color: var(--red); } .badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.green { background: var(--green-soft); color: var(--green); } .badge.blue { background: var(--blue-soft); color: var(--blue); } .badge.gray { background: var(--bg); color: var(--muted); }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 1.2rem; width: min(520px, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin-top: 0; } .dialog-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; }
.secret { font-family: ui-monospace, monospace; word-break: break-all; background: var(--bg); padding: .6rem; border-radius: 8px; border: 1px dashed var(--accent); }

#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 100; width: min(440px, calc(100vw - 2rem)); }
.toast { background: var(--text); color: var(--bg); padding: .7rem 1rem; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.toast.error { background: var(--red); color: #fff; }

.login { max-width: 380px; margin: 12vh auto 0; padding: 0 1rem; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.fach-list { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: .1rem .3rem .1rem .7rem; font-size: .9rem; }
.chip button { min-height: 24px; padding: 0 .4rem; border: 0; background: none; color: var(--muted); }
video.scan { width: 100%; border-radius: 8px; background: #000; max-height: 280px; }

@media (max-width: 640px) {
  .top-inner { gap: .4rem; } nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  nav a { white-space: nowrap; }
  th, td { padding: .5rem .5rem; }
}
input[type=checkbox] { width: auto; min-height: 0; }

.thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; background: var(--bg); flex: none; }
.frage { display: flex; gap: .9rem; align-items: flex-start; }
.stack { display: grid; gap: .7rem; }
.pos-list { margin: .4rem 0 0; padding-left: 1rem; font-size: .9rem; }
.actions-row { margin-top: .5rem; gap: .4rem; } .actions-row > * { flex: 0 0 auto; }
.pair { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.qr { width: 240px; height: 240px; background: #fff; border-radius: 8px; padding: 6px; }
.qr.expired { opacity: .15; }
.upload-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
@media (max-width: 640px) { .thumb { width: 72px; height: 72px; } .qr { width: 100%; height: auto; max-width: 300px; } }

.einkauf-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .4rem; }
.einkauf-item { display: flex; align-items: center; justify-content: space-between; gap: .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .8rem; min-height: 52px; }
.einkauf-item.done .einkauf-check span:not(.badge) { text-decoration: line-through; color: var(--muted); }
.einkauf-check { display: flex; align-items: center; gap: .7rem; margin: 0; font-size: 1.05rem; color: var(--text); flex: 1; cursor: pointer; }
.einkauf-check input { width: 1.4rem; height: 1.4rem; }
.einkauf-actions { white-space: nowrap; }
.vorrat-card .row { align-items: center; gap: .5rem; } .vorrat-card .row > * { flex: 0 0 auto; }
.spacer { height: .8rem; }

.abdeckung { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); }
.abdeckung-fill { display: inline-block; width: 64px; height: 8px; border-radius: 4px; background: var(--border); position: relative; overflow: hidden; }
.abdeckung-fill::after { content: ""; position: absolute; inset: 0 auto 0 0; background: var(--orange); width: 50%; }
.abdeckung-fill.full::after { background: var(--green); width: 100%; } .abdeckung-fill.most::after { background: var(--green); width: 80%; } .abdeckung-fill.part::after { background: var(--orange); width: 50%; }
.rezept-card .row { align-items: center; gap: .5rem; } .rezept-card .row > * { flex: 0 0 auto; }
tr.klickbar { cursor: pointer; } tr.klickbar:hover td { background: var(--bg); }
.rohtext { white-space: pre-wrap; font: .85rem/1.4 ui-monospace, monospace; background: var(--bg); padding: .7rem; border-radius: 8px; max-height: 280px; overflow: auto; }
.anleitung p { margin: .4rem 0; }
