:root {
  --bg: #f3f5f4;
  --flaeche: #ffffff;
  --flaeche-2: #e7eeeb;
  --rand: #d3dcd8;
  --text: #15201c;
  --text-2: #5a6a65;
  --akzent: #136b50;          /* Vereinsgrün (T-Shirt) */
  --akzent-text: #ffffff;
  --akzent-hell: #dcefe7;
  --hinweis: #fff4c2;
  --hinweis-text: #5c4300;
  --gefahr: #b3261e;
  --foto-bg: #ffffff;
  --schatten: 0 1px 2px rgba(15, 40, 35, .06), 0 3px 12px rgba(15, 40, 35, .06);
  --radius: 12px;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tabbar: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513; --flaeche: #18201d; --flaeche-2: #212b27; --rand: #2f3b37;
    --text: #e4ece9; --text-2: #97a8a2; --akzent: #4fc39a; --akzent-text: #062019; --akzent-hell: #183a2f;
    --hinweis: #3d3414; --hinweis-text: #f5dc85; --gefahr: #f08a80;
    --schatten: 0 1px 2px rgba(0, 0, 0, .3), 0 3px 12px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--schrift); -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
a { color: var(--akzent); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
.klein { font-size: .85em; color: var(--text-2); }
.leer { color: var(--text-2); padding: 2rem 0; text-align: center; }
.fehler { color: var(--gefahr); }
.zahl { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
.zeile { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ---------- Kopf und Tab-Leiste ---------- */
.kopf {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--flaeche); border-bottom: 1px solid var(--rand);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.logo img { border-radius: 8px; flex: none; }
.logo span { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.logo small { color: var(--text-2); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 2px; margin-left: auto; }
.tabs a {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px;
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.tabs a svg { width: 20px; height: 20px; }
.tabs a.aktiv { color: var(--akzent); background: var(--akzent-hell); }

@media (max-width: 760px) {
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0;
    height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--flaeche); border-top: 1px solid var(--rand); justify-content: space-around;
  }
  .tabs a { flex-direction: column; gap: 2px; font-size: .72rem; padding: 8px 4px; flex: 1; justify-content: center; border-radius: 0; }
  .tabs a.aktiv { background: none; }
  .inhalt { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px) !important; }
}

.inhalt { max-width: 860px; margin: 0 auto; padding: 16px; }

/* ---------- Bedienelemente ---------- */
button, .knopf {
  font: inherit; border: 1px solid var(--rand); background: var(--flaeche); color: var(--text);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .knopf:hover { border-color: var(--text-2); }
button.primaer, .knopf.primaer { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); font-weight: 600; }
button.gross { width: 100%; justify-content: center; padding: 12px; font-size: 1.05rem; }
button.gefahr { color: var(--gefahr); }
button.flach { border-color: transparent; background: none; }
button:disabled { opacity: .5; cursor: default; }
button svg { width: 18px; height: 18px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--akzent); outline-offset: -1px; }
label { display: block; font-size: .85rem; color: var(--text-2); margin-bottom: .75rem; }
label input, label textarea { margin-top: 4px; }
.schalter { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: .95rem; cursor: pointer; }
.schalter input { width: auto; margin: 0; accent-color: var(--akzent); }
.honig { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); box-shadow: var(--schatten); padding: 14px 16px; margin-bottom: 12px; }
.karte.schmal { max-width: 380px; }

.segment { display: inline-flex; background: var(--flaeche-2); border-radius: 9px; padding: 3px; gap: 2px; }
.segment button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; color: var(--text-2); font-size: .92rem; }
.segment button.aktiv { background: var(--flaeche); color: var(--text); box-shadow: var(--schatten); font-weight: 600; }

.hinweis { background: var(--hinweis); color: var(--hinweis-text); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; white-space: pre-line; }
.hinweis.warn { font-weight: 600; }
.einleitung { margin-top: -.2em; }

/* ---------- Bestellseite ---------- */
.ausfuehrung-wahl {
  position: sticky; top: 57px; z-index: 10; background: var(--bg); padding: 8px 0 10px; margin-bottom: 4px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.artikel { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 12px; }
.artikel.gewaehlt { border-color: var(--akzent); box-shadow: 0 0 0 1px var(--akzent), var(--schatten); }
.foto {
  position: relative; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: var(--foto-bg);
  width: 120px; aspect-ratio: 4 / 5; align-self: start; display: block;
}
.foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto:disabled { opacity: 1; cursor: default; background: var(--flaeche-2); }
.kein-foto { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--text-2); gap: 4px; }
.kein-foto svg { width: 44px; height: 44px; opacity: .5; }
.mehr-fotos { position: absolute; right: 4px; bottom: 4px; background: rgba(0, 0, 0, .55); color: #fff; font-size: .7rem; padding: 1px 6px; border-radius: 99px; }
.artikel-text { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.artikel-text h3 { margin-bottom: 2px; font-size: 1.05rem; }
.farbe { font-weight: 400; color: var(--text-2); }
.preise { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-bottom: 8px; }
.preise .an { color: var(--text); font-weight: 600; }
.positionen { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-bottom: 8px; }
.positionen:empty { display: none; }
.pos { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pos + .pos { border-top: 1px dashed var(--rand); padding-top: 6px; }
.pos select { width: auto; min-width: 0; padding: 7px 8px; }
.pos select[data-feld="groesse"] { min-width: 86px; }
.pos select.offen { border-color: var(--akzent); color: var(--text-2); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--rand); border-radius: 8px; overflow: hidden; }
.stepper button { border: 0; border-radius: 0; padding: 6px 11px; font-size: 1.1rem; line-height: 1; }
.stepper b { min-width: 24px; text-align: center; }
.entfernen { padding: 6px; color: var(--text-2); }
.hinzu.flach { padding-left: 0; color: var(--akzent); }
.hinzu:not(.flach) { border-color: var(--akzent); color: var(--akzent); font-weight: 600; }

@media (max-width: 480px) {
  .artikel { grid-template-columns: 92px 1fr; gap: 12px; }
  .foto { width: 92px; }
  .pos select[data-feld="ausfuehrung"] { max-width: 100px; }
}

.abschluss { margin-top: 20px; border-color: var(--akzent); }
.zusammenfassung { margin-bottom: 14px; }
.zusammenfassung td:first-child { width: 2.5em; white-space: nowrap; }
.zusammenfassung td:last-child, .zusammenfassung th:last-child { text-align: right; white-space: nowrap; }
.zusammenfassung tfoot th { border-top: 2px solid var(--rand); text-align: left; color: var(--text); }

/* ---------- Bestellungen ---------- */
.filterleiste {
  position: sticky; top: 57px; z-index: 10; background: var(--bg); padding: 8px 0 10px; margin-bottom: 4px;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.filterleiste input { flex: 1; min-width: 160px; width: auto; }
.bestellung { padding: 10px 14px; }
.bestellung.storniert { opacity: .55; }
.bestellung.storniert .pos-liste { text-decoration: line-through; }
.bestellung-kopf { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.pos-liste { margin: 6px 0; padding-left: 1.1em; }
.pos-liste li { margin: 2px 0; }
.groesse { display: inline-block; min-width: 2.2em; text-align: center; font-weight: 700; font-size: .85em; background: var(--akzent-hell); color: var(--akzent); border-radius: 6px; padding: 0 5px; }
.bestellung-fuss { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bestellung-fuss button { padding: 2px 6px; }
.artikel-summe h3 .klein { font-weight: 400; }
.artikel-summe .tabelle td { padding: 5px 4px; }
.groesse-zelle { width: 3.5em; }
.artikel-summe td.zahl { width: 2.5em; text-align: right; padding-right: 12px; font-weight: 600; }

.fuss { text-align: center; margin: 28px 0 8px; line-height: 1.8; }

/* ---------- Dialog ---------- */
.dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px);
  background: var(--flaeche); color: var(--text); box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
.dialog::backdrop { background: rgba(10, 20, 18, .45); }
.dialog-kopf { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--rand); position: sticky; top: 0; background: var(--flaeche); z-index: 1; }
.dialog-kopf h2 { margin: 0; flex: 1; }
.dialog-inhalt { padding: 14px 16px; }
.dialog-fuss { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--rand); position: sticky; bottom: 0; background: var(--flaeche); }
.fotos { display: flex; flex-direction: column; gap: 8px; padding: 8px; background: var(--foto-bg); }
.fotos img { width: 100%; height: auto; display: block; border-radius: 8px; }

/* ---------- Meldung ---------- */
.meldung {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--schatten); max-width: calc(100vw - 32px);
}
@media (max-width: 760px) { .meldung { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px); } }
.meldung.fehler { background: var(--gefahr); color: #fff; }

table.tabelle { width: 100%; border-collapse: collapse; }
.tabelle td, .tabelle th { padding: 8px 6px; border-top: 1px solid var(--rand); text-align: left; vertical-align: middle; }
.tabelle th { font-size: .8rem; color: var(--text-2); border-top: 0; }

/* ---------- Zugriffsstatistik ---------- */
.stat-tabelle td, .stat-tabelle th { padding: 4px 6px; font-size: .88rem; }
.stat-tabelle .zahl { text-align: right; font-variant-numeric: tabular-nums; }
.stat-tabelle tfoot th { border-top: 2px solid var(--rand); color: var(--text); }
.stat-tabelle .leer-zeile td { color: var(--text-2); }
.balken-zelle { width: 35%; }
.balken-zelle i { display: block; height: 8px; border-radius: 4px; background: var(--akzent); min-width: 0; }

/* Hinweis auf vorhandene Bestellungen (oben auf der Bestellseite) */
.bestand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); background: var(--akzent-hell); border-color: var(--akzent); }
.bestand:hover { box-shadow: 0 0 0 1px var(--akzent), var(--schatten); }
.bestand-icon { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--akzent); color: var(--akzent-text); display: grid; place-items: center; }
.bestand-icon svg { width: 22px; height: 22px; }
.bestand-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bestand-pfeil { font-size: 1.8rem; line-height: 1; color: var(--akzent); }
