/* Zahlungsseite C2PD – Handy zuerst (ab 360 px), helles und dunkles Farbschema, Systemschriften. */

:root {
  --hintergrund: #f5f6f8;
  --flaeche: #ffffff;
  --text: #1b1f24;
  --leise: #5b6470;
  --linie: #d9dde3;
  --akzent: #0b5cad;
  --akzent-text: #ffffff;
  --rot: #b3261e;
  --rot-flaeche: #fdecea;
  --gelb: #8a5a00;
  --gelb-flaeche: #fff4d6;
  --gruen: #1e6b34;
  --gruen-flaeche: #e5f4e9;
  --blau-flaeche: #e6effa;
  --schatten: 0 1px 2px rgba(0, 0, 0, 0.06);
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --hintergrund: #111418;
    --flaeche: #1b2026;
    --text: #e8eaed;
    --leise: #9aa3ad;
    --linie: #2f3740;
    --akzent: #6fa8ff;
    --akzent-text: #0b1420;
    --rot: #ff8a80;
    --rot-flaeche: #3a1d1b;
    --gelb: #ffd166;
    --gelb-flaeche: #3a3017;
    --gruen: #7fd89a;
    --gruen-flaeche: #17321f;
    --blau-flaeche: #1a2a40;
    --schatten: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--hintergrund);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

body.beschaeftigt main { opacity: 0.6; pointer-events: none; }

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.1rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }

a { color: var(--akzent); }

.leise { color: var(--leise); }
.fehler { color: var(--rot); }
.warnung { color: var(--gelb); background: var(--gelb-flaeche); padding: 8px 10px; border-radius: 8px; margin: 8px 0; }

/* ---------------------------------------------------------------- Kopf */
.kopf {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
}
.kopf-titel { display: flex; flex-direction: column; min-width: 0; }
.kopf h1 { white-space: nowrap; }
.kopf-knoepfe { display: flex; gap: 4px; flex-shrink: 0; }
.stand { font-size: 0.85rem; color: var(--leise); }
.stand-alt { color: var(--rot); font-weight: 600; }

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 12px 16px 96px;
  outline: none;
}

/* ---------------------------------------------------------------- Knöpfe */
.knopf {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--linie);
  border-radius: 8px;
  background: var(--flaeche);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.knopf:hover:not(:disabled) { border-color: var(--akzent); }
.knopf:disabled { opacity: 0.5; cursor: not-allowed; }
.knopf-haupt { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.knopf-rot { color: var(--rot); border-color: var(--rot); }
.knopf-warnung { background: var(--rot); border-color: var(--rot); color: #fff; }
.knopf-klein { min-height: 40px; padding: 6px 10px; font-size: 0.9rem; }

.linkknopf {
  min-height: 44px;
  padding: 8px;
  border: 0;
  background: none;
  color: var(--akzent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.knoepfe { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.knoepfe .knopf { flex: 1 1 auto; }

:focus-visible { outline: 3px solid var(--akzent); outline-offset: 2px; }

/* ---------------------------------------------------------------- Abschnitte und Listen */
.abschnitt { margin: 18px 0; }
.abschnitt > h2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--linie);
  margin-bottom: 8px;
}

.karte {
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 10px 0;
  box-shadow: var(--schatten);
}
.anmeldung { margin-top: 32px; text-align: center; }
.anmeldung .knopf { width: 100%; max-width: 360px; margin-top: 8px; }

.liste { list-style: none; margin: 0; padding: 0; }
.liste > li { margin: 6px 0; }
.liste > li.mit-wahl { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: stretch; }
.wahl { display: flex; flex-direction: column; gap: 4px; }
.wahl-knopf {
  min-width: 76px; min-height: 40px; flex: 1; padding: 4px 8px; border-radius: var(--radius);
  border: 1px solid var(--linie); background: var(--flaeche); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.wahl-knopf:disabled { opacity: 0.4; cursor: not-allowed; }
.wahl-frei[aria-pressed="true"] { background: var(--gruen-flaeche); color: var(--gruen); border-color: currentColor; }
.wahl-nein[aria-pressed="true"] { background: var(--rot-flaeche); color: var(--rot); border-color: currentColor; }
.auswahl-leiste {
  position: sticky; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 5;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
  margin-top: 10px; padding: 8px 10px; border-radius: var(--radius);
  background: var(--blau-flaeche); color: var(--text); border: 1px solid var(--akzent); font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.auswahl-leiste .knoepfe { display: flex; gap: 8px; }
.liste-schlicht { margin: 6px 0; padding-left: 18px; }
.liste-schlicht li { margin: 4px 0; }

.zeile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--flaeche);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--schatten);
}
.zeile:hover { border-color: var(--akzent); }
.zeile-oben { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.zeile-text { font-weight: 600; overflow-wrap: anywhere; }
.zeile-unten { display: flex; justify-content: space-between; gap: 8px; color: var(--leise); font-size: 0.9rem; }
.zeile-hinweis { color: var(--gelb); font-size: 0.9rem; font-weight: 600; }
.zeile-hinweis.fehler { color: var(--rot); }
.betrag { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; color: var(--text); }

.abzeichen {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--blau-flaeche);
  color: var(--akzent);
  white-space: nowrap;
}
.abzeichen-neu { background: var(--akzent); color: var(--akzent-text); }
.abzeichen-vorschlag { background: var(--gruen-flaeche); color: var(--gruen); }
.abzeichen-rot { background: var(--rot-flaeche); color: var(--rot); }
.abzeichen-gelb { background: var(--gelb-flaeche); color: var(--gelb); }
.abzeichen-gruen { background: var(--gruen-flaeche); color: var(--gruen); }

.klappe { margin: 10px 0; }
.klappe > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 8px 4px;
  font-weight: 600;
  cursor: pointer;
}
.klappe > summary::marker { content: ""; }
.klappe > summary::before { content: "▸"; display: inline-block; width: 1.2em; transition: transform 0.15s; }
.klappe[open] > summary::before { transform: rotate(90deg); }

/* ---------------------------------------------------------------- Zu überweisen */
.gruppe { margin: 12px 0 18px; }
.gruppe > h3 { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; color: var(--leise); }
.ueberweisung, .ueberwiesen {
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 4px 8px 2px;
}
.ueberweisung .zeile, .ueberwiesen .zeile { border: 0; box-shadow: none; padding: 8px 4px; min-height: 44px; }
.kopier-zeile {
  display: grid;
  grid-template-columns: 4.2em 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-top: 1px solid var(--linie);
}
.kopier-beschriftung { color: var(--leise); font-size: 0.85rem; }
.kopier-wert { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }

/* ---------------------------------------------------------------- Rechnungsansicht */
.leiste {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 4px 0 10px;
}
.leiste-blaettern { display: flex; gap: 6px; }

.rechnung-kopf h2 { display: flex; justify-content: space-between; gap: 8px; font-size: 1.15rem; }
.rechnung-kopf .zeile-oben { margin: 6px 0; }
.sprung { display: inline-block; padding: 6px 0; min-height: 32px; }

.pdf { margin: 8px -16px; background: var(--linie); padding: 6px 0; }
.pdf-seiten { display: flex; flex-direction: column; gap: 6px; }
.pdf-seite { display: block; width: 100%; height: auto; background: #fff; }
.pdf-status { margin: 4px 16px; }
.pdf-status:empty { display: none; }
.pdf-link { margin: 6px 16px 0; }
.pdf-link:empty { display: none; }

.angaben { margin-top: 12px; }
.angaben > h2, .vorschlaege > h2, .anmerkungen > h2 { margin: 18px 0 6px; }

.gelesen {
  display: grid;
  grid-template-columns: minmax(7.5em, max-content) 1fr;
  gap: 4px 12px;
  margin: 0;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.gelesen dt { color: var(--leise); }
.gelesen dd { margin: 0; overflow-wrap: anywhere; }
.iban { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

.vorschlag p { margin: 4px 0; }
.vorschlag-rot { border-left: 4px solid var(--rot); }
.vorschlag-gelb { border-left: 4px solid var(--gelb); }

.haken { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 8px 0; cursor: pointer; }
.haken input { width: 22px; height: 22px; margin: 0; flex-shrink: 0; }

.status { margin: 6px 0; padding: 6px 10px; border-radius: 8px; background: var(--blau-flaeche); }
.status-ok { background: var(--gruen-flaeche); color: var(--gruen); }
.status-rot { background: var(--rot-flaeche); color: var(--rot); }

textarea, input[type="text"], select {
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--linie);
  border-radius: 8px;
  background: var(--flaeche);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; }

.formular { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.formular label { font-size: 0.9rem; color: var(--leise); }

.entscheidung { margin: 18px 0 8px; padding-top: 8px; border-top: 2px solid var(--linie); }

/* ---------------------------------------------------------------- Meldungen */
.meldung {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: 836px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 14px;
  border-radius: var(--radius);
  background: var(--gruen-flaeche);
  color: var(--gruen);
  border: 1px solid currentColor;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.meldung[hidden] { display: none; }
.meldung-fehler { background: var(--rot-flaeche); color: var(--rot); }
.meldung-hinweis { background: var(--gelb-flaeche); color: var(--gelb); }
.meldung-frage { background: var(--flaeche); color: var(--text); flex-wrap: wrap; }
.meldung-frage .knoepfe { display: flex; gap: 8px; }
.meldung .linkknopf { color: inherit; font-size: 1.3rem; text-decoration: none; }

@media (min-width: 700px) {
  .pdf { margin: 8px 0; border-radius: var(--radius); }
  .knoepfe .knopf { flex: 0 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
