/* =========================================================================
   Brain – Reiter Buchhaltung (seit 2026-11-12). Baut auf app.css auf.
   Reihenfarben aus der geprüften Referenzpalette (dataviz): Einnahmen blau,
   Ausgaben orange, je Look eigene Stufe. Text nie in Reihenfarbe.
   ========================================================================= */
:root, :root[data-theme="hell"] { --s-ein: #2a78d6; --s-aus: #eb6834; --s-plus: #1f7a4d; --s-minus: #a33a1f; }
:root[data-theme="dunkel"] { --s-ein: #3987e5; --s-aus: #d95926; --s-plus: #6fcf9e; --s-minus: #ff8a73; }

/* ---------- Kopf ---------- */
.bh-titel { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; }
.bh-reiterleiste { display: flex; gap: 4px; background: var(--soft); padding: 4px; border-radius: 12px; }
.bh-reiter { min-height: 40px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.bh-reiter[aria-current="page"] { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.bh-kopf { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; justify-content: space-between; }
.bh-jahr { display: flex; gap: 6px; align-items: center; }
.bh-jahrwahl { width: auto; min-width: 96px; height: 40px; font-weight: 600; font-family: var(--mono); }
.bh-aktionen { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Kennzahlen ---------- */
.bh-kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.bh-kachel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.bh-kachel::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line2); }
.bh-kachel.ein::before { background: var(--s-ein); }
.bh-kachel.aus::before { background: var(--s-aus); }
.bh-kachel.plus::before { background: var(--s-plus); }
.bh-kachel.minus::before { background: var(--s-minus); }
.bh-zahl { margin: 0; font-family: var(--head); font-size: clamp(26px, 3.4vw, 34px); font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bh-kachel.minus .bh-zahl { color: var(--s-minus); }
.bh-diff { font-weight: 600; }
.bh-diff.gut { color: var(--ok); }
.bh-diff.schlecht { color: var(--warn); }
.bh-vj { color: var(--muted); }

/* ---------- Hinweise ---------- */
.bh-hinweise { display: flex; flex-direction: column; gap: 8px; }
.bh-hinweis { margin: 0; padding: 10px 14px 10px 40px; border-radius: 10px; background: var(--panel2); font-size: 15px; position: relative; }
.bh-hinweis::before { position: absolute; left: 14px; top: 10px; font-weight: 700; }
.bh-hinweis.offen::before { content: "€"; color: var(--warn); }
.bh-hinweis.beleg::before { content: "📎"; }
.bh-hinweis.jahr::before { content: "↻"; color: var(--accent); }

/* ---------- Raster ---------- */
.bh-raster2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 22px; }
.bh-raster2.gleich { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.bh-raster3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px; align-items: start; }
@media (max-width: 980px) { .bh-raster2, .bh-raster2.gleich { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Grafiken ---------- */
.bh-legende { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.bh-legende > span { display: inline-flex; align-items: center; gap: 6px; }
.bh-punkt { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--muted); flex: 0 0 auto; }
.bh-punkt.ein { background: var(--s-ein); }
.bh-punkt.aus { background: var(--s-aus); }
.bh-punkt.linie, .bh-linie { width: 18px; height: 0; border-radius: 0; border-top: 2px solid var(--text); background: none; display: inline-block; }
.bh-punkt.linie.vj, .bh-linie.vj { border-top: 2px dashed var(--muted); }
.bh-svg-wrap { width: 100%; min-height: 250px; }
.bh-svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.bh-gitter { stroke: var(--line); stroke-width: 1; }
.bh-achse { stroke: var(--line2); stroke-width: 1.5; }
.bh-ticktext { fill: var(--muted); font-family: var(--mono); font-size: 11px; }
.bh-balken.ein { fill: var(--s-ein); }
.bh-balken.aus { fill: var(--s-aus); }
.bh-monat.zukunft .bh-ticktext { opacity: 0.45; }
.bh-monat:hover .bh-balken { filter: brightness(1.12); }
.bh-treffer { fill: transparent; cursor: pointer; }
.bh-kurve { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.bh-kurve.vj { stroke: var(--muted); stroke-dasharray: 5 4; }
.bh-endpunkt { fill: var(--s-plus); stroke: var(--panel); stroke-width: 2; }
.bh-endpunkt.minus { fill: var(--s-minus); }
.bh-kreuz { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }

/* Tooltip */
.bh-tip { position: fixed; z-index: 30; pointer-events: none; min-width: 170px; background: var(--panel); color: var(--text); border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.bh-tip-titel { margin: 0 0 2px; font-weight: 700; }
.bh-tip-zeile { display: flex; align-items: center; gap: 8px; }
.bh-tip-zeile strong { margin-left: auto; font-variant-numeric: tabular-nums; padding-left: 12px; }

/* Querbalken */
.bh-quer { display: flex; flex-direction: column; gap: 8px; }
.bh-quer-zeile { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.bh-quer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bh-quer-spur { height: 12px; display: block; }
.bh-quer-balken { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.bh-quer-balken.ein { background: var(--s-ein); }
.bh-quer-balken.aus { background: var(--s-aus); }
.bh-quer-zeile.rest .bh-quer-balken { opacity: 0.55; }
.bh-quer-wert { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 84px; text-align: right; }

/* ---------- Offene Posten, Grenze, EÜR ---------- */
.bh-offen { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.bh-offen:last-child { border-bottom: 0; }
.bh-offen-unten { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; }
.bh-grenze { gap: 6px; }
.bh-grenze .zeile { justify-content: space-between; font-size: 14px; }
.bh-euer { display: flex; flex-direction: column; }
.bh-euer-zeile { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.bh-euer-zeile strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bh-euer-zeile.summe { border-bottom: 0; border-top: 2px solid var(--text); font-size: 16px; }

/* ---------- Liste ---------- */
.bh-filterzeile { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.bh-suche { max-width: 300px; height: 40px; }
.bh-zeilen { display: flex; flex-direction: column; }
.bh-zeile { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 4px; color: var(--text); border-radius: 0; }
.bh-zeile:hover { background: var(--soft); }
.bh-zeile:last-child { border-bottom: 0; }
.bh-z-datum { font-family: var(--mono); font-size: 13px; display: flex; flex-direction: column; }
.bh-z-datum small { color: var(--muted); font-size: 11px; }
.bh-z-text { display: flex; flex-direction: column; min-width: 0; }
.bh-z-text strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bh-z-text small { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bh-z-marken { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.bh-marke { font-size: 11px; font-family: var(--mono); padding: 2px 7px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.bh-marke.offen { background: var(--bad-bg); color: var(--warn); font-weight: 600; }
.bh-marke.beleg { color: var(--warn); }
.bh-marke.ok { color: var(--ok); }
.bh-marke.jahr { background: var(--panel2); color: var(--accent); }
.bh-z-betrag { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; min-width: 96px; text-align: right; }
.bh-zeile.einnahme .bh-z-betrag { color: var(--ok); }
.bh-mehr-zeigen { align-self: center; margin-top: 10px; }

/* ---------- Dialog ---------- */
.bh-dialog { width: min(640px, calc(100% - 24px)); max-height: calc(100dvh - 24px); border: 1px solid var(--line); border-radius: 16px; padding: 22px; background: var(--panel); color: var(--text); }
.bh-dialog::backdrop { background: rgba(10, 12, 16, 0.45); }
.bh-dialog form.stapel { gap: 14px; }
.bh-feld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.bh-feldreihe > .bh-feld { flex: 1 1 200px; }
.bh-feld > label, .bh-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.bh-feld .klein { font-size: 12px; }
.bh-feldreihe { display: flex; gap: 12px; flex-wrap: wrap; }
.bh-check { min-height: 46px; align-items: center; gap: 8px; }
.bh-check input { width: 20px; height: 20px; accent-color: var(--accent); }
.bh-seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; }
.bh-seg-knopf { min-height: 38px; padding: 0 14px; border: 0; background: var(--panel); color: var(--muted); font-weight: 600; }
.bh-seg-knopf.einnahme[aria-pressed="true"] { background: var(--s-ein); color: #fff; }
.bh-seg-knopf.ausgabe[aria-pressed="true"] { background: var(--s-aus); color: #fff; }
.bh-dialog-hinweis { margin: 0; padding: 10px 12px; background: var(--panel2); border-radius: 10px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.bh-mehr > summary { font-size: 14px; color: var(--muted); padding: 4px 0; }
.bh-mehr[open] > summary { margin-bottom: 10px; }
.bh-belege { display: flex; flex-direction: column; gap: 4px; font-size: 14px; overflow-wrap: anywhere; }
.bh-datei { position: relative; align-self: flex-start; display: inline-flex; align-items: center; cursor: pointer; }
.bh-datei input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.bh-datei:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.bh-loeschen { color: var(--warn); margin-right: auto; }
.bh-rueck { color: var(--bg); text-decoration: underline; margin-left: 8px; }
.dialog-knoepfe { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

@media (max-width: 640px) {
  .bh-kacheln { grid-template-columns: 1fr 1fr; gap: 10px; }
  .bh-kachel { padding: 12px 12px 12px 16px; }
  .bh-zahl { font-size: 21px; }
  .bh-kachel .klein { font-size: 12px; }
  .bh-kopf { align-items: stretch; }
  .bh-aktionen { width: 100%; }
  .bh-aktionen .knopf { flex: 1 1 auto; }
  .bh-zeile { grid-template-columns: 58px minmax(0, 1fr) auto; }
  .bh-z-marken { grid-column: 2 / 3; justify-content: flex-start; grid-row: 2; }
  .bh-z-betrag { grid-row: 1; grid-column: 3; min-width: 0; }
  .bh-suche { max-width: none; }
  .bh-quer-zeile { grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 13px; }
  .bh-quer-name { grid-column: 1 / -1; }
  .bh-quer-wert { min-width: 70px; }
  .bh-dialog { padding: 16px; }
}

/* =========================================================================
   Angebote & Rechnungen (dokumente.js, seit 2026-11-12)
   ========================================================================= */
.dk-zeile { text-decoration: none; }
.dk-marke { font-size: 11px; font-family: var(--mono); padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.dk-marke.offen { background: var(--panel2); color: var(--accent); font-weight: 600; }
.dk-marke.gut { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.dk-marke.schlecht { background: var(--bad-bg); color: var(--warn); font-weight: 600; }
.dk-marke.entwurf { border: 1px dashed var(--line2); background: transparent; }
.dk-titelzeile { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.dk-titelzeile h2 { margin-right: auto; }
.dk-titelzeile > a { flex-basis: 100%; font-size: 14px; }
.dk-raster { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr); gap: 22px; align-items: start; }
.dk-vorschau-spalte { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 8px; }
.dk-vorschau { width: 100%; height: calc(100vh - 140px); min-height: 520px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.dk-pos { display: flex; flex-direction: column; gap: 8px; padding: 12px 0 14px; border-bottom: 1px solid var(--line); }
.dk-pos:first-child { padding-top: 0; }
.dk-pos-kopf { display: flex; justify-content: space-between; align-items: center; }
.dk-pos-knoepfe { display: flex; gap: 4px; }
.dk-pos-knoepfe .knopf { min-width: 36px; padding: 0 8px; }
.dk-pos-zahlen { display: grid; grid-template-columns: 1fr 1.2fr 1.3fr auto; gap: 8px; align-items: end; }
.dk-pos-zahlen label, .dk-pos-summe { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dk-pos-summe { align-items: flex-end; min-width: 90px; }
.dk-pos-gesamt { font-weight: 700; font-variant-numeric: tabular-nums; min-height: 46px; display: flex; align-items: center; }
.dk-summe { font-family: var(--head); font-size: 22px; font-variant-numeric: tabular-nums; }
.dk-leiste { position: sticky; bottom: 0; z-index: 4; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.dk-leiste .bh-loeschen { margin-right: auto; }
.dk-stand { min-width: 90px; text-align: right; }
.dk-frage { width: min(460px, calc(100% - 24px)); }
.dk-frage p { margin: 0; line-height: 1.5; }
@media (max-width: 1100px) {
  .dk-raster { grid-template-columns: minmax(0, 1fr); }
  .dk-vorschau-spalte { position: static; }
  .dk-vorschau { height: 70vh; }
}
@media (max-width: 640px) {
  .dk-pos-zahlen { grid-template-columns: 1fr 1fr; }
  .dk-pos-summe { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
  .bh-reiterleiste { width: 100%; }
  .bh-reiter { flex: 1 1 auto; justify-content: center; padding: 0 8px; font-size: 14px; }
  .dk-vorschau-spalte { display: none; }
}
