/* Rechnungsprogramm — Gestaltung
   Grundgedanke: Werkstatt statt Büro. Dunkle Kopfleiste wie eine Werkbankplatte,
   Papierweiß für alles, was ein Beleg ist, Messing als einziger Schmuck.
   Alle Bedienelemente mindestens 48px hoch — bedienbar mit Arbeitshandschuh. */

:root {
  --tinte: #14171c;
  --tinte-weich: #2b3038;
  --papier: #f7f5f1;
  --karte: #ffffff;
  --messing: #9a7538;
  --messing-hell: #f5eee1;
  --gruen: #1c7048;
  --gruen-hell: #e6f2eb;
  --bernstein: #a86a11;
  --bernstein-hell: #fbf0dc;
  --rot: #ab221f;
  --rot-hell: #fbe9e8;
  --grau: #666d77;
  --grau-hell: #9aa1ab;
  --linie: #e3e0da;
  --schatten: 0 1px 2px rgba(20, 23, 28, .06), 0 4px 14px rgba(20, 23, 28, .05);
  --rund: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px; line-height: 1.45; color: var(--tinte); background: var(--papier);
  -webkit-font-smoothing: antialiased;
}
.zahl, .betrag, table { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ------------------------------------------------------------- Kopfleiste */
.kopf {
  position: sticky; top: 0; z-index: 30;
  background: var(--tinte); color: #fff;
  padding: 14px 16px calc(14px + env(safe-area-inset-top)) 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 12px; min-height: 60px;
}
.kopf h1 { font-size: 18px; font-weight: 650; margin: 0; letter-spacing: -.02em; flex: 1;
           overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kopf .unter { font-size: 12.5px; color: #a8aeb8; font-weight: 400; letter-spacing: 0; }
.kopf button {
  background: rgba(255,255,255,.1); border: 0; color: #fff; width: 40px; height: 40px;
  border-radius: 11px; display: grid; place-items: center; cursor: pointer; flex: none;
}
.kopf button:active { background: rgba(255,255,255,.22); }
.zurueck { font-size: 15px; }

/* ------------------------------------------------------------ Fußnavigation */
.fussnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--linie); display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.fussnav a {
  flex: 1; text-align: center; padding: 9px 2px 10px; text-decoration: none;
  color: var(--grau); font-size: 10.5px; font-weight: 550; letter-spacing: -.01em;
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 56px;
  justify-content: center;
}
.fussnav a.an { color: var(--tinte); }
.fussnav a.an svg { color: var(--messing); }
.fussnav svg { width: 22px; height: 22px; }

.seite { padding: 16px 16px 96px; max-width: 720px; margin: 0 auto; }

/* ------------------------------------------------------------------ Karten */
.karte {
  background: var(--karte); border-radius: var(--rund); box-shadow: var(--schatten);
  margin-bottom: 12px; overflow: hidden;
}
.karte-inhalt { padding: 16px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--grau);
     font-weight: 650; margin: 26px 0 10px; }
h2:first-child { margin-top: 4px; }

/* Kennzahl auf der Startseite: die Zahl ist die Überschrift, nicht ihr Etikett. */
.kennzahl { padding: 20px 18px; }
.kennzahl .wert { font-size: 40px; font-weight: 700; letter-spacing: -.035em; line-height: 1.05; }
.kennzahl .etikett { font-size: 13.5px; color: var(--grau); margin-top: 4px; }
.kennzahl .neben { display: flex; gap: 22px; margin-top: 16px; padding-top: 14px;
                   border-top: 1px solid var(--linie); }
.kennzahl .neben div { font-size: 13px; color: var(--grau); }
.kennzahl .neben b { display: block; font-size: 19px; color: var(--tinte); font-weight: 650;
                     letter-spacing: -.02em; }

/* --------------------------------------------------------------- Listen */
.reihe {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 62px;
  cursor: pointer; background: none; width: 100%; text-align: left; font: inherit; color: inherit;
  /* Erst alles weg — sonst bleibt bei <button> der Standardrahmen oben und rechts stehen. */
  border: 0; border-bottom: 1px solid var(--linie); border-left: 3px solid transparent;
}
.reihe:last-child { border-bottom: 0; }
.reihe:active { background: #f2f0ec; }
.reihe .haupt { flex: 1; min-width: 0; }
.reihe .titel { font-weight: 600; font-size: 15.5px; letter-spacing: -.01em;
                overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reihe .neben { font-size: 13px; color: var(--grau); margin-top: 2px;
                overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reihe .rechts { text-align: right; flex: none; }
.reihe .summe { font-weight: 650; font-size: 15.5px; letter-spacing: -.015em; }
.reihe .pfeil { color: var(--grau-hell); flex: none; }
/* Zustand am linken Rand, wie ein Reiter im Ordner – kein zweites Etikett nötig. */
.reihe.st-offen { border-left-color: var(--bernstein); }
.reihe.st-bezahlt { border-left-color: var(--gruen); }
.reihe.st-ueberfaellig { border-left-color: var(--rot); }
.reihe.st-entwurf { border-left-color: var(--grau-hell); }
.reihe.st-storno { border-left-color: var(--grau-hell); opacity: .6; }

.marke { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11.5px;
         font-weight: 650; letter-spacing: .01em; }
.m-offen { background: var(--bernstein-hell); color: var(--bernstein); }
.m-bezahlt { background: var(--gruen-hell); color: var(--gruen); }
.m-ueberfaellig { background: var(--rot-hell); color: var(--rot); }
.m-entwurf { background: #eeecE8; color: var(--grau); }
.m-messing { background: var(--messing-hell); color: var(--messing); }

/* ------------------------------------------------------------- Belegkette */
/* Das Erkennungszeichen der App: man sieht immer, woher ein Beleg kommt
   und was daraus geworden ist. */
.kette { display: flex; align-items: stretch; gap: 0; margin: 0; padding: 0; }
.kette .glied {
  flex: 1; padding: 11px 10px; text-align: center; background: #f2f0ec; border-right: 1px solid var(--linie);
  font-size: 11px; color: var(--grau-hell); text-decoration: none; display: block;
}
.kette .glied:last-child { border-right: 0; }
.kette .glied .was { text-transform: uppercase; letter-spacing: .07em; font-weight: 650; font-size: 9.5px; }
.kette .glied .nr { font-size: 13.5px; font-weight: 650; margin-top: 3px; color: var(--grau); }
.kette .glied.da { background: var(--tinte); color: #fff; }
.kette .glied.da .nr, .kette .glied.da .was { color: #fff; }
.kette .glied.gibt { background: var(--messing-hell); }
.kette .glied.gibt .nr { color: var(--messing); }
.kette .glied.gibt .was { color: var(--messing); }

/* ------------------------------------------------------------- Formulare */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--grau);
        margin: 0 0 6px; letter-spacing: .01em; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 13px 14px; min-height: 50px;
  border: 1.5px solid var(--linie); border-radius: 11px; background: #fff; color: var(--tinte);
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(154,117,56,.22); border-color: var(--messing);
}
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.feld { margin-bottom: 14px; }
.paar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.drei { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }

.knopf {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 54px; padding: 15px 18px; border: 0; border-radius: 12px;
  font: inherit; font-size: 16px; font-weight: 650; letter-spacing: -.01em;
  cursor: pointer; background: var(--tinte); color: #fff; margin-bottom: 10px;
}
.knopf:active { transform: scale(.985); }
.knopf.zweit { background: #fff; color: var(--tinte); box-shadow: inset 0 0 0 1.5px var(--linie); }
.knopf.messing { background: var(--messing); }
.knopf.gefahr { background: #fff; color: var(--rot); box-shadow: inset 0 0 0 1.5px #f0cdcb; }
.knopf.klein { min-height: 44px; font-size: 14.5px; padding: 10px 14px; width: auto; }
.knopf:disabled { opacity: .45; }

.meldung { padding: 13px 15px; border-radius: 11px; font-size: 14.5px; margin-bottom: 12px;
           border-left: 3px solid; }
.meldung.gut { background: var(--gruen-hell); color: var(--gruen); border-color: var(--gruen); }
.meldung.schlecht { background: var(--rot-hell); color: var(--rot); border-color: var(--rot); }
.meldung.hinweis { background: var(--messing-hell); color: #6d5326; border-color: var(--messing); }

.leer { text-align: center; padding: 44px 22px; color: var(--grau); }
.leer .gross { font-size: 16px; font-weight: 600; color: var(--tinte); margin-bottom: 6px; }
.leer p { margin: 0 0 18px; font-size: 14px; }

/* ------------------------------------------------------------- Positionen */
.pos {
  background: #fff; border: 1.5px solid var(--linie); border-radius: 12px;
  padding: 12px; margin-bottom: 10px;
}
.pos .kopfzeile { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.pos .kopfzeile .nr { width: 24px; height: 24px; border-radius: 7px; background: var(--messing-hell);
  color: var(--messing); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.pos .weg { margin-left: auto; background: none; border: 0; color: var(--grau-hell);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.pos .weg:active { background: var(--rot-hell); color: var(--rot); }
.pos input { min-height: 46px; padding: 11px 12px; }
.pos .zeilensumme { text-align: right; font-size: 13.5px; color: var(--grau); margin-top: 8px; }
.pos .zeilensumme b { color: var(--tinte); font-size: 15.5px; font-weight: 650; }

.summenblock { background: var(--tinte); color: #fff; border-radius: var(--rund); padding: 16px 18px; }
.summenblock .z { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14.5px; color: #b6bcc6; }
.summenblock .gesamt { display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 10px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.16); }
.summenblock .gesamt span { font-size: 14.5px; color: #b6bcc6; }
.summenblock .gesamt b { font-size: 27px; font-weight: 700; letter-spacing: -.03em; }

/* --------------------------------------------------------------- Fenster */
.schleier { position: fixed; inset: 0; background: rgba(20,23,28,.5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center; }
.fenster { background: #fff; width: 100%; max-width: 560px; border-radius: 20px 20px 0 0;
  max-height: 92vh; overflow-y: auto; padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); }
.fenster .griff { width: 38px; height: 4px; background: var(--linie); border-radius: 99px;
  margin: 8px auto 14px; }
.fenster h3 { font-size: 19px; margin: 0 0 4px; letter-spacing: -.02em; }
.fenster .erklaerung { color: var(--grau); font-size: 14px; margin: 0 0 18px; }

.suchzeile { position: relative; margin-bottom: 14px; }
.suchzeile input { padding-left: 42px; }
.suchzeile svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--grau-hell); pointer-events: none; }

.wahl { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 2px; }
.wahl button { flex: none; padding: 9px 15px; min-height: 42px; border-radius: 99px; border: 1.5px solid var(--linie);
  background: #fff; font: inherit; font-size: 14px; font-weight: 600; color: var(--grau); cursor: pointer; }
.wahl button.an { background: var(--tinte); border-color: var(--tinte); color: #fff; }

.zeile { display: flex; justify-content: space-between; gap: 14px; padding: 12px 0;
  border-bottom: 1px solid var(--linie); font-size: 14.5px; }
.zeile:last-child { border-bottom: 0; }
.zeile .k { color: var(--grau); flex: none; }
.zeile .w { text-align: right; font-weight: 550; }

.schalter { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--linie); }
.schalter:last-child { border-bottom: 0; }
.schalter .txt { flex: 1; }
.schalter .txt b { display: block; font-size: 15px; font-weight: 600; }
.schalter .txt span { font-size: 13px; color: var(--grau); }
.schalter input[type=checkbox] { width: 52px; height: 31px; border-radius: 99px; background: var(--linie);
  border: 0; position: relative; flex: none; cursor: pointer; min-height: 0; transition: background .18s; }
.schalter input[type=checkbox]::after { content: ''; position: absolute; top: 3px; left: 3px;
  width: 25px; height: 25px; border-radius: 99px; background: #fff; transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.schalter input[type=checkbox]:checked { background: var(--gruen); }
.schalter input[type=checkbox]:checked::after { transform: translateX(21px); }

.hilfe { font-size: 13px; color: var(--grau); line-height: 1.5; margin: -4px 0 14px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
:focus-visible { outline: 3px solid var(--messing); outline-offset: 2px; }

/* Verlauf: linksbündig, Zeilenumbrüche erhalten — ein protokollierter Beleg
   ist mehrzeilig und in einer rechtsbündigen Wertespalte unlesbar. */
.verlaufzeile { padding: 11px 0; border-bottom: 1px solid var(--linie); }
.verlaufzeile:last-child { border-bottom: 0; }
.verlaufzeile .k { font-size: 12px; color: var(--grau-hell); margin-bottom: 3px; }
.verlaufzeile .was { font-size: 14px; line-height: 1.45; }
.verlaufzeile .was.block {
  white-space: pre-line; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; background: #f7f5f1; border-left: 3px solid var(--messing);
  padding: 9px 11px; border-radius: 0 8px 8px 0; margin-top: 4px;
}

/* Gliederung: Hauptpunkt hebt sich ab, Unterpunkt rückt ein. */
.pos.gruppe { border-color: var(--messing); background: var(--messing-hell); }
.pos.gruppe .nr { background: var(--messing); color: #fff; }
.pos.unterpunkt { margin-left: 14px; border-left: 3px solid var(--messing-hell); }
.pos .nr { width: auto; min-width: 24px; padding: 0 5px; }
.pos .schieb { background: none; border: 0; color: var(--grau-hell); width: 34px; height: 34px;
  border-radius: 8px; cursor: pointer; display: grid; place-items: center; flex: none; }
.pos .schieb:active { background: var(--linie); color: var(--tinte); }
.pos .schieb:disabled { opacity: .25; }
.pos .schieb.runter svg { transform: rotate(180deg); }
.pos .kopfzeile .weg { margin-left: 0; }
.pos .zeilensumme { min-height: 34px; line-height: 34px; }

/* Aufmaß: vier schmale Zahlenfelder nebeneinander. */
.vier { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.massreihe { background: #fff; border: 1.5px solid var(--linie); border-radius: 11px;
  padding: 11px; margin-bottom: 9px; }
.massreihe .nr { width: 22px; height: 22px; border-radius: 6px; background: var(--messing-hell);
  color: var(--messing); font-size: 11.5px; font-weight: 700; display: grid; place-items: center; flex: none; }
.massreihe .kopfzeile { display: flex; align-items: center; gap: 7px; }
.massreihe .weg { background: none; border: 0; color: var(--grau-hell); width: 32px; height: 32px;
  border-radius: 8px; cursor: pointer; display: grid; place-items: center; flex: none; }
.masszeile { display: flex; gap: 7px; margin-top: 9px; }
.masszeile .knopf { flex: 1; min-height: 40px; font-size: 13.5px; padding: 8px 10px; }
