:root {
  --bg: #f6f3ee;
  --karte: #ffffff;
  --text: #1d2320;
  --leise: #5f6b66;
  --linie: #e3ddd3;
  --primaer: #1f3d34;
  --primaer-text: #ffffff;
  --akzent: #b8322a;
  --gold: #c99a2e;
  --ok: #2f7a4f;
  --warn: #9a6a00;
  --warn-bg: #fff4d6;
  --fehler-bg: #fde8e6;
  --chip: #eee8de;
  --schatten: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --karte: #1b211e;
    --text: #e8ece9;
    --leise: #9aa7a1;
    --linie: #2c3531;
    --primaer: #5fae8f;
    --primaer-text: #0d1311;
    --akzent: #ef6b61;
    --gold: #e0b450;
    --ok: #6cc592;
    --warn: #f0c050;
    --warn-bg: #3a3018;
    --fehler-bg: #3d1f1c;
    --chip: #262e2a;
    --schatten: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
.kopf {
  position: sticky; top: 0; z-index: 10; background: var(--primaer); color: var(--primaer-text);
  padding-top: env(safe-area-inset-top);
}
.kopf-innen { display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 0 auto; padding: 10px 16px; }
.logo { font-size: 26px; }
.kopf-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.kopf-text strong { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf-text span { font-size: 13px; opacity: .85; }
.netz { background: var(--akzent); color: #fff; border-radius: 99px; padding: 2px 10px; font-size: 13px; }
.inhalt { max-width: 760px; margin: 0 auto; padding: 14px 16px 24px; }
.leer { color: var(--leise); text-align: center; padding: 28px 8px; }
h2 { font-size: 20px; margin: 18px 0 10px; }
h3 { font-size: 15px; margin: 16px 0 6px; color: var(--leise); text-transform: uppercase; letter-spacing: .04em; }
.karte {
  background: var(--karte); border-radius: var(--radius); box-shadow: var(--schatten);
  border: 1px solid var(--linie); padding: 14px; margin: 10px 0;
}
.zeile { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--linie); }
.zeile:first-child { border-top: 0; }
.zeile .haupt { flex: 1; min-width: 0; }
.zeile .titel { font-weight: 600; }
.zeile .klein, .klein { font-size: 13px; color: var(--leise); }
.preis { font-variant-numeric: tabular-nums; white-space: nowrap; }
.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; min-height: 44px; cursor: pointer;
  background: var(--primaer); color: var(--primaer-text); font-weight: 600;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.zweit { background: var(--chip); color: var(--text); }
.btn.gefahr { background: var(--akzent); color: #fff; }
.btn.klein { padding: 6px 12px; min-height: 36px; font-size: 14px; }
/* .klein ist auch eine Textklasse (grau) – bei Knöpfen die Knopffarbe behalten */
.btn.klein { color: var(--primaer-text); }
.btn.zweit.klein { color: var(--text); }
.btn.gefahr.klein { color: #fff; }
.btn.breit { width: 100%; }
.knoepfe { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--linie);
  background: var(--karte); font-size: 22px; line-height: 1; cursor: pointer;
}
.stepper button.plus { background: var(--primaer); color: var(--primaer-text); border-color: var(--primaer); }
.stepper .zahl { min-width: 22px; text-align: center; font-weight: 700; }
.leiste {
  position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 9;
  padding: 0 16px 10px; pointer-events: none;
}
.leiste .btn { display: block; max-width: 728px; margin: 0 auto; width: 100%; pointer-events: auto; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center;
  background: var(--karte); border-top: 1px solid var(--linie); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; max-width: 140px; border: 0; background: none; padding: 8px 2px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 12px; color: var(--leise);
  position: relative;
}
.tabs button .ico { font-size: 21px; }
.tabs button[aria-current="page"] { color: var(--primaer); font-weight: 700; }
.badge {
  position: absolute; top: 4px; right: calc(50% - 22px); background: var(--akzent); color: #fff;
  border-radius: 99px; font-size: 11px; padding: 0 6px; min-width: 18px; text-align: center;
}
.chip { display: inline-block; background: var(--chip); border-radius: 99px; padding: 1px 9px; font-size: 12px; margin-right: 4px; }
.chip.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.aus { text-decoration: line-through; }
.hinweis { background: var(--warn-bg); color: var(--text); border-radius: 12px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.fehlerbox { background: var(--fehler-bg); border-radius: 12px; padding: 10px 12px; margin: 10px 0; }
label.feld { display: block; margin: 10px 0; font-size: 14px; color: var(--leise); }
label.feld input, label.feld select, label.feld textarea, input.eingabe, select.eingabe {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--linie); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 16px;
}
label.check { display: flex; align-items: center; gap: 10px; margin: 8px 0; min-height: 36px; }
label.check input { width: 22px; height: 22px; }
.summen { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-variant-numeric: tabular-nums; }
.summen .gross { font-size: 20px; font-weight: 700; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(140px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: 520px; margin: 0 auto; background: var(--text); color: var(--bg); border-radius: 12px;
  padding: 12px 14px; box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: 88vh;
  background: var(--karte); color: var(--text);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg { padding: 18px; overflow-y: auto; max-height: 88vh; }
.dlg h2 { margin-top: 0; }
.zettel { font-size: 22px; line-height: 1.5; }
.zettel .anz { font-weight: 800; display: inline-block; min-width: 2.4em; }
.tabelle { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabelle th, .tabelle td { padding: 7px 4px; border-top: 1px solid var(--linie); text-align: left; vertical-align: middle; }
.tabelle td.r, .tabelle th.r { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }
.qr { display: block; width: 220px; height: 220px; margin: 10px auto; background: #fff; border-radius: 10px; }
.link-text { word-break: break-all; font-size: 13px; background: var(--chip); padding: 8px; border-radius: 8px; user-select: all; }
.unsicher { background: var(--warn-bg); }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.edit-grid input, .edit-grid select { width: 100%; padding: 8px; border: 1px solid var(--linie); border-radius: 8px; background: var(--bg); min-height: 40px; font-size: 16px; }
.edit-grid .voll { grid-column: 1 / -1; }
.segment { display: flex; background: var(--chip); border-radius: 12px; padding: 3px; gap: 3px; margin: 8px 0; }
.segment button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 4px; min-height: 40px; cursor: pointer; font-size: 14px; }
.segment button[aria-pressed="true"] { background: var(--karte); font-weight: 700; box-shadow: var(--schatten); }
.gruppe-titel { margin: 14px 0 0; font-weight: 700; }
.gestrichen { text-decoration: line-through; color: var(--leise); }
.status-gewuenscht { color: var(--warn); }
.status-bestellt { color: var(--primaer); }
.status-geliefert { color: var(--ok); }
.status-storniert { color: var(--leise); }
a { color: var(--primaer); }
@media (min-width: 640px) { .edit-grid { grid-template-columns: 2fr 1fr 1fr 1fr; } }

.uebersicht th, .uebersicht td { white-space: nowrap; }
.uebersicht td:first-child { white-space: normal; }
.uebersicht tr.klickbar { cursor: pointer; }
.uebersicht tr.klickbar:hover td { background: var(--chip); }
.uebersicht tr.details td { border-top: 0; padding-top: 0; padding-left: 14px; white-space: normal; }
.uebersicht tfoot th { border-top: 2px solid var(--linie); }
.uebersicht .chip { margin-left: 6px; }
.sortknopf { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; cursor: pointer; color: inherit; }

.stift { border: 0; background: none; font-size: 18px; padding: 6px; min-width: 36px; min-height: 36px; cursor: pointer; opacity: .7; }
.stift:hover { opacity: 1; }
.storno-info { font-size: 13px; color: var(--leise); margin-top: 3px; }
.storno-info.wartet { color: var(--warn); font-weight: 600; }
.storno-info.abgelehnt { color: var(--akzent); }
.zeile.markiert { background: var(--warn-bg); border-radius: 10px; padding-left: 8px; padding-right: 8px; }
.scroll-seg { overflow-x: auto; }
.scroll-seg button { flex: 0 0 auto; padding-left: 12px; padding-right: 12px; white-space: nowrap; }
h2.ohne-abstand { margin: 0; font-size: 17px; }
.zettel-block + .zettel-block { margin-top: 18px; border-top: 1px solid var(--linie); padding-top: 12px; }
select.eingabe { margin: 6px 0; }

.budget-balken { position: relative; height: 12px; background: var(--chip); border-radius: 99px; overflow: hidden; margin: 8px 0 6px; }
.budget-voll { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ok); }
.budget-geplant { position: absolute; top: 0; bottom: 0; background: var(--ok); opacity: .4; }
.budget-schwelle { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: .5; }
.budget-warn .budget-voll, .budget-warn .budget-geplant { background: var(--gold); }
.budget-ueber .budget-voll, .budget-ueber .budget-geplant { background: var(--akzent); }
.budget-warn { border-color: var(--gold); }
.budget-ueber { border-color: var(--akzent); }
.budget-meldung { font-weight: 700; margin-top: 4px; }
.budget-ueber .budget-meldung { color: var(--akzent); }
.budget-warn .budget-meldung { color: var(--warn); }

input.pin { font-size: 24px; letter-spacing: .4em; text-align: center; }
.hinweis .btn.klein { margin-left: 4px; }

.stern { border: 0; background: none; font-size: 22px; line-height: 1; padding: 6px 4px; min-width: 36px; min-height: 40px; cursor: pointer; color: var(--leise); }
.stern.an { color: var(--gold); }
.zeile.kompakt { padding: 6px 0; }
.zeile.kompakt .stepper button { width: 36px; height: 36px; font-size: 20px; }
.favoriten { border-color: var(--gold); }
input.suche { margin: 4px 0 8px; }
.kategorie + .kategorie { border-top: 1px solid var(--linie); }
.kategorie-kopf { display: flex; justify-content: space-between; align-items: center; width: 100%; border: 0; background: none;
  padding: 12px 2px; min-height: 48px; font: inherit; font-weight: 700; cursor: pointer; color: inherit; text-align: left; }
