:root {
  --bg: #f4f5f3;
  --karte: #ffffff;
  --rand: #e1e4df;
  --text: #1c2321;
  --text-2: #5b6662;
  --akzent: #0f766e;
  --akzent-text: #0b5a54;
  --akzent-hell: #e2f1ef;
  --einnahme: #0f766e;
  --ausgabe: #c2410c;
  --gruen-bg: #dcf3e4; --gruen: #14663a;
  --blau-bg: #dde9fb; --blau: #1d4ea0;
  --gelb-bg: #fbefc6; --gelb: #7a5a00;
  --rot-bg: #fbdcd8; --rot: #a12a1f;
  --grau-bg: #e8ebe7; --grau: #4a5450;
  --schatten: 0 1px 2px rgb(20 30 25 / .06);
  --radius: 10px;
  --seitenleiste: 220px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131816; --karte: #1b221f; --rand: #2c3531; --text: #e6ebe8; --text-2: #9aa6a1;
    --akzent: #2dd4bf; --akzent-text: #5eead4; --akzent-hell: #17332f;
    --einnahme: #2dd4bf; --ausgabe: #fb923c;
    --gruen-bg: #173826; --gruen: #7ee2a8; --blau-bg: #1a2c4d; --blau: #9cc2ff;
    --gelb-bg: #3d3210; --gelb: #f2d67a; --rot-bg: #4a1f1b; --rot: #ffa9a0;
    --grau-bg: #2a3330; --grau: #b4beb9; --schatten: none;
  }
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--akzent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
h2.zwischen { margin-top: 1.25rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.klein { font-size: .8rem; color: var(--text-2); }
.gedaempft { color: var(--text-2); }
.umbruch { white-space: pre-line; overflow-wrap: anywhere; }
.zahl { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gross { font-size: 1.6rem; font-weight: 650; margin: .25rem 0 .5rem; font-variant-numeric: tabular-nums; }
.leer { color: var(--text-2); margin: .5rem 0; }
.fehler { background: var(--rot-bg); color: var(--rot); padding: .6rem .8rem; border-radius: 8px; }

/* Rahmen */
.rahmen { display: grid; grid-template-columns: var(--seitenleiste) 1fr; min-height: 100vh; }
.seitenleiste { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1rem; padding: 1rem .75rem; border-right: 1px solid var(--rand); background: var(--karte); }
.marke { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem; color: var(--text); font-weight: 650; }
.marke:hover { text-decoration: none; }
.marke-zeichen { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--akzent); color: #fff; font-weight: 700; }
.nav-liste { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: .65rem; padding: .5rem .6rem; border-radius: 8px; color: var(--text); }
.nav-item:hover { background: var(--bg); text-decoration: none; }
.nav-item.aktiv { background: var(--akzent-hell); color: var(--akzent-text); font-weight: 600; }
.nav-item.bald { color: var(--text-2); opacity: .55; cursor: default; }
.nav-item.bald:hover { background: none; }
.nav-extern { border-top: 1px solid var(--rand); padding-top: .75rem; }
.nav-titel { padding: 0 .6rem .25rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.nav-item.extern { font-size: .9rem; padding: .35rem .6rem; color: var(--text-2); }
.nav-item.extern .icon { width: 16px; height: 16px; }
.liste .icon { width: 14px; height: 14px; vertical-align: -2px; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.seitenleiste-fuss { margin-top: auto; display: flex; flex-direction: column; gap: .35rem; padding: 0 .5rem; }
.link-knopf { background: none; border: 0; padding: 0; color: var(--akzent-text); font: inherit; cursor: pointer; text-align: left; }
.link-knopf:hover { text-decoration: underline; }
.inhalt { padding: 1.5rem clamp(1rem, 3vw, 2.25rem) 3rem; max-width: 1280px; width: 100%; }

/* Kopf, Karten, Raster */
.kopf { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.untertitel { margin: .25rem 0 0; color: var(--text-2); }
.kopf-aktionen { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.karte { background: var(--karte); border: 1px solid var(--rand); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--schatten); margin-bottom: 1rem; min-width: 0; }
.karte-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .5rem; }
.karte-kopf h2 { margin: 0; }
.spalten { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; align-items: start; }
.spalten .breit { grid-column: 1 / -1; }
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kachel { background: var(--karte); border: 1px solid var(--rand); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--schatten); border-left: 4px solid var(--rand); }
.kachel.einnahme { border-left-color: var(--einnahme); }
.kachel.ausgabe { border-left-color: var(--ausgabe); }
.kachel.warnung { border-left-color: var(--rot); }
.kachel-label { font-size: .8rem; color: var(--text-2); }
.kachel-wert { font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; margin: .1rem 0; }
.kachel-hinweis { font-size: .8rem; color: var(--text-2); }

/* Tabellen */
.tabelle-huelle { overflow-x: auto; position: relative; }   /* relative: damit auch .sr-only (absolut) im Scrollbereich bleibt */
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .6rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rand); }
th { font-size: .78rem; font-weight: 600; color: var(--text-2); text-transform: none; }
thead th { position: sticky; top: 0; background: var(--karte); }
tbody tr:hover { background: color-mix(in srgb, var(--akzent-hell) 45%, transparent); }
th.zahl, td.zahl { text-align: right; }
tfoot th, tfoot td { border-top: 2px solid var(--rand); border-bottom: 0; font-weight: 650; }
.gruppenkopf th { background: var(--bg); color: var(--text); font-size: .85rem; padding-top: .7rem; }
.summenzeile th, .summenzeile td { font-weight: 650; }
tr.gewaehlt { background: var(--akzent-hell); }
td a, .karte a { overflow-wrap: anywhere; }
.symbol { display: inline-flex; color: var(--text-2); }
.symbol:hover { color: var(--akzent-text); }

/* Marken */
.marke-status { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.marke-status.gruen { background: var(--gruen-bg); color: var(--gruen); }
.marke-status.blau { background: var(--blau-bg); color: var(--blau); }
.marke-status.gelb { background: var(--gelb-bg); color: var(--gelb); }
.marke-status.rot { background: var(--rot-bg); color: var(--rot); }
.marke-status.grau { background: var(--grau-bg); color: var(--grau); }

/* Formulare */
input, select, button, .knopf { font: inherit; }
input, select, textarea { padding: .4rem .55rem; border: 1px solid var(--rand); border-radius: 8px; background: var(--karte); color: var(--text); min-height: 2.25rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
button, .knopf { display: inline-flex; align-items: center; padding: .4rem .85rem; border: 1px solid var(--rand); border-radius: 8px; background: var(--karte); color: var(--text); cursor: pointer; min-height: 2.25rem; }
button:hover, .knopf:hover { border-color: var(--akzent); text-decoration: none; }
button.primaer { background: var(--akzent); border-color: var(--akzent); color: #fff; font-weight: 600; justify-content: center; }
@media (prefers-color-scheme: dark) { button.primaer { color: #0b1512; } }
.filterleiste { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.filterleiste label { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; color: var(--text-2); }
.filterleiste input[type=search] { min-width: 14rem; }
.seitenwahl { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; color: var(--text-2); }
.seite-waehlen { display: inline-flex; align-items: center; gap: .35rem; margin: 0; }
.seite-waehlen label { display: inline-flex; align-items: center; gap: .35rem; }
.seite-waehlen input[type=number] { width: 4.5rem; text-align: center; padding: .25rem .4rem; border: 1px solid transparent; border-radius: 6px; background: transparent; color: inherit; font: inherit; -moz-appearance: textfield; appearance: textfield; }
.seite-waehlen input[type=number]::-webkit-inner-spin-button, .seite-waehlen input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.seite-waehlen input[type=number]:hover { border-color: var(--rand); }
.seite-waehlen input[type=number]:focus { border-color: var(--akzent); background: var(--karte); outline: none; }

/* Formulare in Karten */
.formular { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; align-items: end; }
.formular label { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; color: var(--text-2); min-width: 0; }
.formular .breit2 { grid-column: span 2; }
.formular .voll { grid-column: 1 / -1; }
.formular label.haken, label.haken { flex-direction: row; align-items: center; gap: .5rem; font-size: .9rem; color: var(--text); }
input[type=checkbox] { min-height: 0; width: 1.05rem; height: 1.05rem; accent-color: var(--akzent); }
.aktionen { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .25rem; }
form > .aktionen { margin: 1rem 0 0; }
a.primaer-link { background: var(--akzent); border-color: var(--akzent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { a.primaer-link { color: #0b1512; } }
button.gefahr { border-color: var(--rot); color: var(--rot); }
button.gefahr:hover { background: var(--rot-bg); }
button[disabled] { opacity: .55; cursor: not-allowed; }
.erfolg { background: var(--gruen-bg); color: var(--gruen); padding: .6rem .8rem; border-radius: 8px; margin: 0 0 .75rem; }
.hinweis { background: var(--gelb-bg); color: var(--gelb); padding: .6rem .8rem; border-radius: 8px; margin: 0 0 .75rem; }
.fehler { margin: 0 0 .75rem; }
table.eingabe td { padding: .3rem .4rem; }
table.eingabe input { width: 100%; }
table.eingabe input.schmal { min-width: 5.5rem; }
details.nachtrag > summary { cursor: pointer; list-style: none; }
details.nachtrag > summary::-webkit-details-marker { display: none; }
details.nachtrag > summary h2 { margin: 0; display: inline; }
details.nachtrag > summary::after { content: ' +'; color: var(--text-2); font-weight: 600; }
details.nachtrag[open] > summary { margin-bottom: .75rem; }
details.nachtrag[open] > summary::after { content: ' –'; }
.wochenwahl { display: flex; gap: .4rem; flex-wrap: wrap; }
.timer-zeile { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.timer-anzeige { font-size: 2rem; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--akzent-text); }
.timer.laeuft { border-color: var(--akzent); }
.aktion form { margin: 0; }

.reiter-leiste { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.reiter { padding: .35rem .8rem; border: 1px solid var(--rand); border-radius: 999px; color: var(--text); background: var(--karte); }
.reiter:hover { text-decoration: none; border-color: var(--akzent); }
.reiter.aktiv { background: var(--akzent-hell); color: var(--akzent-text); border-color: var(--akzent); font-weight: 600; }
.sammelleiste { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: .5rem 0; margin-top: 0; }

/* Daten, Listen */
.daten { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.daten dt { color: var(--text-2); }
.daten dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.liste { list-style: none; padding: 0; margin: 0; }
.liste li { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: 1px solid var(--rand); }
.liste li:last-child { border-bottom: 0; }
.aufgaben { margin: 0; padding-left: 1.1rem; display: grid; gap: .35rem; }
.roh { margin-top: 1rem; }
.roh pre { overflow: auto; max-height: 18rem; background: var(--bg); padding: .75rem; border-radius: 8px; font-size: .78rem; }
.pdf { width: 100%; height: min(78vh, 900px); border: 1px solid var(--rand); border-radius: 8px; background: var(--bg); }

/* Grenzbalken */
.grenze { margin-bottom: .9rem; }
.grenze-kopf { display: flex; justify-content: space-between; gap: .75rem; font-size: .9rem; margin-bottom: .25rem; }
.grenze-balken { width: 100%; height: .7rem; appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: var(--grau-bg); }
.grenze-balken::-webkit-meter-bar { background: var(--grau-bg); border: 0; border-radius: 999px; height: .7rem; }
.grenze-balken::-webkit-meter-optimum-value, .grenze-balken::-webkit-meter-suboptimum-value, .grenze-balken::-webkit-meter-even-less-good-value { border-radius: 999px; }
.grenze-balken.gruen::-webkit-meter-optimum-value, .grenze-balken.gruen::-webkit-meter-suboptimum-value, .grenze-balken.gruen::-webkit-meter-even-less-good-value { background: var(--einnahme); }
.grenze-balken.gelb::-webkit-meter-optimum-value, .grenze-balken.gelb::-webkit-meter-suboptimum-value, .grenze-balken.gelb::-webkit-meter-even-less-good-value { background: #d9a400; }
.grenze-balken.rot::-webkit-meter-optimum-value, .grenze-balken.rot::-webkit-meter-suboptimum-value, .grenze-balken.rot::-webkit-meter-even-less-good-value { background: var(--rot); }
.grenze-balken.gruen::-moz-meter-bar { background: var(--einnahme); }
.grenze-balken.gelb::-moz-meter-bar { background: #d9a400; }
.grenze-balken.rot::-moz-meter-bar { background: var(--rot); }

/* Diagramm */
.diagramm { margin: 0; }
.diagramm svg { width: 100%; height: auto; display: block; }
.diagramm .gitter { stroke: var(--rand); stroke-width: 1; }
.diagramm .achse { fill: var(--text-2); font-size: 11px; }
.balken.einnahme, .punkt.einnahme { fill: var(--einnahme); background: var(--einnahme); }
.balken.ausgabe, .punkt.ausgabe { fill: var(--ausgabe); background: var(--ausgabe); }
.diagramm figcaption { display: flex; gap: 1rem; font-size: .8rem; color: var(--text-2); margin-top: .25rem; }
.legende { display: inline-flex; align-items: center; gap: .35rem; }
.punkt { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; }

/* Anmeldung */
body.anmeldung { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-karte { width: min(380px, 100%); background: var(--karte); border: 1px solid var(--rand); border-radius: 14px; padding: 1.75rem; box-shadow: var(--schatten); display: grid; gap: 1rem; }
.login-karte form { display: grid; gap: .9rem; }
.login-karte label { display: grid; gap: .25rem; font-size: .85rem; color: var(--text-2); }

/* Bank */
.einnahme-text { color: var(--einnahme); }
.ausgabe-text { color: var(--ausgabe); }
td.zahl { white-space: nowrap; }
.aktionszelle { white-space: nowrap; text-align: right; }
.aktionszelle form.inline, .liste form.inline { display: inline; }
.aktionszelle > * { margin-left: .25rem; }
button.klein-knopf, .knopf.klein-knopf { min-height: 0; padding: .2rem .6rem; font-size: .85rem; }
.liste li > span { min-width: 0; overflow-wrap: anywhere; }
.liste li form.inline { flex: none; }
.stapel { min-width: 0; }
.sammelleiste { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* Schmale Bildschirme: Navigation unten */
@media (max-width: 860px) {
  .rahmen { grid-template-columns: minmax(0, 1fr); }
  .inhalt { min-width: 0; }
  /* Tabellen behalten ihre Spaltenbreite und scrollen in der Karte, statt die ganze Seite zu verbreitern */
  .tabelle-huelle > table { min-width: 34rem; }
  .tabelle-huelle > table.eingabe { min-width: 30rem; }
  td a { overflow-wrap: break-word; }
  .seitenleiste { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; gap: 0; padding: .25rem .25rem calc(.25rem + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--rand); z-index: 10; }
  .marke, .seitenleiste-fuss, .nav-item.bald, .nav-extern { display: none; }
  /* Zehn Einträge passen nicht nebeneinander: die Leiste scrollt seitlich, jeder Eintrag bleibt groß genug zum Tippen */
  .nav-liste { flex-direction: row; width: 100%; justify-content: flex-start; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.75rem), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 1.75rem), transparent); }
  .nav-liste::-webkit-scrollbar { display: none; }
  .nav-item { flex: 0 0 auto; flex-direction: column; align-items: center; gap: .1rem; padding: .4rem .5rem; font-size: .7rem; min-width: 4.6rem; min-height: 2.9rem; }
  .inhalt { padding: 1rem 1rem 5.5rem; }
  .spalten { grid-template-columns: 1fr; }
  .nav-item span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
}
@media print {
  .seitenleiste { display: none; }
  .rahmen { display: block; }
}

/* Belege prüfen: PDF links, Formular rechts */
.pruef { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr); gap: 1rem; align-items: start; }
.pruef-pdf { position: sticky; top: 1rem; padding: .5rem; }
.pruef-pdf .pdf { height: calc(100vh - 9rem); min-height: 420px; }
.pruef-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hinweisliste { list-style: none; padding: 0; margin: 0 0 .75rem; display: flex; flex-direction: column; gap: .4rem; }
.hinweisliste .hinweis { margin: 0; }
details.hochladen { padding: .75rem 1rem; margin-bottom: 1rem; }
details.hochladen summary { cursor: pointer; font-weight: 600; }
details.hochladen .formular { margin-top: .75rem; }
details.hochladen input[type="file"] { padding: 1.25rem .75rem; border: 2px dashed var(--rand); border-radius: 8px; background: var(--bg); }
.aktionen-zelle { white-space: nowrap; }
@media (max-width: 900px) {
  .pruef { grid-template-columns: 1fr; }
  .pruef-pdf { position: static; }
  .pruef-pdf .pdf { height: 60vh; }
}

/* Bank: Vorschau einer Zuordnung */
details.vorschlag { margin-top: .4rem; }
details.vorschlag > summary { cursor: pointer; color: var(--akzent-text); font-size: .9em; }
.vorschau-inhalt { margin-top: .6rem; display: grid; gap: 1rem; }
.vorschau-block { border: 1px solid var(--rand); border-radius: 8px; padding: .75rem; background: var(--bg); }
.vorschau-block h3 { margin: 0 0 .5rem; font-size: 1rem; }
.vorschau-pdf { margin-top: .75rem; height: min(60vh, 560px); }
textarea { font: inherit; resize: vertical; }
.formular textarea { min-height: 5.5rem; }
.formular .hilfe { font-size: .75rem; color: var(--text-2); }
.bewirtung { display: grid; gap: .75rem; }
.bewirtung[hidden] { display: none; }
ul.teilnehmer { margin: 0; padding-left: 1.1rem; }
.fehler-text { color: var(--rot); font-size: .8rem; }

/* Eingabetabellen (Positionen): die Beschreibung bekommt auch auf schmalen Bildschirmen genug Platz, der Rest scrollt */
table.eingabe td:first-child input { min-width: 13rem; }

/* Bank: Auswahlfelder in der Zuordnungstabelle */
table.eingabe select { width: 100%; max-width: 16rem; }
.bank-zweck { max-width: 28rem; overflow-wrap: anywhere; }

/* Anmeldung und Konto */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-karte { width: min(24rem, 100%); margin: 0; }
.login-karte h1 { margin: .5rem 0 1rem; font-size: 1.3rem; }
.login-karte .formular, .karte form.formular[action="/konto"] { grid-template-columns: 1fr; }
.login-karte label, form.formular[action="/konto"] label { display: grid; gap: .25rem; }
.login-karte input, form.formular[action="/konto"] input { width: 100%; }
.konto { display: flex; gap: .75rem; align-items: baseline; }
form.inline { display: inline; margin: 0; }
button.textknopf { border: 0; background: none; padding: 0; min-height: 0; color: var(--akzent); text-decoration: underline; }
