/* ==================================================================
   Umsatzerfassung – Stylesheet
   Farbwelt: Espresso, Walnuss, Cognac auf Hafer; Kassenbon als Blickfang.
   Keine externen Ressourcen (Systemschriften).
   ================================================================== */

:root {
  /* Grundpalette */
  --espresso: #2b1f18;
  --walnuss: #5b3f2d;
  --cognac: #a5643a;
  --cognac-tief: #874d28;
  --hafer: #ece4da;
  --papier: #faf6f1;

  /* Rollen (werden im Dunkelmodus umdefiniert) */
  --hg: var(--hafer);
  --flaeche: #f6f0e9;
  --flaeche-2: #fffcf8;
  --rand: #d6c7b6;
  --rand-stark: #bba792;
  --text: var(--espresso);
  --text-leise: #786352;
  --akzent: var(--cognac);
  --akzent-tief: var(--cognac-tief);
  --akzent-text: #fffaf4;
  --primaer: var(--walnuss);
  --primaer-hover: #4a3223;
  --primaer-text: #fbf5ee;
  --kopf-hg: var(--espresso);
  --kopf-text: #f1e6d8;
  --kopf-leise: #b9a08a;
  --bon-hg: var(--papier);
  --erfolg: #3e7a4b;
  --erfolg-hg: #e3efe2;
  --gefahr: #a2392b;
  --gefahr-hg: #f6e3df;
  --schatten: 0 1px 0 rgba(43, 31, 24, .06), 0 6px 18px -10px rgba(43, 31, 24, .35);

  /* Schrift */
  --sans: system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Maße */
  --r-klein: 7px;
  --r: 11px;
  --rand-x: 16px;
  --max: 560px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --hg: #19120d;
    --flaeche: #231912;
    --flaeche-2: #2c2018;
    --rand: #46362a;
    --rand-stark: #5d4837;
    --text: #f0e5d8;
    --text-leise: #b09a86;
    --akzent: #c47f4f;
    --akzent-tief: #d8955f;
    --akzent-text: #1b120c;
    --primaer: #d5ab80;
    --primaer-hover: #e2bb93;
    --primaer-text: #1d140e;
    --kopf-hg: #110b07;
    --bon-hg: #2a1f17;
    --erfolg: #6fae78;
    --erfolg-hg: #1f2e21;
    --gefahr: #e0806f;
    --gefahr-hg: #3a1f1a;
    --schatten: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 20px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

/* ---------- Grundlagen ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--hg);
  color: var(--text);
  font: 16px/1.45 var(--sans);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body.breite-mittel { --max: 960px; }
body.breite-breit { --max: 1180px; }

.inhalt {
  max-width: var(--max);
  margin: 0 auto;
  padding: 18px var(--rand-x) 40px;
}

a { color: var(--akzent-tief); }

:focus-visible { outline: 2.5px solid var(--akzent); outline-offset: 2px; }

.nur-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Kopfbereich ---------- */
.kopf {
  background: var(--kopf-hg);
  color: var(--kopf-text);
  padding-top: env(safe-area-inset-top, 0px);
}
.kopf-innen, .menue {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--rand-x);
}
.kopf-innen {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
}
.marke {
  font: 600 21px/1.1 var(--sans);
  color: var(--kopf-text);
  text-decoration: none;
  letter-spacing: .01em;
}
.abmelden {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--kopf-leise);
  text-decoration: none;
  font-size: 13.5px;
  padding: 8px 0 8px 10px;
}
.abmelden:hover { color: var(--kopf-text); }

.menue {
  display: flex;
  gap: 4px;
}
.menue a {
  flex: 1;
  text-align: center;
  padding: 10px 6px 12px;
  color: var(--kopf-leise);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  border-bottom: 3px solid transparent;
}
.menue a:hover { color: var(--kopf-text); }
.menue a.aktiv { color: var(--kopf-text); border-bottom-color: var(--akzent); }
@media (min-width: 700px) {
  .menue a { flex: 0 0 auto; padding-inline: 14px; }
  .menue { gap: 10px; }
}

/* ---------- Felder ---------- */
.feld { margin-bottom: 16px; scroll-margin: 12px; }

.feld-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-leise);
  margin: 0 0 5px 2px;
  letter-spacing: .01em;
  transition: color .15s;
}
.feld:focus-within > .feld-label { color: var(--akzent-tief); }
.feld-hilfe { margin: 5px 2px 0; font-size: 13px; color: var(--text-leise); }

.eingabe {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--flaeche-2);
  border: 1px solid var(--rand);
  border-radius: var(--r-klein);
  appearance: none;
}
select.eingabe {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-leise) 50%), linear-gradient(135deg, var(--text-leise) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
.eingabe:focus { border-color: var(--akzent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--akzent) 22%, transparent); }
.eingabe.nur-lesen { background: var(--flaeche); color: var(--text-leise); }
.eingabe-gross { font-size: 22px; text-align: center; letter-spacing: .15em; }
.eingabe[aria-invalid="true"] { border-color: var(--gefahr); }

/* ---------- Knöpfe ---------- */
.knopf {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  font: 600 16px/1 var(--sans);
  border-radius: var(--r-klein);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  touch-action: manipulation;
  transition: background-color .12s, border-color .12s, transform .06s;
}
.knopf:active:not(:disabled) { transform: scale(.98); }
.knopf:disabled { cursor: not-allowed; opacity: .45; }

.knopf-primaer { background: var(--primaer); color: var(--primaer-text); }
.knopf-primaer:hover:not(:disabled) { background: var(--primaer-hover); }
.knopf-leise { background: var(--flaeche-2); color: var(--text); border-color: var(--rand); }
.knopf-leise:hover:not(:disabled) { border-color: var(--rand-stark); }
.knopf-gefahr { background: var(--gefahr); color: #fff; }
.knopf-gefahr-leise { background: transparent; color: var(--gefahr); border-color: color-mix(in srgb, var(--gefahr) 45%, transparent); }
.knopf-gefahr-leise:hover { background: var(--gefahr-hg); }
.knopf-voll { width: 100%; }
.knopf-klein { min-height: 34px; padding: 0 12px; font-size: 14px; font-weight: 500; }

/* ---------- Button-Liste ---------- */
.bl {
  --luecke: 6px;
  display: flex;
  gap: 8px;
}
.bl-fenster {
  flex: 1;
  min-width: 0;
  max-height: calc(var(--zeilen) * var(--zeile-h) + (var(--zeilen) - 1) * var(--luecke));
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.bl-fenster::-webkit-scrollbar { display: none; }
.bl-raster {
  display: grid;
  grid-template-columns: repeat(var(--spalten), minmax(0, 1fr));
  grid-auto-rows: var(--zeile-h);
  gap: var(--luecke);
}
.bl-element {
  scroll-snap-align: start;
  display: flex; align-items: center; justify-content: center;
  padding: 2px 8px;
  min-width: 0;
  background: var(--flaeche-2);
  color: var(--text);
  border: 1px solid var(--rand);
  border-radius: var(--r-klein);
  font: 500 15px/1.15 var(--sans);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .1s, border-color .1s, color .1s;
}
.bl-element > span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: center;
  overflow-wrap: anywhere;
}
.bl-element:hover { border-color: var(--rand-stark); }
.bl-element.gewaehlt {
  background: var(--akzent);
  border-color: var(--akzent-tief);
  color: var(--akzent-text);
  font-weight: 650;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .14);
}
.bl-leer { grid-column: 1 / -1; margin: 0; align-self: center; color: var(--text-leise); font-size: 14px; }

/* Blätterleiste rechts (ca. 15 % der Breite) */
.bl-leiste {
  flex: 0 0 15%;
  max-width: 64px;
  min-width: 46px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bl-leiste[hidden] { display: none; }
.bl-hoch, .bl-runter {
  flex: 1 1 0;
  min-height: 26px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  background: var(--flaeche);
  color: var(--walnuss);
  border: 1px solid var(--rand);
  border-radius: var(--r-klein);
  cursor: pointer;
  touch-action: manipulation;
}
@media (prefers-color-scheme: dark) { .bl-hoch, .bl-runter { color: var(--primaer); } }
.bl-hoch svg, .bl-runter svg { width: 22px; height: 22px; }
.bl-hoch:active:not(:disabled), .bl-runter:active:not(:disabled) { background: var(--rand); }
.bl-hoch:disabled, .bl-runter:disabled { opacity: .35; cursor: default; }
.bl-spur {
  position: relative;
  flex: 0 0 auto;
  height: 40%;
  width: 4px;
  margin: 2px auto;
  border-radius: 2px;
  background: var(--rand);
}
.bl-griff {
  position: absolute; left: 0; right: 0;
  min-height: 8px;
  border-radius: 2px;
  background: var(--akzent);
}
/* bei nur einer sichtbaren Zeile keine Spur, damit die Knöpfe groß bleiben */
.bl[data-zeilen="1"] .bl-spur, .bl[data-zeilen="2"] .bl-spur { display: none; }

/* ---------- Anzahl ---------- */
.zaehler {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  gap: 8px;
}
.knopf-zaehler {
  padding: 0;
  font: 400 28px/1 var(--sans);
  background: var(--flaeche-2);
  color: var(--text);
  border-color: var(--rand);
}
.zaehler-wert {
  display: flex; align-items: center; justify-content: center;
  min-height: 48px;
  font: 600 20px/1 var(--sans);
  font-variant-numeric: tabular-nums;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--r-klein);
}

/* ---------- Datum ---------- */
.datum-zeile { display: flex; gap: 8px; }
.datum-zeile .eingabe { flex: 1; min-width: 0; }
.datum-zeile .knopf { flex: 0 0 64px; padding: 0; letter-spacing: .04em; }

/* ---------- Kassenbon (Zusammenfassung) ---------- */
.bon {
  position: relative;
  margin: 10px 0 20px;
  padding: 16px 16px 14px;
  min-height: 62px;
  background: var(--bon-hg);
  font: 400 17px/1.45 var(--sans);
  font-variant-numeric: tabular-nums;
  box-shadow: var(--schatten);
}
/* gezackte Abrisskanten oben und unten */
.bon::before, .bon::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 7px;
  background-size: 12px 7px;
  background-repeat: repeat-x;
}
.bon::before { top: -7px; background-image: radial-gradient(circle at 6px 7px, var(--bon-hg) 5px, transparent 5.6px); }
.bon::after { bottom: -7px; background-image: radial-gradient(circle at 6px 0, var(--bon-hg) 5px, transparent 5.6px); }
.bon-leer { color: var(--text-leise); font-size: 15px; }
.bon-rechnung { white-space: nowrap; }
.bon-summe { font-weight: 650; color: var(--akzent-tief); }
.bon-luecke {
  display: inline-block;
  padding: 0 6px;
  margin: 1px 0;
  font: 500 13px/1.6 var(--sans);
  color: var(--text-leise);
  border: 1px dashed var(--rand-stark);
  border-radius: 4px;
  vertical-align: 2px;
}

.aktionen {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
}
.aktionen .knopf { min-height: 56px; font-size: 18px; }
#knopf-ok { letter-spacing: .06em; }

.erfassung { transition: opacity .2s; }
.erfassung.gesperrt { pointer-events: none; opacity: .55; }

/* ---------- Statusmeldung (oben, fixiert) ---------- */
.meldung {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 14px;
  text-align: center;
  font-weight: 600;
  font-size: 17px;
  transform: translateY(-105%);
  transition: transform .22s ease-out;
  pointer-events: none;
}
.meldung.sichtbar { transform: translateY(0); }
.meldung-ok { background: var(--erfolg); color: #fff; }
.meldung-fehler { background: var(--gefahr); color: #fff; }
@media (prefers-color-scheme: dark) { .meldung-ok, .meldung-fehler { color: #120c08; } }

/* ---------- Hinweise ---------- */
.hinweis {
  margin: 0 0 16px;
  padding: 11px 14px;
  border-radius: var(--r-klein);
  font-size: 15px;
  transition: opacity .4s;
}
.hinweis-ok { background: var(--erfolg-hg); color: var(--erfolg); border: 1px solid color-mix(in srgb, var(--erfolg) 30%, transparent); }
.hinweis-fehler { background: var(--gefahr-hg); color: var(--gefahr); border: 1px solid color-mix(in srgb, var(--gefahr) 30%, transparent); }
.hinweis.ausgeblendet { opacity: 0; }

.leer {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-leise);
}
.leer p { margin: 0 0 14px; }

/* ---------- Seitentitel ---------- */
.seiten-titel {
  font: 600 28px/1.15 var(--sans);
  margin: 6px 0 6px;
}
.seiten-text { margin: 0 0 18px; color: var(--text-leise); }

/* ---------- Anmeldung ---------- */
.anmeldung {
  min-height: 82vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 340px;
  margin: 0 auto;
}
.anmeldung-titel {
  font: 600 34px/1.1 var(--sans);
  text-align: center;
  margin: 0 0 30px;
}
.anmeldung-form .eingabe { margin-bottom: 14px; }

/* ---------- Storno ---------- */
.buchungsliste { list-style: none; margin: 0; padding: 0; }
.buchung {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rand);
}
.buchung:first-child { border-top: 1px solid var(--rand); }
.buchung-text { flex: 1; min-width: 0; }
.buchung-kopf { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.buchung-kunde { font: 600 18px/1.25 var(--sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.buchung-summe { font: 600 18px/1.25 var(--sans); font-variant-numeric: lining-nums tabular-nums; }
.buchung-detail { margin-top: 2px; font-size: 15px; }
.buchung-meta { margin-top: 3px; font-size: 13px; color: var(--text-leise); }
.buchung .knopf { min-height: 44px; padding: 0 14px; }

/* ---------- Auswertung ---------- */
.filter {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 14px;
  padding: 16px 16px 2px;
  margin: 14px 0 24px;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--r);
}
@media (min-width: 700px) {
  .filter { grid-template-columns: 2fr 1fr auto; align-items: end; }
}
.feld-knopf .knopf { width: 100%; }

.ergebnis-kopf {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.ergebnis-titel { font: 600 24px/1.2 var(--sans); margin: 0; }
.ergebnis-unter { margin: 4px 0 0; color: var(--text-leise); font-size: 14.5px; }
.ergebnis-summe { text-align: right; }
.ergebnis-summe-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-leise); }
.ergebnis-summe-wert { font: 600 32px/1.1 var(--sans); font-variant-numeric: lining-nums tabular-nums; color: var(--akzent-tief); }

/* ---------- Tabellen ---------- */
.tabelle-rahmen {
  overflow-x: auto;
  background: var(--flaeche-2);
  border: 1px solid var(--rand);
  border-radius: var(--r);
}
.tabelle {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.tabelle th, .tabelle td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--rand);
  white-space: nowrap;
}
.tabelle th {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-leise);
  background: var(--flaeche);
}
.tabelle tbody tr:hover { background: color-mix(in srgb, var(--akzent) 6%, transparent); }
.tabelle tbody tr:last-child td { border-bottom: 0; }
.tabelle tfoot td {
  font-weight: 700;
  background: var(--flaeche);
  border-top: 2px solid var(--rand-stark);
  border-bottom: 0;
}
.tabelle .zahl { text-align: right; }
.tabelle tr.inaktiv td:not(.spalte-aktionen) { color: var(--text-leise); }

/* ---------- Stammdaten ---------- */
.stamm-kopf {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--rand);
}
.stamm-kopf .seiten-titel { margin-bottom: 12px; }
.reiter { display: flex; gap: 4px; }
.reiter a {
  padding: 10px 16px 11px;
  text-decoration: none;
  color: var(--text-leise);
  font-weight: 500;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.reiter a:hover { color: var(--text); }
.reiter a.aktiv { color: var(--text); border-bottom-color: var(--akzent); }
.reiter-zahl {
  display: inline-block;
  min-width: 22px;
  margin-left: 4px;
  padding: 1px 6px;
  font-size: 12px;
  text-align: center;
  border-radius: 10px;
  background: var(--flaeche);
  border: 1px solid var(--rand);
}
.stamm-werkzeug {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.stamm-titel { font: 600 22px/1.2 var(--sans); margin: 0; }
.spalte-aktionen { width: 1%; text-align: right !important; }
.spalte-aktionen .knopf + form { margin-left: 6px; }
form.inline { display: inline; }

.marker {
  display: inline-block;
  padding: 2px 9px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 10px;
}
.marker-an { background: var(--erfolg-hg); color: var(--erfolg); }
.marker-aus { background: var(--flaeche); color: var(--text-leise); border: 1px solid var(--rand); }

/* ---------- Dialoge ---------- */
.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 22px;
  color: var(--text);
  background: var(--flaeche-2);
  border: 1px solid var(--rand);
  border-radius: var(--r);
  box-shadow: 0 24px 60px -20px rgba(20, 12, 6, .55);
}
.dialog::backdrop { background: rgba(30, 20, 13, .5); }
.dialog[open] { animation: dialog-auf .16s ease-out; }
@keyframes dialog-auf { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialog-titel { font: 600 22px/1.25 var(--sans); margin: 0 0 12px; }
.dialog-text { margin: 0 0 20px; color: var(--text-leise); overflow-wrap: anywhere; }
.dialog-aktionen {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}
.dialog-frage .dialog-aktionen .knopf { flex: 1; }

.schalter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 18px;
  cursor: pointer;
}
.schalter input {
  width: 20px; height: 20px;
  accent-color: var(--akzent);
}

/* ---------- Bewegung reduzieren ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
