/* Farben und Maße wie im Grundsystem. Die Akzentfarbe kommt je Betrieb aus
   den Einstellungen (erscheinung.py) und wird im Kopf jeder Seite gesetzt;
   hier steht nur die Vorgabe. */
:root {
  --bg: #f5f6f8;
  --karte: #ffffff;
  --rand: #e4e7ec;
  --text: #1b1f24;
  --grau: #667085;
  --akzent: #2563eb;
  --akzent-hell: #e9effd;
  --akzent-schrift: #ffffff;
  --gruen: #157347;
  --rot: #b02a37;
  --gelb: #b7791f;
  --rund: 12px;
  --schatten: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  /* Höchstbreite des Inhalts neben der Leiste — breite Tabellen (Aufträge,
     Artikel) brauchen sie. Steht nur hier. */
  --inhalt-breite: 1300px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Rahmen: Seitenleiste + Inhalt (wie im Grundsystem) ----------------- */
.rahmen { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.leiste {
  background: var(--karte); border-right: 1px solid var(--rand);
  padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.leiste .titel { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px;
                 font-weight: 700; color: var(--text); }
.leiste .titel:hover { text-decoration: none; }
/* Das Firmenlogo aus den Einstellungen — dort oft groß hochgeladen. Hier nur
   so groß, dass es die Leiste nicht sprengt; das Seitenverhältnis bleibt. */
.leiste .titel img { display: block; max-height: 40px; max-width: 180px;
                     width: auto; height: auto; }
.punkt {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  color: var(--grau); font-weight: 500;
}
.punkt:hover { background: var(--bg); color: var(--text); text-decoration: none; }
/* Der aktuelle Bereich trägt die Akzentfarbe — ein Zustand, keine Verzierung. */
.punkt.hier { background: var(--akzent-hell); color: var(--akzent); }
.punkt svg { width: 18px; height: 18px; flex: none; }
.leiste .trenn { height: 1px; background: var(--rand); margin: 12px 6px; }

.oben {
  display: flex; align-items: center; gap: 14px; padding: 12px 28px;
  border-bottom: 1px solid var(--rand); background: var(--karte);
  position: sticky; top: 0; z-index: 2;
}
.oben .ich { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--grau); }
.oben .abmelden { color: var(--grau); }
.oben .abmelden:hover { color: var(--text); }
.kreis {
  width: 32px; height: 32px; border-radius: 50%; background: var(--akzent-hell); color: var(--akzent);
  display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}

main { max-width: var(--inhalt-breite); padding: 24px 28px 64px; }
/* Anmeldeseite: ohne Leiste, mittig. */
.ohne-leiste main { margin: 0 auto; }
main.schmal { max-width: 620px; margin: 3rem auto; }

@media (max-width: 900px) {
  .rahmen { grid-template-columns: minmax(0, 1fr); }
  .leiste { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 2px; padding: 8px; }
  .leiste .trenn { display: none; }
  .leiste .titel { width: 100%; padding-bottom: 6px; }
  main, .oben { padding-left: 16px; padding-right: 16px; }
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.6rem; }
h3 { font-size: 0.95rem; margin: 0 0 0.6rem; color: var(--grau); }
.karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: var(--rund);
  box-shadow: var(--schatten);
  padding: 1.1rem 1.3rem;
  margin-bottom: 1rem;
}
.karte.breit { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--rand); }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--grau); }
tr:last-child td { border-bottom: none; }
.badge {
  display: inline-block; font-size: 0.78rem; font-weight: 600;
  padding: 0.15rem 0.55rem; border-radius: 999px;
}
.badge.ok { background: #e6f4ea; color: var(--gruen); }
.badge.neutral { background: #eef1f4; color: var(--grau); }
.badge.warn { background: #fdf3e0; color: var(--gelb); }
input, button, select, textarea {
  font: inherit;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--rand);
  border-radius: 9px;
  background: #fff;
}
textarea { resize: vertical; }
button, .btn {
  background: var(--akzent); color: var(--akzent-schrift); border: none; cursor: pointer;
  font-weight: 600; padding: 0.5rem 1rem; border-radius: 9px;
  display: inline-block;
}
.btn:hover { text-decoration: none; }
/* Hell, auch als Verweis: Vorher galt das nur für <button>, und jeder
   „sekundäre“ Verweis (Filter, Protokoll, Inventur) stand gefüllt da. Der
   gewählte Filter wird über `.btn.aktiv` weiter unten wieder gefüllt. */
button.sekundaer, .btn.sekundaer { background: #eef1f4; color: var(--text); }
/* Farbige Knöpfe: grün für „geht raus“, rot für „macht rückgängig“.
   Eigene Namen statt .gruen/.rot — das sind dort Textfarben. */
button.positiv, .btn.positiv { background: var(--gruen); color: #fff; }
button.gefahr, .btn.gefahr { background: var(--rot); color: #fff; }
button.klein { padding: 0.25rem 0.55rem; font-size: 0.85rem; }
button:hover { opacity: 0.92; }
button:disabled { opacity: 0.35; cursor: default; }
.zeile { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.zeile + .zeile { margin-top: 0.6rem; }
.feld { margin-bottom: 0.9rem; display: flex; flex-direction: column; gap: 0.3rem; }
.feld > label { font-size: 0.85rem; color: var(--grau); }
.feld.fehlerhaft input, .feld.fehlerhaft select, .feld.fehlerhaft textarea {
  border-color: var(--rot);
}
.checkbox-zeile {
  display: flex; align-items: center; gap: 0.45rem; font-size: 0.95rem;
  white-space: nowrap;
}
.checkbox-zeile input { width: auto; padding: 0; }
.hinweis { color: var(--grau); font-size: 0.85rem; }
.fehler { color: var(--rot); font-size: 0.85rem; }
.fehler-box {
  background: #fdecea; color: var(--rot); border-radius: 7px;
  padding: 0.6rem 0.8rem; font-size: 0.9rem;
}
.grau { color: var(--grau); font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.leer { color: var(--grau); font-style: italic; padding: 0.5rem 0; }
.beschreibung { white-space: pre-wrap; color: var(--grau); }
.zentriert { max-width: 380px; margin: 4rem auto; }
.feldtitel { font-size: 0.85rem; color: var(--grau); }
.optionen-liste { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.1rem 0; }
/* Lieferadressen stehen zweizeilig — mit voller Anschrift, nicht nur PLZ/Ort. */
/* Sortierbare Spaltenköpfe: als Kopf lesbar, als Verweis erkennbar. */
th a.sortkopf { color: inherit; text-decoration: none; white-space: nowrap; }
th a.sortkopf:hover { text-decoration: underline; }
th a.sortkopf.aktiv { color: var(--akzent); }
th a.sortkopf .pfeil { margin-left: 0.25rem; font-size: 0.8em; }

.adressen { margin: 0.3rem 0 0.9rem; }
.adress-wahl { align-items: flex-start; white-space: normal; padding: 0.2rem 0; }
.adress-wahl input { margin-top: 0.25rem; }
/* .checkbox-zeile setzt display:flex — das hebelt [hidden] aus. */
.adress-wahl[hidden] { display: none; }
.adress-filter { margin: 0.3rem 0 0.5rem; max-width: 28rem; }
.bereich-zeile { display: flex; align-items: center; gap: 0.6rem; }
.bereich-zeile input[type=range] { flex: 1; padding: 0; border: none; background: none; }
.bereich-zeile output {
  min-width: 3rem; text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 600;
}
input[type=color] { padding: 0.2rem; height: 2.4rem; width: 4rem; }

/* Bestellungen */
.artikel-zeile { display: flex; align-items: center; gap: 0.8rem; }
.artikel-zeile label { font-size: 0.95rem; color: var(--text); }
.artikel-zeile input.menge { width: 5rem; text-align: right; }
.summe-zeile {
  display: flex; justify-content: space-between; align-items: baseline;
  border-top: 1px solid var(--rand); margin-top: 0.9rem; padding-top: 0.7rem;
  font-weight: 600; font-size: 1.1rem;
}
.summe-zeile output { font-variant-numeric: tabular-nums; }
td.rechts, th.rechts { text-align: right; }
table.bestellung { margin: 1rem 0; }
tr.summe td { font-weight: 600; border-top: 2px solid var(--rand); }
form.inline { display: inline; }
form.inline select { padding: 0.25rem 0.4rem; font-size: 0.85rem; }

/* Feldliste im Editor */
table.felder td { vertical-align: top; }
table.felder td.nr { color: var(--grau); width: 2rem; }
table.felder td.aktionen { text-align: right; white-space: nowrap; width: 1%; }
.feld-neu {
  margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--rand);
}
.entfernte { margin-top: 0.8rem; }
.entfernte summary { cursor: pointer; color: var(--grau); font-size: 0.85rem; }

/* Öffentliche Seite */
body.oeffentlich { background: #eceff2; }
.vorschau-hinweis {
  background: #fdf3e0; color: var(--gelb); border-radius: 7px;
  padding: 0.6rem 0.8rem; font-size: 0.9rem;
}

/* --- Bestandssystem ---------------------------------------------------- */
/* Die Breite steht oben in `--inhalt-breite`. Hier stand sie früher ein
   zweites Mal als feste Zahl und hat die Variable überschrieben: Der Inhalt
   war 1300 breit, die Kopfzeile 900 — und keine Prüfung sah es, weil beide
   Stellen für sich stimmig aussahen. */
h1 .badge { vertical-align: middle; margin-left: 0.5rem; }
/* Beträge brechen nie um — „1.234,50 €“ gehört in eine Zeile. Tabellarische
   Ziffern, damit Spalten untereinander stehen. Zellen mit `colspan` sind
   Beschriftungen (z. B. der Kleinunternehmer-Hinweis) und dürfen umbrechen. */
.rechts { text-align: right; font-variant-numeric: tabular-nums; }
td.rechts:not([colspan]), th.rechts, .betrag { white-space: nowrap; }
.betrag { font-variant-numeric: tabular-nums; }
.rot { color: var(--rot); font-weight: 600; }
.gruen { color: var(--gruen); }
tr.inaktiv td { opacity: 0.55; }
/* Textzeile im Beleg: trägt keine Zahlen, trennt Abschnitte. */
tr.textzeile td { padding-top: 0.7rem; color: var(--text); }
tr.summe td { font-weight: 600; border-top: 2px solid var(--rand); }

.kacheln { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.kachel {
  flex: 1 1 10rem; display: flex; flex-direction: column; gap: 0.2rem;
  margin-bottom: 0; text-decoration: none; color: var(--text);
}
.kachel:hover { text-decoration: none; border-color: var(--akzent); }
.kachel .zahl { font-size: 1.6rem; font-weight: 600; }
.kachel.warnung { border-color: var(--gelb); background: #fffdf7; }

/* Schnellwahl: ein Knopf je Auftragsquelle. Nur das Icon, damit drei Knöpfe
   in eine Tabellenspalte passen — die Bedeutung steht im title/aria-label. */
.schnellwahl { gap: 0.35rem; justify-content: flex-end; flex-wrap: nowrap; }
button.nur-icon, .btn.nur-icon {
  padding: 0.4rem 0.5rem; line-height: 0;
  background: #eef1f4; color: var(--text);
}
button.nur-icon:hover { background: var(--akzent); color: var(--akzent-schrift); opacity: 1; }
button.nur-icon svg { display: block; }

.archiv-leiste { display: flex; gap: 0.8rem; align-items: center; }

.blaettern { justify-content: center; margin-bottom: 1.5rem; }
.btn.aktiv { background: var(--akzent); color: var(--akzent-schrift); }
.trefferzeile { padding: 0.35rem 0; border-bottom: 1px solid var(--rand); }
.trefferzeile:last-child { border-bottom: none; }

/* Beleg-Druckansicht */
body.druck { background: #eceff2; }
.druckleiste {
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  max-width: 800px; margin: 1rem auto; padding: 0 1rem;
}
.beleg {
  background: #fff; max-width: 800px; margin: 0 auto 3rem; padding: 2.5rem;
  border: 1px solid var(--rand); border-radius: 4px;
}
.beleg-kopf { display: flex; justify-content: space-between; gap: 2rem; margin-bottom: 2.5rem; }
.beleg-kopf h1 { font-size: 1.6rem; margin-bottom: 0.8rem; }
.kopfdaten td { border: none; padding: 0.15rem 0 0.15rem 1rem; }
.beleg-positionen { margin-bottom: 1.5rem; }
.beleg-positionen th { border-bottom: 2px solid var(--text); }

/* Randlose Seite: Ohne Platz im Blattrand druckt der Browser seine eigene
   Kopf- und Fußzeile (URL, Datum, Seitenzahl) nicht mehr auf. Der Abstand zum
   Blattrand kommt dann aus dem Beleg selbst. Vollständig abschalten kann das
   nur der Nutzer im Druckdialog — das entscheidet der Browser, nicht die Seite. */
@page { margin: 0; }

@media print {
  .druckleiste, .leiste, .oben { display: none; }
  body.druck { background: #fff; }
  .beleg {
    border: none; margin: 0; max-width: none;
    padding: 18mm 18mm 20mm;
  }
}

.ok-box {
  background: #e6f4ea; color: var(--gruen); border-radius: 7px;
  padding: 0.6rem 0.8rem; font-size: 0.9rem;
}
/* Logo im Belegkopf: Höhe begrenzt, Seitenverhältnis bleibt. Rechtsbündig
   über der Absenderzeile — so bleibt das Anschriftfeld unangetastet. */
.beleg-logo { text-align: right; margin-bottom: 1.2rem; }
.beleg-logo img { max-height: 22mm; max-width: 60%; height: auto; }
.farbmuster { display: inline-block; width: 2.2rem; height: 2.2rem;
  border-radius: 8px; border: 1px solid var(--rand); }
.logo-vorschau {
  max-height: 60px; max-width: 220px; height: auto;
  border: 1px solid var(--rand); border-radius: 6px; padding: 0.3rem;
  background: #fff;
}

.beleg-absender {
  font-size: 0.85rem; padding-bottom: 1.2rem; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--rand);
}
.beleg-fuss {
  font-size: 0.78rem; margin-top: 2.5rem; padding-top: 0.8rem;
  border-top: 1px solid var(--rand);
  /* Blockweise nebeneinander wie im PDF; auf schmalem Schirm untereinander. */
  display: flex; flex-wrap: wrap; gap: 0 1.2rem;
}
.beleg-fuss .fussblock { min-width: 11rem; }
.beleg-fuss .fussblock strong { display: block; color: var(--text); }

.badge.offen { background: #fdecea; color: var(--rot); }

tr.zeile-fehler td { background: #fdf6f5; }
tr.zeile-warnung td { background: #fffdf7; }
.kachel.fehlerhaft-kachel { border-color: var(--rot); }
pre.detail {
  white-space: pre-wrap; font-size: 0.78rem; color: var(--grau);
  background: #f7f8fa; padding: 0.6rem; border-radius: 6px; margin: 0.4rem 0 0;
  max-height: 16rem; overflow: auto;
}
details summary { cursor: pointer; font-size: 0.8rem; }
/* Ein zusammengeklappter Block als eigene Karte trägt eine Überschrift,
   keine Fußnote — deshalb hier die normale Schriftgröße. */
details.karte > summary { font-size: 1rem; font-weight: 500; }

/* Kleiner Dreher für "wird gerade erledigt" */
.dreher {
  display: inline-block; width: 0.7em; height: 0.7em; margin-right: 0.3em;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: drehen 0.8s linear infinite;
  vertical-align: -0.1em;
}
@keyframes drehen { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dreher { animation: none; } }

.btn.klein { padding: 0.25rem 0.6rem; font-size: 0.85rem; }

/* Balken für Monatsverläufe — ohne Diagramm-Bibliothek */
.balken {
  height: 0.9rem; min-width: 2px; border-radius: 3px;
  background: var(--akzent); opacity: 0.75;
}
h2 .btn.klein { vertical-align: middle; margin-left: 0.6rem; font-weight: 400; }

.tabellenfuss {
  margin: 0.5rem 0 0; padding-top: 0.5rem; border-top: 1px solid var(--rand);
  font-size: 0.88rem; color: var(--grau);
}
.tabellenfuss strong { color: var(--text); }

/* --- Margenampel ------------------------------------------------------
   Farbe allein trägt die Aussage nicht: Wer Rot und Grün nicht unterscheidet,
   sieht nur zwei graue Punkte. Deshalb steht die Prozentzahl immer daneben,
   und der graue Zustand schreibt „n. b." aus. */
.ampel { font-size: 1.05rem; line-height: 1; margin-right: 0.15rem; }
.ampel.gruen { color: var(--gruen); }
.ampel.gelb  { color: var(--gelb); }
.ampel.rot   { color: var(--rot); }
.ampel.grau  { color: var(--grau); }
.nowrap { white-space: nowrap; }

.info-knopf {
  width: 1.15rem; height: 1.15rem; padding: 0; margin-left: 0.35rem;
  border: 1px solid var(--rand); border-radius: 50%;
  background: var(--karte); color: var(--grau);
  font-size: 0.7rem; font-weight: 700; line-height: 1; cursor: pointer;
  vertical-align: middle;
}
.info-knopf:hover { border-color: var(--akzent); color: var(--akzent); }

.marge-fenster {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(31, 41, 51, 0.35);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.marge-fenster > .karte {
  max-width: 46rem; width: 100%; max-height: 85vh; overflow: auto; margin: 0;
}
.marge-fenster td.duenn { color: var(--rot); }
.marge-fenster td.fehlt { color: var(--grau); font-style: italic; }

/* --- Preis übertippen (Auftragsposition im Entwurf) --------------------
   Aufgeklappt unter dem Preis, linksbündig, damit die Felder nicht an der
   rechten Tabellenkante kleben. */
.preis-abweichung { font-size: 0.8rem; color: var(--gelb); white-space: normal;
                    max-width: 16rem; margin-left: auto; }
details.preis-aendern { font-size: 0.8rem; }
details.preis-aendern summary { color: var(--akzent); }
details.preis-aendern form { display: flex; flex-direction: column; gap: 0.4rem;
  align-items: stretch; text-align: left; width: 16rem; margin: 0.4rem 0 0 auto; }
details.preis-aendern label { display: flex; flex-direction: column; gap: 0.15rem;
  color: var(--grau); }
details.preis-aendern button { align-self: flex-start; }
/* Regel 5: Während des Speicherns ersetzt die Anzeige den Knopf. */
details.preis-aendern .laeuft { display: none; color: var(--grau); }
details.preis-aendern form.htmx-request .laeuft { display: inline; }
details.preis-aendern form.htmx-request button { display: none; }

/* --- Kundenformular: Umschalter und Blöcke ------------------------------
   Umschalter: Optionsfelder als Segmentknöpfe — ein Klick, alle Möglichkeiten
   auf einen Blick. Gewählt trägt die Akzentfarbe. */
.kopfzeile-formular { display: flex; gap: 1rem; align-items: flex-end;
                      justify-content: space-between; flex-wrap: wrap; margin-bottom: 1rem; }
.umschalter { display: inline-flex; align-self: flex-start; border: 1px solid var(--rand);
              border-radius: 9px; overflow: hidden; background: var(--bg); }
.umschalter label { margin: 0; cursor: pointer; }
.umschalter input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.umschalter span { display: block; padding: 0.45rem 1.1rem; font-weight: 600;
                   color: var(--grau); border-left: 1px solid var(--rand); }
.umschalter label:first-child span { border-left: 0; }
.umschalter input:checked + span { background: var(--akzent); color: var(--akzent-schrift); }
.umschalter input:focus-visible + span { outline: 2px solid var(--akzent); outline-offset: -2px; }
.umschalter.klein span { padding: 0.3rem 0.9rem; font-weight: 500; }
/* Zwei Spalten, die sich zu einer schließen, wenn ein Block ausgeblendet ist
   (Privatkunde: kein Firmenblock) — auf dem Handy untereinander. */
.zweispaltig { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
               gap: 0.4rem 1.2rem; align-items: start; }
@media (max-width: 52rem) { .zweispaltig { grid-template-columns: minmax(0, 1fr); } }
.zweispaltig > [hidden] { display: none; }
fieldset.block { border: 1px solid var(--rand); border-radius: 10px; padding: 0.6rem 1rem 0.2rem;
                 margin: 0 0 0.6rem; min-width: 0; }
fieldset.block legend { font-weight: 600; padding: 0 0.4rem; }
[data-nur][hidden] { display: none; }

/* --- Reiter (wie im Grundsystem) ------------------------------------------
   Nur der gewählte Reiter ist sichtbar; alle stehen im selben Formular. */
nav.reiter { display: flex; gap: 2px; margin: 0 0 1rem; border-bottom: 1px solid var(--rand);
             overflow-x: auto; }
nav.reiter a { padding: 0.55rem 0.9rem; color: var(--grau); font-weight: 600;
               border-bottom: 2px solid transparent; white-space: nowrap; }
nav.reiter a:hover { color: var(--text); text-decoration: none; }
nav.reiter a.hier { color: var(--akzent); border-bottom-color: var(--akzent); }
.reiterblatt { display: none; }
.reiterblatt.hier { display: block; }

/* Vorschau der Belege: das PDF selbst, fast blattfüllend. */
.beleg-pdf { display: block; width: min(900px, calc(100% - 2rem)); height: calc(100vh - 5rem);
             margin: 0 auto 1rem; border: 1px solid var(--rand); border-radius: 4px;
             background: #fff; }

/* Gekaufte Produkte am Kunden: die einzelnen Käufe unter dem Artikel. */
.kaeufe { margin-top: 0.2rem; font-size: 0.85rem; line-height: 1.45; }

/* Schnellknöpfe auf der Übersicht: doppelt so hoch (Marco, 28.10.2026) —
   die häufigsten Wege des Tages sollen sich groß treffen lassen. */
.btn.gross { padding: 1.45rem 1.6rem; font-size: 1.05rem;
             border: 1px solid rgba(0, 0, 0, 0.18); }
