/* =====================================================================================
   klaerfaelle.css · Klärfälle + Quarantäne (Rechnungseingang BA 4, WP4.F1)
   ALMAS-Webdesign v2: hell/premium, Rot #FF2325 (Flächen) / #D81020 (Text, Knöpfe), weiche Schatten,
   gerundet, Helvetica Neue (Tokens aus almas-design.css + rechnungstool-theme.css). Präfix kf- / qu-.
   ===================================================================================== */

.kf, .qu { min-width: 0; }
.kf-unsichtbar {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.kf-icon { width: 16px; height: 16px; flex: 0 0 auto; }
.kf-leise { color: var(--text-secondary); font-size: 13px; }
.kf-umbruch { overflow-wrap: anywhere; }
.kf-pflicht { color: var(--text-secondary); font-weight: 400; } /* AA: text-tertiary hätte auf Weiß nur 3,3:1 */

/* ─── Werkzeugleiste: Schalter, Suche, Grund-Chips ─── */
.kf-werkzeuge { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; min-width: 0; }
.kf-werkzeuge-zeile { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; min-width: 0; }

.kf-schalter {
  display: inline-flex; gap: 3px; padding: 4px; max-width: 100%; overflow-x: auto;
  background: var(--bg-tertiary); border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(16, 17, 22, .06);
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.kf-schalter::-webkit-scrollbar { display: none; }
.kf-schalter-knopf {
  border: 0; background: transparent; border-radius: 999px; padding: 7px 14px; min-height: 34px;
  font: 600 13px/1.2 var(--font-family); color: var(--text-secondary); cursor: pointer; white-space: nowrap;
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.kf-schalter-knopf:hover { color: var(--text-primary); }
.kf-schalter-knopf[aria-pressed="true"] { background: #fff; color: var(--text-primary); box-shadow: var(--shadow-md); }

.kf-suche { position: relative; flex: 1 1 240px; min-width: 200px; max-width: 440px; }
.kf-suche > .kf-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); pointer-events: none; }
.kf-suche .almas-input { padding-left: 38px; border-radius: 999px; min-height: 40px; box-shadow: var(--shadow-sm); }

.kf-gruende { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.kf-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 34px;
  padding: 5px 6px 5px 12px; border: 1px solid var(--border-secondary); border-radius: 999px;
  background: var(--bg-secondary); color: var(--text-primary); box-shadow: var(--shadow-sm);
  font: 500 13px/1.25 var(--font-family); text-align: left; cursor: pointer;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease, color .2s ease, transform .2s ease;
}
.kf-chip:hover { border-color: var(--border-primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
/* Aktiver Chip: deckender Rotton statt rgba(…, .08) – #D81020 auf #FFF3F3 = 4,8:1 auf jedem Untergrund
   (vorher über dem grauen Seitengrund #F7E5E7: 4,31:1). Wie lieferanten.css .lf-chip.is-aktiv. */
.kf-chip[aria-pressed="true"] { background: #FFF3F3; border-color: var(--almas-red-border); color: var(--almas-red-hover); box-shadow: none; transform: none; }
.kf-chip-zahl {
  min-width: 22px; padding: 2px 7px; border-radius: 999px; text-align: center;
  background: var(--bg-tertiary); color: var(--text-secondary); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.kf-chip[aria-pressed="true"] .kf-chip-zahl { background: #fff; color: var(--almas-red-hover); }
.kf-chip-danger::before, .kf-chip-info::before, .kf-chip-warning::before, .kf-chip-neutral::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; margin-right: -2px;
}
.kf-chip-danger::before { background: #E0202A; }
.kf-chip-info::before { background: #2F7BE0; }
.kf-chip-warning::before { background: #E3A100; }
.kf-chip-neutral::before { background: #A3A6AD; }
.kf-chip-klein { min-height: 30px; padding: 4px 10px; font-size: 12.5px; box-shadow: none; }
.kf-chip-notiz { color: var(--text-secondary); font-weight: 400; }
/* Schnellwahl: lange Adressen brechen im Chip um, statt das Detail zu verbreitern. */
.kf-chip-klein { flex-wrap: wrap; row-gap: 2px; min-width: 0; }
.kf-chip-mail, .kf-chip-notiz { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
/* Lange Adressen/Nummern ohne Trennstelle (z. B. „zugewiesen an …“) brechen im Detail um statt es zu verbreitern. */
.kf-detail-inhalt p, .kf-detail-inhalt li, .kf-detail-inhalt dd { overflow-wrap: anywhere; }

/* ─── Plaketten (Badges) in normaler Schreibung – lange Gründe nicht in Versalien ─── */
.kf .almas-badge, .qu .almas-badge {
  text-transform: none; letter-spacing: 0; font-size: 12px; line-height: 1.3; font-weight: 600; max-width: 100%;
}
.kf-marken { display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* ─── Liste + Detail ─── */
.kf-teilung { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; min-width: 0; }
.kf-liste-bereich { min-width: 0; }
.kf-liste-kopf { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 4px 8px; min-width: 0; }
.kf-liste-titel { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; color: var(--text-primary); }
.kf-liste-zahl { font-size: 12px; color: var(--text-secondary); text-align: right; }

.kf-liste {
  background: var(--bg-secondary); border: 1px solid var(--border-secondary); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); min-width: 0;
}
.kf-liste[aria-busy="true"] .kf-zeilen { opacity: .55; transition: opacity .2s ease; }
.kf-zeilen { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.kf-zeilen > li { animation: kf-auf .28s ease both; }
.kf-zeilen > li:nth-child(2) { animation-delay: .02s; }
.kf-zeilen > li:nth-child(3) { animation-delay: .04s; }
.kf-zeilen > li:nth-child(4) { animation-delay: .06s; }
.kf-zeilen > li:nth-child(n+5) { animation-delay: .08s; }
.kf-zeile {
  display: flex; flex-direction: column; gap: 5px; width: 100%; min-width: 0; padding: 11px 12px;
  border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--text-primary);
  font-family: var(--font-family); text-align: left; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.kf-zeile:hover { background: var(--bg-primary); }
.kf-zeile:focus-visible { outline: 2px solid var(--almas-red-hover); outline-offset: -2px; }
.kf-zeile.is-aktiv { background: var(--almas-red-light); border-color: var(--almas-red-border); }
.kf-zeile.is-aktiv .kf-zeile-titel { color: var(--almas-red-hover); }
.kf-zeile-oben { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.kf-zeile-oben .kf-grund { display: inline-block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.kf-zeile-alter { flex: 0 0 auto; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.kf-zeile-titel { font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kf-zeile-unter { display: flex; justify-content: space-between; gap: 10px; min-width: 0; font-size: 13px; color: var(--text-secondary); }
.kf-zeile-bezug { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kf-zeile-betrag { flex: 0 0 auto; font-weight: 600; color: var(--text-primary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.kf-zeile-fuss { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.kf-gesellschaft {
  padding: 2px 8px; border-radius: 999px; background: var(--bg-tertiary);
  font-size: 11.5px; font-weight: 600; color: var(--text-secondary); white-space: nowrap;
}
.kf-mehr { padding: 6px 12px 12px; text-align: center; }
.kf-leer { padding: 36px 20px; }
.kf-leer p { margin: 0 auto 12px; color: var(--text-secondary); }
.kf-laedt { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 36px 20px; color: var(--text-secondary); font-size: 14px; }

.kf-detail {
  min-width: 0; background: var(--bg-secondary); border: 1px solid var(--border-secondary);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.kf-detail-leer { padding: 48px 24px; text-align: center; color: var(--text-secondary); font-size: 14px; }
.kf-detail-leer p { margin: 0; }
.kf-detail-fehler { padding: 24px; font-size: 14px; }
.kf-detail-fehler p { margin: 8px 0 12px; overflow-wrap: anywhere; }
.kf-detail-inhalt { padding: 20px 24px 8px; animation: kf-blende .25s ease both; }
/* Stilles Aktualisieren gescheitert: Detail bleibt stehen, Hinweis darüber */
.kf-aktual-fehler {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 4px 0 14px; padding: 10px 12px;
  border-radius: 10px; font-size: 13px; line-height: 1.45; color: #C20F1C;
  background: var(--almas-red-light); border: 1px solid var(--almas-red-border);
}
.kf-aktual-fehler p { margin: 0; min-width: 0; flex: 1 1 240px; overflow-wrap: anywhere; }
.kf-aktual-fehler .almas-btn { flex: 0 0 auto; }

@media (min-width: 1025px) {
  .kf-teilung { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
  .kf-detail {
    position: sticky; top: calc(var(--header-height, 56px) + 16px);
    max-height: calc(100vh - var(--header-height, 56px) - 32px); overflow-y: auto; overscroll-behavior: contain;
  }
}
@media (min-width: 1360px) {
  .kf-teilung { grid-template-columns: minmax(300px, 370px) minmax(0, 1fr); }
}

/* Kopf des Details */
.kf-dk { padding-bottom: 14px; }
.kf-zurueck { display: none; align-items: center; gap: 4px; margin: -4px 0 10px -8px; }
.kf-dk-plaketten { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kf-dk-titel { margin: 10px 0 4px; font-size: 20px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; color: var(--text-primary); overflow-wrap: anywhere; }
.kf-dk-titel:focus { outline: none; }
.kf-dk-titel:focus-visible { outline: 2px solid var(--almas-red-hover); outline-offset: 3px; border-radius: 4px; }
.kf-dk-meta { margin: 0 0 8px; font-size: 13px; color: var(--text-secondary); }

/* Abschnitte (keine Karten in Karten: Trennlinien statt Rahmen) */
.kf-abschnitt { padding: 16px 0; border-top: 1px solid var(--border-secondary); min-width: 0; }
.kf-abschnitt h4 {
  margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary);
}
.kf-abschnitt.kf-todo { border-top: 0; margin: 2px 0 14px; padding: 14px 16px; background: var(--bg-primary); border-radius: 14px; }
.kf-todo-text { margin: 0 0 6px; font-size: 15px; font-weight: 600; line-height: 1.45; color: var(--text-primary); }
.kf-todo-detail { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text-secondary); overflow-wrap: anywhere; }
.kf-todo-stand { margin: 10px 0 0; font-size: 13.5px; line-height: 1.5; }
.kf-todo-erledigt .kf-todo-stand { margin: 0 0 6px; font-size: 14px; }
/* Rückfrage eines Freigebers (BA 5 WP5.4): Frage und Antwort mehrzeilig wie eingegeben */
.kf-rueckfrage { margin: 8px 0 0; min-width: 0; }
.kf-rueckfrage-kopf { margin: 10px 0 4px; font-size: 13px; line-height: 1.4; color: var(--text-primary); }
.kf-rueckfrage-kopf:first-child { margin-top: 0; }
.kf-rueckfrage-text {
  margin: 0; padding: 10px 12px; font-size: 14px; line-height: 1.55; color: var(--text-primary);
  background: var(--bg-secondary); border: 1px solid var(--border-primary); border-radius: 10px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.kf-rueckfrage-antwort { border-color: var(--almas-red-border); }

/* Aktionen */
.kf-aktion-knoepfe { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.kf-aktion { display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
.kf-aktion .almas-btn { min-height: 36px; }
.kf-aktion-stand { margin: 0 0 10px; }
.kf-aktion-hinweis { max-width: 240px; font-size: 12px; line-height: 1.35; color: var(--text-secondary); }
.kf .almas-btn.is-offen { box-shadow: 0 0 0 3px var(--almas-red-light), inset 0 0 0 1px var(--almas-red-border); }
.kf .almas-btn:disabled, .qu .almas-btn:disabled { box-shadow: none; }
.kf .almas-btn:focus-visible, .qu .almas-btn:focus-visible, .kf-dialog .almas-btn:focus-visible { outline: 2px solid var(--almas-red-hover); outline-offset: 2px; }

/* Bestätigungsschritt: keine Karte in der Detail-Karte – abgesetzt nur durch eine Trennlinie darüber. */
.kf-form-rahmen {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border-secondary); animation: kf-auf .22s ease both;
}
.kf-form { min-width: 0; }
.kf-form-titel { margin: 0 0 8px; font-size: 15px; font-weight: 700; color: var(--text-primary); }
.kf-form-titel:focus { outline: none; }
.kf-form-erkl { margin: 0 0 12px; font-size: 13.5px; line-height: 1.5; color: var(--text-secondary); }
.kf-form .almas-form-group { margin-bottom: 12px; min-width: 0; }
.kf-form .almas-form-group label { font-weight: 600; color: var(--text-primary); }
.kf-form .almas-input, .kf-form .almas-textarea, .kf-form .almas-select { background: #fff; }
.kf-feld-hilfe { margin: 5px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--text-secondary); }
.kf-felder-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 12px; }
.kf-felder-2 .kf-feld-breit { grid-column: 1 / -1; }
.kf-keine-mail {
  display: inline-block; margin: 2px 0 0; padding: 7px 12px; border-radius: 10px;
  background: rgba(0, 122, 255, .08); color: #0057B8; font-size: 13px;
}
.kf-lernen { margin: 4px 0 0; }
.kf-form-fehler {
  margin: 10px 0 0; padding: 9px 12px; border-radius: 10px; font-size: 13px; line-height: 1.45;
  color: #C20F1C; background: var(--almas-red-light); border: 1px solid var(--almas-red-border); overflow-wrap: anywhere;
}
.kf-form-fehler[hidden] { display: none; }
.kf-form-knoepfe { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.kf-form-knoepfe .almas-btn { min-height: 36px; }

/* Auswahl (Radio) als ruhige Optionen */
.kf-wahl { margin: 0 0 12px; padding: 0; border: 0; min-width: 0; }
.kf-wahl legend { margin-bottom: 8px; padding: 0; font-size: 13px; font-weight: 600; color: var(--text-primary); }
.kf-wahl-quer { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.kf-wahl-quer .kf-wahl-option { margin-bottom: 0; }
/* Optionen als ruhige Zeilen (kein Rahmen, keine Karte): Auswahl zeigt der Radioknopf plus zarte Tönung. */
.kf-wahl-option {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 4px; padding: 9px 10px;
  background: transparent; border: 0; border-radius: 10px; cursor: pointer;
  transition: background-color .2s ease;
}
.kf-wahl-option:hover { background: var(--bg-primary); }
.kf-wahl-option:has(input:checked) { background: var(--almas-red-light); }
.kf-wahl-option:has(input:checked) .kf-wahl-titel { color: var(--almas-red-hover); }
.kf-wahl-option:has(input:focus-visible) { outline: 2px solid var(--almas-red-hover); outline-offset: 2px; }
.kf-wahl-option input { flex: 0 0 auto; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--almas-red-hover); }
.kf-wahl-option.is-gesperrt { cursor: not-allowed; opacity: .65; }
.kf-wahl-text { min-width: 0; }
.kf-wahl-titel { display: block; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.kf-wahl-satz { display: block; margin-top: 2px; font-size: 13px; line-height: 1.45; color: var(--text-secondary); }
.kf-wahl-sperre { color: #8A5A00; }

/* „Schalter“-Umschalter */
.kf-switch-zeile { margin: 4px 0 8px; }
.kf-switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.kf-switch input { position: absolute; left: 0; top: 50%; width: 44px; height: 26px; margin: -13px 0 0; opacity: 0; cursor: pointer; }
.kf-switch-bahn { position: relative; flex: 0 0 auto; width: 44px; height: 26px; border-radius: 999px; background: #CFD0D6; transition: background-color .2s ease; }
.kf-switch-bahn::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(16, 17, 22, .25); transition: transform .2s ease;
}
.kf-switch input:checked + .kf-switch-bahn { background: var(--almas-red-hover); }
.kf-switch input:checked + .kf-switch-bahn::after { transform: translateX(18px); }
.kf-switch input:focus-visible + .kf-switch-bahn { outline: 2px solid var(--almas-red-hover); outline-offset: 2px; }

/* Personen-Vorschläge, Schnellwahl, Suchtreffer */
.kf-person { position: relative; }
.kf-schnell { display: flex; min-width: 0; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.kf-vorschlaege {
  position: absolute; left: 0; right: 0; z-index: 30; margin: 4px 0 0; padding: 4px; list-style: none;
  max-height: 260px; overflow: auto; background: #fff; border: 1px solid var(--border-secondary);
  border-radius: 12px; box-shadow: var(--shadow-lg);
}
.kf-vorschlaege[hidden] { display: none; }
.kf-vorschlag {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; padding: 8px 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text-primary);
  font: 14px var(--font-family); text-align: left; cursor: pointer;
}
.kf-vorschlag:hover, .kf-vorschlag:focus-visible { background: var(--bg-tertiary); outline: none; }
.kf-vorschlag-name { font-weight: 600; }
.kf-treffer { min-width: 0; }
.kf-treffer > p { margin: 6px 0 0; }
.kf-treffer-liste { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.kf-treffer-liste { gap: 0; }
.kf-treffer-liste li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0;
  padding: 8px 4px; border-bottom: 1px solid var(--border-secondary); font-size: 13.5px;
}
.kf-treffer-liste li:last-child { border-bottom: 0; }
.kf-treffer-liste li > span { min-width: 0; overflow-wrap: anywhere; }
.kf-treffer-liste li .almas-btn { flex: 0 0 auto; }
.kf-treffer-liste li.is-gewaehlt { padding-left: 10px; padding-right: 10px; border-radius: 10px; background: var(--almas-red-light); border-bottom-color: transparent; }
.kf-gewaehlt { margin: 8px 0 0; font-size: 13px; color: var(--text-secondary); }
.kf-gewaehlt strong { color: var(--text-primary); }
.kf-entscheidung {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.5;
  background: rgba(253, 196, 0, .14);
}
.kf-entscheidung p { margin: 0; }
.kf-entscheidung .kf-treffer-liste { margin-top: 10px; }
/* Entscheidung nach „abwesend“: je Wahl ein Knopf und ein Satz, was sie bewirkt */
.kf-entscheid-liste { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.kf-entscheid-option { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.kf-entscheid-option .almas-btn { max-width: 100%; min-height: 36px; white-space: normal; text-align: left; overflow-wrap: anywhere; }
.kf-entscheid-satz { max-width: 68ch; min-width: 0; font-size: 13px; line-height: 1.45; color: var(--text-secondary); overflow-wrap: anywhere; }
.kf-form-fehler:focus { outline: none; }
.kf-form-fehler:focus-visible { outline: 2px solid var(--almas-red-hover); outline-offset: 2px; }
.kf-form-hinweis { margin: 10px 0 0; padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.45; color: #0057B8; background: rgba(0, 122, 255, .08); }
.kf-form-hinweis[hidden] { display: none; }
.kf-form-hinweis { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.kf-form-hinweis > span { min-width: 0; flex: 1 1 220px; }
.kf-form-hinweis:focus-visible { outline: 2px solid #0057B8; outline-offset: 2px; }
.kf-form-hinweis-knopf { flex: 0 0 auto; max-width: 100%; white-space: normal; text-align: left; }

/* PDF aufteilen: Vorschau der Teile */
.kf-teile { min-width: 0; }
.kf-teile-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.kf-teile-liste li {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; padding: 6px 0;
  border-bottom: 1px solid var(--border-secondary); font-size: 13.5px;
}
.kf-teile-liste li:last-child { border-bottom: 0; }
.kf-teile-liste li .almas-btn { margin-left: auto; }
.kf-teil-name { min-width: 54px; font-weight: 700; }
.kf-teile-fehler { margin: 6px 0 0; font-size: 13px; color: #C20F1C; }
.kf-teile-ok { margin: 6px 0 0; font-size: 13px; color: #147A3D; }

/* Ergebnis einer Aktion */
.kf-ergebnis {
  margin: 4px 0 14px; padding: 12px 14px; border-radius: 14px;
  background: rgba(52, 199, 89, .12); animation: kf-auf .25s ease both;
}
.kf-ergebnis:focus { outline: none; }
.kf-ergebnis:focus-visible { outline: 2px solid #147A3D; outline-offset: 2px; }
.kf-ergebnis-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kf-ergebnis-text { margin: 2px 0 0; font-size: 14px; color: #0F5E2F; overflow-wrap: anywhere; }
.kf-ergebnis-hinweise { margin: 6px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.5; color: var(--text-primary); }
.kf-ergebnis > .almas-btn { margin-top: 10px; }
.kf-ergebnis-zu { flex: 0 0 auto; padding: 4px 6px; min-height: 28px; }
.kf-folge { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(20, 122, 61, .18); }

/* Original */
.kf-dateien { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; min-width: 0; }
.kf-datei {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: 100%; min-width: 0;
  padding: 8px 12px; background: #fff; border: 1px solid var(--border-secondary); border-radius: 12px;
  font-family: var(--font-family); text-align: left; cursor: pointer; transition: border-color .2s ease, background-color .2s ease;
}
.kf-datei:hover { border-color: var(--border-primary); }
.kf-datei.is-aktiv { background: var(--almas-red-light); border-color: var(--almas-red-border); }
.kf-datei-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.kf-datei-info { font-size: 12px; color: var(--text-secondary); }
.kf-datei-warnung { color: #C20F1C; font-weight: 600; }
.kf-ansicht { min-width: 0; }
.kf-ansicht-leiste { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; min-width: 0; }
.kf-ansicht-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; font-weight: 600; }
.kf-ansicht-name > span:first-of-type { overflow-wrap: anywhere; }
.kf-ansicht-knoepfe { display: flex; flex-wrap: wrap; gap: 6px; }
.kf-ansicht-pdf {
  display: block; width: 100%; height: min(78vh, 920px); min-height: 420px;
  background: var(--bg-tertiary); border: 1px solid var(--border-secondary); border-radius: 12px;
}
.kf-ansicht-bildrahmen { padding: 8px; text-align: center; background: var(--bg-tertiary); border: 1px solid var(--border-secondary); border-radius: 12px; }
.kf-ansicht-bild { max-width: 100%; height: auto; max-height: 78vh; border-radius: 8px; }
.kf-ansicht-text {
  margin: 0; max-height: 60vh; overflow: auto; padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere;
  background: #FAFAFB; border: 1px solid var(--border-secondary); border-radius: 12px;
  font: 12.5px/1.55 var(--font-mono); color: var(--text-primary);
}
.kf-ansicht-text:focus-visible { outline: 2px solid var(--almas-red-hover); outline-offset: 2px; }
.kf-ansicht-notiz { margin: 0 0 8px; font-size: 12.5px; color: var(--text-secondary); }
.kf-ansicht-hinweis { padding: 16px; font-size: 13.5px; line-height: 1.5; background: var(--bg-primary); border-radius: 12px; }
.kf-ansicht-hinweis p { margin: 0 0 8px; overflow-wrap: anywhere; }
.kf-ansicht-warnung, .kf-ansicht-fehler { background: var(--almas-red-light); }
.kf-ansicht-laedt { display: flex; align-items: center; gap: 10px; padding: 24px; font-size: 14px; color: var(--text-secondary); }
.kf-ansicht-status { margin: 8px 0 0; }

/* Ausgelesene Daten */
.kf-tabelle-rahmen { max-width: 100%; overflow-x: auto; }
.kf-datentabelle { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kf-datentabelle th, .kf-datentabelle td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border-secondary); overflow-wrap: anywhere; }
.kf-datentabelle thead th { background: var(--bg-primary); font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.kf-datentabelle tbody th { width: 28%; font-weight: 500; color: var(--text-secondary); }
.kf-datentabelle tbody tr:last-child th, .kf-datentabelle tbody tr:last-child td { border-bottom: 0; }
.kf-abweichung { background: rgba(0, 122, 255, .04); }
.kf-tabelle-rahmen + .kf-leise, .kf-dl + .kf-leise { margin: 8px 0 0; }
.kf-feldmarke { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; vertical-align: 1px; }
.kf-feldmarke-neutral { background: rgba(142, 142, 147, .14); color: var(--text-secondary); }
.kf-feldmarke-warning { background: rgba(255, 149, 0, .12); color: #8A5A00; }
.kf-feldmarke-info { background: rgba(0, 122, 255, .08); color: #0057B8; }

/* Definitionslisten (Erkennung, Lieferant, Mail) */
.kf-dl { margin: 0; }
.kf-dl-zeile {
  display: grid; grid-template-columns: minmax(110px, 28%) minmax(0, 1fr); gap: 12px; padding: 7px 0;
  border-bottom: 1px solid var(--border-secondary); font-size: 13.5px;
}
.kf-dl-zeile:last-child { border-bottom: 0; }
.kf-dl dt { font-weight: 500; color: var(--text-secondary); }
.kf-dl dd { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; margin: 0; overflow-wrap: anywhere; }
.kf-dl-warum { font-size: 12.5px; line-height: 1.45; color: var(--text-secondary); }

.kf-bank { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.kf-bank li { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
.kf-iban { font-family: var(--font-mono); font-size: 13px; letter-spacing: .02em; overflow-wrap: anywhere; }

.kf-verwandte { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.kf-verwandt {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; padding: 8px 10px;
  background: #fff; border: 1px solid var(--border-secondary); border-radius: 10px;
  font: 13.5px var(--font-family); color: var(--text-primary); text-align: left; cursor: pointer;
}
.kf-verwandt:hover { border-color: var(--border-primary); background: var(--bg-primary); }

.kf-verlauf { list-style: none; margin: 0; padding: 0; }
.kf-verlauf li {
  display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 7px 0;
  border-bottom: 1px solid var(--border-secondary); font-size: 13px;
}
.kf-verlauf li:last-child { border-bottom: 0; }
.kf-verlauf-zeit { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.kf-verlauf-text { min-width: 0; overflow-wrap: anywhere; }
.kf-verlauf-aenderung { display: block; margin-top: 2px; color: var(--text-secondary); }
.kf-alt { text-decoration: line-through; text-decoration-color: rgba(194, 15, 28, .5); }

/* Filter nicht angewendet (Ladefehler beim Filterwechsel) */
.kf-filter-fehler {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 6px 6px 4px; padding: 10px 12px;
  border-radius: 12px; background: var(--almas-red-light); font-size: 13px; line-height: 1.45; color: #9E0C17;
}
.kf-filter-fehler p { flex: 1 1 260px; min-width: 0; margin: 0; overflow-wrap: anywhere; }

/* Kein Recht / nicht eingerichtet */
.kf-sperre { max-width: 640px; padding: 28px; }
.kf-sperre h2 { margin: 0 0 8px; font-size: 18px; letter-spacing: -.01em; }
.kf-sperre p { margin: 0 0 6px; color: var(--text-secondary); line-height: 1.5; }

/* ─── Quarantäne ─── */
.qu-werkzeuge .kf-werkzeuge-zeile { justify-content: space-between; }
.qu-erkl { flex: 1 1 320px; min-width: 0; margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
#quErgebnis:empty { display: none; }
#quErgebnis:focus { outline: none; }
#quErgebnis:focus-visible .kf-ergebnis { outline: 2px solid #147A3D; outline-offset: 2px; }
/* Zeilen sind nur per Programm fokussierbar (nach „Weitere laden“: erste neue Zeile) */
.qu-tabelle tbody tr:focus { outline: none; }
.qu-tabelle tbody tr:focus-visible { outline: 2px solid var(--almas-red-hover); outline-offset: -2px; }
.qu-tabelle-rahmen { min-width: 0; }
.qu-tabelle td { vertical-align: top; font-size: 13.5px; }
.qu-tabelle td > span { display: block; }
.qu-tabelle td > .almas-badge { display: inline-flex; }
.qu-tabelle td > .kf-marke { margin-top: 4px; }
.qu-absender { font-weight: 600; overflow-wrap: anywhere; }
.qu-betreff { margin-top: 2px; font-size: 13px; color: var(--text-secondary); overflow-wrap: anywhere; }
.qu-datei { overflow-wrap: anywhere; }
.qu-typ { margin-top: 2px; }
.qu-aktionen { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; min-width: 220px; max-width: 330px; margin-left: auto; }
.qu-tabelle th { color: var(--text-secondary); } /* AA: .almas-table th nimmt --text-tertiary (#8A8D94 auf Weiß 3,3:1) – wie lieferanten.css */
.qu-tabelle td[data-label="Lange Aufbewahrung"], .qu-seit-datum { white-space: nowrap; }
.qu-tabelle td[data-label="Seit"] { min-width: 150px; }
.qu-tabelle td[data-label="Datei"] { max-width: 220px; }
.qu-tabelle tr.is-offen > td { background: var(--bg-primary); }
.qu-bestaetigen-zeile > td { padding: 0 16px 16px !important; background: var(--bg-primary); }
.qu-bestaetigen { padding: 14px 16px; background: #fff; border: 1px solid var(--border-secondary); border-radius: 12px; animation: kf-auf .2s ease both; }
.qu-bestaetigen h3 { margin: 0 0 6px; font-size: 15px; }
.qu-bestaetigen h3:focus { outline: none; }
.qu-bestaetigen p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text-secondary); }
.qu .kf-mehr { padding: 14px 0 0; }

/* Unter 1280 px: Einträge als Karten statt Tabelle (sechs Spalten passen nicht mehr) */
@media (max-width: 1280px) {
  .qu-tabelle-rahmen { overflow: visible; background: transparent; border: 0; box-shadow: none; }
  .qu-tabelle, .qu-tabelle tbody, .qu-tabelle tr, .qu-tabelle td { display: block; width: 100%; min-width: 0 !important; }
  .qu-tabelle { min-width: 0 !important; }
  .qu-tabelle thead { display: none; }
  .qu-tabelle tbody { display: flex; flex-direction: column; gap: 10px; }
  .qu-tabelle tbody tr {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 16px; padding: 14px 16px;
    background: var(--bg-secondary); border: 1px solid var(--border-secondary); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  }
  .qu-tabelle tbody tr:hover { background: var(--bg-secondary); }
  .qu-tabelle tbody td { padding: 0 !important; border: 0 !important; }
  .qu-tabelle tbody td::before {
    content: attr(data-label); display: block; margin-bottom: 3px; font-size: 11.5px; font-weight: 600; color: var(--text-secondary);
  }
  .qu-tabelle tbody td[data-label="Absender / Betreff"] { grid-column: span 2; }
  .qu-tabelle .qu-aktionen-zelle { grid-column: 1 / -1; padding-top: 4px !important; border-top: 1px solid var(--border-secondary) !important; }
  .qu-tabelle .qu-aktionen-zelle::before { display: none; }
  .qu-aktionen { justify-content: flex-start; min-width: 0; max-width: none; margin-left: 0; padding-top: 8px; }
  .qu-tabelle td[data-label="Datei"] { max-width: none; }
  .qu-tabelle tr.is-offen { border-color: var(--almas-red-border); }
  .qu-tabelle tr.is-offen > td { background: transparent; }
  .qu-tabelle tbody tr.qu-bestaetigen-zeile { display: block; margin-top: -4px; padding: 0; background: transparent; border: 0; box-shadow: none; }
  .qu-bestaetigen-zeile > td { padding: 0 !important; background: transparent; }
  .qu-bestaetigen-zeile > td::before { display: none !important; }
}

/* ─── Dialog „Original ansehen“ ─── */
.kf-dialog-waechter { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.kf-dialog { display: flex; flex-direction: column; width: 100%; max-width: min(1040px, 100%); max-height: 92vh; padding: 16px 20px 20px; }
.kf-dialog-kopf { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; min-width: 0; }
.almas-modal .kf-dialog-kopf h2, .kf-dialog-kopf h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; min-width: 0; overflow-wrap: anywhere; }
.kf-dialog-zu { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.kf-dialog-ansicht { flex: 1 1 auto; min-height: 0; overflow: auto; }
.kf-dialog .kf-ansicht-pdf { height: 72vh; }

/* ─── Schmal: Liste und Detail untereinander ─── */
@media (max-width: 1024px) {
  .kf-zurueck { display: inline-flex; }
  .kf-detail:has(.kf-detail-leer) { display: none; }
  .kf-detail { scroll-margin-top: calc(var(--header-height, 56px) + 12px); }
  /* Platzhalter so hoch wie der Schirm: der Sprung zum Detail landet schon beim Laden an der richtigen Stelle. */
  .kf-detail > .kf-laedt { min-height: calc(100vh - var(--header-height, 56px) - 24px); align-items: flex-start; padding-top: 48px; }
  .kf-suche { max-width: none; }
}
@media (max-width: 640px) {
  .kf-detail-inhalt { padding: 16px 16px 4px; }
  .kf-dk-titel { font-size: 18px; }
  .kf-dl-zeile { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kf-verlauf li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kf-datentabelle tbody th { width: 36%; }
  .kf-ansicht-pdf { min-height: 360px; height: 65vh; }
  .kf-suche { flex-basis: 100%; min-width: 0; }
  .kf-schalter { flex: 0 1 auto; }
  .kf-aktion-hinweis { max-width: none; }
  .qu-tabelle tbody td[data-label="Absender / Betreff"] { grid-column: auto; }
  .kf-dialog { padding: 14px; }
}

/* ─── Touch (Tablet/iPad meldet sich als Desktop): jedes Tippziel mindestens 44 px hoch ─── */
@media (pointer: coarse) {
  .kf-schalter-knopf, .kf-chip, .kf-chip-klein, .kf-zurueck,
  .kf .almas-btn, .qu .almas-btn, .kf-dialog .almas-btn,
  .kf-aktion .almas-btn, .kf-form-knoepfe .almas-btn, .kf-entscheid-option .almas-btn,
  .qu-aktionen .almas-btn, .qu-bestaetigen .almas-btn,
  .kf-ergebnis-zu, .kf-form-hinweis-knopf, .kf-dialog-zu,
  .kf-datei, .kf-vorschlag, .kf-verwandt, .kf-wahl-option, .kf-switch {
    min-height: 44px;
  }
  /* Text senkrecht mittig; „Zur Liste“ bleibt ab 1025 px ausgeblendet, [hidden] bleibt verborgen. */
  .kf .almas-btn:not(.kf-zurueck):not([hidden]), .qu .almas-btn:not([hidden]), .kf-dialog .almas-btn:not([hidden]) { display: inline-flex; align-items: center; justify-content: center; }
  .kf-zurueck { margin: -6px 0 8px -8px; }
  .kf-datei, .kf-vorschlag, .kf-verwandt { justify-content: center; }
  .kf .almas-input, .kf .almas-select, .qu .almas-input, .qu .almas-select,
  .kf-suche .almas-input { min-height: 44px; }
  .kf-schalter { gap: 4px; }
  .kf-gruende, .qu-aktionen, .kf-dateien { gap: 8px; }
}

/* ─── Bewegung ─── */
@keyframes kf-auf { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes kf-blende { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .kf *, .qu *, .kf-dialog-overlay, .kf-dialog, .kf-dialog * { animation: none !important; transition: none !important; }
  .kf .almas-spinner, .qu .almas-spinner, .kf-dialog .almas-spinner { animation: almas-spin 1.6s linear infinite !important; }
}
