:root {
  --bg: #f6f4f0;
  --flaeche: #ffffff;
  --tinte: #1d1b17;
  --gedaempft: #6b665c;
  --linie: #e3ded4;
  --akzent: #b34e0a;
  --akzent-text: #ffffff;
  --ok: #1f7a4d;
  --ok-bg: #e3f4ea;
  --warn: #7a4600;
  --warn-bg: #fff1d6;
  --fehler: #b3261e;
  --fehler-bg: #fde8e6;
  --info-bg: #eef1f6;
  --radius: 14px;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --flaeche: #201e1b;
    --tinte: #f1ede4;
    --gedaempft: #a8a295;
    --linie: #37332d;
    --akzent: #f08a3c;
    --akzent-text: #1b1209;
    --ok: #5fd397;
    --ok-bg: #12301f;
    --warn: #f2b75b;
    --warn-bg: #3a2a08;
    --fehler: #ff8f86;
    --fehler-bg: #3d1511;
    --info-bg: #1d2431;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--tinte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px);
}
a { color: var(--akzent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; margin: 24px 0 10px; }
p { margin: 0 0 8px; }
.klein { font-size: .875rem; }
.ohne-abstand { margin-top: 0; }
.leer-hinweis { text-align: center; padding: 24px 0; }
.gedaempft { color: var(--gedaempft); }
.rechts { text-align: right; }

/* ---------- Kopf & Navigation ---------- */
.kopf {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--linie);
}
.marke { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; }
.marke img { border-radius: 8px; }
.text-knopf { background: none; border: 0; color: var(--gedaempft); font: inherit; padding: 10px 4px; min-height: 44px; cursor: pointer; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }

.leiste {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--flaeche); border-top: 1px solid var(--linie);
}
.leiste a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 48px; padding: 6px 8px; color: var(--gedaempft); text-decoration: none; font-size: .75rem;
}
.leiste a[aria-current="page"] { color: var(--akzent); font-weight: 600; }
.leiste .plus {
  width: 66px; height: 66px; margin: -28px 12px 0; border-radius: 50%;
  background: var(--akzent); color: var(--akzent-text);
  box-shadow: 0 6px 18px rgb(0 0 0 / .28);
}
.leiste .plus[aria-current="page"] { color: var(--akzent-text); outline: 3px solid color-mix(in srgb, var(--akzent) 35%, transparent); outline-offset: 2px; }

/* ---------- Bausteine ---------- */
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 16px; }
.karte + .karte { margin-top: 12px; }

.held { padding: 20px 18px; }
.held .zahl { font-size: 2.2rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kennzahlen { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--linie); }
.kennzahlen strong { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.banner { display: block; padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; background: var(--info-bg); color: var(--tinte); text-decoration: none; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.fehler { background: var(--fehler-bg); color: var(--fehler); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner strong { display: block; }
.banner .knopf { display: flex; width: fit-content; margin-top: 12px; }

.balken { display: block; color: inherit; text-decoration: none; padding: 12px 0; border-bottom: 1px solid var(--linie); }
.balken:last-child { border-bottom: 0; }
.balken-kopf { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.balken-spur { display: block; height: 8px; border-radius: 4px; background: var(--linie); margin: 8px 0 4px; overflow: hidden; }
.balken-fuell { display: block; height: 100%; border-radius: 4px; background: var(--akzent); }

.leer { text-align: center; padding: 36px 20px; }
.leer img { border-radius: 18px; margin-bottom: 14px; }

/* Buttons */
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border: 0; border-radius: 12px;
  background: var(--akzent); color: var(--akzent-text);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
}
.knopf.zweit { background: var(--flaeche); color: var(--tinte); border: 1px solid var(--linie); }
.knopf.gefahr { background: none; color: var(--fehler); border: 0; font-weight: 500; }
.knopf.voll { width: 100%; }
.knopf[disabled], .knopf[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.knopf:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--akzent) 55%, transparent); outline-offset: 2px;
}
.knopfreihe { display: grid; gap: 10px; margin-top: 16px; }
.knopfreihe.zwei { grid-template-columns: 1fr 1fr; }

/* Liste */
.suche { width: 100%; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 12px; margin: 0 -16px; padding-inline: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--linie);
  background: var(--flaeche); color: var(--tinte); font: inherit; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); font-weight: 600; }

.eintrag {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: start;
  padding: 14px 16px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius);
  color: inherit; text-decoration: none; margin-bottom: 10px;
}
.eintrag .name { font-weight: 650; overflow-wrap: anywhere; }
.eintrag .betrag { font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plaketten { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.plakette { font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--info-bg); }
.plakette.warn { background: var(--warn-bg); color: var(--warn); }
.plakette.ok { background: var(--ok-bg); color: var(--ok); }
.plakette.fehler { background: var(--fehler-bg); color: var(--fehler); }
.listenfuss { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 16px 0; }

/* Formular */
.feld { display: block; margin-bottom: 14px; }
.feld > span { display: block; font-size: .875rem; color: var(--gedaempft); margin-bottom: 4px; }
.feld small { display: block; color: var(--gedaempft); margin-top: 4px; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; font-size: 1rem; /* 16px: kein Zoom auf dem iPhone */
  color: var(--tinte); background: var(--flaeche); border: 1px solid var(--linie); border-radius: 10px;
}
textarea { min-height: 88px; resize: vertical; }
.gitter { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.schalter { display: flex; align-items: center; gap: 12px; min-height: 48px; margin-bottom: 14px; cursor: pointer; }
.schalter input { width: 26px; height: 26px; min-height: 0; accent-color: var(--akzent); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; font-size: 1.05rem; margin: 22px 0 10px; padding: 0; }
.fehlertext { color: var(--fehler); }

.belege { display: flex; gap: 10px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 4px; }
.belege a { flex: none; display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--linie); background: var(--flaeche); }
.belege img { display: block; height: 150px; width: auto; }
.belege .pdf { display: grid; place-items: center; height: 150px; width: 120px; font-weight: 700; color: var(--gedaempft); text-decoration: none; }

details { margin-top: 16px; }
summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.positionen { width: 100%; border-collapse: collapse; font-size: .9rem; }
.positionen td { padding: 8px 4px; border-top: 1px solid var(--linie); vertical-align: top; }
.positionen td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Neue Rechnung */
.seiten { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.seite { position: relative; width: 96px; height: 128px; border-radius: 10px; overflow: hidden; border: 1px solid var(--linie); background: var(--flaeche); display: grid; place-items: center; font-weight: 700; color: var(--gedaempft); }
.seite img { width: 100%; height: 100%; object-fit: cover; }
.seite button { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgb(0 0 0 / .65); color: #fff; font-size: 1rem; cursor: pointer; }
.datei-knopf { position: relative; }
.datei-knopf input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; min-height: 0; cursor: pointer; font-size: 0; }
.tipp { font-size: .9rem; color: var(--gedaempft); margin-top: 14px; }

.laeuft { text-align: center; padding: 32px 16px; }
.dreher { width: 44px; height: 44px; margin: 0 auto 16px; border-radius: 50%; border: 4px solid var(--linie); border-top-color: var(--akzent); animation: dreh 0.9s linear infinite; }
@keyframes dreh { to { transform: rotate(360deg); } }

/* Meldung */
#meldung {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px); z-index: 10;
  max-width: 520px; margin: 0 auto; padding: 12px 16px; border-radius: 12px; text-align: center;
  background: var(--tinte); color: var(--bg); font-weight: 600; box-shadow: 0 6px 20px rgb(0 0 0 / .3);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s;
}
#meldung.sichtbar { opacity: 1; transform: none; }
#meldung.fehler { background: var(--fehler); color: #fff; }
@media (prefers-color-scheme: dark) { #meldung.fehler { color: #1b0805; } }

/* Anmeldung */
.anmeldung { padding-bottom: 0; min-height: 100vh; display: grid; place-items: center; }
.anmelde-karte { width: min(100%, 380px); text-align: center; padding: 24px 20px; }
.anmelde-karte img { border-radius: 22px; margin-bottom: 12px; }
.anmelde-karte h1 { margin-bottom: 22px; }
.anmelde-karte form { text-align: left; }
.anmelde-karte .knopf { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  .dreher { animation-duration: 3s; }
  #meldung { transition: none; }
}
