/* <sistenta-finanzen> -- Deals & Finanzen im Aufbau des Stripe-Dashboards (02.10.2026).
   Farben nur ueber die vorhandenen Variablen (--text, --muted, --line, --panel,
   --panel2, --accent, --on-accent, --warn). Eigene Farbe nur Rot fuer
   "Ueberfaellig". Status traegt immer Symbol + Wort, nie Farbe allein.
   Der Graph hat eine Reihe (Akzent); die Deal-Leiste ist geordnet und
   nutzt eine Farbe in vier Stufen von hell nach dunkel. */
sistenta-finanzen {
  display: block; margin: 0 0 28px; color: var(--text);
  --fz-flaeche: var(--panel, #0d2631);
  --fz-flaeche2: var(--panel2, #11313c);
  --fz-kante: var(--line);
  --fz-gut: var(--accent);
  --fz-warn: var(--warn);
  --fz-rot: #ec958b;
  --fz-leise: color-mix(in srgb, var(--text) 6%, transparent);
  --fz-gitter: color-mix(in srgb, var(--text) 9%, transparent);
  --fz-radius: 14px;
}
:root[data-theme=light] sistenta-finanzen { --fz-rot: #b3412f; --fz-gitter: color-mix(in srgb, var(--text) 10%, transparent); }

sistenta-finanzen [hidden] { display: none !important; }
sistenta-finanzen button { font: inherit; color: inherit; }
sistenta-finanzen :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fz { position: relative; }
.fz-i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.fz-i--pill { width: 13px; height: 13px; stroke-width: 2.2; }
.fz-unsichtbar { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fz-zahl { font-variant-numeric: tabular-nums; }
.fz-r { text-align: right; }
.fz-leise { color: var(--muted); font-weight: 450; }

/* ---------- Leiste: Reiter links, Verbinden rechts ---------- */
.fz__leiste { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--fz-kante); margin: 0 0 20px; }
.fz__reiter { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-bottom: -1px; }
.fz__reiter::-webkit-scrollbar { display: none; }
.fz__tab { border: 0; background: none; padding: 10px 12px 11px; font-size: 14px; font-weight: 560; color: var(--muted);
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; transition: color .15s, border-color .15s; }
.fz__tab:hover { color: var(--text); }
.fz__tab--an { color: var(--text); border-bottom-color: var(--accent); }
.fz__rechts { position: relative; display: flex; align-items: center; gap: 6px; padding-bottom: 6px; }
.fz__zahl { font-size: 11px; font-weight: 650; color: var(--muted); padding: 1px 6px; border-radius: 8px; background: var(--fz-leise); }

/* ---------- Knoepfe ---------- */
.fz-k { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 0 13px;
  border: 1px solid var(--fz-kante); border-radius: 9px; background: var(--fz-flaeche); font-size: 13.5px; font-weight: 560;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.fz-k:hover { background: var(--fz-flaeche2); }
.fz-k--klein { min-height: 30px; padding: 0 11px; font-size: 13px; }
.fz-k--leise { background: transparent; border-color: transparent; color: var(--muted); }
.fz-k--leise:hover { color: var(--text); background: var(--fz-leise); }
.fz-k--haupt { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.fz-k--haupt:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.fz-k--rund { width: 30px; padding: 0; }
.fz-k .fz-i { width: 15px; height: 15px; }

/* ---------- Menue (Verbinden, Zeilen-Aktionen) ---------- */
.fz-menue { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; width: min(340px, calc(100vw - 32px));
  background: var(--fz-flaeche); border: 1px solid var(--fz-kante); border-radius: 12px; padding: 6px;
  box-shadow: 0 18px 48px #0000003a; }
.fz-menue--klein { width: 230px; top: calc(100% + 2px); }
.fz-menue__titel { margin: 6px 10px 6px; font-size: 12px; color: var(--muted); font-weight: 560; }
.fz-menue__fuss { margin: 6px 10px 6px; padding-top: 8px; border-top: 1px solid var(--fz-kante); font-size: 12px; color: var(--muted); line-height: 1.45; }
.fz-menue__zeile { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border: 0;
  border-radius: 8px; background: none; cursor: pointer; font-size: 13.5px; }
.fz-menue__zeile:hover, .fz-menue__zeile:focus-visible { background: var(--fz-leise); }
.fz-menue__zeile > .fz-i { color: var(--muted); width: 14px; height: 14px; }
.fz-menue__text { flex: 1; display: grid; gap: 1px; min-width: 0; }
.fz-menue__text b { font-weight: 600; }
.fz-menue__text small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fz-punkt { width: 8px; height: 8px; border-radius: 50%; flex: none; border: 1.5px solid var(--muted); box-sizing: border-box; }
.fz-punkt--an { background: var(--fz-gut); border-color: var(--fz-gut); }

/* ---------- Karten ---------- */
.fz-karte { background: var(--fz-flaeche); border: 1px solid var(--fz-kante); border-radius: var(--fz-radius);
  padding: 18px 20px; margin: 0 0 16px; min-width: 0; }
.fz-karte__kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px 16px; flex-wrap: wrap; margin: 0 0 14px; }
.fz-karte__kopf h3 { margin: 0; font-size: 15px; font-weight: 620; letter-spacing: -.2px; }
.fz-karte__unter { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.fz-zwei { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 0 16px; }
.fz-hinweis { font-size: 12.5px; color: var(--muted); margin: -6px 0 14px; }
.fz-laden { padding: 40px 0; color: var(--muted); text-align: center; }

/* ---------- Kennzahlen ---------- */
.fz-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 0 0 16px;
  background: var(--fz-flaeche); border: 1px solid var(--fz-kante); border-radius: var(--fz-radius); overflow: hidden; }
.fz-kpi { padding: 16px 20px 17px; border-left: 1px solid var(--fz-kante); min-width: 0; }
.fz-kpi:first-child { border-left: 0; }
.fz-kpi__titel { margin: 0; font-size: 13px; color: var(--muted); font-weight: 540; }
.fz-kpi__wert { margin: 6px 0 4px; font-size: 24px; font-weight: 620; letter-spacing: -.6px; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.fz-kpi--haupt .fz-kpi__wert { font-size: 28px; }
.fz-kpi__unter { margin: 0; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fz-kpi__warn { color: var(--fz-rot); display: inline-flex; }
.fz-kpi__warn .fz-i { width: 18px; height: 18px; }
.fz-delta { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px 1px 4px; border-radius: 6px; font-weight: 620; color: var(--text); }
.fz-delta--auf { background: color-mix(in srgb, var(--fz-gut) 16%, transparent); }
.fz-delta--auf .fz-i { color: var(--fz-gut); }
.fz-delta--ab { background: color-mix(in srgb, var(--fz-rot) 14%, transparent); }
.fz-delta--ab .fz-i { color: var(--fz-rot); }
.fz-delta--gleich { background: var(--fz-leise); }

/* ---------- Status-Pillen ---------- */
.fz-pille { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 6px; border-radius: 999px; font-size: 12px;
  font-weight: 600; white-space: nowrap; line-height: 18px; color: var(--text); background: var(--fz-leise); }
.fz-pille--gut { background: color-mix(in srgb, var(--fz-gut) 15%, transparent); }
.fz-pille--gut .fz-i { color: var(--fz-gut); }
.fz-pille--warn { background: color-mix(in srgb, var(--fz-warn) 18%, transparent); }
.fz-pille--warn .fz-i { color: var(--fz-warn); }
.fz-pille--rot { background: color-mix(in srgb, var(--fz-rot) 16%, transparent); }
.fz-pille--rot .fz-i { color: var(--fz-rot); }
.fz-pille--neutral .fz-i { color: var(--muted); }
.fz-pille--leise { color: var(--muted); background: transparent; border: 1px solid var(--fz-kante); }

/* ---------- Vorschlaege ---------- */
.fz-vorschlaege { border-color: color-mix(in srgb, var(--fz-warn) 45%, var(--fz-kante)); }
.fz-vliste { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.fz-v { display: grid; grid-template-columns: minmax(120px, auto) 1fr auto auto; align-items: center; gap: 10px 16px;
  padding: 10px 12px; border-radius: 10px; background: var(--fz-leise); }
.fz-v__geld, .fz-v__ziel > div { display: grid; gap: 1px; min-width: 0; }
.fz-v__geld b { font-variant-numeric: tabular-nums; font-size: 15px; }
.fz-v small { color: var(--muted); font-size: 12px; }
.fz-v__ziel { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fz-v__ziel small { overflow: hidden; text-overflow: ellipsis; }
.fz-v__pfeil { color: var(--muted); }
.fz-v__konf { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.fz-v__knoepfe { display: flex; gap: 6px; }

/* ---------- Graph ---------- */
.fz-graph__flaeche { min-height: 120px; }
.fz-svg { display: block; width: 100%; height: auto; overflow: visible; }
.fz-achse__linie { stroke: var(--fz-gitter); stroke-width: 1; }
.fz-achse__linie--null { stroke: color-mix(in srgb, var(--text) 22%, transparent); }
.fz-achse__text { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.fz-balken { fill: var(--accent); transition: opacity .15s; }
.fz-balken--laufend { fill-opacity: .45; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 3; }
.fz-treffer { fill: transparent; cursor: default; outline: none; }
.fz-treffer--an { fill: var(--fz-leise); }
.fz-graph__fuss { margin: 6px 0 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.fz-muster { width: 12px; height: 12px; border-radius: 3px; border: 1.5px dashed var(--accent);
  background: color-mix(in srgb, var(--accent) 45%, transparent); box-sizing: border-box; }
.fz-tip { position: absolute; z-index: 25; transform: translate(-50%, -100%); pointer-events: none; display: grid; gap: 1px;
  background: var(--fz-flaeche2); border: 1px solid var(--fz-kante); border-radius: 9px; padding: 7px 10px; font-size: 12.5px;
  box-shadow: 0 8px 22px #00000030; white-space: nowrap; }
.fz-tip span { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.fz-tip small { color: var(--muted); }

/* ---------- Filter ---------- */
.fz-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.fz-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--fz-kante); background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 560; cursor: pointer; }
.fz-chip:hover { color: var(--text); }
.fz-chip--an { color: var(--text); background: var(--fz-flaeche2); border-color: color-mix(in srgb, var(--text) 18%, transparent); }
.fz-chip__zahl { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11.5px; }

/* ---------- Tabelle ---------- */
.fz-tabelle-huelle { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.fz-tabelle { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.fz-tabelle th { text-align: left; font-size: 12px; font-weight: 560; color: var(--muted); padding: 0 10px 8px; border-bottom: 1px solid var(--fz-kante); white-space: nowrap; }
.fz-tabelle th.fz-r { text-align: right; }
.fz-tabelle td { padding: 10px; border-bottom: 1px solid var(--fz-kante); vertical-align: middle; }
.fz-tabelle tr:last-child td { border-bottom: 0; }
.fz-tabelle tbody tr:hover td { background: var(--fz-leise); }
.fz-tabelle td:first-child, .fz-tabelle th:first-child { padding-left: 0; }
.fz-tabelle td:last-child, .fz-tabelle th:last-child { padding-right: 0; }
.fz-zeile--leise td { color: var(--muted); }
.fz-von { display: grid; gap: 1px; min-width: 0; }
.fz-von b { font-weight: 580; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }
.fz-von small { color: var(--muted); font-size: 12px; }
.fz-datum { color: var(--muted); white-space: nowrap; }
.fz-mehr { position: relative; display: inline-block; }
.fz-mehr-zeilen { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0 0;
  border-top: 1px solid var(--fz-kante); font-size: 12.5px; color: var(--muted); }
.fz-mehr .fz-menue { text-align: left; }

/* ---------- Deals-Leiste ---------- */
.fz-leiste { display: block; width: 100%; margin: 2px 0 14px; }
.fz-stufe { fill: var(--accent); }
.fz-stufe--0, .fz-stufen__farbe--0 { fill-opacity: .3; opacity: 1; }
.fz-stufe--1 { fill-opacity: .5; }
.fz-stufe--2 { fill-opacity: .74; }
.fz-stufe--3 { fill-opacity: 1; }
.fz-stufen { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.fz-stufen li { display: grid; gap: 2px; min-width: 0; }
.fz-stufen__name { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fz-stufen__farbe { width: 8px; height: 8px; border-radius: 2px; flex: none; background: var(--accent); }
.fz-stufen__farbe--0 { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.fz-stufen__farbe--1 { background: color-mix(in srgb, var(--accent) 50%, transparent); }
.fz-stufen__farbe--2 { background: color-mix(in srgb, var(--accent) 74%, transparent); }
.fz-stufen b { font-size: 18px; font-weight: 620; }
.fz-stufen small { font-size: 12px; color: var(--muted); }

/* ---------- Rechnungsliste ---------- */
.fz-rliste { list-style: none; margin: 0; padding: 0; }
.fz-rliste li { display: grid; grid-template-columns: 1fr auto minmax(88px, auto); align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--fz-kante); }
.fz-rliste li:last-child { border-bottom: 0; }

/* ---------- Leerzustaende ---------- */
.fz-leer { text-align: center; padding: 26px 16px; }
.fz-leer--flach { padding: 18px 8px 8px; }
.fz-leer__titel { margin: 0 0 4px; font-weight: 600; font-size: 14px; }
.fz-leer__text { margin: 0 auto 12px; color: var(--muted); font-size: 13px; max-width: 52ch; line-height: 1.5; }

/* ---------- Dialog fuer die vorhandenen Bausteine ---------- */
.fz-dialog { width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--fz-kante);
  border-radius: 16px; background: var(--bg, var(--fz-flaeche)); color: var(--text); }
.fz-dialog::backdrop { background: #0008; }
.fz-dialog__kopf { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 18px; background: var(--bg, var(--fz-flaeche)); border-bottom: 1px solid var(--fz-kante); }
.fz-dialog__kopf h2 { margin: 0; font-size: 17px; }
.fz-dialog__inhalt { padding: 16px 18px 18px; }
.fz-bausteine > * + * { margin-top: 16px; }

/* ---------- Schmal ---------- */
@media (max-width: 900px) {
  .fz-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fz-kpi:nth-child(3) { border-left: 0; }
  .fz-kpi:nth-child(n+3) { border-top: 1px solid var(--fz-kante); }
}
@media (max-width: 560px) {
  .fz-karte { padding: 16px; }
  .fz-tabelle-huelle { margin: 0 -16px; padding: 0 16px; }
  .fz-kpi { padding: 14px 14px 15px; }
  .fz-kpi__wert, .fz-kpi--haupt .fz-kpi__wert { font-size: 20px; }
  .fz-weg-schmal { display: none; }
  /* Zahlungen am Handy als zweizeilige Zeilen statt Tabelle (wie die Stripe-App). */
  .fz-zahlungen { overflow: visible; }
  .fz-zahlungen thead { display: none; }
  .fz-zahlungen tbody, .fz-zahlungen table { display: block; }
  .fz-zahlungen tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 10px; align-items: center;
    grid-template-areas: "von betrag mehr" "status datum mehr"; padding: 11px 0; border-bottom: 1px solid var(--fz-kante); }
  .fz-zahlungen tr:last-child { border-bottom: 0; }
  .fz-zahlungen td { padding: 0 !important; border: 0 !important; background: none !important; }
  .fz-zahlungen td:nth-child(1) { grid-area: betrag; }
  .fz-zahlungen td:nth-child(2) { grid-area: status; }
  .fz-zahlungen td:nth-child(3) { grid-area: von; }
  .fz-zahlungen td:nth-child(5) { grid-area: datum; text-align: right; font-size: 12.5px; }
  .fz-zahlungen td:nth-child(6) { grid-area: mehr; }
  .fz-zahlungen .fz-von b { max-width: none; }
  .fz-v { grid-template-columns: 1fr auto; }
  .fz-v__ziel { grid-column: 1 / -1; order: 3; }
  .fz-v__knoepfe { grid-column: 1 / -1; order: 4; }
  .fz-stufen { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fz__rechts { margin-left: auto; }
  .fz__verbinden span:first-of-type { display: inline; }
}
@media (prefers-reduced-motion: reduce) { sistenta-finanzen * { transition: none !important; } }
:root[data-motion=off] sistenta-finanzen * { transition: none !important; }
