:root {
  --primary: #303093;
  --primary-dark: #24246e;
  --primary-light: #eef0fd;
  --secondary: #6B7280;
  --bg: #F8F9FA;
  --border: #e5e7eb;
  --danger: #b91c1c;
  --success: #166534;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: #1f2937;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* --- Kopfzeile --- */
.topbar { background: linear-gradient(180deg, var(--primary), var(--primary-dark)); color: #fff; }
.topbar-inner {
  max-width: 1000px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px 16px;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; text-decoration: none; color: inherit; }
.topbar-brand:hover { opacity: 0.92; }
.brand-logo { height: 32px; width: auto; border-radius: 4px; display: block; flex-shrink: 0; }
.brand { font-weight: 600; font-size: 1.05rem; letter-spacing: 0.01em; }
.brand-sub { color: #c7c8e8; font-size: 0.88rem; }
.topbar-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.logout-form { margin: 0; }

.content { flex: 1; max-width: 1000px; margin: 0 auto; padding: 32px 20px; width: 100%; }
.footer { color: var(--secondary); font-size: 0.8rem; text-align: center; padding: 18px 16px; }
.footer p { margin: 4px 0; }
.footer-rechtliches a { color: var(--secondary); text-decoration: underline; }
.footer-rechtliches a:hover { color: #374151; }

/* --- Karten --- */
.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; max-width: 420px; margin: 24px auto;
  box-shadow: var(--shadow);
}
.card h1 { font-size: 1.3rem; margin: 0 0 6px; color: var(--primary); line-height: 1.3; }
.card h2 { line-height: 1.3; }
.card p.hint { color: var(--secondary); font-size: 0.9rem; margin-top: 0; }

.card-wide { max-width: 940px; }
.card-vorschau { max-width: 1040px; }

/* --- Formulare --- */
label { display: block; font-size: 0.88rem; font-weight: 600; margin: 14px 0 5px; color: #374151; }
input[type=email], input[type=password], input[type=text], input[type=number] {
  width: 100%; padding: 11px 12px; border: 1px solid #d1d5db; border-radius: 7px;
  font-size: 1rem; background: #fff; color: #1f2937;
}
select {
  width: 100%; padding: 11px 12px; border: 1px solid #d1d5db; border-radius: 7px;
  font-size: 1rem; background: #fff; color: #1f2937;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary);
}
input[type=file] {
  width: 100%; padding: 10px 12px; border: 1px dashed #c7c9d1; border-radius: 7px;
  font-size: 0.95rem; background: #fbfbfc;
}

/* Groessere, deutlich erkennbare Ablagezone fuer Datei-Uploads. Kein JavaScript noetig:
   moderne Browser nehmen Dateien, die per Drag+Drop auf ein input[type=file] gezogen werden,
   automatisch in dessen Dateiliste auf - dieselbe Zone dient also gleichzeitig als Klick-Ziel
   fuer den nativen Dateidialog. */
.dropfeld {
  border: 2px dashed #b9bdf0; border-radius: 10px; background: var(--primary-light);
  padding: 42px 14px; margin-top: 6px; text-align: center;
  min-height: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.dropfeld input[type=file] {
  border: none; background: transparent; padding: 4px 0; margin: 0 auto; text-align: center;
}
.dropfeld-hinweis { display: block; font-size: 0.78rem; color: #57606f; margin-top: 10px; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 7px; cursor: pointer;
  font-size: 0.98rem; font-weight: 500; padding: 11px 18px; margin-top: 18px;
  text-decoration: none; text-align: center; box-sizing: border-box;
  min-height: 42px; line-height: 1.2;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: transparent; color: #fff; border: 1px solid #ffffff5c; font-size: 0.85rem; padding: 7px 13px; margin: 0; min-height: 34px; }
.btn-secondary:hover { background: #ffffff22; }

/* Sekundaerer Button auf weissem Hintergrund (z. B. "Herunterladen" in Tabellen) */
.btn-secondary-outline { background: #fff; color: #374151; border: 1px solid #d1d5db; }
.btn-secondary-outline:hover { background: #f3f4f6; border-color: #c1c5cc; }

/* Abbrechen-Link im Bestaetigungsdialog */
.btn-cancel { display: block; background: transparent; color: var(--secondary); border: 1px solid #d1d5db; width: 100%; margin-top: 12px; }
.btn-cancel:hover { background: #f3f4f6; }

/* Kleine Buttons in Tabellenzeilen: kein Vollbreiten-Layout */
.btn-small { width: auto; padding: 8px 14px; font-size: 0.85rem; margin-top: 0; min-height: 36px; }

.alert { border-radius: 8px; padding: 12px 14px; font-size: 0.9rem; margin: 14px 0 0; border: 1px solid transparent; }
.alert-error { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border-color: #bbf7d0; }

/* Dezenter Hinweis-/Nudge-Kasten (z. B. "jetzt erstes Steuerjahr anlegen") - bewusst kein
   alert-error/-success, da es keine Fehler-/Erfolgsmeldung ist, sondern eine Handlungsempfehlung. */
.hinweisbox {
  background: var(--primary-light); border: 1px solid #c7cbf5; border-left: 4px solid var(--primary);
  border-radius: 8px; padding: 14px 16px; margin: 16px 0; font-size: 0.9rem; color: #303050;
}
.hinweisbox strong { display: block; color: var(--primary); margin-bottom: 3px; }
.hinweisbox a { color: var(--primary); font-weight: 600; text-decoration: none; margin-left: 4px; white-space: nowrap; }
.hinweisbox a:hover { text-decoration: underline; }

.linkrow { margin-top: 18px; font-size: 0.88rem; }
/* :not(.btn) verhindert, dass ein in .linkrow verpackter Button (z. B. "Neues Mandat
   anlegen") seine weisse Schrift verliert - .linkrow a haette sonst durch die hoehere
   Selektor-Spezifitaet Vorrang vor .btn-primary { color: #fff }. */
.linkrow a:not(.btn) { color: var(--primary); text-decoration: none; }
.linkrow a:not(.btn):hover { text-decoration: underline; }
.linkrow.breadcrumb { margin-top: 0; margin-bottom: 4px; color: var(--secondary); }
.code-input { letter-spacing: 0.4em; text-align: center; font-size: 1.3rem; }

/* --- Jahresordner, Dateiliste, Upload --- */
.section-title {
  font-size: 1.02rem; color: var(--primary); margin: 30px 0 10px;
  border-top: 1px solid var(--border); padding-top: 22px;
  font-weight: 600;
}

/* Haken-Icon-Badge, u. a. in der "Als fertig melden"-Leiste unten. */
.icon-abschluss {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 999px;
  background: #dcfce7; color: var(--success);
  display: flex; align-items: center; justify-content: center;
}
.icon-haken { width: 16px; height: 16px; }

/* "Als fertig melden"-Leiste: direkt oben auf der Seite (kein Scrollen noetig) UND beim
   Scrollen weiterhin sichtbar (position: sticky, rein CSS-basiert, kein JavaScript). */
.abschluss-leiste {
  position: sticky; top: 10px; z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #dcfce7; border: 1px solid #bbf7d0; border-radius: 8px;
  padding: 10px 14px; margin: 4px 0 22px;
  box-shadow: var(--shadow);
}
.abschluss-leiste .icon-abschluss { background: #fff; }
.abschluss-text { flex: 1; min-width: 140px; font-size: 0.88rem; font-weight: 500; color: #14532d; }
.abschluss-leiste .btn { margin-top: 0; }

/* Nur fuer Screenreader sichtbar - z. B. das Suchfeld-Label, dessen Zweck visuell schon
   durch Platzhaltertext/Icon klar ist und daher keinen sichtbaren Text braucht. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.status {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 600; background: var(--primary-light); color: var(--primary);
  white-space: nowrap;
}
.status-offen { background: var(--primary-light); color: var(--primary); }
.status-gemeldet { background: #fef9c3; color: #854d0e; }
.status-in_bearbeitung { background: #dbeafe; color: #1e40af; }
.status-abgeschlossen { background: #dcfce7; color: var(--success); }

/* Kontostatus (users.status) - eigene Klassen, damit sie sich nicht mit Ordnerstatus ueberschneiden */
.status-eingeladen { background: #f3f4f6; color: #57606f; }
.status-aktiv { background: #dcfce7; color: var(--success); }
.status-gesperrt { background: #fef2f2; color: var(--danger); }
.status-inaktiv { background: #f3f4f6; color: #57606f; }

/* Hervorhebung, z. B. Anzahl gemeldeter Ordner > 0 im Dashboard */
.hervorhebung { color: var(--danger); font-weight: 700; }

/* Formular mit mehreren Feldern nebeneinander (z. B. Mandant anlegen, Jahresordner anlegen) */
.formular-zeile { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.formular-zeile > div { flex: 1; min-width: 180px; }
.formular-zeile .btn { margin-top: 18px; }

/* Kompakte Statuswechsel-Buttonleiste */
.statusleiste { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }

/* Ein-/ausklappbarer Bereich - fuer Formulare, die nicht dauerhaft sichtbar sein muessen (z. B.
   "Bestehenden Benutzer verknuepfen": erst nach Klick oeffnet sich die Suchliste). Rein
   CSS-basiert per <details>/<summary>, oeffnet inline im aktuellen Fenster - kein Popup, kein
   neuer Tab, kein JavaScript noetig fuer das Auf-/Zuklappen selbst. */
.details-block { margin: 10px 0 0; }
.details-block summary {
  cursor: pointer; font-weight: 600; color: var(--primary); list-style: none;
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 0;
}
.details-block summary::-webkit-details-marker { display: none; }
.details-block summary::before { content: "▸"; font-size: 0.8em; }
.details-block[open] summary::before { content: "▾"; }
.details-block .details-inhalt { margin-top: 10px; }

/* Durchsuchbare Auswahlliste bestehender Mandanten-Logins beim Verknuepfen mit einem Mandat
   (kanzlei_mandant.php) - gedacht fuer eine dreistellige Anzahl an Eintraegen. Filterung per
   externem JS (mandant-user-suche.js, CSP-konform); ohne JS bleibt die komplette Liste sichtbar
   und per Scrollen/Klick bedienbar (progressive enhancement). */
.mandant-user-liste {
  max-height: 320px; overflow-y: auto; margin-top: 10px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.mandant-user-zeile {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); font-weight: 400; margin: 0; cursor: pointer;
}
.mandant-user-zeile:last-child { border-bottom: none; }
.mandant-user-zeile:hover { background: #fafaff; }
.mandant-user-zeile[hidden] { display: none; }
.mandant-user-zeile input[type=radio] { width: auto; flex-shrink: 0; }
.mandant-user-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mandant-user-name { font-weight: 600; color: #1f2937; }
.mandant-user-email { color: var(--secondary); font-size: 0.83rem; word-break: break-all; }

/* Radiobutton-Zeilen (z. B. Bulk-Anlage: "Fuer wen?") */
.radio-zeile { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; }
.radio-zeile label { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; }
.radio-zeile input[type=radio] { width: auto; }

/* Einzelne Checkbox-Zeile (z. B. "Themenordner-Struktur aus dem Vorjahr uebernehmen") */
.checkbox-zeile { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 14px 0 0; }
.checkbox-zeile input[type=checkbox] { width: auto; }

code.hash-kurz { font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.83rem; color: var(--secondary); }

/* --- Ordner-Karten: einheitliche, hervorgehobene Darstellung fuer Jahresordner UND
   Themenordner/Unter-Unterordner - jede Karte ist ein Link, links ein Ordnersymbol. --- */
.ordner-liste { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.ordner-karte {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 8px; padding: 13px 16px; text-decoration: none; color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.ordner-karte:hover { box-shadow: var(--shadow); border-left-color: var(--primary-dark); transform: translateX(1px); }
.ordner-karte-icon {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 8px;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.icon-ordner { width: 20px; height: 20px; }
.ordner-karte-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ordner-karte-titel { font-weight: 600; color: #1f2937; font-size: 0.98rem; }
.ordner-karte-meta { font-size: 0.8rem; color: var(--secondary); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Mandat-Auswahl (Login mit mehreren Mandaten): dieselbe Optik wie .ordner-karte, aber als
   <button> statt <a>, da jede Karte ihr eigenes POST-Formular ist (CSRF-Schutz). */
.mandat-auswahl-form { margin: 0; }
.ordner-karte-button {
  width: 100%; border: 1px solid var(--border); border-left: 4px solid var(--primary);
  background: #fff; font: inherit; margin-top: 0; cursor: pointer;
}

.quick-setup { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.quick-setup form { margin: 0; }
.btn-quick {
  background: var(--primary-light); color: var(--primary); border: 1px dashed #b9bdf0;
  font-size: 0.85rem; padding: 8px 14px; margin-top: 0; min-height: 36px;
}
.btn-quick:hover { background: #e2e5fb; border-color: var(--primary); }

.quick-setup-manuell { margin-top: 14px; max-width: 480px; }
.quick-setup-manuell label { margin-top: 0; }

/* Unaufdringliche Kurzanleitung fuer Mandanten (Startscreen), per <details> ohne JS.
   Standardmaessig eingeklappt, damit sie erfahrene Nutzer nicht stoert. */
.anleitung {
  background: var(--primary-light); border: 1px solid #c7cbf5; border-radius: 8px;
  padding: 12px 16px; margin: 6px 0 20px; font-size: 0.88rem; color: #303050;
}
.anleitung summary {
  cursor: pointer; font-weight: 600; color: var(--primary); list-style: none;
}
.anleitung summary::-webkit-details-marker { display: none; }
.anleitung summary::before { content: "▸ "; }
.anleitung[open] summary::before { content: "▾ "; }
.anleitung ol { margin: 12px 0 2px; padding-left: 20px; }
.anleitung li { margin-bottom: 6px; }
.anleitung li:last-child { margin-bottom: 0; }

/* --- Online-Vorschau von Belegen (PDF/Bild), ohne Download --- */
.vorschau-kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.vorschau-kopf h1 { margin-bottom: 4px; word-break: break-word; }
.vorschau-aktionen { display: flex; gap: 8px; flex-wrap: wrap; }
.vorschau-aktionen .btn { margin-top: 0; }

.vorschau-frame {
  margin-top: 18px; border: 1px solid var(--border); border-radius: var(--radius);
  background: #eef0f3; height: 76vh; min-height: 380px; max-height: 900px;
  overflow: hidden;
}
.vorschau-bild-wrap {
  width: 100%; height: 100%; overflow: auto; box-sizing: border-box;
  display: flex; align-items: flex-start; justify-content: center; padding: 18px;
}
.vorschau-bild { max-width: 100%; height: auto; border-radius: 6px; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,0.18); }
.vorschau-iframe { width: 100%; height: 100%; border: none; display: block; background: #fff; }
.vorschau-hinweis { margin-top: 4px; }

/* --- Mobile Anpassungen --- */
@media (max-width: 720px) {
  .content { padding: 20px 14px 32px; }
  .card { padding: 22px 18px; }
  .card-wide, .card-vorschau { max-width: 100%; }
  .topbar-inner { padding: 12px 14px; }
  .section-title { margin: 24px 0 8px; padding-top: 18px; }
  .vorschau-frame { height: 68vh; }
  .formular-zeile { align-items: stretch; }
  .formular-zeile .btn { width: 100%; }
  .tabelle th, .tabelle td { padding: 10px 13px; }
  .tabelle-suche, .tabelle-filter-auswahl { max-width: none; width: 100%; }
}

@media (max-width: 480px) {
  .brand-sub { display: none; }
  .card { padding: 18px 14px; margin: 14px auto; }
  .card h1 { font-size: 1.15rem; }
  .btn-primary { padding: 12px 16px; }
  .vorschau-kopf { flex-direction: column; }
  .vorschau-aktionen { width: 100%; }
  .vorschau-aktionen .btn { flex: 1; }
  .workflow-schritte { flex-direction: column; align-items: flex-start; gap: 10px; }
  .workflow-schritt { white-space: normal; }
  .workflow-schritt:not(:last-child)::after { display: none; }
}

/* --- JavaScript-Erweiterungen (progressive enhancement): Drag+Drop-Ablagezonen und
   Datei-Vorschau als Dialog. Bewusst zurueckhaltend gestaltet, im selben Look wie .dropfeld
   und .vorschau-* oben - JS kommt nur dort zum Einsatz, wo reines HTML/CSS nicht ausreicht
   (Ablagezone ueber die gesamte Flaeche statt nur auf dem <input>, Vorschau ohne
   Seitenwechsel). Ohne JS bleiben Formulare und Links unveraendert nutzbar (dropzone.js,
   vorschau-modal.js). */

.dropfeld-aktiv { border-color: var(--primary); background: #e2e5fb; }

.dropfeld-dateiliste { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dropfeld-dateiliste[hidden] { display: none; }
.dropfeld-datei {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--border); border-radius: 7px;
  padding: 8px 10px; font-size: 0.85rem;
}
.dropfeld-datei-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #1f2937; }
.dropfeld-datei-groesse { color: var(--secondary); font-size: 0.8rem; flex-shrink: 0; }
.dropfeld-datei-entfernen {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 999px; border: none;
  background: #f3f4f6; color: var(--secondary); cursor: pointer; font-size: 0.72rem;
  display: flex; align-items: center; justify-content: center; padding: 0; margin: 0;
}
.dropfeld-datei-entfernen:hover { background: #fee2e2; color: var(--danger); }

.btn:disabled { opacity: 0.7; cursor: default; }

/* Vorschau-Dialog: natives <dialog>-Element (vorschau-modal.js) - Zentrierung, Escape zum
   Schliessen und der Rand (::backdrop) kommen vom Browser, kein eigener Overlay-Div noetig. */
.vorschau-dialog {
  border: none; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 0; width: min(900px, 92vw); max-width: 900px; max-height: 88vh; background: #fff;
}
.vorschau-dialog::backdrop { background: rgba(17, 20, 33, 0.55); }
.vorschau-dialog-kopf {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.vorschau-dialog-titel {
  font-size: 1rem; margin: 0; color: var(--primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vorschau-dialog-aktionen { display: flex; gap: 8px; flex-shrink: 0; }
.vorschau-dialog-aktionen .btn { margin-top: 0; }
.vorschau-dialog-koerper {
  background: #eef0f3; height: 72vh; max-height: 760px;
  display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 18px;
}
.vorschau-dialog-bild { max-width: 100%; height: auto; border-radius: 6px; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,0.18); margin: 0 auto; }
.vorschau-dialog-iframe { width: 100%; height: 100%; border: none; background: #fff; }

@media (max-width: 720px) {
  .vorschau-dialog { width: 96vw; }
  .vorschau-dialog-koerper { height: 64vh; padding: 10px; }
}

/* --- Generische Datentabellen (Mandate-Uebersicht, Benutzer-Uebersicht, Audit-Log,
   Checklisten, ...): kompaktere Schrift, grosszuegiges Zellen-Padding mit duennen
   Spaltentrennlinien statt eines vollen Gitters, dezente Zeilentrennung + Hover.
   .tabelle-wrap faengt horizontales Ueberlaufen ab (z. B. Audit-Log mit vielen Spalten auf
   schmalen Bildschirmen); overflow-y: hidden verhindert dabei einen unbeabsichtigten
   vertikalen Scrollbalken (Browser befoerdern overflow-y sonst von "visible" auf "auto",
   sobald die X-Achse "auto" ist - derselbe Effekt, der zuvor bei der Dateiliste zu einem
   nicht bedienbaren Scrollbalken gefuehrt hat). */
.tabelle-wrap {
  overflow-x: auto; overflow-y: hidden; margin-top: 10px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
.tabelle { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tabelle th, .tabelle td {
  padding: 12px 18px; text-align: left; border-right: 1px solid var(--border);
}
.tabelle th:last-child, .tabelle td:last-child { border-right: none; }
.tabelle thead th {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--secondary); background: #f9fafb; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tabelle tbody tr { border-bottom: 1px solid var(--border); }
.tabelle tbody tr:last-child { border-bottom: none; }
.tabelle tbody tr:hover { background: #fafaff; }
.tabelle td { color: #1f2937; vertical-align: middle; }
.tabelle-aktionen { text-align: right; white-space: nowrap; }

/* Werkzeugleiste oberhalb einer Datentabelle: Suchfeld + ein oder mehrere Filter-Auswahllisten,
   selbes Muster wie die Dateiliste-Werkzeugleiste unten, nur allgemein statt dateibezogen.
   Mehrere Tabellen auf einer Seite (z. B. Kanzlei-Benutzer + Mandanten-Benutzer) bekommen
   jeweils ihre eigene Werkzeugleiste, verknuepft per data-tabelle-ziel mit der Tabellen-ID
   (siehe tabellen-werkzeuge.js). */
.tabelle-werkzeugleiste { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 14px 0 10px; }
.tabelle-werkzeugleiste > div { margin: 0; }
.tabelle-suche { max-width: 280px; margin: 0; }
.tabelle-filter-auswahl { max-width: 210px; margin: 0; }

/* Kompakte "Rolle aendern"-Mini-Form innerhalb eines Aktionen-Menues (kanzlei_benutzer.php) -
   ersetzt die frueher permanent in der Tabellenzeile sichtbare Auswahlliste + Buttons, die bei
   schmaleren Bildschirmen bzw. laengeren Namen/E-Mails zum Umbruch der ganzen Zeile fuehrten. */
.aktionen-menu-liste form.aktionen-menu-rollenform { padding: 6px 11px 8px; }
.aktionen-menu-liste form.aktionen-menu-rollenform select {
  width: 100%; padding: 7px 9px; font-size: 0.83rem; margin: 0 0 6px; border-radius: 6px;
}
.aktionen-menu-liste form.aktionen-menu-rollenform .aktionen-menu-eintrag {
  padding: 7px 0; text-align: center; background: var(--primary-light); color: var(--primary);
  font-weight: 600; border-radius: 6px;
}
.aktionen-menu-liste form.aktionen-menu-rollenform .aktionen-menu-eintrag:hover { background: #e2e5fb; }

/* "Name aendern"/"E-Mail aendern"-Mini-Formen innerhalb eines Aktionen-Menues
   (kanzlei_benutzer.php, Mandanten-Benutzer; kanzlei_mandant.php) - ein Textfeld + Button,
   gleiches kompaktes Muster wie .aktionen-menu-rollenform oben. */
.aktionen-menu-liste form.aktionen-menu-textform { padding: 6px 11px 8px; }
.aktionen-menu-liste form.aktionen-menu-textform input[type="text"],
.aktionen-menu-liste form.aktionen-menu-textform input[type="email"] {
  width: 100%; padding: 7px 9px; font-size: 0.83rem; margin: 0 0 6px; border-radius: 6px;
  border: 1px solid #d1d5db;
}
.aktionen-menu-liste form.aktionen-menu-textform .aktionen-menu-eintrag {
  padding: 7px 0; text-align: center; background: var(--primary-light); color: var(--primary);
  font-weight: 600; border-radius: 6px;
}
.aktionen-menu-liste form.aktionen-menu-textform .aktionen-menu-eintrag:hover { background: #e2e5fb; }

/* --- Dateiliste: Werkzeugleiste (Suche + Sortierung) und Kachel-Grid.
   Suche und Sortierung brauchen JS (dynamisches Umsortieren/Filtern laesst sich nicht
   sinnvoll in CSS abbilden), das Grid-Layout selbst ist reines CSS. */

/* Werkzeugleiste oberhalb der Dateiliste: Suchfeld und Sortierknoepfe nebeneinander,
   umbrechen bei Bedarf auf schmalen Bildschirmen. */
.dateien-werkzeugleiste { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 14px 0 10px; }
#dateien-filter { max-width: 280px; margin: 0; }
.dateien-filter-select { width: auto; max-width: 240px; margin: 0; }

.dateien-sortleiste { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.dateien-sortleiste-label { font-size: 0.82rem; color: var(--secondary); font-weight: 600; }
.sort-knopf {
  display: inline-flex; align-items: center; gap: 1px;
  padding: 6px 12px; border: 1px solid #d1d5db; border-radius: 999px;
  background: #fff; color: #374151; font-size: 0.82rem; font-family: inherit; font-weight: 500;
  cursor: pointer;
}
.sort-knopf:hover { background: #f3f4f6; border-color: #c1c5cc; }
.sort-knopf-aktiv, .sort-knopf-aktiv:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.sort-pfeil { display: inline-block; font-size: 0.75em; }

/* --- Aktionen-Menue in der Dateiliste: ein einziger kompakter Knopf pro Zeile statt einer
   Reihe von Buttons, damit die Zeile nicht mehr horizontal gescrollt werden muss (vorher:
   bis zu 5 Buttons in der letzten Spalte). Natives <details>/<summary> statt eines
   JS-Dropdowns - Auf-/Zuklappen und Tastaturbedienung kommen direkt vom Browser; ueber das
   gemeinsame name-Attribut ("dateien-aktionen") schliesst der Browser zudem automatisch ein
   bereits offenes Menue einer anderen Zeile, wenn ein neues geoeffnet wird (exklusive
   <details>-Gruppen, von allen gaengigen Browsern unterstuetzt) - kein JavaScript noetig. */
.aktionen-menu { position: relative; display: inline-block; }
.aktionen-menu > summary {
  list-style: none; cursor: pointer; width: 34px; height: 34px; border-radius: 7px;
  border: 1px solid #d1d5db; background: #fff; color: var(--secondary);
  display: flex; align-items: center; justify-content: center;
}
.aktionen-menu > summary::-webkit-details-marker { display: none; }
.aktionen-menu > summary:hover { background: #f3f4f6; border-color: #c1c5cc; color: #374151; }
.aktionen-menu[open] > summary { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.icon-mehr { width: 17px; height: 17px; }

/* position: fixed statt absolute: dateien-aktionen.js setzt beim Oeffnen die exakte
   Position (top/right, ggf. oberhalb des Knopfes gespiegelt) per Inline-Style. So
   entkommt das Menue zuverlaessig jedem overflow:hidden/auto eines Vorfahren - z. B. wenn
   eine Kachel nahe am unteren/rechten Rand des Bildschirms liegt und das Menue sonst
   abgeschnitten wuerde. Ohne JavaScript faellt die Liste auf ihre normale Fliessposition
   direkt unter dem Knopf zurueck (weiterhin bedienbar). */
.aktionen-menu-liste {
  position: fixed; z-index: 20; min-width: 190px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column; gap: 1px;
}
.aktionen-menu-liste form { margin: 0; }
.aktionen-menu-eintrag {
  display: block; width: 100%; box-sizing: border-box; margin: 0; padding: 9px 11px; border: none;
  background: none; border-radius: 6px; color: #1f2937; font-size: 0.88rem; font-family: inherit;
  text-decoration: none; text-align: left; cursor: pointer;
}
.aktionen-menu-eintrag:hover { background: #f3f4f6; }
.aktionen-menu-eintrag-hervorgehoben { color: var(--primary); font-weight: 600; }
.aktionen-menu-eintrag-gefahr {
  color: var(--danger); margin-top: 4px; border-top: 1px solid var(--border);
  border-radius: 0 0 6px 6px; padding-top: 12px;
}
.aktionen-menu-eintrag-gefahr:hover { background: #fef2f2; }

/* "SHA-256 kopieren": ersetzt die frueher permanent sichtbare SHA-256-Spalte (Kanzlei-
   Ansicht) - der Hash wird nur selten gebraucht, verdient also keinen Dauerplatz in der
   Liste, bleibt aber bei Bedarf ueber das Aktionen-Menue einen Klick entfernt. */
.aktionen-menu-eintrag-hash { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; color: var(--secondary); }
.aktionen-menu-eintrag-hash-status { font-size: 0.78rem; color: var(--success); white-space: nowrap; }

.aktionen-menu-backdrop { position: fixed; inset: 0; z-index: 15; background: transparent; }

/* --- Dateiliste als Kachel-Grid: jede Datei ist eine eigene Kachel, mehrere pro Zeile,
   Anzahl passt sich automatisch an die verfuegbare Breite an (CSS Grid auto-fill) - kein
   horizontales Scrollen und keine feste Breakpoint-Logik noetig. Jede Kachel zeigt oben
   ein Vorschau-Bild (bei Bildern) bzw. ein farbcodiertes Typ-Icon (bei allen anderen
   Dateien), darunter Namen, eine kompakte Meta-Zeile und bei Bedarf einen Freigabe-Status;
   das Aktionen-Menue sitzt als kleiner Knopf oben rechts in der Kachel. */
.dateien-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-top: 6px; }

.datei-kachel {
  position: relative; display: flex; flex-direction: column; align-items: center;
  border: 1px solid var(--border); border-radius: 12px; background: #fff;
  padding: 16px 12px 13px; text-align: center;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.datei-kachel:hover { box-shadow: var(--shadow); border-color: #c7cbf5; }

.datei-kachel-menu { position: absolute; top: 8px; right: 8px; }

.datei-kachel-flaeche {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: 100%; max-width: 100%; padding-top: 4px; margin: 0;
  color: inherit; text-decoration: none; background: none; border: none; font: inherit; cursor: default;
}
a.datei-kachel-flaeche { cursor: pointer; }
a.datei-kachel-flaeche:hover .datei-kachel-name { color: var(--primary); }

.datei-kachel-icon {
  width: 52px; height: 52px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.datei-kachel-icon svg { width: 26px; height: 26px; }
.datei-kachel-icon-pdf      { background: #fef2f2; color: #b91c1c; }
.datei-kachel-icon-bild     { background: #f5f3ff; color: #6d28d9; }
.datei-kachel-icon-excel    { background: #ecfdf5; color: #047857; }
.datei-kachel-icon-word     { background: #eff6ff; color: #1d4ed8; }
.datei-kachel-icon-sonstige { background: #f3f4f6; color: var(--secondary); }

.datei-kachel-bild-wrap {
  width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: #f3f4f6;
}
.datei-kachel-bild { width: 100%; height: 100%; object-fit: cover; display: block; }

.datei-kachel-name {
  font-size: 0.85rem; font-weight: 500; color: #1f2937; max-width: 100%;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word; line-height: 1.3;
}

.datei-kachel-meta { font-size: 0.74rem; color: var(--secondary); margin-top: 7px; }
/* Upload-Kennzeichnung: wer hat hochgeladen (eigene Zeile, da Namen laenger sein koennen) */
.datei-kachel-uploader {
  display: block; margin-top: 2px; font-weight: 600; color: #374151;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.datei-kachel-status { margin-top: 6px; }

/* --- Gefuehrter Anlage-Workflow (Benutzer -> Mandat -> Steuerjahr) ---
   Schrittanzeige ("Stepper") oben auf der jeweiligen Seite: erledigte Schritte gefuellt mit
   Haekchen und in der Primaerfarbe verbunden, der aktuelle Schritt umrandet hervorgehoben,
   spaetere Schritte ausgegraut. Die Verbindungslinie zwischen den Kreisen ist ein ::after auf
   jedem Schritt (ausser dem letzten) und wuchs mit flex:1 in die Luecke bis zum naechsten
   Kreis - dadurch braucht es dafuer kein eigenes HTML-Element. Reines CSS, kein JS. Wird von
   kanzlei_mandant.php und kanzlei_mandant_workflow.php verwendet. */
.workflow-schritte {
  list-style: none; display: flex; align-items: center;
  margin: 0 0 20px; padding: 0; font-size: 0.85rem; color: var(--secondary);
}
.workflow-schritt {
  display: flex; align-items: center; gap: 8px; flex: 1 1 0; min-width: 0;
  white-space: nowrap;
}
.workflow-schritt:not(:last-child)::after {
  content: ''; flex: 1 1 auto; height: 2px; min-width: 12px; margin: 0 10px;
  background: var(--border);
}
.workflow-schritt > span {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--border); background: #fff; font-size: 0.78rem; font-weight: 600;
}
.workflow-schritt-erledigt { color: var(--primary); }
.workflow-schritt-erledigt > span { background: var(--primary); border-color: var(--primary); font-size: 0; }
.workflow-schritt-erledigt > span::before { content: '✓'; font-size: 0.8rem; font-weight: 700; color: #fff; }
.workflow-schritt-erledigt:not(:last-child)::after { background: var(--primary); }
.workflow-schritt-aktiv { color: #1f2937; font-weight: 600; }
.workflow-schritt-aktiv > span { background: #fff; border-color: var(--primary); color: var(--primary); }

/* Link "bearbeiten" hinter den freigeschalteten Nummernkreisen in der Benutzertabelle */
.bereiche-link { margin-left: 6px; font-size: 0.82rem; color: var(--primary); text-decoration: none; white-space: nowrap; }
.bereiche-link:hover { text-decoration: underline; }
