:root {
  --gruen: #1f4d3a;
  --gruen-d: #163a2b;
  --gruen-l: #e4efe8;
  --apricot: #f6a97a;
  --apricot-d: #d9824f;
  --apricot-l: #fdeadc;
  --bg: #f8f5ef;
  --karte: #ffffff;
  --text: #25382f;
  --text2: #5d6f66;
  --linie: #e4dfd3;
  --plus: #2c7a4d;
  --minus: #b25a34;
  --intern: #456a8c;
  --warn: #c0392b;
  --warn-l: #fdecea;
  --radius: 16px;
  --nav-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; } h2 { font-size: 20px; } h3 { font-size: 17px; }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
.laden { padding: 48px 24px; text-align: center; color: var(--text2); }

/* Kopf */
.kopf { background: var(--gruen); color: #fff; padding: calc(env(safe-area-inset-top) + 14px) 16px 16px; }
.kopf .zeile { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.kopf .titel { font-weight: 700; font-size: 20px; }
.kopf .wer { font-size: 14px; opacity: .85; }
main { padding: 12px 14px; max-width: 760px; margin: 0 auto; }

/* Karten */
.karte { background: var(--karte); border-radius: var(--radius); padding: 16px; margin: 0 0 12px; box-shadow: 0 1px 2px rgba(31,77,58,.08); border: 1px solid var(--linie); }
.karte h3 { margin-bottom: 8px; }
.karte.gruen { background: var(--gruen); color: #fff; border-color: var(--gruen); }
.karte.gruen .klein { color: rgba(255,255,255,.8); }
.karte.warn { background: var(--warn-l); border-color: #f0b8b1; }
.karte.apricot { background: var(--apricot-l); border-color: #f3cdb4; }
.gross { font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
.klein { font-size: 14px; color: var(--text2); }
.zeile2 { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--linie); }
.zeile2:last-child { border-bottom: 0; }
.zeile2 .betrag { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.plus { color: var(--plus); } .minus { color: var(--minus); } .intern { color: var(--intern); }
.gruen .plus, .gruen .minus { color: #fff; }
.balken { height: 10px; background: rgba(255,255,255,.25); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.balken > i { display: block; height: 100%; background: var(--apricot); border-radius: 6px; }

/* Bedienelemente */
.seg { display: flex; background: #ece7db; border-radius: 12px; padding: 3px; gap: 3px; margin: 0 0 10px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 10px 6px; border-radius: 10px; font-weight: 600; font-size: 15px; color: var(--text2); min-height: 44px; }
.seg button.an { background: var(--gruen); color: #fff; }
.zeitraum { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.zeitraum button { width: 48px; height: 44px; border: 1px solid var(--linie); background: #fff; border-radius: 12px; font-size: 20px; }
.zeitraum strong { font-size: 18px; }
.btn { display: block; width: 100%; min-height: 52px; border: 0; border-radius: 14px; background: var(--gruen); color: #fff; font-weight: 700; font-size: 17px; padding: 12px 16px; text-align: center; text-decoration: none; }
.btn.apricot { background: var(--apricot); color: #4a2a14; }
.btn.hell { background: #fff; color: var(--gruen); border: 2px solid var(--gruen); }
.btn.rot { background: #fff; color: var(--warn); border: 2px solid var(--warn); }
.btn.klein-btn { min-height: 44px; font-size: 15px; display: inline-block; width: auto; padding: 8px 16px; }
.btn[disabled] { opacity: .5; }
.btn + .btn { margin-top: 10px; }
.reihe { display: flex; gap: 10px; }
.reihe > * { flex: 1; }

label.feld { display: block; margin: 0 0 14px; }
label.feld > span { display: block; font-size: 14px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=month], input[type=search], select, textarea {
  width: 100%; min-height: 50px; padding: 11px 14px; border: 1.5px solid #d3cdbf; border-radius: 12px; background: #fff; font-size: 17px;
}
textarea { min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(246,169,122,.55); border-color: var(--apricot-d); }
.hinweis { font-size: 14px; background: var(--apricot-l); border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; }
.fehler { font-size: 15px; background: var(--warn-l); color: #8b2a20; border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; }

/* Liste */
.liste { list-style: none; margin: 0; padding: 0; }
.eintrag { display: flex; gap: 12px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--linie); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; min-height: 60px; }
.eintrag .links { flex: 1; min-width: 0; }
.eintrag .titel { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eintrag .betrag { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.eintrag.storniert .titel, .eintrag.storniert .betrag { text-decoration: line-through; opacity: .55; }
.monat { font-size: 14px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; margin: 16px 4px 2px; }
.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 20px; background: var(--gruen-l); color: var(--gruen); margin-right: 4px; }
.chip.einnahme { background: #dff1e6; color: var(--plus); }
.chip.ausgabe { background: var(--apricot-l); color: var(--minus); }
.chip.intern { background: #e2ebf3; color: var(--intern); }
.chip.kaution { background: #eee6f5; color: #6b4f8a; }
.chip.warn { background: var(--warn-l); color: var(--warn); }
.chip.ok { background: #dff1e6; color: var(--plus); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; }
.chips button { flex: none; border: 1.5px solid var(--linie); background: #fff; border-radius: 22px; padding: 8px 14px; font-weight: 600; font-size: 15px; min-height: 40px; }
.chips button.an { background: var(--gruen); color: #fff; border-color: var(--gruen); }

/* Neue Buchung: Auswahl */
.raster { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.raster button { border: 1.5px solid var(--linie); background: #fff; border-radius: 16px; padding: 14px 10px; min-height: 84px; font-weight: 700; font-size: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.raster button span { font-size: 26px; }
.raster button small { font-weight: 500; color: var(--text2); font-size: 13px; }
.abschnitt { font-size: 14px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; margin: 14px 2px 8px; }

/* Navigation unten */
nav.unten { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff; border-top: 1px solid var(--linie); display: flex; padding-bottom: env(safe-area-inset-bottom); }
nav.unten button { flex: 1; border: 0; background: none; height: var(--nav-h); font-size: 12px; font-weight: 600; color: var(--text2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
nav.unten button span { font-size: 22px; line-height: 1; }
nav.unten button.an { color: var(--gruen); }
nav.unten button.plusb span { background: var(--apricot); color: #4a2a14; width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; margin-top: -18px; box-shadow: 0 2px 6px rgba(0,0,0,.18); }

/* Sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(22,58,43,.45); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 760px; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 24px); }
.sheet .kopfzeile { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.sheet .zu { border: 0; background: #ece7db; border-radius: 50%; width: 40px; height: 40px; font-size: 20px; flex: none; }
details { margin: 8px 0; }
summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; }
.tab { width: 100%; border-collapse: collapse; font-size: 15px; }
.tab td, .tab th { padding: 7px 4px; border-bottom: 1px solid var(--linie); text-align: right; vertical-align: top; }
.tab th:first-child, .tab td:first-child { text-align: left; }
.tab th { font-size: 13px; color: var(--text2); }
.tab tr.summe td { font-weight: 800; border-top: 2px solid var(--text2); }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px); background: var(--gruen-d); color: #fff; padding: 12px 18px; border-radius: 14px; z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; text-align: center; }
#toast.sichtbar { opacity: 1; }
#toast.fehler { background: var(--warn); }

/* Anmeldung */
.login { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 40px) 20px 24px; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 14px; display: block; }
.login h1 { text-align: center; color: var(--gruen); margin-bottom: 4px; }
.login .unter { text-align: center; color: var(--text2); margin-bottom: 24px; }
.linkbtn { background: none; border: 0; color: var(--gruen); text-decoration: underline; font-size: 16px; padding: 12px 4px; min-height: 44px; }

/* Drucken (PDF-Export über „Teilen → Sichern als PDF“ bzw. Drucken) */
.nur-druck { display: none; }
@media print {
  body { background: #fff; padding: 0; font-size: 12pt; }
  nav.unten, .kopf, .keindruck, #toast, .sheet-bg .zu { display: none !important; }
  .nur-druck { display: block; margin-bottom: 12px; }
  .karte { box-shadow: none; break-inside: avoid; }
  main { max-width: none; padding: 0; }
}

/* Belegansicht im Vollbild mit Zurück-Knopf */
.belegbtn { text-align: left; padding: 8px 0; text-decoration: none; font-weight: 600; }
.beleg-viewer { position: fixed; inset: 0; z-index: 60; background: #14231c; display: flex; flex-direction: column; }
.beleg-kopf { display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 10px) 12px 10px; background: var(--gruen); color: #fff; }
.beleg-zurueck { flex: none; border: 0; background: rgba(255,255,255,.18); color: #fff; font-size: 18px; font-weight: 700; min-height: 48px; padding: 0 18px; border-radius: 14px; }
.beleg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; opacity: .9; }
.beleg-inhalt { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; display: flex; align-items: flex-start; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
.beleg-bild { max-width: 100%; height: auto; touch-action: pinch-zoom; }
.beleg-pdf { width: 100%; height: 100%; border: 0; background: #fff; }
@media print { .beleg-viewer { display: none !important; } }
