/* ============================================================================
   Eventures Cockpit – Komponentenbibliothek.
   Nutzt ausschließlich Tokens aus tokens.css. Keine hart codierten Farben/Größen.
   ============================================================================ */

/* Roboto lokal (kein CDN). Variable woff2 (Gewicht 100–900) unter /static/fonts/ –
   fehlt die Datei, greift der Fallback aus --font-sans. Siehe fonts/README.md. */
@font-face {
  font-family: "Roboto"; font-style: normal; font-weight: 100 900;
  font-display: swap; src: url("/static/fonts/Roboto-roman.var.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto"; font-style: italic; font-weight: 100 900;
  font-display: swap; src: url("/static/fonts/Roboto-italic.var.woff2") format("woff2");
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body); line-height: var(--lh-body);
  background: var(--bg-seite); color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primaer); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); font-weight: var(--fw-bold); margin: 0 0 var(--sp-4); letter-spacing: -0.01em; }
h2 { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: var(--fw-semibold); margin: 0 0 var(--sp-3); }
h3 { font-size: var(--fs-small); line-height: var(--lh-small); font-weight: var(--fw-semibold); margin: 0 0 var(--sp-2); text-transform: none; color: var(--text); }

/* ================================================================= App-Shell */
.icon { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: middle; }

/* --- Sidebar --- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-breite); z-index: 40;
  background: var(--flaeche); border-right: 1px solid var(--rand);
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-marke {
  display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-4);
  font-weight: var(--fw-bold); font-size: var(--fs-h3); color: var(--text);
  border-bottom: 1px solid var(--rand); position: sticky; top: 0; background: var(--flaeche);
}
.sidebar-marke:hover { text-decoration: none; }
.sidebar-marke img { height: 30px; width: auto; }
.sidebar-nav { padding: var(--sp-3) var(--sp-2); display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex; align-items: center; gap: var(--sp-3); padding: 0.55rem 0.7rem;
  border-radius: var(--radius-s); color: var(--text-sek); font-size: var(--fs-small);
  font-weight: var(--fw-medium); white-space: nowrap;
}
.nav-link:hover { background: var(--flaeche-2); color: var(--text); text-decoration: none; }
.nav-link.aktiv { background: var(--primaer-weich); color: var(--primaer-dunkel); font-weight: var(--fw-semibold); }
.nav-link.aktiv .icon { color: var(--primaer); }
.nav-link .icon { color: var(--text-schwach); }
.nav-link.aktiv .icon, .nav-link:hover .icon { color: inherit; }
.nav-link .nav-badge { margin-left: auto; }

/* Gruppen (aufklappbar) */
.nav-gruppe { margin-bottom: 2px; }
.nav-gruppe > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--sp-3);
  padding: 0.55rem 0.7rem; border-radius: var(--radius-s); color: var(--text-sek);
  font-size: var(--fs-small); font-weight: var(--fw-semibold);
}
.nav-gruppe > summary::-webkit-details-marker { display: none; }
.nav-gruppe > summary:hover { background: var(--flaeche-2); color: var(--text); }
.nav-gruppe > summary .icon:first-child { color: var(--text-schwach); }
.nav-gruppe > summary .txt { flex: 1; }
.nav-gruppe > summary .icon:last-child { width: 16px; height: 16px; transition: transform 0.15s; color: var(--text-schwach); }
.nav-gruppe[open] > summary .icon:last-child { transform: rotate(180deg); }
.nav-gruppe .nav-link { margin-left: 0.8rem; padding-left: 0.9rem; }
.nav-badge { background: var(--fehler); color: #fff; font-size: 11px; font-weight: var(--fw-semibold); border-radius: var(--radius-pill); padding: 0.05rem 0.4rem; min-width: 1.1rem; text-align: center; }
.nav-trenner { height: 1px; background: var(--rand); margin: var(--sp-2) var(--sp-2); }

/* --- Topbar --- */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-breite); right: 0; height: var(--topbar-hoehe); z-index: 30;
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--flaeche); border-bottom: 1px solid var(--rand); padding: 0 var(--sp-4);
}
.burger { display: none; cursor: pointer; padding: 0.35rem; border-radius: var(--radius-s); color: var(--text-sek); }
.burger:hover { background: var(--flaeche-2); }
.topbar-suche { flex: 1; max-width: 460px; display: flex; align-items: center; gap: var(--sp-2); background: var(--flaeche-2); border: 1px solid var(--rand); border-radius: var(--radius-pill); padding: 0.35rem 0.8rem; }
.topbar-suche .icon { color: var(--text-schwach); width: 18px; height: 18px; }
.topbar-suche input { flex: 1; border: none; background: transparent; padding: 0.2rem 0; font-size: var(--fs-small); }
.topbar-suche input:focus { outline: none; box-shadow: none; }
.topbar-icon { position: relative; margin-left: auto; color: var(--text-sek); padding: 0.4rem; border-radius: var(--radius-s); display: inline-flex; }
.topbar-icon:hover { background: var(--flaeche-2); color: var(--text); }
.topbar-icon .punkt { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--fehler); border: 2px solid var(--flaeche); }

/* Benutzer-Menü */
.benutzer-menue { position: relative; }
.benutzer-menue > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--sp-2); padding: 0.3rem 0.4rem; border-radius: var(--radius-s); }
.benutzer-menue > summary::-webkit-details-marker { display: none; }
.benutzer-menue > summary:hover { background: var(--flaeche-2); }
.benutzer-menue .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primaer); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: var(--fw-semibold); font-size: var(--fs-small); }
.benutzer-menue .name-rolle { display: flex; flex-direction: column; line-height: 1.15; }
.benutzer-menue .name { font-size: var(--fs-small); font-weight: var(--fw-semibold); color: var(--text); }
.benutzer-menue .rolle { font-size: var(--fs-caption); color: var(--text-sek); text-transform: capitalize; }
.benutzer-menue > summary .icon { width: 16px; height: 16px; color: var(--text-schwach); }
.menue-panel { position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); box-shadow: var(--schatten-l); padding: var(--sp-1); z-index: 50; }
.menue-panel a { display: flex; align-items: center; gap: var(--sp-2); padding: 0.5rem 0.6rem; border-radius: var(--radius-s); color: var(--text); font-size: var(--fs-small); }
.menue-panel a:hover { background: var(--flaeche-2); text-decoration: none; }
.menue-panel a.abmelden { color: var(--fehler); }
.abmelden { color: var(--fehler); }
.nav-backdrop { display: none; }

/* --- Inhaltsbereich --- */
main.mit-shell { margin-left: var(--sidebar-breite); padding: calc(var(--topbar-hoehe) + var(--sp-5)) var(--sp-5) var(--sp-6); max-width: calc(var(--sidebar-breite) + var(--inhalt-max)); }
main.ohne-shell { max-width: var(--inhalt-max); margin: var(--sp-5) auto; padding: 0 var(--sp-4); }

/* --- Ladebalken beim Bereichswechsel (htmx) ---
   Zeigt oben am Rand, dass die neue Ansicht unterwegs ist. Bewusst dezent,
   kein Overlay, damit die alte Ansicht bedienbar bleibt. */
.ladebalken { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; background: var(--primaer-weich); overflow: hidden; }
.ladebalken::after {
  content: ""; display: block; height: 100%; width: 40%;
  background: var(--primaer); animation: ladebalken-lauf 0.9s ease-in-out infinite;
}
@keyframes ladebalken-lauf {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
@media (prefers-reduced-motion: reduce) {
  .ladebalken::after { animation: none; width: 100%; opacity: 0.5; }
}

/* --- Untere Tab-Leiste (nur mobil/Tablet) ---
   Fünf Ziele; „Mehr“ öffnet dieselbe Sidebar wie der Burger. Auf Desktop
   ausgeblendet, dort führt die Sidebar. Touch-Ziele mindestens 44px hoch. */
.tableiste { display: none; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 44px; padding: var(--sp-1) var(--sp-1) var(--sp-2);
  color: var(--text-sek); font-size: var(--fs-caption); line-height: var(--lh-caption);
  text-decoration: none; cursor: pointer; position: relative;
}
.tab:hover { text-decoration: none; color: var(--text); }
.tab .icon { color: var(--text-schwach); width: 22px; height: 22px; }
.tab.aktiv { color: var(--primaer-dunkel); font-weight: var(--fw-semibold); }
.tab.aktiv .icon { color: var(--primaer); }
.tab .nav-badge { position: absolute; top: 2px; left: 50%; margin-left: 4px; }

/* --- Responsive: Sidebar off-canvas per Burger + untere Tab-Leiste --- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--schatten-l); }
  .nav-umschalter:checked ~ .sidebar { transform: none; }
  .nav-umschalter:checked ~ .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,20,30,0.4); z-index: 35; }
  .topbar { left: 0; }
  .burger { display: inline-flex; }
  /* Unten zusätzlich Platz für die Tab-Leiste freihalten. */
  main.mit-shell { margin-left: 0; padding: calc(var(--topbar-hoehe) + var(--sp-4)) var(--sp-4) calc(56px + var(--sp-5)); }
  .benutzer-menue .name-rolle { display: none; }
  .tableiste {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--flaeche); border-top: 1px solid var(--rand);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

/* ------------------------------------------------------ Bestätigungsdialog */
/* Rückfrage vor folgenreichen Aktionen; ersetzt confirm(). Liegt über dem
   Dokument-Overlay, weil er aus ihm heraus geöffnet werden kann. */
/* z-index über dem Dokument-Overlay (1000), weil die Rückfrage aus ihm heraus
   geöffnet wird und sonst dahinter verschwindet. */
.bestaetigung { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
/* Muss sein: das display:flex oben gewinnt sonst gegen das hidden-Attribut,
   und der Dialog stünde dauerhaft auf jeder Seite. */
.bestaetigung[hidden] { display: none; }
.bestaetigung-bg { position: absolute; inset: 0; background: rgba(15, 20, 30, 0.45); }
.bestaetigung-panel {
  position: relative; background: var(--flaeche); border-radius: var(--radius-l);
  box-shadow: var(--schatten-overlay); padding: var(--sp-5);
  max-width: 440px; width: 100%;
}
.bestaetigung-panel h2 { margin: 0 0 var(--sp-2); font-size: var(--fs-h3); line-height: var(--lh-h3); }
.bestaetigung-panel p { margin: 0; color: var(--text-sek); }
.bestaetigung-panel .aktionsleiste { justify-content: flex-end; margin-top: var(--sp-4); }

/* Seite hinter einem offenen Dialog nicht mitscrollen. */
body.overlay-offen { overflow: hidden; }

/* Kopfzeile des Dokument-Overlays: Titel links, Betrag rechts daneben. */
.dok-ov-titel { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; }
.dok-ov-betrag { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: var(--fw-semibold); white-space: nowrap; }
.dok-ov-zusammenfassung { padding: 0 var(--sp-4); }

/* --------------------------------------------------- Seitenkopf & Werkzeuge */
/* Titel links, genau eine Hauptaktion rechts. Mobil untereinander. */
.seiten-kopf { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.seiten-kopf h1 { margin: 0; }

.werkzeugleiste { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); margin-bottom: var(--sp-3); flex-wrap: wrap; }

/* Segment-Umschalter (z. B. Tabelle/Karten): zwei bis drei gleichwertige
   Optionen, von denen genau eine aktiv ist. */
.segment { display: inline-flex; border: 1px solid var(--rand); border-radius: var(--radius-s); overflow: hidden; background: var(--flaeche); }
.segment > a {
  padding: 0.4rem 0.8rem; font-size: var(--fs-small); color: var(--text-sek);
  text-decoration: none; min-height: 36px; display: inline-flex; align-items: center;
}
.segment > a + a { border-left: 1px solid var(--rand); }
.segment > a:hover { background: var(--flaeche-2); color: var(--text); text-decoration: none; }
.segment > a.aktiv { background: var(--primaer-weich); color: var(--primaer-dunkel); font-weight: var(--fw-semibold); }

/* --------------------------------------------------------- Dokument-Karten */
/* Kartenansicht der Dokumentliste – mobil statt der breiten Tabelle. */
.dok-karten { display: flex; flex-direction: column; gap: var(--sp-3); }
.dok-karte {
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius);
  box-shadow: var(--schatten-s); padding: var(--sp-3); cursor: pointer;
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.dok-karte:hover { border-color: var(--primaer); }
.dok-karte:focus-visible { outline: none; box-shadow: var(--fokus-ring); }
/* Hohe Priorität: linker roter Rand, wie in der Tabelle die Zeile. */
.dok-karte.hoch { border-left: 3px solid var(--fehler); }
.dok-karte-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-2); }
.dok-karte-fuss { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* Klickbare Tabellenzeile (öffnet das Dokument-Overlay). */
tr.js-dok { cursor: pointer; }

/* --------------------------------------------------------------- Filterleiste */
.filter { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-4); align-items: center; }
.schmal { width: 150px; min-width: 0; }
.eingabe-name { width: 220px; max-width: 100%; }
/* Aktionsleiste: Formular-Buttons/Selects nebeneinander innerhalb einer Karte. */
.aktionsleiste { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-top: var(--sp-3); }
/* Gestapelte Auswahlliste (Checkboxen untereinander, z. B. Rollen/Mandanten). */
.checkliste { margin-top: var(--sp-2); }
.checkliste label { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-small); padding: 2px 0; }
.rollen-chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
/* Eingebettete Detail-/Vergleichsfläche innerhalb einer Karte (dezent abgesetzt). */
.karte-innen { background: var(--flaeche-2); border: 1px solid var(--rand); border-radius: var(--radius); padding: var(--sp-3); margin-top: var(--sp-3); }
.karte-innen table { background: transparent; }
/* Schlüssel-Wert-Tabelle (Label links, Wert rechts) – kein Großbuchstaben-Kopf. */
.kv-tabelle th { text-transform: none; letter-spacing: 0; background: transparent; color: var(--text-sek); font-weight: var(--fw-semibold); white-space: nowrap; width: 1%; }

/* --------------------------------------------------------------- Formularfelder */
input, select, textarea {
  font-family: inherit; font-size: var(--fs-small); color: var(--text);
  padding: 0.5rem 0.65rem; border: 1px solid var(--rand); border-radius: var(--radius-s);
  background: var(--flaeche); transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primaer); box-shadow: var(--fokus-ring); }
input[type=search] { min-width: 220px; }
textarea { line-height: var(--lh-small); }
label { font-size: var(--fs-small); }

.feld { margin-bottom: var(--sp-4); }
.feld label { display: block; font-weight: var(--fw-semibold); margin-bottom: var(--sp-1); font-size: var(--fs-small); }
.feld input, .feld select, .feld textarea { width: 100%; max-width: 440px; }
.inline-form { display: inline; }

/* ------------------------------------------------------------------- Buttons */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 0.5rem 0.9rem; border: 1px solid var(--rand); border-radius: var(--radius-s);
  background: var(--flaeche); cursor: pointer; font-family: inherit;
  font-size: var(--fs-small); font-weight: var(--fw-medium); color: var(--text);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
  text-decoration: none; line-height: 1.2;
}
button:hover, .btn:hover { border-color: var(--rand-stark); background: var(--flaeche-2); text-decoration: none; }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--fokus-ring); }
button.primaer, .btn.primaer { background: var(--primaer); color: #fff; border-color: var(--primaer); }
button.primaer:hover, .btn.primaer:hover { background: var(--primaer-dunkel); border-color: var(--primaer-dunkel); }
button.gefahr, .btn.gefahr { background: var(--fehler); color: #fff; border-color: var(--fehler); }
button.gefahr:hover, .btn.gefahr:hover { opacity: 0.92; background: var(--fehler); }
.btn.text, button.text { background: transparent; border-color: transparent; color: var(--primaer); padding: 0.4rem 0.5rem; }
.btn.text:hover, button.text:hover { background: var(--primaer-weich); }

/* ------------------------------------------------------------ Karten & Tabellen */
.karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius-l); padding: var(--sp-4); margin-bottom: var(--sp-4); box-shadow: var(--schatten); }
/* Kartenkopf: Überschrift links, Aktion rechts. */
.karte-kopf { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.karte-kopf h2, .karte-kopf h3 { margin: 0; }
.karte-kopf .filter { margin: 0; }

.tabelle-wrap { overflow-x: auto; border-radius: var(--radius-l); }
table { width: 100%; border-collapse: collapse; background: var(--flaeche); }
.karte table { background: transparent; }
th, td { text-align: left; padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--rand); vertical-align: top; }
th { background: var(--flaeche-2); font-size: var(--fs-caption); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-sek); font-weight: var(--fw-semibold); }
th a { color: inherit; }
tbody tr:hover { background: var(--flaeche-2); }
tr:last-child td { border-bottom: none; }
tr.hoch { box-shadow: inset 3px 0 0 var(--fehler); }
tr.hoch:hover { background: var(--fehler-weich); }
/* Dichte Variante für spaltenreiche Dokumenttabellen (kompaktere Abstände). */
.tabelle-dicht th, .tabelle-dicht td { padding: 0.55rem 0.55rem; }

/* ----------------------------------------------- Dokument-Listen (Posteingang …) */
/* Kopfzeile einer Dokumentzeile: Typ/Richtung/Prio als Chips nebeneinander. */
.dok-kopf { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; margin-bottom: var(--sp-1); }
.dok-absender { font-weight: var(--fw-medium); color: var(--text); }
.dok-meta { color: var(--text-sek); font-size: var(--fs-caption); margin-top: 2px; }
/* Lange KI-Zusammenfassung auf zwei Zeilen begrenzen, damit die Spalte nicht ausufert. */
.dok-zusammenfassung {
  color: var(--text-sek); font-size: var(--fs-small); margin-top: var(--sp-1); max-width: 42ch;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.zell-betrag { text-align: right; font-weight: var(--fw-semibold); white-space: nowrap; }
.zell-pruefung { font-size: var(--fs-small); }
.zell-pruefung select { max-width: 128px; }
.zell-pruefung .buchhaltung-status { margin-top: var(--sp-1); }

/* --------------------------------------------------------- Badges, Chips, Ampel */
.badge, .chip {
  display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill); font-size: var(--fs-caption); font-weight: var(--fw-medium);
  background: var(--flaeche-2); color: var(--text-sek); white-space: nowrap; border: 1px solid var(--rand);
}
.badge.info,  .chip.info  { background: var(--info-weich);   color: var(--primaer-dunkel); border-color: transparent; }
.badge.gruen, .badge.pnr-ok, .badge.erfolg { background: var(--erfolg-weich); color: var(--erfolg); border-color: transparent; }
.badge.gelb,  .badge.warnung { background: var(--warnung-weich); color: var(--warnung-text); border-color: transparent; }
.badge.hoch,  .badge.rot, .badge.fehler { background: var(--fehler-weich); color: var(--fehler); border-color: transparent; }

.ampel { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; box-shadow: 0 0 0 3px rgba(0,0,0,0.03); }
.ampel.gruen { background: var(--erfolg); }
.ampel.gelb { background: var(--warnung); }
.ampel.rot { background: var(--fehler); }
.ampel.grau { background: var(--text-schwach); }
.status-text.grau { color: var(--text-sek); }
.status-text.gruen { color: var(--erfolg); }
.status-text.gelb { color: var(--warnung-text); }
.status-text.rot { color: var(--fehler); }

/* -------------------------------------------------------------- Alerts/Hinweise */
.alert, .fehler, .hinweis {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: 0.7rem 0.9rem; border-radius: var(--radius); margin-bottom: var(--sp-4);
  font-size: var(--fs-small); border: 1px solid transparent;
}
.fehler, .alert.fehler { background: var(--fehler-weich); color: var(--fehler); border-color: rgba(220,38,38,0.25); }
.hinweis, .alert.erfolg { background: var(--erfolg-weich); color: var(--erfolg); border-color: rgba(22,163,74,0.25); }
.alert.info { background: var(--info-weich); color: var(--primaer-dunkel); border-color: rgba(0,159,227,0.25); }
.alert.warnung { background: var(--warnung-weich); color: var(--warnung-text); border-color: rgba(245,158,11,0.3); }
.alert .schliessen { margin-left: auto; background: transparent; border: none; color: inherit; cursor: pointer; padding: 0 0.2rem; font-size: 1rem; line-height: 1; }

/* ------------------------------------------------------------- Stat-Karten (KPI) */
.stat-reihe { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-4); }
.stat { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius-l); padding: var(--sp-4); box-shadow: var(--schatten); }
.stat .stat-label { font-size: var(--fs-small); color: var(--text-sek); margin-bottom: var(--sp-1); }
.stat .stat-zahl { font-size: var(--fs-h1); line-height: 1.1; font-weight: var(--fw-bold); letter-spacing: -0.02em; }
.stat .stat-delta { font-size: var(--fs-caption); color: var(--text-sek); margin-top: var(--sp-1); }
.stat.fehler .stat-zahl { color: var(--fehler); }
.stat.warnung .stat-zahl { color: var(--warnung-text); }
.stat.erfolg .stat-zahl { color: var(--erfolg); }

/* ------------------------------------------------------------- Toggle-Schalter */
.toggle { position: relative; display: inline-flex; align-items: center; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .spur { width: 38px; height: 22px; border-radius: var(--radius-pill); background: var(--rand-stark); transition: background 0.15s; }
.toggle .spur::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: var(--schatten-s); }
.toggle input:checked + .spur { background: var(--primaer); }
.toggle input:checked + .spur::after { transform: translateX(16px); }

/* -------------------------------------------------------------- Fortschritt */
.fortschritt { height: 8px; border-radius: var(--radius-pill); background: var(--flaeche-2); overflow: hidden; border: 1px solid var(--rand); }
.fortschritt > span { display: block; height: 100%; background: var(--primaer); }
.fortschritt-wrap { max-width: 180px; margin-bottom: var(--sp-1); }
.fortschritt.gruen > span { background: var(--erfolg); }
.fortschritt.gelb > span { background: var(--warnung); }
.fortschritt.rot > span { background: var(--fehler); }

/* --------------------------------------------------------------- Leer-Zustand */
.leer-zustand { text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--text-sek); }
.leer-zustand .icon { font-size: 2rem; margin-bottom: var(--sp-2); opacity: 0.7; }
.leer { color: var(--text-sek); text-align: center; padding: var(--sp-5); }

/* ------------------------------------------------------------------ Skeleton */
.skeleton { border-radius: var(--radius-s); background: linear-gradient(90deg, var(--flaeche-2) 25%, #eef0f3 37%, var(--flaeche-2) 63%); background-size: 400% 100%; animation: skeleton 1.4s ease infinite; min-height: 1rem; }
@keyframes skeleton { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* --------------------------------------------------------------- Hilfsklassen */
.klein { font-size: var(--fs-small); color: var(--text-sek); }
.rechts { text-align: right; }

/* -------------------------------------------------------------- Upload-Dropzone */
.dropzone { border: 2px dashed var(--rand-stark); border-radius: var(--radius-l); padding: var(--sp-6) var(--sp-4); text-align: center; cursor: pointer; background: var(--flaeche-2); transition: border-color 0.15s, background 0.15s; }
.dropzone.aktiv { border-color: var(--primaer); background: var(--primaer-weich); }
.dropzone p { margin: var(--sp-1) 0; }
.dropzone .icon { width: 36px; height: 36px; color: var(--primaer); margin-bottom: var(--sp-2); }
.dateiliste { margin: var(--sp-3) 0; color: var(--text-sek); }
.dateiliste:empty { display: none; }

/* --------------------------------------------------------------- PDF-Vorschau */
.pdf-vorschau { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius-l); overflow: hidden; box-shadow: var(--schatten); }
.pdf-vorschau iframe { width: 100%; height: calc(100vh - 200px); min-height: 480px; border: 0; display: block; }

/* --------------------------------------------------------------- Archiv-Explorer */
.brotkrumen { margin-bottom: var(--sp-4); color: var(--text-sek); }
.brotkrumen span { color: var(--text-schwach); margin: 0 var(--sp-1); }
.archiv-gitter { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-3); }
.karte.ordner { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: 0; padding: 0.8rem 1rem; }
/* Anschlusszeile unter einer Tabellenzeile (z. B. „Neu zuordnen") – ohne oberen Abstand. */
.zelle-anschluss { padding-top: 0; }
.karte.ordner:hover { border-color: var(--primaer); box-shadow: var(--schatten-l); }
.ordner-name { font-weight: var(--fw-semibold); }

/* ------------------------------------------------------- Login (self-contained) */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.login-box { width: 100%; max-width: 400px; }
.login-marke { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.login-marke img { height: 44px; width: auto; }
.login-marke .app-name { font-size: var(--fs-h2); font-weight: var(--fw-bold); letter-spacing: -0.01em; }
.login-box .karte { padding: var(--sp-5); }
.login-box input { width: 100%; margin-bottom: var(--sp-3); }
.login-box button { width: 100%; }
.login-fuss { text-align: center; margin-top: var(--sp-4); color: var(--text-schwach); font-size: var(--fs-caption); }
.block-btn { display: block; width: 100%; text-align: center; padding: 0.7rem; }

/* ------------------------------------------------- Dokument-Vorschau-Overlay */
.dok-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.dok-overlay[hidden] { display: none; }
.dok-overlay-bg { position: absolute; inset: 0; background: rgba(15, 20, 30, 0.55); }
.dok-overlay-panel {
  position: relative; background: var(--flaeche); border-radius: var(--radius-l);
  width: min(1000px, 94vw); height: min(92vh, 900px);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--schatten-overlay);
}
.dok-overlay-x { position: absolute; top: 8px; right: 10px; z-index: 2; background: transparent; border: none; font-size: 1.1rem; line-height: 1; padding: 0.3rem 0.5rem; cursor: pointer; color: var(--text-sek); border-radius: var(--radius-s); }
.dok-overlay-x:hover { background: var(--flaeche-2); color: var(--text); }
#dok-overlay-inhalt { display: flex; flex-direction: column; height: 100%; }
.dok-ov-kopf { display: flex; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; align-items: center; padding: 0.85rem 2.6rem 0.7rem 1rem; border-bottom: 1px solid var(--rand); }
.dok-ov-aktionen { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.dok-ov-neuzuordnen, .dok-ov-kommentare { padding: 0.7rem 1rem; border-bottom: 1px solid var(--rand); background: var(--flaeche-2); }
.dok-ov-kommentare { max-height: 40%; overflow-y: auto; }
.dok-ov-kommentare .kommentar { padding: 0.35rem 0; border-bottom: 1px solid var(--rand); }
.dok-ov-kommentare .kommentar:last-of-type { border-bottom: none; }
.kommentar-symbol { color: var(--text-sek); white-space: nowrap; }
/* Unveränderbarkeit: Fassungen und Content-Hash am Dokument (Archiv-Kern) */
.dok-ov-revision { padding: var(--sp-2) var(--sp-4); border-bottom: 1px solid var(--rand); }
.dok-ov-revision summary { cursor: pointer; color: var(--text-sek); }
.dok-ov-versionen { list-style: none; margin: var(--sp-2) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.dok-ov-hash { font-family: var(--font-mono); font-size: var(--fs-caption); line-height: var(--lh-caption); color: var(--text-schwach); word-break: break-all; }
.dok-ov-pdf { flex: 1; min-height: 0; background: var(--flaeche-2); }
.dok-ov-pdf iframe { width: 100%; height: 100%; border: none; display: block; }

/* Projektnummer-Inline-Editor */
.pnr-form { display: inline-flex; gap: var(--sp-1); align-items: center; margin: 0; }
.pnr-form input[type="text"] { padding: 0.2rem 0.4rem; font-size: var(--fs-caption); width: 6.5rem; }
.pnr-form button { padding: 0.25rem 0.5rem; font-size: var(--fs-caption); line-height: 1; }

@media (max-width: 640px) {
  .topbar-suche { max-width: none; }
  th, td { padding: 0.55rem 0.5rem; font-size: var(--fs-small); }
  .stat-reihe { grid-template-columns: 1fr 1fr; }
}

/* --- Strecke (Stationen eines Vorgangs, Onboarding Personal) ------------- */
/* Waagerechte Stationsanzeige: erledigt / aktuell / offen. Bewusst als eigene
   Komponente, damit spätere Vorgangsarten (Freelancer, Vertrag) sie mitnutzen. */
.strecke {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  list-style: none;
  margin: 0 0 var(--sp-4);
  padding: 0;
}
.strecke li {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--rand);
  border-radius: var(--radius-pill);
  background: var(--flaeche);
  color: var(--text-schwach);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
}
.strecke li .nr {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-pill);
  background: var(--flaeche-2);
  color: var(--text-sek);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
}
.strecke li.erledigt {
  border-color: var(--erfolg);
  background: var(--erfolg-weich);
  color: var(--text);
}
.strecke li.erledigt .nr { background: var(--erfolg); color: var(--karte); }
.strecke li.aktuell {
  border-color: var(--primaer);
  background: var(--primaer-weich);
  color: var(--text);
  font-weight: var(--fw-semibold);
}
.strecke li.aktuell .nr { background: var(--primaer); color: var(--karte); }
.strecke li.abgebrochen {
  border-color: var(--fehler);
  background: var(--fehler-weich);
  color: var(--text);
}

/* Feld mit Fehlermeldung im Formular (serverseitige Prüfung) */
.feld.hat-fehler input,
.feld.hat-fehler select { border-color: var(--fehler); }
.feld .feld-fehler {
  display: block;
  margin-top: var(--sp-1);
  color: var(--fehler);
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
}
.feld .feld-hinweis {
  display: block;
  margin-top: var(--sp-1);
  color: var(--text-schwach);
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
}
.feld .freiwillig-marke {
  margin-left: var(--sp-1);
  color: var(--text-schwach);
  font-size: var(--fs-caption);
  font-weight: var(--fw-regular);
}

/* Wiederholgruppe (Kinder, weitere Beschäftigungen) */
.gruppe-zeile {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: flex-end;
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--rand);
}
.gruppe-zeile:last-child { border-bottom: 0; }
.gruppe-zeile .feld { flex: 1 1 12rem; margin-bottom: 0; }

/* --- Öffentliche Seiten (Kandidaten-Fragebogen, ohne Login) --------------- */
/* Eigene Hülle statt der Dashboard-Sidebar: wer nicht angemeldet ist, sieht
   nur den Inhalt. Breiter als .login-box, weil der Fragebogen lang ist. */
.oeffentlich-shell {
  max-width: 46rem;
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-7);
}
.oeffentlich-shell.schmal { max-width: 30rem; }
.oeffentlich-shell h1 {
  font-size: var(--fs-h1);
  line-height: var(--lh-h1);
  margin: 0 0 var(--sp-3);
}
.oeffentlich-marke {
  display: flex;
  justify-content: center;
  margin-bottom: var(--sp-5);
}
.oeffentlich-marke img { height: 2.5rem; }
.oeffentlich-fuss {
  margin-top: var(--sp-5);
  color: var(--text-schwach);
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  text-align: center;
}

/* Einmalige Anzeige eines Links, der nicht gemailt werden konnte.
   Umbruch erzwingen, damit der lange Token nicht aus der Karte läuft. */
.link-anzeige {
  margin-top: var(--sp-2);
  padding: var(--sp-2);
  border-radius: var(--radius-s);
  background: var(--flaeche-2);
  font-size: var(--fs-caption);
  overflow-wrap: anywhere;
  word-break: break-all;
}

/* Vorschau eines erzeugten Dokuments (Vertragsgenerator).
   Papierähnliche Fläche, damit erkennbar ist: so sieht das PDF aus. */
.dokument-vorschau {
  max-height: 28rem;
  overflow-y: auto;
  padding: var(--sp-4);
  border: 1px solid var(--rand);
  border-radius: var(--radius-s);
  background: var(--karte);
  font-size: var(--fs-small);
  line-height: var(--lh-body);
}
.dokument-vorschau h1 { font-size: var(--fs-h3); margin: 0 0 var(--sp-3); }
.dokument-vorschau h2 { font-size: var(--fs-body); margin: var(--sp-4) 0 var(--sp-2); }
.dokument-vorschau h3 { font-size: var(--fs-body); margin: var(--sp-3) 0 var(--sp-1); }
.dokument-vorschau p { margin: 0 0 var(--sp-2); }
.dokument-vorschau ul { margin: 0 0 var(--sp-2) var(--sp-4); }

/* Formularzeile: Eingabefeld und Knopf nebeneinander, umbruchfähig.
   Ersetzt die wiederholten Inline-Styles
   (display:flex; gap; flex-wrap; align-items) in den Admin-Ansichten –
   Regel aus .claude/rules/oberflaeche.md: wiederkehrende Muster gehören als
   Klasse hierher, nicht als Attribut ins Template. */
.formzeile {
  display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center;
}
.formzeile input[type="text"],
.formzeile input[type="number"],
.formzeile select { flex: 1 1 14rem; min-width: 0; }
/* Bestätigungsfelder ("Namen eintippen") brauchen Platz, sollen aber die
   Zeile auf schmalen Geräten nicht sprengen. */
.formzeile .bestaetigungsfeld { flex: 1 1 16rem; max-width: 22rem; }
/* Kurze Werte (Zahlen, Schwellwerte) in Tabellenzellen. */
.formzeile .feld-schmal { flex: 0 1 7rem; }

/* Nachgeordnete Angabe (wer zuletzt geändert hat, Zeitstempel in Tabellen). */
.text-schwach { color: var(--text-schwach); }

/* Mehrzeiliges Eingabefeld für technische Inhalte (Wissensmodule, Vorlagen):
   Festbreitenschrift, damit Einrückungen und Tabellen im Text stimmen. */
.feld-mono {
  width: 100%; font-family: var(--font-mono);
  font-size: var(--fs-small); line-height: var(--lh-small);
}

/* ============================================ Tabellen als Karten (schmal)
   Unter 700 px wird jede beschriftete Tabelle zur Liste von Karten: eine Karte
   je Zeile, in ihr je Wert eine Zeile "Spaltenname: Wert". Das ersetzt das
   seitliche Scrollen, bei dem man Werte ohne ihre Überschrift sah.

   Die Spaltennamen setzt static/tabellen.js automatisch aus der Kopfzeile als
   data-spalte – deshalb muss kein Template angefasst werden und keine künftige
   Spalte daran denken. Ohne JavaScript greift diese Darstellung nicht und es
   bleibt beim Scrollen: unbequemer, aber vollständig. */
@media (max-width: 700px) {
  .tabelle-karten,
  .tabelle-karten tbody,
  .tabelle-karten tr,
  .tabelle-karten td { display: block; width: auto; }

  /* Die Kopfzeile wird zur Beschriftung IN den Zellen – hier verschwindet sie.
     Nicht display:none für Screenreader-Nutzer? Doch: Der Name steht über
     data-spalte im Textfluss jeder Zelle, geht also nicht verloren. */
  .tabelle-karten thead { display: none; }

  .tabelle-karten tr {
    background: var(--flaeche);
    border: 1px solid var(--rand); border-radius: var(--radius);
    box-shadow: var(--schatten-s);
    padding: var(--sp-2); margin-bottom: var(--sp-3);
  }
  .tabelle-karten tr:hover { background: var(--flaeche); }

  .tabelle-karten td {
    border-bottom: none; padding: var(--sp-1) 0;
    display: flex; gap: var(--sp-3); align-items: baseline;
  }
  /* Zellen ohne Spaltennamen (Aktions-Spalten) stehen für sich. */
  .tabelle-karten td[data-spalte]::before {
    content: attr(data-spalte);
    flex: 0 0 40%;
    color: var(--text-sek); font-size: var(--fs-caption);
    font-weight: var(--fw-semibold); text-transform: uppercase;
    letter-spacing: 0.04em; line-height: var(--lh-body);
  }
  /* Beträge stehen in der Kartenansicht links wie alles andere – rechtsbündig
     ergäbe ohne Spaltenraster kein Bild. */
  .tabelle-karten .zell-betrag { text-align: left; }
  /* Der Rahmen der Karte ersetzt den Rahmen der Tabellenhülle. */
  .tabelle-wrap { overflow-x: visible; }
}

/* Vorformatierter Textblock (gelernte Regeln, Prompt-Auszüge). Bricht um,
   statt die Karte in die Breite zu ziehen. */
.textblock {
  white-space: pre-wrap; word-break: break-word; margin: 0;
  padding: var(--sp-3); border-radius: var(--radius-s);
  background: var(--flaeche-2); border: 1px solid var(--rand);
  font-family: var(--font-mono); font-size: var(--fs-small);
  line-height: var(--lh-small); color: var(--text);
}

/* Geänderter Wert in einer Gegenüberstellung alt/neu (Prüfschritt der
   Selbstauskunft). Bei zwanzig Feldern soll niemand suchen müssen, was sich
   tatsächlich unterscheidet. */
.zell-geaendert {
  background: var(--warnung-weich);
  font-weight: var(--fw-semibold);
}

/* ================================================== Versions- und Umgebungsecke
   Klein unten in der Ecke auf jeder Seite (CLAUDE.md: sichtbare Versionsnummer).
   Im Testsystem wird dieselbe Ecke zum farbigen Banner – der Roadmap-Eintrag
   dockt die Umgebungs-Kennzeichnung ausdrücklich hier an, statt einen eigenen
   Streifen über das Layout zu legen.
   z-index über der Sidebar (40), aber unter Overlay (1000) und Rückfrage (1100):
   Die Ecke soll nie einen Dialog verdecken, den jemand gerade bestätigen will. */
.umgebungsecke {
  position: fixed; left: var(--sp-3); bottom: var(--sp-3); z-index: 45;
  display: inline-flex; align-items: baseline; gap: var(--sp-2);
  max-width: calc(100vw - 2 * var(--sp-3));
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--rand); border-radius: var(--radius-pill);
  background: var(--flaeche); color: var(--text-schwach);
  font-size: var(--fs-caption); line-height: var(--lh-caption);
  box-shadow: var(--schatten-s);
  pointer-events: none;   /* rein informativ – verdeckt keinen Klick */
}
.umgebungsecke-kennzeichen { letter-spacing: 0.04em; text-transform: uppercase; }
.umgebungsecke-hinweis { color: inherit; }

/* Testsystem: warnfarbig und fett. Bewusst auffällig – die reale Gefahr ist,
   Live für Test zu halten, nicht umgekehrt. */
.umgebungsecke.test {
  background: var(--warnung-weich); border-color: var(--warnung);
  color: var(--warnung-text); font-weight: var(--fw-semibold);
  box-shadow: var(--schatten);
}

@media (max-width: 900px) {
  /* Über der unteren Tab-Leiste bleiben (dieselben 56px wie im Innenabstand
     von main.mit-shell); ohne Anmeldung gibt es keine Tab-Leiste. */
  .umgebungsecke.mit-shell { bottom: calc(56px + var(--sp-2)); }
  /* Auf schmalen Geräten nur die Kurzform, sonst wird die Ecke zum Block. */
  .umgebungsecke .umgebungsecke-hinweis { display: none; }
}

/* Vertraulichkeitsmarke am Dokument (Personal-Trennblatt). Marke, Lösen-Knopf
   und Hinweistext stehen in einer Zeile und dürfen auf schmalen Geräten
   umbrechen, statt die Kopfzeile des Overlays zu sprengen. */
.vertraulich-toggle {
  display: inline-flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
}

/* ------------------------------------------------- Vertragsgenerator: Bausteine
   Ein Vertrag hat über hundert Bausteine. Ohne sichtbare Gliederung ist der
   Editor eine Wüste aus gleich aussehenden Kästen; die Einrückung zeigt, was
   Paragraf und was Absatz ist. */
.baustein-ebene-1 { border-left: 3px solid var(--primaer); }
.baustein-ebene-2 { margin-left: var(--sp-5); border-left: 1px solid var(--rand-stark); }

/* Drei schmale Felder nebeneinander (Ebene, Auswahlart, Reihenfolge). */
.feld-reihe { display: flex; flex-wrap: wrap; gap: var(--sp-4); }
.feld-reihe .feld { flex: 1 1 180px; margin-bottom: var(--sp-3); }
.feld-reihe .feld input, .feld-reihe .feld select { max-width: none; }

/* Ankreuzfeld mit nachgestelltem Hinweistext. */
.feld-schalter label { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: var(--fw-medium); }
.feld-schalter input { width: auto; }

/* --------------------------------------------- Klauselauswahl beim Erstellen */
.klauselwahl {
  border: 1px solid var(--rand); border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4);
  background: var(--flaeche-2);
}
.klauselwahl legend { font-weight: var(--fw-semibold); font-size: var(--fs-small); padding: 0 var(--sp-2); }
.klausel {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: var(--sp-1) 0; font-size: var(--fs-small); line-height: var(--lh-small);
}
.klausel input { width: auto; margin-top: 3px; flex: none; }
.klausel-gruppe { color: var(--text-sek); font-weight: var(--fw-semibold); }
