:root {
  --hg: #f3f4f8; --karte: #fff; --text: #111827; --leise: #6b7280; --rand: #e6e8ef;
  --akzent: #4f46e5; --akzent-2: #7c3aed; --akzent-text: #fff; --gut: #1a7f45; --warn: #a15c00; --schlecht: #c0262d;
  --warn-hg: #fff6e5; --gut-hg: #e8f6ee; --schlecht-hg: #fdecec; --info-hg: #eef0ff;
  --schatten: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  color-scheme: light;
}
/* Dunkel: per System (wenn nicht ausdrücklich Hell gewählt) oder ausdrücklich gewählt */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --hg: #12141a; --karte: #1b1e26; --text: #e7e9ee; --leise: #9aa3b2; --rand: #2c303b;
    --akzent: #8b8cff; --akzent-2: #b18cff; --akzent-text: #0b1020; --gut: #4fc283; --warn: #f0a640; --schlecht: #ff6b6b;
    --warn-hg: #33270f; --gut-hg: #12301f; --schlecht-hg: #3a1717; --info-hg: #23254a;
    --schatten: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .2);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --hg: #12141a; --karte: #1b1e26; --text: #e7e9ee; --leise: #9aa3b2; --rand: #2c303b;
  --akzent: #8b8cff; --akzent-2: #b18cff; --akzent-text: #0b1020; --gut: #4fc283; --warn: #f0a640; --schlecht: #ff6b6b;
  --warn-hg: #33270f; --gut-hg: #12301f; --schlecht-hg: #3a1717; --info-hg: #23254a;
  --schatten: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .2);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--hg); color: var(--text); }
a { color: var(--akzent); }
h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 .5rem; }
h2 { font-size: 1rem; font-weight: 650; margin: 1.25rem 0 .5rem; }
main { max-width: 1100px; margin: 0 auto; padding: 2rem 16px 3rem; transition: opacity .15s; }
main.htmx-request { opacity: .6; }
main.schmal { max-width: 560px; }
main.breit { max-width: 1500px; }

.leiste { position: sticky; top: 0; z-index: 5; display: flex; gap: 1.5rem; align-items: center; padding: .6rem 24px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--karte) 85%, transparent); backdrop-filter: blur(10px); box-shadow: 0 1px 0 var(--rand); }
.leiste .marke { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; }
.leiste .marke::before { content: "€"; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: var(--akzent-text); background: linear-gradient(135deg, var(--akzent), var(--akzent-2)); }
.leiste nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.leiste nav a { text-decoration: none; color: var(--leise); font-weight: 500; padding: .4rem .8rem; border-radius: 8px; }
.leiste nav a:hover { background: var(--hg); color: var(--text); }
.konto { display: flex; gap: .5rem .75rem; align-items: center; flex-wrap: wrap; color: var(--leise); }
.konto form { margin: 0; }
.modus { display: inline-flex; border: 1px solid var(--rand); border-radius: 6px; overflow: hidden; }
.modus button { border: 0; border-radius: 0; padding: .2rem .5rem; background: transparent; color: var(--leise); font-size: .85rem; line-height: 1.4; }
.modus button + button { border-left: 1px solid var(--rand); }
.modus button[aria-pressed="true"] { background: var(--akzent); color: var(--akzent-text); }
.modus button:focus-visible { outline: 2px solid var(--akzent); outline-offset: -2px; }
.modus-allein { display: flex; justify-content: flex-end; padding: .6rem 16px 0; }

.karte { background: var(--karte); border-radius: 14px; box-shadow: var(--schatten); padding: 1.25rem 1.5rem; margin: 1rem 0; }
.karte h2:first-child { margin-top: 0; }
.leer { text-align: center; color: var(--leise); padding: 2rem; }
.leise { color: var(--leise); font-size: .9rem; }
.titelzeile { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--leise); margin-bottom: .75rem; }
input, select { font: inherit; color: var(--text); background: var(--karte); border: 1px solid var(--rand); border-radius: 8px; padding: .4rem .5rem; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--akzent); outline-offset: -1px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled input, fieldset:disabled select { background: transparent; border-color: transparent; }
fieldset:disabled .neue-zeile, fieldset:disabled .zeile-weg { display: none; }

button, .knopf { font: inherit; cursor: pointer; border: 1px solid var(--rand); background: var(--karte); color: var(--text); border-radius: 9px; padding: .5rem 1rem; font-weight: 550; box-shadow: 0 1px 2px rgba(16, 24, 40, .06); text-decoration: none; display: inline-block; }
button.primaer, .knopf.primaer { background: linear-gradient(135deg, var(--akzent), var(--akzent-2)); color: var(--akzent-text); border-color: transparent; }
button.link { background: none; border: 0; padding: 0; color: var(--akzent); font-weight: inherit; box-shadow: none; }
.gefahr { color: var(--schlecht) !important; }
.knoepfe { display: flex; gap: .75rem; margin: 1rem 0; flex-wrap: wrap; align-items: center; }
.knoepfe.klein { font-size: .9rem; gap: 1.25rem; }
.knoepfe form, form.inline { display: inline; margin: 0; }

.meldung { padding: .6rem .9rem; border-radius: 8px; margin: .5rem 0 1rem; background: var(--info-hg); }
.meldung.success { background: var(--gut-hg); }
.meldung.warning { background: var(--warn-hg); }
.meldung.error { background: var(--schlecht-hg); }
.meldung ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.feldfehler { color: var(--schlecht); font-size: .8rem; display: block; }

.reiter { display: inline-flex; flex-wrap: wrap; gap: .25rem; background: var(--rand); padding: 4px; border-radius: 11px; margin: 1rem 0; }
.reiter a { padding: .35rem .9rem; text-decoration: none; color: var(--leise); border-radius: 8px; }
.reiter a.aktiv { color: var(--text); background: var(--karte); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); font-weight: 600; }
.reiter .zaehler { font-size: .75rem; font-weight: 600; background: var(--warn-hg); color: var(--warn); border-radius: 99px; padding: 0 .45rem; margin-left: .15rem; }
.leiste nav a.aktiv { color: var(--akzent); background: var(--info-hg); }

/* Filter */
.filter { padding: .6rem 1rem; margin-top: 0; }
.filter summary { cursor: pointer; font-weight: 600; color: var(--leise); }
.filter[open] summary { margin-bottom: .75rem; }
.filterfelder { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0 .75rem; }
.filterfelder .weit { grid-column: span 2; }
.filterfelder label { margin-bottom: .5rem; }
.filterfuss { display: flex; justify-content: space-between; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; border-top: 1px solid var(--rand); padding-top: .5rem; }
.filterfuss .knoepfe { margin: 0; }
.schnellwahl { font-size: .85rem; color: var(--leise); display: flex; gap: .25rem .75rem; flex-wrap: wrap; align-items: center; }
.schnellwahl a { text-decoration: none; }
.schnellwahl a.aktiv { font-weight: 600; text-decoration: underline; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: -.25rem 0 1rem; }
.chip { font-size: .85rem; font-weight: 550; text-decoration: none; background: var(--info-hg); color: var(--akzent); border-radius: 99px; padding: .15rem .65rem; }
.chip span { color: var(--leise); margin-left: .2rem; }
.chip:hover span { color: var(--schlecht); }

.kopfzahlen { margin: -.25rem 0 0; }
.kopfzahlen strong { color: var(--text); }
.titelzeile .knoepfe { margin: .5rem 0; }
.tabellenrahmen { overflow-x: auto; border-radius: 14px; box-shadow: var(--schatten); }
.tabellenrahmen .tabelle tr:last-child td { border-bottom: 0; }
.sortieren { color: inherit; text-decoration: none; white-space: nowrap; }
.sortieren:hover { color: var(--akzent); }
.unterzeile { font-size: .8rem; color: var(--leise); }
.marke-wallet { font-size: .8rem; font-weight: 550; background: var(--info-hg); color: var(--akzent); border-radius: 6px; padding: .1rem .5rem; white-space: nowrap; }
.seiten { display: flex; gap: 1rem; justify-content: center; align-items: center; margin: 1rem 0; }

/* Übersicht */
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin: 1rem 0; }
.kachel { --farbe: var(--akzent); display: flex; flex-direction: column; gap: .15rem; background: var(--karte); border-left: 4px solid var(--farbe); border-radius: 14px; box-shadow: var(--schatten); padding: 1.1rem 1.25rem; color: var(--text); text-decoration: none; }
.kachel:nth-child(2) { --farbe: var(--akzent-2); }
.kachel:nth-child(3) { --farbe: var(--gut); }
a.kachel:hover { outline: 1px solid var(--farbe); }
.kachel.hinweis { --farbe: var(--warn); background: linear-gradient(135deg, var(--warn-hg), var(--karte)); }
.kachel-titel { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--leise); }
.kachel-wert { font-size: 1.85rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; margin: .2rem 0; }
.spalten { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 1rem; }

.monate { display: flex; gap: 6px; align-items: stretch; height: 240px; padding-top: 1.25rem; }
.monat { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; text-decoration: none; color: var(--text); position: relative; border-radius: 6px; }
.monat:hover, .monat:focus-visible { background: var(--hg); }
.monat-wert { font-size: .7rem; color: var(--leise); text-align: center; height: 1.1rem; white-space: nowrap; overflow: hidden; }
/* Hilfslinien alle 48px */
.monat-saeule { flex: 1; display: flex; align-items: flex-end; justify-content: center; background: repeating-linear-gradient(to top, transparent 0 47px, var(--rand) 47px 48px); }
.monat-saeule span { width: min(60%, 34px); background: linear-gradient(180deg, var(--akzent-2), var(--akzent)); border-radius: 8px 8px 3px 3px; min-height: 0; }
.monat:hover .monat-saeule span { filter: brightness(1.15); }
.monat-name { font-size: .75rem; text-align: center; padding-top: .25rem; line-height: 1.2; height: 2.2rem; }
.tipp { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--karte); font-size: .8rem; padding: .35rem .6rem; border-radius: 6px; white-space: nowrap; z-index: 2; pointer-events: none; }
.monat:hover .tipp, .monat:focus-visible .tipp { display: block; }

.balkenliste { list-style: none; padding: 0; margin: 0; }
.balkenliste li { display: grid; grid-template-columns: 1fr auto; gap: .1rem .75rem; padding: .45rem 0; }
.balken-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balken-wert { font-variant-numeric: tabular-nums; white-space: nowrap; }
.balken { grid-column: 1 / -1; height: 8px; background: var(--hg); border-radius: 99px; overflow: hidden; }
.balken span { display: block; height: 100%; background: linear-gradient(90deg, var(--akzent), var(--akzent-2)); border-radius: 99px; }
.tabelle.schlicht { background: transparent; }
.zweizeilig li { display: flex; justify-content: space-between; border-bottom: 1px solid var(--rand); }
.neueste { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.neueste a { display: flex; gap: .6rem; align-items: center; padding: .6rem; border-radius: 12px; color: var(--text); text-decoration: none; background: var(--hg); }
.neueste a:hover { background: var(--info-hg); }
.neu-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.neu-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.neueste img { width: 48px; height: 60px; object-fit: cover; border-radius: 6px; flex: none; background: var(--karte); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.tabelle { width: 100%; border-collapse: collapse; background: var(--karte); }
.tabelle th { text-align: left; font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--leise); padding: .75rem .6rem; border-bottom: 1px solid var(--rand); }
.tabelle td { padding: .7rem .6rem; border-bottom: 1px solid var(--rand); vertical-align: middle; }
.tabelle tbody tr[onclick] { cursor: pointer; }
.tabelle td a, .balken-name a { text-decoration: none; font-weight: 550; color: var(--text); }
.tabelle td a:hover, .balken-name a:hover { color: var(--akzent); }
.tabelle tbody tr[onclick]:hover { background: var(--hg); }
.tabelle tr.abgelaufen { opacity: .5; }
.zahl, .tabelle th.zahl { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.zahl.gut { color: var(--gut); } .zahl.schlecht { color: var(--schlecht); font-weight: 600; }
.mini { width: 48px; }
.mini img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; display: block; }

.tabelle.eingabe td { padding: .2rem; }
.tabelle.eingabe input { padding: .3rem .4rem; }
#positionen td:first-child { width: 40%; }
.loeschen { width: 2rem; text-align: center; }
.loeschen input[type=checkbox] { display: none; }

.status { font-size: .75rem; font-weight: 600; padding: .15rem .6rem; border-radius: 99px; background: var(--hg); white-space: nowrap; }
.status::before { content: ""; display: inline-block; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; margin-right: .3rem; vertical-align: 1px; }
.status.pruefen { background: var(--warn-hg); color: var(--warn); }
.status.fertig { background: var(--gut-hg); color: var(--gut); }
.status.fehler { background: var(--schlecht-hg); color: var(--schlecht); }
.haken { color: var(--gut); }

.zweispaltig { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 1.5rem; align-items: start; }
.bildspalte { position: sticky; top: 4.5rem; background: var(--karte); border-radius: 14px; box-shadow: var(--schatten); padding: .5rem; max-height: calc(100vh - 5.5rem); overflow: auto; }
.belegbild { position: relative; cursor: zoom-in; }
.belegbild img { width: 100%; display: block; }
.belegbild.gross { width: 200%; cursor: zoom-out; }
.belegbild + .belegbild { margin-top: .5rem; }
.markierung { position: absolute; box-sizing: content-box; margin: -4px; padding: 4px; border: 2px solid var(--akzent); border-radius: 4px; background: color-mix(in srgb, var(--akzent) 18%, transparent); pointer-events: none; }
.bildspalte p.klein { margin: .5rem 0 0; font-size: .85rem; }
.raster { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 .75rem; }
.raster .weit { grid-column: span 2; }
.reihe { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; }
.reihe label { flex: 1; min-width: 160px; }
.reihe button { margin-bottom: .75rem; }
.liste-schlicht { list-style: none; padding: 0; margin: 0 0 .75rem; }
.liste-schlicht li { padding: .25rem 0; }

.ablage { border: 2px dashed var(--rand); border-radius: 10px; padding: 2rem 1rem; text-align: center; align-items: center; color: var(--text); cursor: pointer; }
.ablage input { max-width: 320px; }

@media (max-width: 900px) {
  .leiste { position: static; gap: .5rem 1rem; }
  .leiste nav { order: 3; flex-basis: 100%; }
  .leiste nav a { padding: .3rem .6rem; }
  .zweispaltig { grid-template-columns: minmax(0, 1fr); }
  .bildspalte { position: static; max-height: 60vh; }
  .raster { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabelle.eingabe { display: block; overflow-x: auto; }
  .breit-nur, .tabelle .mini { display: none; }
  .filterfelder .weit { grid-column: 1 / -1; }
  .monat-wert { display: none; }
}

/* Fortschrittsbalken beim Lesen */
.fortschritt { display: flex; flex-direction: column; gap: .35rem; }
.fortschritt .balken { height: 10px; border-radius: 99px; background: var(--hg); border: 1px solid var(--rand); overflow: hidden; }
.fortschritt .balken span { display: block; height: 100%; background: var(--akzent); border-radius: 99px; transition: width 2s linear; }
.fortschritt-text { font-size: .9rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; }
.fortschritt-text .rest { color: var(--leise); }
.fortschritt.unbestimmt .balken span { width: 30% !important; animation: fortschritt-wandern 1.6s ease-in-out infinite; }
@keyframes fortschritt-wandern { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { .fortschritt.unbestimmt .balken span { animation: none; width: 100% !important; opacity: .3; } }
.fortschritt.klein { margin-top: .3rem; min-width: 8rem; gap: .15rem; }
.fortschritt.klein .balken { height: 6px; }
.fortschritt.klein .fortschritt-text { font-size: .75rem; color: var(--leise); }
.fortschritt.klein .rest { display: none; }
.karte.lesen { padding: 1.25rem; }
.karte.lesen p { margin: .75rem 0 0; font-size: .85rem; }

/* Mehrfachauswahl in der Belegliste */
.tabelle .wahl { width: 2.25rem; padding: 0; }
.tabelle td.wahl { cursor: default; }
.wahl label { display: flex; align-items: center; justify-content: center; margin: 0; padding: .6rem .5rem; cursor: pointer; }
.tabelle th.wahl { text-align: center; }
.wahl input { width: 1.05rem; height: 1.05rem; margin: 0; cursor: pointer; accent-color: var(--akzent); }
.tabelle tbody tr.gewaehlt { background: var(--info-hg); }
.tabelle tbody tr.gewaehlt:hover { background: var(--info-hg); }
.aktionsleiste { position: sticky; top: 3.5rem; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem;
  background: var(--karte); border: 1px solid var(--akzent); border-radius: 14px; box-shadow: var(--schatten); padding: .5rem .75rem; margin: 0 0 .75rem; }
.aktionsleiste[hidden], .aktionsleiste [hidden] { display: none; }
.aktionsleiste select { width: auto; max-width: 100%; }
.aktionsleiste .gewaehlt { white-space: nowrap; }
.aktionsleiste.leer { border-color: transparent; color: var(--leise); }
@media (max-width: 900px) { .aktionsleiste { top: 0; } }
.aktionsleiste.leer .gewaehlt::after { content: " – Belege anhaken, um mehrere auf einmal zu bearbeiten"; }
.bestaetigung ul { max-height: 16rem; overflow: auto; margin: .25rem 0 1rem; padding-left: 1.2rem; }
button.primaer.gefahr-knopf { background: var(--schlecht); border-color: var(--schlecht); color: #fff; }
