:root {
  --bg: #f5f6f8;
  --fl: #ffffff;
  --fl2: #f0f2f5;
  --text: #1c2430;
  --leise: #5d6878;
  --linie: #dde2e8;
  --akzent: #1f3a5f;
  --akzent-hell: #e6edf6;
  --ok: #17703c;
  --ok-bg: #e5f4ea;
  --warn: #8a5a00;
  --warn-bg: #fdf3dc;
  --fehler: #a3231f;
  --fehler-bg: #fbe7e6;
  --soll: #1f3a5f;
  --radius: 8px;
  --schatten: 0 1px 2px rgba(20, 30, 45, .06), 0 1px 1px rgba(20, 30, 45, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --fl: #1a2029;
    --fl2: #212834;
    --text: #e4e8ee;
    --leise: #9aa5b4;
    --linie: #2e3743;
    --akzent: #8db4e8;
    --akzent-hell: #233147;
    --ok: #6fd39a;
    --ok-bg: #173323;
    --warn: #f2c264;
    --warn-bg: #3a2f17;
    --fehler: #ff8f8a;
    --fehler-bg: #3e1d1c;
    --soll: #8db4e8;
    --schatten: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--akzent); }
h1 { font-size: 1.45rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
p { margin: .4rem 0 .8rem; }
.leise { color: var(--leise); }
.klein { font-size: .85rem; }
.zahl, td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--fehler); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }

/* Kopf / Navigation */
.kopf {
  background: var(--akzent); color: #fff; display: flex; align-items: center; gap: 1rem;
  padding: 0 16px; position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
@media (prefers-color-scheme: dark) { .kopf { background: #1a2b42; } }
.marke { color: #fff; font-weight: 700; text-decoration: none; padding: .8rem 0; white-space: nowrap; }
.kopf nav { display: flex; gap: .1rem; align-items: center; flex: 1; flex-wrap: wrap; }
.kopf nav a { color: #dfe8f3; text-decoration: none; padding: .8rem .65rem; border-bottom: 3px solid transparent; }
.kopf nav a:hover { color: #fff; }
.kopf nav a.aktiv { color: #fff; border-bottom-color: #8fc1ff; }
.nav-user { margin-left: auto; display: flex; gap: .4rem; align-items: center; }
.nav-user a { padding: .8rem .3rem !important; }
.kopf .link { color: #dfe8f3; }
.menu-knopf { display: none; margin-left: auto; background: none; border: 0; color: #fff; font-size: 1.4rem; }
@media (max-width: 900px) {
  .menu-knopf { display: block; }
  .kopf nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; padding-bottom: .5rem; }
  .kopf nav.offen { display: flex; }
  .kopf nav a { padding: .55rem .2rem; border-bottom: 0; }
  .kopf nav a.aktiv { font-weight: 700; }
  .nav-user { margin-left: 0; }
}

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
main.schmal { max-width: 520px; padding-top: 8vh; }

/* Karten & Raster */
.karte { background: var(--fl); border: 1px solid var(--linie); border-radius: var(--radius); padding: 16px; box-shadow: var(--schatten); }
.karte + .karte { margin-top: 16px; }
.raster { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.raster2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.kennzahl .label { color: var(--leise); font-size: .85rem; }
.kennzahl .wert { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: .2rem; }
.kennzahl .sub { color: var(--leise); font-size: .82rem; margin-top: .2rem; }
.zeile { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.zeile.ende { justify-content: flex-end; }
.zwischen { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* Hinweise */
.hinweis { padding: .7rem .9rem; border-radius: var(--radius); margin-bottom: .8rem; border: 1px solid transparent; }
.hinweis.ok { background: var(--ok-bg); color: var(--ok); }
.hinweis.warnung { background: var(--warn-bg); color: var(--warn); }
.hinweis.fehler { background: var(--fehler-bg); color: var(--fehler); }
.hinweis.info { background: var(--akzent-hell); color: var(--text); }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--fl2); color: var(--leise); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.fehler { background: var(--fehler-bg); color: var(--fehler); }
.ampel { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; vertical-align: middle; margin-right: .3rem; }
.ampel.gruen { background: var(--ok); } .ampel.gelb { background: #d89b00; } .ampel.rot { background: var(--fehler); }
.balken { height: 8px; background: var(--fl2); border-radius: 99px; overflow: hidden; margin-top: .5rem; }
.balken > span { display: block; height: 100%; background: var(--ok); }
.balken.gelb > span { background: #d89b00; } .balken.rot > span { background: var(--fehler); }

/* Tabellen */
.tabelle-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: var(--fl); }
th, td { padding: .45rem .6rem; border-bottom: 1px solid var(--linie); text-align: left; vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--leise); font-weight: 600; background: var(--fl2); }
tr.summe td { font-weight: 700; background: var(--fl2); border-top: 2px solid var(--linie); }
tr.gruppe td { font-weight: 650; background: var(--akzent-hell); }
tr.unter td:first-child { padding-left: 1.6rem; color: var(--leise); }
tr.entwurf td { background: var(--warn-bg); }
tr.storniert td { color: var(--leise); text-decoration: line-through; }
td.aktion { white-space: nowrap; text-align: right; }

/* Formulare */
label { display: block; font-weight: 550; font-size: .88rem; margin: .6rem 0 .25rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--fl); border: 1px solid var(--linie); border-radius: 6px;
  padding: .5rem .6rem; width: 100%; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--akzent); outline-offset: -1px; }
input[type=checkbox] { width: auto; min-height: 0; }
input.zahl { text-align: right; }
.feld-raster { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.hilfe { color: var(--leise); font-size: .83rem; margin-top: .2rem; }
.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
.check input { margin-top: .25rem; }
button, .knopf {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 6px; padding: .5rem 1rem; min-height: 40px;
  border: 1px solid var(--akzent); background: var(--akzent); color: #fff; text-decoration: none; display: inline-flex;
  align-items: center; gap: .3rem; white-space: nowrap;
}
@media (prefers-color-scheme: dark) { button, .knopf { color: #10161e; } }
button.zweit, .knopf.zweit { background: var(--fl); color: var(--akzent); }
button.gefahr { background: var(--fl); color: var(--fehler); border-color: var(--fehler); }
button.link { background: none; border: 0; padding: 0; min-height: 0; color: var(--akzent); font-weight: 500; text-decoration: underline; }
button.klein, .knopf.klein { padding: .2rem .6rem; min-height: 30px; font-size: .85rem; }
button:disabled { opacity: .45; cursor: not-allowed; }
form.inline { display: inline; }

/* Buchungsmaske */
.zeilen { width: 100%; }
.zeilen td { border: 0; padding: .25rem .25rem; }
.zeilen th { background: none; padding: .2rem .25rem; }
.zeilen .k { min-width: 230px; } .zeilen .b { width: 130px; } .zeilen .ks { width: 150px; } .zeilen .op { width: 140px; }
.summenzeile { display: flex; gap: 1.2rem; justify-content: flex-end; padding: .6rem .3rem; font-variant-numeric: tabular-nums; }
.summenzeile .diff.nicht0 { color: var(--fehler); font-weight: 700; }
.vorlagen { display: flex; flex-wrap: wrap; gap: .4rem; }
.vorlagen button { background: var(--fl); color: var(--text); border-color: var(--linie); font-weight: 500; padding: .35rem .7rem; min-height: 32px; font-size: .88rem; white-space: normal; text-align: left; }
.vorlagen button.aktiv { border-color: var(--akzent); background: var(--akzent-hell); }
details > summary { cursor: pointer; font-weight: 600; }
@media (max-width: 760px) {
  .zeilen thead { display: none; }
  .zeilen tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border-bottom: 1px solid var(--linie); padding: 6px 0; }
  .zeilen td:first-child { grid-column: 1 / -1; }
  .zeilen td { padding: 0; }
  .zeilen .k, .zeilen .b, .zeilen .ks, .zeilen .op { width: auto; min-width: 0; }
}

/* Balkendiagramm */
.chart { display: flex; align-items: flex-end; gap: 14px; height: 160px; padding: 8px 0 0; }
.chart .monat { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.chart .saeulen { display: flex; align-items: flex-end; gap: 4px; height: 130px; }
.chart .s { width: 18px; border-radius: 3px 3px 0 0; min-height: 1px; }
.chart .s.e { background: var(--ok); } .chart .s.a { background: #c0623c; }
.chart .lbl { font-size: .75rem; color: var(--leise); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.legende { display: flex; gap: 1rem; font-size: .8rem; color: var(--leise); }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }

.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--linie); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .8rem; text-decoration: none; color: var(--leise); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.aktiv { color: var(--text); border-bottom-color: var(--akzent); font-weight: 600; }
.pruef li { margin: .35rem 0; list-style: none; }
.pruef { padding-left: 0; }
.drucken-aus { }
@media print { .kopf, .drucken-aus, button, form { display: none !important; } body { background: #fff; } .karte { border: 0; box-shadow: none; } }
