:root {
  --bg: #f3f1ea;
  --ink: #1b2a2f;
  --muted: #6b7570;
  --accent: #1b2a2f;
  --accent-ink: #ffffff;
  --card: #ffffff;
  --error: #8a2e2e;
  --positiv: #2f6f4f;
  --hinweis: #93690a;
  --border: #d9d5c9;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131c1b;
    --ink: #eef1ea;
    --muted: #93a29b;
    --accent: #d7dcc9;
    --accent-ink: #14201f;
    --card: #1c2825;
    --error: #ff9b9b;
    --positiv: #8fd6a6;
    --hinweis: #e8c468;
    --border: #2e3c39;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #131c1b;
  --ink: #eef1ea;
  --muted: #93a29b;
  --accent: #d7dcc9;
  --accent-ink: #14201f;
  --card: #1c2825;
  --error: #ff9b9b;
  --positiv: #8fd6a6;
  --hinweis: #e8c468;
  --border: #2e3c39;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.tabular-nums { font-variant-numeric: tabular-nums; }

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--card);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.eyebrow {
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1 { margin: 0 0 16px; font-size: 1.4rem; }

.auth-form { display: flex; flex-direction: column; gap: 10px; }

label { font-size: 0.85rem; color: var(--muted); }

input[type="password"] {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 1rem;
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  cursor: pointer;
  min-height: 44px;
}

.wide { width: 100%; }

.error { color: var(--error); font-size: 0.9rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 1.1rem; margin: 0; }

.link {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}

.content { padding: 24px 20px; max-width: 640px; margin: 0 auto; }

.muted { color: var(--muted); }

@media (max-width: 480px) {
  .auth-card { padding: 24px 20px; }
}

.nav { display: flex; gap: 14px; flex: 1; margin: 0 16px; flex-wrap: wrap; }
.nav a { color: var(--ink); text-decoration: none; font-size: 0.9rem; }
.nav a:hover { text-decoration: underline; }

h2 { font-size: 1.05rem; margin: 20px 0 10px; }

.tabelle { width: 100%; border-collapse: collapse; margin-bottom: 20px; font-size: 0.9rem; }
.tabelle th, .tabelle td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.tabelle th { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.tabelle .betrag { text-align: right; white-space: nowrap; }
.tabelle .zweck { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.formular, .filter { display: flex; flex-direction: column; gap: 10px; max-width: 420px; margin-bottom: 20px; }
.filter { flex-direction: row; flex-wrap: wrap; align-items: center; max-width: none; }
.formular label { font-size: 0.85rem; color: var(--muted); }
.formular input, .formular select, .filter input, .filter select {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); font-size: 0.95rem;
}
.inline-formular { display: inline; }

.karte { background: var(--card); border-radius: 12px; padding: 16px; margin-bottom: 20px; }
.zaehler { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

/* Auftrag P2: Schnellerfassung - Kategorie-Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; border: none; padding: 0; margin: 0 0 18px; }
.chips legend { font-size: 0.85rem; color: var(--muted); padding: 0; margin-bottom: 6px; }
.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 0 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--ink); font-size: 0.9rem; cursor: pointer; user-select: none;
}
.chip input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-button {
  min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--ink); font-size: 0.85rem; cursor: pointer;
}

/* Schnellerfassung: grosses Betragsfeld, Konto/Notiz/Datum defaultmaessig eingeklappt */
.betrag-label { font-size: 0.9rem; color: var(--muted); }
.betrag-eingabe {
  display: block; width: 100%; font-size: 2.4rem; padding: 14px 12px; margin: 6px 0 16px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--ink);
}
.einnahme-umschalter { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; min-height: 44px; font-size: 0.9rem; }
.details-erweitert { margin-bottom: 18px; }
.details-erweitert summary { cursor: pointer; color: var(--muted); padding: 10px 0; min-height: 44px; }
.details-erweitert label { display: block; margin-top: 10px; font-size: 0.85rem; color: var(--muted); }
.details-erweitert input, .details-erweitert select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  font-size: 0.95rem; background: var(--card); color: var(--ink);
}
.buchen-knopf { font-size: 1.1rem; padding: 16px; min-height: 52px; }

/* Bestaetigungsseite nach dem Buchen */
.bestaetigung { text-align: center; }
.betrag-gross { font-size: 2.6rem; margin: 8px 0; }
.betrag-gross.positiv { color: var(--positiv); }
.button-link {
  display: block; text-align: center; text-decoration: none; margin-top: 16px; padding: 14px;
  border-radius: 10px; min-height: 44px;
}

/* Monatsuebersicht: Summen, Band, Budgetbalken */
.band { font-size: 0.85rem; color: var(--muted); margin: 6px 0; }
.band a { color: inherit; }
.hinweis-text { font-size: 0.85rem; color: var(--hinweis); margin: 10px 0; }
.summen { display: flex; gap: 28px; }
.summen > div { display: flex; flex-direction: column; gap: 2px; }
.summen .betrag { font-size: 1.25rem; }
.positiv { color: var(--positiv); }

.budget-balken { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.budget-kopf { display: flex; justify-content: space-between; gap: 8px; font-size: 0.9rem; margin-bottom: 4px; }
.balken-spur { background: var(--border); border-radius: 999px; height: 10px; overflow: hidden; }
.balken-fuellung { height: 100%; border-radius: 999px; background: var(--accent); }
.balken-fuellung.status-hinweis { background: var(--hinweis); }
.balken-fuellung.status-ueberschritten { background: var(--error); }
.balken-fuellung.status-ohne_budget { background: var(--border); }
.marker { color: var(--hinweis); }

/* R22: die Fuellbreite kam bisher aus einem Inline-style="width:X%", das die
   eigene CSP (style-src 'self', kein 'unsafe-inline') blockiert - jede
   Fuellung war dadurch immer 100% breit. Ersatz: feste Klassen in 5-%-Stufen,
   von der Route auf die naechste Stufe gerundet (siehe _balken_stufe). */
.breite-0 { width: 0%; }
.breite-5 { width: 5%; }
.breite-10 { width: 10%; }
.breite-15 { width: 15%; }
.breite-20 { width: 20%; }
.breite-25 { width: 25%; }
.breite-30 { width: 30%; }
.breite-35 { width: 35%; }
.breite-40 { width: 40%; }
.breite-45 { width: 45%; }
.breite-50 { width: 50%; }
.breite-55 { width: 55%; }
.breite-60 { width: 60%; }
.breite-65 { width: 65%; }
.breite-70 { width: 70%; }
.breite-75 { width: 75%; }
.breite-80 { width: 80%; }
.breite-85 { width: 85%; }
.breite-90 { width: 90%; }
.breite-95 { width: 95%; }
.breite-100 { width: 100%; }

/* R22 nebenbei: offline.html nutzte ebenfalls ein Inline-style, von derselben
   CSP blockiert (sie wird auch fuer den Static-Mount gesetzt). */
.offline-inhalt { text-align: center; padding-top: 72px; }

/* Pruefliste, Mehr-Seite */
.pruefliste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.mehr-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mehr-liste a {
  display: block; padding: 14px 4px; min-height: 44px; line-height: 44px;
  color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--border);
}

/* Budget-Bildschirm */
.budget-eingabe-formular { display: flex; gap: 6px; align-items: center; }
.budget-eingabe { width: 90px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); }

/* Navigation unten (Auftrag P2 Bauen Punkt 6): Monat, Erfassen, Umsaetze, Pruefen, Mehr */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  z-index: 10;
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 48px; color: var(--muted); text-decoration: none; font-size: 0.7rem;
}
.bottom-nav a span:first-child { font-size: 1.15rem; }
.content { padding-bottom: 88px; }

@media (min-width: 720px) {
  .bottom-nav { display: none; }
  .content { padding-bottom: 24px; }
}
@media (max-width: 719px) {
  .topbar .nav { display: none; }
}

/* Auftrag P4: Rechnungen-Reiter, ueberfaellige Zeile rot (Architektur
   Abschnitt 8: "Rot nur fuer ueberfaellig") */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs a {
  padding: 10px 14px; color: var(--muted); text-decoration: none; font-size: 0.9rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a.aktiv { color: var(--ink); border-bottom-color: var(--accent); }
tr.ueberfaellig td { color: var(--error); }

/* Pruefen: Extraktionszweifel-Korrekturformular */
.korrektur-formular { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.korrektur-formular label { font-size: 0.8rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.korrektur-formular input, .korrektur-formular select {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); font-size: 0.9rem;
}
.zweifel-liste { list-style: none; margin: 4px 0; padding: 0; font-size: 0.8rem; color: var(--hinweis); }
.chip-button.vorgeschlagen { border-color: var(--accent); font-weight: 600; }

/* Auftrag P3: Belege - Volltext lesbar umbrechen, nicht ueberlaufen */
.beleg-text {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Auftrag P5: Rechnung-Detail, Abgleich-Vorschlaege */
.felder { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 8px; }
.felder dt { color: var(--muted); font-size: 0.85rem; }
.felder dd { margin: 0; overflow-wrap: anywhere; }
.felder dd.ueberfaellig { color: var(--error); }
.kandidat { border-top: 1px solid var(--border); padding-top: 10px; }
.kandidat p, .pruefliste .karte p { margin: 2px 0; overflow-wrap: anywhere; }
