/* ─────────────────────────────────────────────────────────────────────────
   Finanzbereich — geteilte Bausteine
   ─────────────────────────────────────────────────────────────────────────
   Global statt CSS-isoliert, aus demselben Grund wie social-components.css:
   Blazors Isolation reicht nicht in Kind-Komponenten, und eine Klasse, die
   mehrere Seiten vergeben, gäbe es sonst nur als Handkopie je Seite. Genau so
   standen Tabelle, Banner und Detailkarte vor #1881 allein in
   Zahlungen.razor.css — mit der dritten Seite im selben Look (Zahlungen,
   Rechnungs-Sync, Lieferanten) ist das der Moment, sie einmal zu halten.

   Der fz-Präfix ist Pflicht, nicht Geschmack: ungescopt würden Namen wie
   .zustand oder .balken auf jede Seite der App wirken.

   Ausschließlich DS-Tokens aus design-tokens.css.
   ───────────────────────────────────────────────────────────────────────── */

/* ── Seitenfläche ────────────────────────────────────────────────────────── */
.fz-flaeche {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 20px 16px;
    min-height: 0;
}

/* ── Banner ──────────────────────────────────────────────────────────────
   Standard ist die Warnfarbe. .rot für Fehler, .teal für den laufenden oder
   gerade beendeten Vorgang. .zeile macht daraus die Icon-Form des Entwurfs —
   nicht der Default, weil ein Banner mit Absatz und Liste darin (Zahlungen)
   als Flex-Zeile auseinanderfiele. */
.fz-banner {
    border-radius: 14px;
    padding: 10px 13px;
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    line-height: 1.45;
    background: var(--warning-100);
    color: var(--warning-600);
}

.fz-banner.rot { background: var(--danger-100); color: var(--danger-600); }
.fz-banner.teal { background: var(--brand-wash); color: var(--brand-strong); }

.fz-banner.zeile { display: flex; align-items: center; gap: 10px; }
.fz-banner.zeile > svg { flex: none; }
.fz-banner.zeile b { font-weight: 600; }
.fz-banner .sp { margin-left: auto; white-space: nowrap; }

/* ── Laufstreifen ────────────────────────────────────────────────────────
   Der Balken kennt zwei Formen: mit transform:scaleX() gesetzter Fortschritt
   (Zahlungen, der Worker meldet ihn) und .unbestimmt für Läufe ohne Meldung
   (Rechnungs-Sync). */
.fz-lauf {
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 14px;
    padding: 10px 13px;
    background: var(--brand-wash);
    color: var(--brand-strong);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    font-weight: 600;
}

.fz-balken {
    flex: 1;
    max-width: 320px;
    height: 6px;
    border-radius: 999px;
    background: var(--surface-card);
    overflow: hidden;
}

.fz-balken div {
    height: 100%;
    width: 100%;
    background: var(--brand);
    transform-origin: left;
    transition: transform .3s var(--lh-ease, ease);
}

.fz-balken.unbestimmt div {
    width: 38%;
    border-radius: 999px;
    animation: fz-balken-wandern 1.4s ease-in-out infinite;
}

@keyframes fz-balken-wandern {
    0% { margin-left: 0; }
    50% { margin-left: 62%; }
    100% { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .fz-balken.unbestimmt div { animation: none; margin-left: 31%; }
}

/* ── Filter-Pillen ───────────────────────────────────────────────────────── */
.fz-pillen { display: flex; gap: 8px; }

.fz-pillen button {
    height: 34px;
    padding: 0 13px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: var(--surface-card);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-muted);
    cursor: pointer;
}

.fz-pillen button.an { background: var(--brand-wash); border-color: transparent; color: var(--brand-strong); }
.fz-pillen button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Eine Stufe unter dem Pillentext — der Zähler begleitet ihn, er konkurriert nicht. */
.fz-pillen .zahl {
    margin-left: 6px;
    border-radius: 999px;
    padding: 1px 7px;
    background: var(--surface-sunken);
    font-size: var(--text-2xs);
    font-variant-numeric: tabular-nums;
}

/* ── Zustands-Pille ──────────────────────────────────────────────────────
   teal ist bewusst kein Synonym für grün: grün heißt im Finanzbereich
   „erledigt". „wartet auf Zahlung" ist nicht erledigt. */
.fz-zustand {
    justify-self: end;
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: 999px;
    padding: 4px 10px;
    white-space: nowrap;
    display: inline-block;
}

.fz-zustand.amb { background: var(--warning-100); color: var(--warning-600); }
.fz-zustand.rot { background: var(--danger-100); color: var(--danger-600); }
.fz-zustand.gruen { background: var(--success-100); color: var(--success-600); }
.fz-zustand.grau { background: var(--surface-sunken); color: var(--text-subtle); }
.fz-zustand.teal { background: var(--brand-wash); color: var(--brand-strong); }

/* ── Leer-Zustand ────────────────────────────────────────────────────────
   .gross ist die Erfolgsform: der leere Rechnungs-Sync ist kein Mangel,
   sondern das Ziel, und darf so aussehen. */
.fz-leer {
    padding: 24px;
    text-align: center;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--text-muted);
    background: var(--surface-card);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
}

.fz-leer.gross {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.fz-leer .ic {
    width: 52px;
    height: 52px;
    border-radius: 999px;
    background: var(--success-100);
    color: var(--success-600);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.fz-leer b { font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); color: var(--text-strong); }
.fz-leer .text { display: block; line-height: 1.55; max-width: 440px; }

.fz-fuss { font-family: var(--font-ui); font-size: var(--text-xs); color: var(--text-subtle); padding: 4px; }

/* ── Kopfzeile über der Liste ────────────────────────────────────────────── */
.fz-kopfzeile { display: flex; align-items: center; gap: 8px; }
.fz-suche { margin-left: auto; }

.fz-suche input {
    width: 250px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--border-default);
    background: var(--surface-card);
    padding: 0 12px;
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    color: var(--text-body);
}

/* ── Arbeitsfläche: Liste links, Detailkarte rechts ──────────────────────── */
.fz-arbeit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 14px;
    min-height: 0;
}

/* ── Tabelle ─────────────────────────────────────────────────────────────── */
.fz-tabelle {
    min-width: 0;
    background: var(--surface-card);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.fz-tabelle table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    color: var(--text-body);
}

.fz-tabelle th {
    text-align: left;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-subtle);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-page);
    white-space: nowrap;
    user-select: none;
}

.fz-tabelle th button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: inherit;
    cursor: pointer;
}

.fz-tabelle th button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.fz-tabelle th.an { color: var(--brand-strong); }
.fz-tabelle th.num, .fz-tabelle td.num { text-align: right; }

.fz-tabelle td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.fz-tabelle tbody tr:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.fz-tabelle tr.sel td { background: var(--brand-wash); }
.fz-tabelle tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
/* Eine Stufe über dem Zeilentext: die Rechnungsnummer ist das, wonach man sucht. */
.fz-tabelle td.nr { font-family: var(--font-display); font-weight: 600; font-size: var(--text-base); color: var(--text-strong); }
.fz-tabelle td.wer b { display: block; font-weight: 600; color: var(--text-strong); }
.fz-tabelle td.wer span { display: block; font-family: var(--font-body); font-size: var(--text-2xs); color: var(--text-subtle); }
.fz-tabelle td.leise { color: var(--text-subtle); }

/* ── Detailkarte ─────────────────────────────────────────────────────────── */
.fz-detail {
    background: var(--surface-card);
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    padding: 14px 16px;
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    align-self: start;
}

.fz-detail .kopf { display: flex; align-items: center; gap: 9px; }
.fz-detail .kopf b { font-family: var(--font-display); font-size: var(--text-lg); }
.fz-detail a { color: var(--text-link); }

.fz-detail dl {
    display: grid;
    grid-template-columns: 118px minmax(0, 1fr);
    row-gap: 6px;
    margin: 14px 0 0;
}

.fz-detail dt { color: var(--text-subtle); }
.fz-detail dd { margin: 0; font-weight: 600; }

.fz-detail .aktionen {
    margin: 14px -16px -14px;
    padding: 12px 16px 14px;
    border-top: 1px solid var(--border-soft);
    background: var(--surface-page);
    border-radius: 0 0 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.fz-detail .aktionen:empty { display: none; }

.fz-warnung {
    margin-top: 12px;
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--warning-100);
    color: var(--warning-600);
    font-size: var(--text-sm);
    line-height: 1.45;
}

/* ── Knopf ───────────────────────────────────────────────────────────────── */
.fz-knopf {
    height: 42px;
    padding: 0 14px;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--border-default);
    background: var(--surface-card);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-body);
    cursor: pointer;
}

.fz-knopf.pri { background: var(--brand); border-color: transparent; color: var(--text-on-brand); box-shadow: var(--shadow-brand); }
.fz-knopf:disabled { opacity: .45; box-shadow: none; cursor: default; }

/* Der kleine Knopf in einer Tabellenzeile oder einem Kartenkopf. */
.fz-mini {
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--border-default);
    background: var(--surface-card);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: var(--text-xs);
    color: var(--text-muted);
    cursor: pointer;
}

.fz-mini.ok { border-color: var(--brand); color: var(--brand-strong); }
.fz-mini:disabled { opacity: .45; cursor: default; }
.fz-mini:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── Karte mit Kopf und scrollendem Rumpf ────────────────────────────────
   Zwei unabhängige Aufgaben nebeneinander, jede mit eigenem Lade- und
   Fehlerzustand: die Hälften laden getrennt, also meldet jede für sich. */
.fz-karte {
    min-height: 0;
    background: var(--surface-card);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.fz-karte-kopf { flex: none; padding: 12px 14px 10px; border-bottom: 1px solid var(--border-soft); }
.fz-karte-kopf .titel { display: flex; align-items: center; gap: 8px; }
.fz-karte-kopf .titel h2 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: var(--text-base); color: var(--text-strong); }
.fz-karte-kopf .titel .sp { margin-left: auto; }
.fz-karte-kopf p { margin: 6px 0 0; font-family: var(--font-body); font-size: var(--text-sm); line-height: 1.5; color: var(--text-muted); }

.fz-karte-kopf .hin {
    margin-top: 6px;
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    color: var(--text-subtle);
    display: flex;
    align-items: center;
    gap: 6px;
}

.fz-karte-kopf .fz-banner { margin-top: 8px; }

/* Der Rumpf erbt die Tabellenstile, aber nicht Rahmen und Radius — die trägt die Karte. */
.fz-karte .fz-tabelle { border: 0; border-radius: 0; background: transparent; }
.fz-karte .fz-leer { border: 0; border-radius: 0; background: transparent; }

/* ── Ab Rechnerbreite scrollt nur die Liste ──────────────────────────────
   Die Seite füllt den Inhaltsbereich; Kopf, Pillen und Detailkarte bleiben
   stehen. Schmaler (mobile Shell) bleibt es beim normalen Seiten-Scroll. */
@media (min-width: 960px) {
    .fz-flaeche { height: 100%; box-sizing: border-box; overflow: hidden; }
    .fz-arbeit { flex: 1; grid-template-rows: minmax(0, 1fr); }
    .fz-tabelle { align-self: stretch; }
    .fz-tabelle thead th { position: sticky; top: 0; z-index: 1; }
    .fz-detail { max-height: 100%; overflow-y: auto; box-sizing: border-box; }
}
