:root {
  --blau: #0b4f8a;
  --blau-dunkel: #083a66;
  --blau-hell: #e6eff8;
  --blau-band: #f3f7fb;
  --akzent: #e8850c;
  --tinte: #17212b;
  --grau: #5c6975;
  --linie: #cdd6df;
  --linie-fein: #e4e9ee;
  --grund: #eef1f4;
  --blatt: #ffffff;
  --rot: #b3261e;
  --rot-hell: #fbeceb;
  --gelb: #8a5a00;
  --gelb-hell: #fdf3dc;
  --gruen: #1d6b3a;
  --gruen-hell: #e6f3ea;
  --schrift: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.4 var(--schrift); color: var(--tinte); background: var(--grund); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
code { background: var(--blau-band); padding: 1px 5px; border-radius: 3px; font-size: 13px; }

.btn { border: 1px solid var(--linie); background: #fff; padding: 6px 12px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--blau); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav button:focus-visible, .perioden button:focus-visible { outline: 2px solid var(--akzent); outline-offset: 1px; }
.btn.primaer { background: var(--blau); border-color: var(--blau); color: #fff; }
.btn.primaer:hover { background: var(--blau-dunkel); }
.btn.klein { padding: 3px 9px; }
.btn.gefahr { color: var(--rot); }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid var(--linie); border-radius: 4px; padding: 5px 8px; background: #fff; }

/* Kopf */
#app { display: flex; flex-direction: column; height: 100%; }
.kopf { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--blau); color: #fff; flex-wrap: wrap; }
.marke { font-size: 18px; font-weight: 600; letter-spacing: .2px; padding-right: 12px; border-right: 1px solid rgba(255,255,255,.3); }
.kopf .feld { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.kopf select, .kopf input { color: var(--tinte); border-color: transparent; }
.kopf #mandant { min-width: 230px; max-width: 46vw; }
.jahrwahl { display: inline-flex; gap: 4px; }
.jahrwahl input { width: 76px; text-align: center; }
.kopf .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.35); color: #fff; }
.kopf .btn:hover { background: rgba(255,255,255,.24); }
.platz { flex: 1; }
.ampel { font-size: 13px; padding: 3px 10px; border-radius: 12px; background: #fff; color: var(--tinte); font-weight: 600; }
.ampel.ok { color: var(--gruen); }
.ampel.fehler { color: var(--rot); }
.ampel.warnung { color: var(--gelb); }
.ampel:empty { display: none; }

/* Periodenleiste */
.perioden { display: flex; gap: 2px; padding: 6px 16px; background: #fff; border-bottom: 1px solid var(--linie); overflow-x: auto; }
.perioden button { border: 1px solid transparent; background: none; padding: 5px 11px; border-radius: 4px; cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.perioden button:hover { background: var(--blau-band); }
.perioden button.aktiv { background: var(--blau-hell); border-color: var(--blau); font-weight: 600; }
.punkt { width: 8px; height: 8px; border-radius: 50%; background: var(--linie); flex: none; }
.punkt.ok { background: var(--gruen); }
.punkt.fehler { background: var(--rot); }

/* Rumpf */
.rumpf { flex: 1; display: flex; min-height: 0; }
.nav { width: 232px; flex: none; background: #fff; border-right: 1px solid var(--linie); padding: 10px 0; overflow-y: auto; }
.nav h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--grau); padding: 12px 16px 4px; }
.nav button { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; border: 0; border-left: 3px solid transparent; background: none; padding: 7px 16px 7px 13px; cursor: pointer; }
.nav button:hover { background: var(--blau-band); }
.nav button.aktiv { background: var(--blau-hell); border-left-color: var(--blau); font-weight: 600; }
.zahl { font-size: 12px; padding: 0 7px; border-radius: 9px; font-weight: 600; }
.zahl.fehler { background: var(--rot-hell); color: var(--rot); }
.zahl.warnung { background: var(--gelb-hell); color: var(--gelb); }
.zahl.ok { background: var(--gruen-hell); color: var(--gruen); }
.inhalt { flex: 1; min-width: 0; overflow: auto; padding: 16px; }

/* Blatt */
.blatt { background: var(--blatt); border: 1px solid var(--linie); border-radius: 4px; padding: 18px 20px 22px; max-width: 1180px; margin: 0 auto; }
.blatt.breit { max-width: none; }
.blattkopf { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: end; border-bottom: 2px solid var(--blau); padding-bottom: 10px; margin-bottom: 12px; }
.blattkopf .links { font-size: 13px; color: var(--grau); }
.blattkopf .links strong { display: block; font-size: 15px; color: var(--tinte); }
.blattkopf .mitte { text-align: center; }
.blattkopf .mitte h2 { font-size: 18px; color: var(--blau); }
.blattkopf .mitte span { font-size: 13px; color: var(--grau); }
.blattkopf .rechts { text-align: right; font-size: 12px; color: var(--grau); }
.leiste { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.leiste .platz { flex: 1; }
.leiste input[type="search"] { width: 220px; }
.leiste .wnr { width: 90px; }
.hinweis { color: var(--grau); font-size: 13px; margin: 8px 0; }
.keinewerte { padding: 28px; text-align: center; color: var(--grau); }

/* Tabellen */
.tabwrap { overflow-x: auto; }
table.tab { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.tab th, .tab td { padding: 4px 8px; border-bottom: 1px solid var(--linie-fein); text-align: left; vertical-align: baseline; }
.tab thead th { background: var(--blau-hell); color: var(--blau-dunkel); font-weight: 600; font-size: 12.5px; border-bottom: 1px solid var(--blau); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.tab thead tr.ober th { text-align: center; border-bottom-color: var(--linie); }
.tab .r { text-align: right; white-space: nowrap; }
.tab .nr { white-space: nowrap; color: var(--grau); width: 1%; }
.tab .schmal { width: 1%; white-space: nowrap; }
.tab tbody tr:nth-child(even) td { background: var(--blau-band); }
.tab tr.s td { font-weight: 600; background: var(--blau-hell) !important; border-top: 1px solid var(--blau); border-bottom: 1px solid var(--blau); }
.tab tr.z td { font-weight: 600; }
.tab tr.g td { font-weight: 600; padding-top: 9px; }
.tab tr.u td:nth-child(2), .tab tr.u td.t { padding-left: 26px; color: #33414e; }
.tab tr.k td.t { padding-left: 20px; }
.tab tr.h td { font-weight: 600; color: var(--grau); padding-top: 10px; background: #fff !important; }
.tab tr.f td { color: var(--rot); font-weight: 600; }
.tab tr.klasse td { background: #fff !important; font-weight: 600; color: var(--blau); padding-top: 12px; border-bottom: 1px solid var(--blau); }
.tab tfoot td { font-weight: 600; background: var(--blau-hell); border-top: 2px solid var(--blau); position: sticky; bottom: 0; }
.tab .neg { color: var(--rot); }
.tab .pos { color: var(--gruen); }
.tab .mut { color: var(--grau); font-size: 12.5px; }
.tab td.trenn, .tab th.trenn { border-left: 1px solid var(--linie); }
.tab input.betrag { width: 128px; text-align: right; padding: 3px 6px; font-variant-numeric: tabular-nums; }
.tab input.betrag.geaendert { border-color: var(--akzent); background: #fff8ee; }
.tab input.betrag.ungueltig { border-color: var(--rot); background: var(--rot-hell); }
.tab input.kname { width: 100%; min-width: 220px; }
.tab select { max-width: 280px; }
.diff.ok { color: var(--gruen); }
.diff.fehler { color: var(--rot); }

.zwei { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.zwei h3 { font-size: 14px; color: var(--blau); margin-bottom: 6px; }
.abschnitt { margin-top: 22px; }
.abschnitt > h3 { font-size: 15px; color: var(--blau); margin-bottom: 8px; }

/* Prüfung */
.pruefliste { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pruefliste li { border: 1px solid var(--linie); border-left-width: 5px; border-radius: 4px; padding: 9px 12px; background: #fff; }
.pruefliste li.fehler { border-left-color: var(--rot); background: var(--rot-hell); }
.pruefliste li.warnung { border-left-color: var(--akzent); background: var(--gelb-hell); }
.pruefliste li.hinweis { border-left-color: var(--blau); background: var(--blau-band); }
.pruefliste li.ok { border-left-color: var(--gruen); background: var(--gruen-hell); }
.pruefliste .stufe { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; margin-right: 8px; }
.pruefliste ul { margin: 6px 0 0; padding-left: 20px; font-size: 13px; color: #33414e; }

/* Formulare */
.formular { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 14px; align-items: end; }
.formular label { display: grid; gap: 3px; font-size: 12.5px; color: var(--grau); }
.fehlertext { color: var(--rot); min-height: 1.2em; margin: 4px 0; }

.dialog { border: 1px solid var(--linie); border-radius: 6px; padding: 0; width: min(720px, 94vw); }
.dialog::backdrop { background: rgba(11, 33, 54, .45); }
.dialogform { display: grid; gap: 10px; padding: 18px 20px; }
.dialogform textarea { width: 100%; font: 13px/1.4 Consolas, monospace; }
.dialogknopf { display: flex; justify-content: flex-end; gap: 8px; }
.importinfo { font-size: 13px; min-height: 1.3em; }
.importinfo .fehlertext { margin: 0; }

.meldung { position: fixed; right: 18px; bottom: 18px; background: var(--tinte); color: #fff; padding: 10px 16px; border-radius: 4px; max-width: 460px; box-shadow: 0 4px 16px rgba(0,0,0,.25); z-index: 10; }
.meldung.fehler { background: var(--rot); }

.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.loginkarte { background: #fff; border: 1px solid var(--linie); border-top: 4px solid var(--blau); border-radius: 4px; padding: 26px; width: min(360px, 100%); display: grid; gap: 12px; }
.loginkarte h1 { color: var(--blau); font-size: 22px; }
.loginkarte p { margin: 0; color: var(--grau); }
.loginkarte label { display: grid; gap: 4px; font-size: 13px; }

@media (max-width: 900px) {
  .rumpf { flex-direction: column; }
  .nav { width: auto; display: flex; overflow-x: auto; padding: 4px 8px; border-right: 0; border-bottom: 1px solid var(--linie); flex: none; }
  .nav h3 { display: none; }
  .nav button { width: auto; white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; padding: 7px 10px; gap: 6px; }
  .nav button.aktiv { border-bottom-color: var(--blau); }
  .zwei { grid-template-columns: 1fr; }
  .blattkopf { grid-template-columns: 1fr; }
  .blattkopf .mitte, .blattkopf .rechts { text-align: left; }
  .inhalt { padding: 8px; overflow: visible; }
  #app { height: auto; }
  .blatt { padding: 12px; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 10pt; }
  .kopf, .perioden, .nav, .leiste, .meldung, .nurbild { display: none !important; }
  #app, .rumpf, .inhalt { display: block; height: auto; overflow: visible; padding: 0; }
  .blatt { border: 0; padding: 0; max-width: none; }
  .tab thead th, .tab tfoot td { position: static; }
  .tab th, .tab td { padding: 2px 5px; }
  .tab tr { break-inside: avoid; }
  .tabwrap { overflow: visible; }
  .zwei { gap: 12px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
