/* Schlichtes, mobil-zuerst gestaltetes Layout */
:root {
  --text: #1d1d1f;
  --leise: #6b6b73;
  --hintergrund: #f6f6f8;
  --flaeche: #ffffff;
  --linie: #e2e2e6;
  --zeile: #f1f4f2;
  --akzent: #2f6f4f;
  --fehler: #b3261e;
  --ok: #2f6f4f;
  --unsicher: #8a5a00;
  --unsicher-grund: #fff2d6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--hintergrund);
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.45; }
a { color: var(--akzent); }
[hidden] { display: none !important; }

/* Kopfzeile */
.kopf {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem;
  padding: .6rem 1rem; background: var(--akzent); color: #fff;
}
.kopf a { color: inherit; text-decoration: none; }
.marke { font-weight: 700; font-size: 1.1rem; }
.kopf nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.kopf nav a { padding: .35rem .6rem; border-radius: .4rem; }
.kopf nav a[aria-current="page"], .kopf nav a:hover { background: rgba(255, 255, 255, .18); }
.abmelden { margin-left: auto; display: flex; gap: .5rem; align-items: center; font-size: .9rem; }
.abmelden button { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .6); }

main { padding: 1rem; max-width: 80rem; margin: 0 auto; }
h1 { font-size: 1.4rem; margin: .5rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }

/* Bedienelemente – groß genug für Finger */
button, .knopf, input, select {
  font: inherit; min-height: 2.5rem; border-radius: .4rem;
}
button, .knopf {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 1rem; border: 1px solid var(--akzent); background: var(--akzent); color: #fff;
  cursor: pointer; text-decoration: none;
}
input, select { border: 1px solid var(--linie); background: var(--flaeche); padding: 0 .5rem; }
label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--leise); }
label.haken { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); }
label.haken input { min-height: auto; width: 1.2rem; height: 1.2rem; }

.auswahl, .filterleiste, .formular {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem;
}
.formular { flex-direction: column; align-items: stretch; }

/* Vor/Zurück-Blättern */
.blaettern { display: flex; align-items: center; gap: 1rem; }
.blaettern h1 { margin: 0; flex: 1; text-align: center; }
.blaettern .knopf { font-size: 1.5rem; width: 3rem; padding: 0; }

.kennzahlen { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: baseline; }
.kennzahlen strong { font-size: 1.3rem; }

/* Tabellen – scrollen auf dem Handy seitlich, erste Spalte bleibt stehen */
.tabelle-rahmen { overflow-x: auto; background: var(--flaeche); border: 1px solid var(--linie); border-radius: .5rem; }
.tabelle { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.tabelle th, .tabelle td { padding: .45rem .7rem; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--linie); }
.tabelle thead th { background: var(--zeile); font-weight: 600; text-align: center; position: sticky; top: 0; }
.tabelle .links { text-align: left; }
.tabelle tbody tr:hover { background: var(--zeile); }
.tabelle tfoot th, .tabelle tfoot td { font-weight: 700; border-top: 2px solid var(--text); border-bottom: 0; }
.tabelle td a { text-decoration: none; }
.tabelle td a:hover { text-decoration: underline; }
#uebersicht tbody th, #uebersicht tfoot th, #uebersicht thead th:first-child {
  position: sticky; left: 0; background: var(--flaeche); font-weight: 500;
}
#uebersicht thead th:first-child { background: var(--zeile); z-index: 1; }
#uebersicht tfoot th { font-weight: 700; }
.tabelle .gesamt { font-weight: 600; }
.tabelle .null { color: var(--leise); }
.sortierbar th[data-sort] { cursor: pointer; user-select: none; }
.sortierbar th[aria-sort="ascending"]::after { content: " ▲"; font-size: .7em; }
.sortierbar th[aria-sort="descending"]::after { content: " ▼"; font-size: .7em; }

.negativ { color: var(--fehler); }
.fehler { color: var(--fehler); font-weight: 700; }
.ok { color: var(--ok); }
.warnung { color: var(--fehler); }
.leise { color: var(--leise); }
.klein { font-size: .85rem; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.hinweis { background: var(--unsicher-grund); padding: .6rem .8rem; border-radius: .4rem; }
.marke-unsicher {
  display: inline-block; padding: 0 .4rem; border-radius: .3rem; font-size: .75rem;
  color: var(--unsicher); background: var(--unsicher-grund); white-space: nowrap;
}

.export { display: flex; flex-wrap: wrap; gap: .5rem; }
.knopf.zweitrangig { background: var(--flaeche); color: var(--akzent); }

.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: .5rem; padding: 1rem 1.25rem; }
.schmal { max-width: 26rem; margin: 2rem auto; }

/* Kopfdaten eines Bons */
.kopfdaten { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 1rem; }
.kopfdaten dt { color: var(--leise); }
.kopfdaten dd { margin: 0; }

@media (max-width: 40rem) {
  .abmelden span { display: none; }
  .kopfdaten { grid-template-columns: 1fr; }
  .kopfdaten dd { margin-bottom: .4rem; }
}

/* Übersicht: Spalten je Geschäft nur auf Wunsch (Standard: nur Gesamt) */
#uebersicht.ohne-geschaefte .geschaeft { display: none; }

/* Kopfzeile: Mandant (Bereich) */
.kopf .mandant { font-weight: 600; }
.kopf form.mandant select { min-height: auto; padding: .2rem .4rem; border-radius: .4rem; font: inherit; }
.unsichtbar { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.marke-art { font-size: .75rem; padding: .05rem .35rem; border-radius: .3rem; background: #e8eefc; color: #1d3f8f; }

/* Beleg einlesen: Kopfdaten und Positionen in der Vorschau */
.felder { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.tabelle.beleg-formular th, .tabelle.beleg-formular td { padding: .3rem .4rem; }
.tabelle.beleg-formular input, .tabelle.beleg-formular select { min-height: 2.1rem; width: 100%; min-width: 5rem; }
.tabelle.beleg-formular input[type="checkbox"] { min-height: auto; width: 1.2rem; height: 1.2rem; min-width: auto; }
.zeile-unsicher { background: var(--unsicher-grund); }
