/*
 * BFT Fahrten Management System — Haupt-Stylesheet
 * =================================================
 * Autor:    Balz Heusler / Oz AI Agent
 * Zuletzt aktualisiert: April 2026
 *
 * INHALTSVERZEICHNIS
 * ------------------
 *  1.  Reset & CSS-Variablen
 *  2.  App-Shell Layout  (shell.html)
 *  3.  Login-Seite       (login_form.html)
 *  4.  Adressfelder      (generic_form.py)
 *  5.  Dashboard-Uebersicht (dashboard_content.html)
 *  6.  Dashboard-Kacheln    (dashboard_module.html)
 *  7.  Statistik-Karten
 *  8.  Datentabellen     (generic_list.py)
 *  9.  Nachrichten / Alerts
 * 10.  Modale Dialoge    (generic_form.py / content.py)
 * 11.  Buttons (Standard)
 * 12.  Buttons (Klein, fuer Tabellen)
 * 13.  Badges & Status-Anzeigen
 * 14.  Links
 * 15.  Formulare (generisch)
 * 16.  Tabs
 * 17.  Info-Grid
 * 18.  Code-Block
 * 19.  Flash-Nachrichten (Toasts)
 * 20.  Debug-Info
 * 21.  Fehlerseite
 * 22.  Responsive
 *
 * FARBKONZEPT
 * -----------
 * Alle Farben und Abstaende als CSS-Variablen in :root.
 * Aenderung an einer zentralen Stelle wirkt ueberall.
 *
 * KACHEL-GROESSEN
 * ---------------
 * Standardwerte in :root (--kachel-*).
 * Rollen-spezifische Werte via <style>:root{--kachel-*:...}</style>
 * in dashboard_module.html (aus DB-Tabelle rollen).
 *
 * INLINE-STYLES
 * -------------
 * Ziel: keine inline styles in Python/HTML.
 * Noch verbleibende inline styles in content.py sind
 * dynamische f-string Werte (z.B. Farben aus DB) die
 * nicht durch CSS-Klassen ersetzt werden koennen.
 */


/* ============================================================
   1. RESET & CSS-VARIABLEN
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* --- Design-System Farben --- */
    --primary-color:   #2563eb;
    --primary-hover:   #1d4ed8;
    --secondary-color: #64748b;
    --success-color:   #10b981;
    --error-color:     #ef4444;
    --warning-color:   #f59e0b;
    --info-color:      #3b82f6;

    /* --- Hintergruende & Oberflaechen --- */
    --bg-color:      #f8fafc;
    --surface-color: #ffffff;

    /* --- Texte & Rahmen --- */
    --text-color:     #1e293b;
    --text-secondary: #64748b;
    --border-color:   #e2e8f0;

    /* --- Schatten --- */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);

    /* --- App-Shell Farben (shell.html) --- */
    --header-bg:          #ffe0e0;   /* Roetlicher Hintergrund im App-Header */
    --header-title-color: #dc143c;   /* Crimson-Rot fuer den App-Titel */
    --user-info-bg:       #fff9c4;   /* Gelber Hintergrund fuer das User-Info-Panel */
    --user-info-border:   #ffeb3b;

    /* --- Dashboard-Kacheln ---
       Standardwerte. Rollen-spezifische Ueberschreibungen via
       <style>:root{--kachel-breite: Xpx; ...}</style> in dashboard_module.html.
       Die Werte kommen aus DB-Tabelle 'rollen' (dashboard_kachel_* Felder).
    */
    --kachel-breite:              200px;
    --kachel-hoehe:               150px;
    --kachel-abstand:              16px;  /* Horizontaler Abstand zwischen Kacheln */
    --kachel-abstand-vertikal:     16px;  /* Vertikaler Abstand zwischen Zeilen */
    --kachel-icon-groesse:         40px;
    --kachel-titel-groesse:        16px;
    --kachel-beschreibung-groesse: 12px;
    --kachel-bg:            white;
    --kachel-border:        #dee2e6;
    --kachel-border-radius: 8px;

    /* --- Formular-Ueberlagerung ---
       Abstand vom oberen Rand fuer modale Formulare.
       Wird in shell.html ueberschrieben wenn
       system_einstellungen.Form-px-from-top gesetzt ist.
    */
    --form-top-offset: 56px;

    /* --- BFT Action-Buttons (überschreibbar via Farbsystem-Admin) --- */
    --btn-primary:          #007bff;
    --btn-secondary:        #6c757d;
    --btn-danger:           #dc3545;
    --btn-success:          #28a745;
    --btn-warning:          #ffc107;
    --btn-dark:             #343a40;
    --btn-accent:           #6f42c1;
    --btn-info:             #0d9488;

    /* --- Datentabellen (überschreibbar via Farbsystem-Admin) --- */
    --list-bg:              #ffffff;
    --list-header-bg:       #f8f9fa;
    --list-row-hover:       #f8f9fa;
    --list-row-active:      #eef4ff;
    --list-subrow-bg:       #f0f4ff;
    --list-subrow-border:   #c7d9f5;

    /* --- Schriften (überschreibbar via Farbsystem-Admin) --- */
    --font-family:     -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono:       'IBM Plex Mono', Consolas, 'Courier New', monospace; /* IDs, Codes, Debug */
    --font-size-body:  1rem;
    --font-size-small: 0.85rem;
    --font-size-h1:    1.3rem;
    --font-size-label: 0.85rem;

    /* --- Textfarben-Rollen (Kap. 11.3) --- */
    --color-text-muted:      #8a94a3;  /* Hilfetexte, Zeitstempel, Platzhalter */
    --color-text-inverse:    #ffffff;  /* Text auf dunklen Flächen */
    --color-text-link:       #2563eb;  /* Links */
    --debug-color:           #94a3b8;  /* Debug-Hinweise */

    /* --- Oberflächen-Rollen (Kap. 11.4) --- */
    --color-surface:         #ffffff;  /* Karten, Formulare, Modale */
    --color-surface-subtle:  #f8fafc;  /* Formular-Header, Code-Block */
    --color-overlay:         rgba(15,23,42,0.55); /* Modal-Abdunklung */
    --color-focus-ring:      #2563eb;  /* Tastatur-Fokus (WCAG) */

    /* --- Rahmen-Rollen (Kap. 11.5) --- */
    --color-border:          #e2e8f0;  /* Standard-Rahmen (= --border-color) */
    --color-border-strong:   #aeb8c5;  /* Betonte Abgrenzung */
    --color-divider:         #e4e9ef;  /* Trennlinien */

    /* --- Primär-Dunkel für Titel, Tabs, Kacheln --- */
    --color-primary-dark:    #1e3c72;

    /* --- Formulare / Inputs (Kap. 11.7) --- */
    --input-bg:              #ffffff;
    --input-text:            #1e293b;
    --input-placeholder:     #8a94a3;
    --input-border:          #e2e8f0;
    --input-border-hover:    #aeb8c5;
    --input-border-focus:    #2563eb;
    --input-invalid:         #dc3545;
    --input-disabled:        #f1f5f9;
    --form-surface:          #ffffff;
    --form-header-bg:        #f8fafc;
    --label-color:           #334155;

    /* --- Status-Hintergründe (Kap. 11.2) --- */
    --color-success-bg:      #d4edda;
    --color-warning-bg:      #fff3cd;
    --color-error-bg:        #f8d7da;
    --color-info-bg:         #d1ecf1;

    /* --- Button-Hover-Zustände (abgeleitet, überschreibbar via Farbsystem) --- */
    --btn-primary-hover:   #0069d9;
    --btn-secondary-hover: #5a6268;
    --btn-danger-hover:    #c82333;
    --btn-success-hover:   #218838;
    --btn-warning-hover:   #e0a800;
    --btn-dark-hover:      #23272b;
    --btn-accent-hover:    #5a2d91;
    --btn-info-hover:      #0b7a70;

    /* --- Badge-Farben --- */
    --badge-danger-bg:    #dc3545;
    --badge-danger-fg:    #ffffff;
    --badge-warning-bg:   #ffc107;
    --badge-warning-fg:   #212529;
    --badge-success-bg:   #28a745;
    --badge-success-fg:   #ffffff;
    --badge-primary-bg:   #007bff;
    --badge-primary-fg:   #ffffff;
    --badge-secondary-bg: #6c757d;
    --badge-secondary-fg: #ffffff;

    /* --- Komponenten-Schriften (UI-intern, nicht im Typografie-Kontext-System) --- */
    --font-size-footer: 0.8rem;
    --font-size-tab:    0.9rem;
    --font-size-meta:   0.6rem;  /* Winzig-Labels: user-info, kachel-id etc. */

    /* --- Diff-Ansicht (Änderungsprotokoll) --- */
    --diff-row-bg:     #f8f9fa;
    --diff-changed-bg: #fff3cd;
    --diff-json-bg:    #e3f2fd;
    --diff-old-bg:     #ffebee;
    --diff-new-bg:     #e8f5e9;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}


/* ============================================================
   2. APP-SHELL LAYOUT (shell.html)
   Drei-Zonen-Layout: Header -> #main-content -> Footer
   ============================================================ */

/* svh = small viewport height — behebt 100vh-Bug auf Android (Browser-Adressleiste) */
html, body { height: 100svh; overflow: hidden; }
body { display: flex; flex-direction: column; }

/* Header */
.app-header {
    background: var(--header-bg);
    color: var(--text-color);
    /* Padding skaliert mit Viewport */
    padding: clamp(0.4rem, 0.75vw, 0.75rem) clamp(0.75rem, 1.5vw, 1.5rem);
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    flex-shrink: 0;
}
/* 3-Spalten-Layout: Links=Logo/Titel, Mitte=Dashboard, Rechts=Login
   Jeder Bereich bekommt flex:1 damit Mitte wirklich zentriert ist */
.header-left   { display: flex; align-items: center; gap: clamp(0.4rem, 0.75vw, 1rem); flex: 1; min-width: 0; }
.header-center { display: flex; align-items: center; justify-content: center; gap: clamp(0.35rem, 0.6vw, 0.75rem); flex: 1; }
.header-right  { display: flex; align-items: center; justify-content: flex-end; gap: clamp(0.5rem, 0.75vw, 1rem); flex: 1; }
/* Header-Buttons: Schrift + Höhe skalieren mit Viewport */
.header-center .btn {
    display: inline-flex;
    align-items: center;
    height: clamp(28px, 2.8vw, 36px) !important;
    padding-left:  clamp(0.5rem, 0.75vw, 1rem);
    padding-right: clamp(0.5rem, 0.75vw, 1rem);
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    box-sizing: border-box !important;
    white-space: nowrap;
    gap: 6px;
    font-size: clamp(0.78rem, 0.85vw, 0.875rem);
}
/* Innerer Text-Container (Titel + Debug) muss Overflow erlauben */
.header-left > div { min-width: 0; overflow: hidden; }
.logo-link    { display: block; flex-shrink: 0; }
/* Logo skaliert mit Viewport: min 30px, bevorzugt 3.5vw, max 45px */
.app-logo     { height: clamp(30px, 3.5vw, 45px); cursor: pointer; transition: transform 0.2s; }
.app-logo:hover { transform: scale(1.05); }
/* App-Titel: dreistufig responsiv, immer einzeilig
   Umschalter über Media Queries (nicht clamp) — kein Div-Constraint-Problem */
.app-title {
    font-size: var(--typo-app-titel-size, 1.25rem);
    font-weight: var(--typo-app-titel-weight, 600);
    margin: 0;
    color: var(--typo-app-titel-color, var(--header-title-color));
    font-family: var(--typo-app-titel-family, var(--font-family));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
/* Span-Varianten: immer einzeilig */
.title-full, .title-med, .title-short { white-space: nowrap; }
/* Standard: voller Text */
.title-med   { display: none; }
.title-short { display: none; }
/* Ab < 1900px: mittlere Variante */
@media (max-width: 1899px) {
    .title-full  { display: none; }
    .title-med   { display: inline; }
}
/* Ab < 1200px: Kurzform */
@media (max-width: 1199px) {
    .title-med   { display: none; }
    .title-short { display: inline; }
}
/* Debug-Zeile im Header */
#header-revision-line {
    font-size: clamp(0.58rem, 0.65vw, 0.82rem) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* User-Info Panel (oben rechts, nach Login sichtbar) */
.user-info {
    display: none; /* Wird per .active durch JavaScript eingeblendet */
    position: relative;
}
.user-info.active { display: block; }
.user-info-label  { font-size: var(--font-size-meta, 0.6rem); color: var(--color-text-muted); font-weight: 400; margin-bottom: 0.15rem; }
.user-info-row    { display: flex; align-items: center; gap: 0.75rem; }

/* Haupt-Inhalt-Bereich (via HTMX dynamisch befuellt) */
#main-content {
    flex: 1; padding: 0;
    max-width: 100%; width: 100%; margin: 0;
    overflow-y: auto; min-height: 0;
}

/* Lade-Indikator: Inhalt wird waehrend HTMX-Request leicht ausgeblendet */
.htmx-request #main-content { opacity: 0.6; pointer-events: none; }

/* Footer */
/* Footer: 3-Spalten-Layout, spiegelt Header-Struktur */
.app-footer {
    background: #f8f9fa; padding: 0.4rem 1.5rem; color: #6c757d;
    border-top: 1px solid #dee2e6; flex-shrink: 0;
    display: flex; align-items: center;
}
.app-footer p  { margin: 0; font-size: var(--font-size-footer, 0.8rem); }
.footer-left   { display: flex; align-items: center; flex: 1; }
.footer-center { display: flex; align-items: center; justify-content: center; flex: 1; }
.footer-right  { display: flex; align-items: center; justify-content: flex-end; flex: 1; gap: 0.5rem; }
/* Footer-Buttons: gleiche interne Ausrichtung wie Header-Buttons */
.footer-right .btn {
    display: inline-flex;
    align-items: center;
    height: 32px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    box-sizing: border-box !important;
    white-space: nowrap;
    gap: 6px;
}


/* ============================================================
   3. LOGIN-SEITE (partials/login_form.html)
   ============================================================ */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--primary-color) 0%, #1e40af 100%); }
.login-container { width: 100%; max-width: 400px; padding: 2rem; }
.login-box       { background: white; padding: 2rem; border-radius: 0.5rem; box-shadow: var(--shadow-lg); }
.login-header    { text-align: center; margin-bottom: 2rem; }
.login-header h1 { color: var(--primary-color); font-size: 1.75rem; margin-bottom: 0.5rem; }
.login-header p  { color: var(--text-secondary); font-size: 0.875rem; }
.login-form      { display: flex; flex-direction: column; gap: 1rem; }
.login-footer    { text-align: center; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.login-footer p  { color: var(--text-secondary); font-size: 0.75rem; }

.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.form-group label { font-weight: 500; font-size: 0.875rem; color: var(--text-color); }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group select,
.form-group textarea {
    padding: 0.625rem; border: 1px solid var(--border-color);
    border-radius: 0.375rem; font-size: 0.875rem; transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none; border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.checkbox-label         { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }
.password-input-wrapper { position: relative; display: flex; align-items: center; }
.password-input-wrapper input { padding-right: 2.5rem; width: 100%; }
.password-toggle {
    position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; padding: 0.25rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; opacity: 0.6; transition: opacity 0.2s;
}
.password-toggle:hover { opacity: 1; }
.password-toggle:focus { outline: 2px solid var(--primary-color); outline-offset: 2px; border-radius: 0.25rem; }


/* ============================================================
   4. ADRESSFELDER (generic_form.py -> address_standard Layout)
   Spezielle Grid-Layouts fuer Schweizer Adressen
   ============================================================ */
.address-layout       { display: flex; flex-direction: column; gap: 0.4rem; }
.address-row          { display: grid; gap: 0.4rem; }
.address-row-full     { grid-template-columns: 1fr; }
.address-row-street   { grid-template-columns: 8fr 1fr; }
.address-row-street > div:last-child label { text-align: right; white-space: nowrap; }
.address-row-street > div:last-child input { text-align: right; }
.address-row-location { grid-template-columns: 1.5fr 1.5fr 7fr; }

/* === Google Places Autocomplete (bft-google-places.js) === */
.gp-search-wrapper {
    position: relative;
    margin-bottom: 0.6rem;
}
.gp-search-input {
    width: 100%;
    padding: 0.5rem 0.5rem 0.5rem 1.8rem;
    border: 1px solid #007bff;
    border-radius: 4px;
    font-size: 0.875rem;
    background: #f0f8ff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='%23007bff'%3E%3Cpath d='M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5S10.62 6.5 12 6.5s2.5 1.12 2.5 2.5S13.38 11.5 12 11.5z'/%3E%3C/svg%3E") no-repeat 0.4rem center;
}
.gp-search-input:focus { outline: none; border-color: #0056b3; }
.gp-dropdown {
    position: absolute;
    z-index: 2000;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    display: none;
}
.gp-option {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gp-option--hover, .gp-option:hover { background: #e8f0fe; }

/* === PLZ / Land Autocomplete Dropdowns (bft-address.js) === */
.plz-option, .land-option {
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.8rem;
    background: white;
}
.plz-option--hover, .land-option--hover,
.plz-option:hover, .land-option:hover { background: #f0f8ff; }
.plz-logik-badge { color: #28a745; font-size: 0.7rem; margin-left: 0.4rem; }

/* Autocomplete-Container Basisstil */
[id*="-autocomplete"] {
    position: absolute;
    z-index: 1000;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
    display: none;
}

/* Laender-Dropdown: Nur ISO-Code in geschlossenem Zustand, voller Text in Optionen */
select[name="land"] { text-align: center; font-weight: 500; }
select[name="land"] option { text-align: left; padding: 0.5rem; font-weight: normal; }
select[name="land"]:focus option,
select[name="land"][size] option { min-width: 250px; }


/* ============================================================
   5. DASHBOARD-UEBERSICHT (partials/dashboard_content.html)
   Kompakte Kacheln fuer den Admin-Bereich (feste Groesse)
   ============================================================ */

/* Grid-Container; Spaltenanzahl wird inline gesetzt (z.B. repeat(5,1fr)) */
.table-buttons-grid { display: grid; gap: 0.75rem; }

/* Kompakte Kachel (Admin-Dashboard) */
.table-button {
    background: white; border: 2px solid #dee2e6;
    border-radius: 6px; padding: 0.75rem 0.5rem;
    text-align: center; cursor: pointer; transition: all 0.3s;
}
.table-button .button-icon { font-size: 2.2rem; margin-bottom: 0.35rem; }
.table-button h4           { color: #1e3c72; margin: 0; font-size: 0.85rem; line-height: 1.2; }
.table-button:hover        { border-color: #2a5298; box-shadow: 0 4px 12px rgba(42,82,152,0.15); transform: translateY(-2px); }
.table-button:active       { transform: translateY(0); }

/* Abschnitt-Container (um Gruppen von Inhalten) */
.admin-section       { background: var(--surface-color); border-radius: 1rem; padding: 2rem; box-shadow: var(--shadow-md); }
.section-title       { font-size: 2rem; font-weight: 700; color: var(--text-color); margin-bottom: 0.5rem; }
.section-description { color: var(--text-secondary); font-size: 1rem; margin-bottom: 2rem; }

/* Benutzerinformations-Karte */
.user-info-container { background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%); border-radius: 1rem; padding: 2rem; box-shadow: var(--shadow-lg); color: white; }
.user-info-header    { display: flex; align-items: center; gap: 1.5rem; margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.2); }
.user-avatar         { width: 80px; height: 80px; background: rgba(255,255,255,0.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; backdrop-filter: blur(10px); border: 3px solid rgba(255,255,255,0.3); }
.avatar-initials     { text-transform: uppercase; }
.user-details        { flex: 1; }
.user-name           { font-size: 1.75rem; font-weight: 700; margin: 0 0 0.25rem 0; }
.user-role           { font-size: 1rem; opacity: 0.9; margin: 0; font-weight: 500; }
.user-info-grid      { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; }
.info-item           { display: flex; flex-direction: column; gap: 0.5rem; }
.info-label          { font-size: 0.875rem; opacity: 0.8; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.info-value          { font-size: 1.125rem; font-weight: 600; }
.status-badge        { display: inline-block; padding: 0.25rem 0.75rem; border-radius: 0.375rem; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.status-active       { background: rgba(16,185,129,0.2); color: white; border: 1px solid rgba(255,255,255,0.3); }
.button-content      { flex: 1; }
.button-content h3   { font-size: 1.25rem; font-weight: 700; color: var(--text-color); margin: 0 0 0.25rem 0; }
.button-content p    { font-size: 0.875rem; color: var(--text-secondary); margin: 0; }


/* ============================================================
   6. DASHBOARD-KACHELN (partials/dashboard_module.html)
   Groessen ueber CSS-Variablen gesteuert.
   Rollen-spezifische Werte ueberschreiben :root-Defaults via
   <style>:root{--kachel-breite:Xpx;...}</style> im Template.
   ============================================================ */

/* Scrollbarer Wrapper fuer das Kachel-Grid */
.dashboard-scroll    { height: 100%; overflow-y: auto; padding: 1.5rem; }
.dashboard-container { display: flex; flex-direction: column; padding: 0; margin: 0; }

/* Zeile mit Kacheln (Abstand aus CSS-Variable) */
.dashboard-row { display: flex; gap: var(--kachel-abstand); flex-wrap: wrap; margin-bottom: var(--kachel-abstand-vertikal); }

/* Kachel (aktiv) - alle Groessen aus CSS-Variablen */
.dashboard-kachel {
    background: var(--kachel-bg);
    border: 2px solid var(--kachel-border);
    border-radius: var(--kachel-border-radius);
    padding: 1.5rem; cursor: pointer; transition: all 0.3s;
    width: var(--kachel-breite); height: var(--kachel-hoehe);
    display: flex; justify-content: center; align-items: center;
    flex-shrink: 0; gap: 0.75rem; position: relative;
}
.dashboard-kachel:hover  { border-color: #2a5298; box-shadow: 0 6px 16px rgba(42,82,152,0.2); transform: translateY(-4px); }
.dashboard-kachel:active { transform: translateY(-2px); }

/* Leerer Platzhalter (Modul K00 = Abstandshalter) */
.dashboard-kachel-empty {
    background: transparent; border: 2px dashed var(--color-border);
    border-radius: var(--kachel-border-radius);
    width: var(--kachel-breite); height: var(--kachel-hoehe);
    flex-shrink: 0;
}

/* Icon-Position (Klasse aus rolle.dashboard_icon_position gesetzt) */
.kachel-icon-top    { flex-direction: column; text-align: center; }
.kachel-icon-bottom { flex-direction: column-reverse; text-align: center; }
.kachel-icon-left   { flex-direction: row; text-align: left; }
.kachel-icon-right  { flex-direction: row-reverse; text-align: left; }

/* Kachel-Inhalte (Groessen aus CSS-Variablen) */
.kachel-icon        { font-size: var(--kachel-icon-groesse); line-height: 1; transition: transform 0.3s; }
.kachel-icon img    { width: var(--kachel-icon-groesse); height: var(--kachel-icon-groesse); object-fit: contain; display: block; }
.kachel-title       { color: var(--color-primary-dark); margin: 0 0 0.25rem 0; font-size: var(--kachel-titel-groesse); font-weight: 600; line-height: 1.3; }
.kachel-description { color: var(--text-secondary);    font-size: var(--kachel-beschreibung-groesse); margin: 0; line-height: 1.2; }
.kachel-text        { display: flex; flex-direction: column; justify-content: center; }
.kachel-empty-text  { text-align: center; padding: 3rem; background: var(--color-surface-subtle); border-radius: 8px; border: 2px dashed var(--color-border); }
.kachel-modul-id    { position: absolute; top: 0.25rem; left: 0.5rem; font-size: clamp(0.55rem, var(--typo-debug-info-size, 0.65rem), 0.85rem); color: var(--typo-debug-info-color, var(--color-text-muted)); font-family: var(--typo-debug-info-family, var(--font-mono)); font-weight: var(--typo-debug-info-weight, 400); opacity: 0.85; }

/* Hover-Animation auf Icon */
.dashboard-kachel:hover .kachel-icon { transform: scale(1.1); }


/* ============================================================
   7. STATISTIK-KARTEN (partials/dashboard_fahrer.html etc.)
   ============================================================ */
.stats-grid   { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.stat-card    { background: var(--surface-color); padding: 1.5rem; border-radius: 0.75rem; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); display: flex; align-items: center; gap: 1rem; transition: all 0.3s ease; }
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.stat-icon    { font-size: 2.5rem; opacity: 0.8; }
.stat-content { flex: 1; }
.stat-card h3 { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 0.5rem; font-weight: 500; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--primary-color); }


/* ============================================================
   8. DATENTABELLEN (generic_list.py)
   Verwendung: <table class="data-table">
   .td-actions = Aktions-Spalte (Bearbeiten/Loeschen)
   ============================================================ */
.data-table          { width: 100%; border-collapse: collapse; background: var(--list-bg); box-shadow: 0 2px 4px rgba(0,0,0,0.1); font-size: clamp(0.75rem, var(--typo-liste-zelle-size, 0.9rem), 1rem); color: var(--typo-liste-zelle-color, var(--text-color)); font-family: var(--typo-liste-zelle-family, var(--font-family)); }
.data-table thead    { position: sticky; top: 0; background: var(--list-header-bg); z-index: 10; }
.data-table th       { padding: 0.75rem; text-align: left; border-bottom: 2px solid var(--color-border); font-size: clamp(0.75rem, var(--typo-liste-kopf-size, 0.9rem), 1.1rem); font-weight: var(--typo-liste-kopf-weight, 600); color: var(--typo-liste-kopf-color, inherit); font-family: var(--typo-liste-kopf-family, inherit); }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table td       { padding: 0.6rem; border-bottom: 1px solid var(--color-border); font-variant-numeric: tabular-nums; }
.data-table tr:hover { background: var(--list-row-hover); }
/* ==============================================================
   BFT ACTION BUTTONS (.btn-bft)
   Desktop (>1280px): 44px Höhe, Icon 20px
   Tablet 481–1280px: 44px, 6 Buttons pro Zeile vor Umbruch
   Mobil (≤480px):    36px Höhe, Icon 16px (via Media-Query)
   Icon links, Beschriftung rechts.
   ============================================================== */
.btn-bft {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 14px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    box-sizing: border-box;
    text-decoration: none;
    width: auto;           /* Desktop: auto-Breite */
}
/* Icon: immer 20×20px, weiss auf farbigem Hintergrund */
.btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    object-fit: contain;
    filter: brightness(0) invert(1);
    vertical-align: middle;
}
.btn-bft-warning .btn-icon { filter: none; } /* Dunkel auf Gelb */
/* Farben */
.btn-bft-primary   { background: var(--btn-primary);   color: white; }
.btn-bft-secondary { background: var(--btn-secondary); color: white; }
.btn-bft-danger    { background: var(--btn-danger);    color: white; }
.btn-bft-success   { background: var(--btn-success);   color: white; }
.btn-bft-warning   { background: var(--btn-warning);   color: #212529; }
.btn-bft-dark      { background: var(--btn-dark);      color: white; }
.btn-bft-accent    { background: var(--btn-accent);    color: white; }
.btn-bft-info      { background: var(--btn-info);      color: white; }
/* Hover */
.btn-bft-primary:hover   { background: var(--btn-primary-hover,   #0069d9); }
.btn-bft-secondary:hover { background: var(--btn-secondary-hover, #5a6268); }
.btn-bft-danger:hover    { background: var(--btn-danger-hover,    #c82333); }
.btn-bft-success:hover   { background: var(--btn-success-hover,   #218838); }
.btn-bft-warning:hover   { background: var(--btn-warning-hover,   #e0a800); }
.btn-bft-dark:hover      { background: var(--btn-dark-hover,      #23272b); }
.btn-bft-accent:hover    { background: var(--btn-accent-hover,    #5a2d91); }
.btn-bft-info:hover      { background: var(--btn-info-hover,      #0b7a70); }

/* Aktions-Spalte global ausblenden — Buttons erscheinen bei Zeilen-Klick als Sub-Row */
.data-table thead th:last-child            { display: none; }
.data-table tbody td.td-actions            { display: none; }
.data-table tbody tr:not(.action-subrow)   { cursor: pointer; }
.data-table tbody tr.is-open               { background: var(--list-row-active) !important; }

/* Sub-Row: Aktionsbuttons als expandierte Zeile (Desktop: flex, Mobile: grid) */
.action-subrow td {
    padding: 0.5rem 0.75rem;
    background: var(--list-subrow-bg);
    border-bottom: 2px solid var(--list-subrow-border);
}
.action-subrow .td-actions-inner {
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* Aeltere Tabellen-Wrapper */
.table-container { background: var(--surface-color); border-radius: 0.5rem; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); overflow: hidden; }
.table-header    { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.table-header h3 { font-size: 1.125rem; color: var(--text-color); }


/* ============================================================
   9. NACHRICHTEN / ALERTS
   Verwendung in Python:  html += '<div class="msg-error">Fehler</div>'
   Verwendung in Jinja2:  <div class="msg-error">{{ message }}</div>
   ============================================================ */
.msg-error    { padding: 1rem; background: var(--color-error-bg);   color: var(--btn-danger);  border: 1px solid var(--btn-danger);  border-radius: 4px; }
.msg-warning  { padding: 1rem; background: var(--color-warning-bg); color: var(--btn-warning); border: 1px solid var(--btn-warning); border-radius: 4px; }
.msg-success  { padding: 1rem; background: var(--color-success-bg); color: var(--btn-success); border: 1px solid var(--btn-success); border-radius: 4px; }
.msg-info     { padding: 1rem; background: var(--color-info-bg);    color: var(--btn-info);    border: 1px solid var(--btn-info);    border-radius: 4px; }
.msg-error-sm { padding: 0.5rem 0.75rem; background: var(--color-error-bg); color: var(--btn-danger); border: 1px solid var(--btn-danger); border-radius: 4px; font-size: 0.9rem; }


/* ============================================================
   10. MODALE DIALOGE (generic_form.py / content.py)
   .modal-overlay      = voller Bildschirm mit dunklem Hintergrund (z=1000)
   .modal-overlay-top  = Modal mit Abstand fuer sticky Header  (z=2000)
   .modal-container    = weisser Dialog-Container (max 900px)
   .modal-container-wide = breiter Dialog (max 1100px)
   .modal-close-btn    = Abbrechen-Button oben rechts
   .modal-form-name    = kleiner Titel oben links (Formular-Name)
   ============================================================ */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-overlay-top {
    position: fixed; top: var(--form-top-offset, 0); left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
}
.modal-container      { background: white; padding: 2rem; border-radius: 8px; max-width: 900px; width: 90%; max-height: 90vh; overflow-y: auto; position: relative; }
.modal-container-wide { background: white; padding: 1.5rem; border-radius: 8px; max-width: 1100px; width: 95%; overflow-y: auto; position: relative; }
.modal-close-btn      { position: absolute; top: 0.5rem; right: 0.5rem; padding: 0.25rem 0.75rem; background: var(--btn-secondary); color: var(--color-text-inverse); border: none; border-radius: 4px; cursor: pointer; font-size: 0.85rem; }
.modal-form-name      { position: absolute; top: 0.5rem; left: 1rem; font-size: 0.75rem; color: var(--color-text-muted); font-family: var(--font-mono); }
/* Formular-Klassen für generic_form.rs */
.form-modal-container { background: var(--form-surface); }
.form-modal-title     { color: var(--typo-modul-titel-color, var(--color-primary-dark)); margin: 0; font-size: clamp(0.875rem, var(--typo-modul-titel-size, 1rem), 1.6rem); font-weight: var(--typo-modul-titel-weight, 600); font-family: var(--typo-modul-titel-family, var(--font-family)); }
.form-modal-divider   { border-bottom: 1px solid var(--color-border); padding-bottom: 0.25rem; }
.form-tab-active      { padding: 0.5rem 0.75rem; background: none; border: none; border-bottom: 2px solid var(--color-primary-dark); cursor: pointer; font-weight: 500; color: var(--color-primary-dark); font-size: 0.9rem; }
.form-tab-inactive    { padding: 0.5rem 0.75rem; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-weight: 500; color: var(--text-secondary); font-size: 0.9rem; }
.form-footer          { background: var(--form-surface); border-top: 2px solid var(--color-border); padding-top: 0.75rem; margin-top: 0.75rem; }
.form-badge           { display: inline-flex; align-items: center; gap: 0.1rem; background: var(--color-primary-dark); color: var(--color-text-inverse); border-radius: 12px; padding: 0.15rem 0.4rem; font-size: 0.8rem; }
.form-required-mark   { color: var(--input-invalid); }
.form-section-bg      { background: var(--color-surface-subtle); border: 1px solid var(--input-border); border-radius: 4px; padding: 4px; }
.form-mono-value      { font-size: 0.75rem; color: var(--color-text-muted); font-family: var(--font-mono); min-width: 3.5em; }
.form-overlay         { background: var(--color-overlay); }


/* ============================================================
   11. BUTTONS (Standard, normale Groesse)
   Verwendung: class="btn btn-primary"
   ============================================================ */
.btn           { padding: 0.5rem 1rem; border: none; border-radius: 0.375rem; cursor: pointer; font-size: 0.875rem; font-weight: 500; transition: all 0.2s; text-decoration: none; display: inline-block; }
.btn-primary   { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--secondary-color); color: white; }
.btn-secondary:hover { background: var(--btn-secondary-hover, #5a6268); }
.btn-success   { background: var(--success-color); color: white; }
.btn-danger    { background: var(--error-color); color: white; }
.btn-block     { width: 100%; }
.btn-logout    { padding: 0.5rem 1rem; background: var(--error-color); color: white; border: none; border-radius: 0.375rem; font-size: 0.875rem; cursor: pointer; transition: background 0.2s; }
.btn-logout:hover { background: var(--btn-danger-hover, #c82333); }


/* ============================================================
   12. BUTTONS (Klein, fuer Tabellen-Zeilen)
   Kombinieren: class="btn-sm btn-primary-sm"
   btn-sm    = Standard-Padding (mit margin-right)
   btn-sm-md = etwas breiter (ohne margin-right)
   ============================================================ */
.btn-sm    { padding: 0.25rem 0.5rem; border: none; border-radius: 4px; cursor: pointer; font-size: 0.8rem; display: inline-block; }
.btn-sm-md { padding: 0.25rem 0.75rem; border: none; border-radius: 4px; cursor: pointer; font-size: 0.85rem; display: inline-block; }
.btn-primary-sm   { background: var(--btn-primary);   color: var(--color-text-inverse); }
.btn-secondary-sm { background: var(--btn-secondary); color: var(--color-text-inverse); }
.btn-danger-sm    { background: var(--btn-danger);    color: var(--color-text-inverse); }
.btn-success-sm   { background: var(--btn-success);   color: var(--color-text-inverse); }
.btn-warning-sm   { background: var(--btn-warning);   color: #212529; }
.btn-info-sm      { background: var(--btn-teal);      color: var(--color-text-inverse); }
.btn-primary-sm:hover   { filter: brightness(0.9); }
.btn-secondary-sm:hover { filter: brightness(0.9); }
.btn-danger-sm:hover    { filter: brightness(0.9); }
.btn-success-sm:hover   { filter: brightness(0.9); }


/* ============================================================
   13. BADGES & STATUS-ANZEIGEN (generic_list.py)
   Verwendung: <span class="badge badge-success">Aktiv</span>
   .badge-toggle = anklickbar (Aktiv/Inaktiv umschalten via HTMX)
   ============================================================ */
.badge           { padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.75rem; color: white; display: inline-block; }

/* Dynamischer Zähler-Badge auf Aktions-Buttons (z.B. Vormerkungen(2)) */
.btn-badge {
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
    min-width:       18px;
    height:          18px;
    border-radius:   9px;
    font-size:       0.65rem;
    font-weight:     700;
    padding:         0 4px;
    margin-left:     4px;
    vertical-align:  middle;
    line-height:     1;
}
.btn-badge.badge-danger   { background: var(--badge-danger-bg,    #dc3545); color: var(--badge-danger-fg,    white); }
.btn-badge.badge-warning  { background: var(--badge-warning-bg,   #ffc107); color: var(--badge-warning-fg,   #212529); }
.btn-badge.badge-success  { background: var(--badge-success-bg,   #28a745); color: var(--badge-success-fg,   white); }
.btn-badge.badge-primary  { background: var(--badge-primary-bg,   #007bff); color: var(--badge-primary-fg,   white); }
.btn-badge.badge-secondary{ background: var(--badge-secondary-bg, #6c757d); color: var(--badge-secondary-fg, white); }
.badge-success   { background: var(--badge-success-bg,   #28a745); color: var(--badge-success-fg,   white); }
.badge-danger    { background: var(--badge-danger-bg,    #dc3545); color: var(--badge-danger-fg,    white); }
.badge-warning   { background: var(--badge-warning-bg,   #ffc107); color: var(--badge-warning-fg,   #212529); }
.badge-secondary { background: var(--badge-secondary-bg, #6c757d); color: var(--badge-secondary-fg, white); }
.badge-toggle    { cursor: pointer; }
/* Aktions-Badges fuer Aenderungsprotokoll (CREATE / UPDATE / DELETE) */
.badge-create    { background: var(--badge-success-bg,   #28a745); color: var(--badge-success-fg,   white); }
.badge-update    { background: var(--badge-primary-bg,   #007bff); color: var(--badge-primary-fg,   white); }
.badge-delete    { background: var(--badge-danger-bg,    #dc3545); color: var(--badge-danger-fg,    white); }
.badge-insert    { background: var(--badge-success-bg,   #28a745); color: var(--badge-success-fg,   white); }

/* === Diff-Ansicht (Aenderungsprotokoll Feldvergleich) ===
   .diff-row           = Basis-Zeile (unveraendert)
   .diff-row-changed   = Zeile mit Aenderung (gelb)
   .diff-row-json      = JSON-Feld mit Aenderung (blau)
   .diff-value         = Wert-Box (alt/neu)
   .diff-value-old     = Alter Wert (hellrot)
   .diff-value-new     = Neuer Wert (hellgruen)
*/
.diff-row          { background: var(--diff-row-bg, #f8f9fa); border: 2px solid var(--color-border); border-radius: 4px; padding: 0.75rem; }
.diff-row-changed  { background: var(--diff-changed-bg, #fff3cd); border: 2px solid var(--badge-warning-bg, #ffc107); border-radius: 4px; padding: 0.75rem; }
.diff-row-json     { background: var(--diff-json-bg, #e3f2fd); border: 2px solid var(--info-color, #2196f3); border-radius: 4px; padding: 0.75rem; }
.diff-field-name   { font-weight: 600; color: var(--text-color); margin-bottom: 0.5rem; font-size: 0.95rem; }
.diff-grid         { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.diff-label        { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 0.25rem; }
.diff-value        { padding: 0.5rem; border-radius: 3px; border: 1px solid var(--color-border); word-break: break-word; background: var(--form-surface); }
.diff-value-old    { background: var(--diff-old-bg, #ffebee); }
.diff-value-new    { background: var(--diff-new-bg, #e8f5e9); }


/* ============================================================
   14. LINKS
   Verwendung: <a class="link-primary">Text</a>
   ============================================================ */
.link-primary       { color: var(--color-text-link); text-decoration: none; font-weight: 500; cursor: pointer; }
.link-primary:hover { color: var(--color-primary-dark); text-decoration: underline; }


/* ============================================================
   15. FORMULARE (generisch, generic_form.py)
   .form-input  = Standard-Input / Select / Textarea
   .form-label  = Label ueber dem Feld
   .form-field  = Wrapper-Div um Label + Input
   ============================================================ */
.form-input        { width: 100%; padding: 0.5rem; border: 1px solid var(--input-border); border-radius: 4px; font-size: clamp(0.75rem, var(--typo-form-input-size, 0.875rem), 1rem); background: var(--input-bg); color: var(--typo-form-input-color, var(--input-text)); font-family: var(--typo-form-input-family, var(--font-family)); font-weight: var(--typo-form-input-weight, 400); }
.form-input:hover  { border-color: var(--input-border-hover); }
.form-input:focus  { outline: none; border-color: var(--input-border-focus); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.form-input:disabled { background: var(--input-disabled); color: var(--color-text-muted); cursor: not-allowed; }
.form-input[readonly] { background: var(--color-surface-subtle); }
.form-label        { display: block; margin-bottom: 0.25rem; font-weight: var(--typo-form-label-weight, 500); color: var(--typo-form-label-color, var(--label-color)); font-size: clamp(0.75rem, var(--typo-form-label-size, 0.875rem), 1rem); font-family: var(--typo-form-label-family, var(--font-family)); }
.form-field        { margin-bottom: 0.4rem; }


/* ============================================================
   15b. COLOR SELECT WIDGET (type=color_select in generic_form)
   Dropdown mit Farbswatch aus aktuellen CSS-Theme-Variablen
   ============================================================ */
.cs-wrapper      { position: relative; user-select: none; }
.cs-wrapper[data-disabled="true"] { opacity: 0.6; pointer-events: none; }
.cs-trigger      { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.6rem; cursor: pointer; border: 1px solid var(--input-border); border-radius: 4px; background: var(--input-bg); font-size: 0.875rem; transition: border-color 0.15s; }
.cs-trigger:hover { border-color: var(--input-border-hover); }
.cs-swatch       { width: 18px; height: 18px; border-radius: 3px; flex-shrink: 0; border: 1px solid rgba(0,0,0,0.15); }
.cs-cur-label    { flex: 1; font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-color); }
.cs-arrow        { color: var(--color-text-muted); font-size: 0.7rem; }
.cs-dropdown     { position: absolute; top: calc(100% + 2px); left: 0; right: 0; background: var(--form-surface); border: 1px solid var(--input-border); border-radius: 6px; box-shadow: var(--shadow-md); z-index: 600; max-height: 260px; overflow-y: auto; }
.cs-option       { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.6rem; cursor: pointer; transition: background 0.1s; }
.cs-option:hover { background: var(--color-surface-subtle); }
.cs-option.cs-selected { background: var(--list-row-active); }
.cs-opt-label    { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-color); }

/* ============================================================
   16. TABS
   Verwendung: <div class="tab-bar"><button class="tab-btn">Tab</button></div>
   Aktiver Tab: .tab-btn.active oder data-Attribut per JavaScript
   ============================================================ */
.tab-bar { border-bottom: 2px solid var(--color-border); margin-bottom: 1rem; display: flex; gap: 0.25rem; flex-wrap: wrap; }
.tab-btn { padding: 0.5rem 0.75rem; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-weight: 500; color: var(--text-secondary); transition: all 0.2s; font-size: var(--font-size-tab, 0.9rem); margin-bottom: -2px; }
.tab-btn.active,
.tab-btn[aria-selected="true"] { color: var(--color-primary-dark); border-bottom-color: var(--color-primary-dark); }


/* ============================================================
   17. INFO-GRID (Detail-Ansicht)
   Zweispaltige Label/Wert-Tabelle
   Verwendung: <div class="info-grid"><strong>Log-ID:</strong><span>123</span>...
   ============================================================ */
.info-grid { display: grid; grid-template-columns: 150px 1fr; gap: 0.5rem; font-size: 0.9rem; color: var(--color-text-muted); margin-bottom: 1.5rem; background: var(--color-surface-subtle); padding: 1rem; border-radius: 4px; }


/* ============================================================
   18. CODE-BLOCK
   Verwendung: <pre class="code-block">...</pre>
   ============================================================ */
.code-block { background: var(--color-surface-subtle); padding: 1rem; border-radius: 4px; overflow-x: auto; font-size: 0.85rem; font-family: var(--font-mono); white-space: pre-wrap; word-wrap: break-word; }


/* ============================================================
   19. FLASH-NACHRICHTEN (Toasts, utils.py showNotification)
   Erscheinen animiert oben rechts
   ============================================================ */
.flash-messages    { position: fixed; top: 80px; right: 20px; z-index: 1000; max-width: 400px; }
.flash             { padding: 1rem; margin-bottom: 0.5rem; border-radius: 0.375rem; box-shadow: var(--shadow-lg); display: flex; justify-content: space-between; align-items: center; animation: slideIn 0.3s ease-out; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.flash-success     { background: #d1fae5; color: #065f46; border-left: 4px solid var(--success-color); }
.flash-error       { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--error-color); }
.flash-warning     { background: #fef3c7; color: #92400e; border-left: 4px solid var(--warning-color); }
.flash-info        { background: #dbeafe; color: #1e40af; border-left: 4px solid var(--info-color); }
.flash-close       { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: inherit; opacity: 0.5; }
.flash-close:hover { opacity: 1; }


/* ============================================================
   20. DEBUG-INFO
   Sichtbarkeit server-seitig gesteuert (utils/debug.py).
   Python rendert diese Elemente NUR wenn
   system_einstellungen.debug-info = 'Ja'.
   -> Kein JavaScript-Toggle noetig!
   .debug-hint       = inline (z.B. Feldname in Label)
   .debug-hint-block = block  (z.B. Route oben links in Liste/Formular)
   ============================================================ */
.debug-hint       { color: var(--typo-debug-info-color, var(--debug-color)); font-family: var(--typo-debug-info-family, var(--font-mono)); font-size: clamp(0.65rem, var(--typo-debug-info-size, 0.75rem), 0.9rem); font-weight: var(--typo-debug-info-weight, 400); opacity: 0.9; margin-left: 0.5rem; display: inline; }
.debug-hint-block { color: var(--typo-debug-info-color, var(--debug-color)); font-family: var(--typo-debug-info-family, var(--font-mono)); font-size: clamp(0.65rem, var(--typo-debug-info-size, 0.75rem), 0.9rem); font-weight: var(--typo-debug-info-weight, 400); opacity: 0.9; margin-bottom: 0.25rem; display: block; }


/* ============================================================
   21. FEHLERSEITE (templates/error.html)
   ============================================================ */
.error-page          { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 200px); }
.error-container     { text-align: center; }
.error-container h1  { font-size: 6rem; color: var(--primary-color); margin-bottom: 1rem; }
.error-container h2  { font-size: 1.5rem; color: var(--text-color); margin-bottom: 1rem; }
.error-container p   { color: var(--text-secondary); margin-bottom: 2rem; }
.footer              { text-align: center; padding: 2rem; background: var(--surface-color); border-top: 1px solid var(--border-color); color: var(--text-secondary); font-size: 0.875rem; }


/* ============================================================
   23. FAHRTEN-FORMULAR GRID-LAYOUTS
   Desktop-Werte als CSS-Klassen – responsive Overrides in § 22.
   HTML-Struktur ist identisch auf Desktop und Smartphone:
   Nur CSS unterscheidet die Darstellung.
   ============================================================ */

/* Basisdaten: Datum | Wochentag | Uhrzeit | Status */
.bft-grid-basisdaten {
    display: grid;
    grid-template-columns: 1fr auto 1fr 1.2fr;
    gap: 0.5rem;
    align-items: end;
    margin-bottom: 1rem;
}

/* Wegpunkt-Hauptgrid: Links (Typ/Zeit/Personen) | Mitte (Adresse) | Rechts (Route) */
.bft-grid-wegpunkt {
    display: grid;
    grid-template-columns: 280px 1fr 180px;
    gap: 1rem;
}

/* Wegpunkt-Innengrid: Datum | Wochentag | Uhrzeit */
.bft-grid-wp-datetime {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.4rem;
    align-items: end;
}

/* Wegpunkt-Mittelspalte: Adresse + Ein/Aussteigen */
.bft-wp-middle-col {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Wegpunkt-Spalte rechts: Google Route-Info */
.bft-wegpunkt-col3 {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Adress-Innengrid: Land | PLZ | Ort */
.bft-grid-address-lpo {
    display: grid;
    grid-template-columns: 70px 90px 1fr;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}

/* Metriken: Gefahrene KM | Auslagen */
.bft-grid-metriken {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}


/* ============================================================
   22. RESPONSIVE
   Desktop: > 480px — kein einziger Desktop-Style wird veraendert
   Mobile:  ≤ 480px — Galaxy Z Flip 7 Hauptscreen Portrait ~360-390px
   Cover:   ≤ 300px — Flip 7 Cover-Screen ~260px
   ============================================================ */

/* --- Mobile-only Elemente: auf Desktop IMMER versteckt ---
   !important verhindert Override durch spaetere CSS-Regeln
   oder Inline-Styles. Nur @media (max-width:480px) hebt das auf.
   ----------------------------------------------------------- */
.mobile-header-bar  { display: none !important; }
.mobile-menu-panel  { display: none !important; }
.bottom-nav         { display: none !important; }

/* --- Bottom Navigation Basis-Styles --- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 56px; z-index: 600;
    background: var(--header-bg);
    border-top: 2px solid rgba(220,20,60,0.2);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.12);
    align-items: stretch;
}
.bottom-nav-btn {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    background: none; border: none; cursor: pointer;
    font-size: 0.6rem; font-weight: 600; color: #555;
    border-right: 1px solid rgba(0,0,0,0.08);
    min-height: 48px; padding: 0.25rem;
    transition: background 0.15s;
}
.bottom-nav-btn:last-child  { border-right: none; }
.bottom-nav-btn:active       { background: rgba(0,0,0,0.08); }
.bottom-nav-btn-icon         { font-size: 1.25rem; line-height: 1; }

/* --- Mobile Menu Drawer --- */
.mobile-menu-panel {
    position: fixed;
    top: 48px; left: 0; right: 0; /* direkt unter mobile-header-bar */
    background: var(--user-info-bg);
    border-bottom: 2px solid var(--user-info-border);
    padding: 1rem;
    z-index: 9999;
    transform: translateY(-120%);
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1),
                visibility 0s linear 0.25s;
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
    /* Wenn geschlossen: unsichtbar + nicht klickbar */
    visibility: hidden;
    pointer-events: none;
}
.mobile-menu-panel.open {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1),
                visibility 0s linear 0s;
}
.mobile-menu-close {
    position: absolute; top: 0.5rem; right: 0.75rem;
    background: none; border: none;
    font-size: 1.4rem; cursor: pointer; color: #666;
    padding: 0.25rem;
}

/* ============================================================
   BREAKPOINT < 480px — Galaxy Z Flip 7 Hauptscreen
   ============================================================ */
@media (max-width: 480px) {

    /* --- Viewport Fix --- */
    html, body { height: 100svh; }

    /* --- Desktop-Header und Footer verstecken --- */
    .app-header { display: none !important; }
    .app-footer { display: none !important; }

    /* --- Mobile UI einblenden (ueberschreibt das desktop display:none !important) --- */
    .mobile-header-bar { display: flex !important; }
    .mobile-menu-panel { display: block !important; } /* transition aktiv */
    .bottom-nav        { display: flex !important; }

    /* --- Hauptinhalt: scrollbar + Platz fuer Bottom-Nav --- */
    #main-content {
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: 60px;
        -webkit-overflow-scrolling: touch;
    }

    /* --- M050 Fahrtenmanagement / Tagesdisposition ---
       Desktop nutzt height:100% + internen flex:1-Scroll. Auf schmalen
       Screens fuellen Toolbar + Filter die Viewport-Hoehe, sodass der
       flex:1-Listenbereich auf 0px kollabiert und nicht scrollbar ist.
       -> Feste Hoehe entsperren; die Seite (#main-content) uebernimmt
          das Scrollen und die komplette Fahrten-Liste wird erreichbar. */
    .bft-m050-view   { height: auto !important; min-height: 0; }
    .bft-m050-scroll { flex: none !important; overflow-y: visible !important; overflow-x: auto !important; }

    /* --- Dashboard: 2-Spalten-Grid statt Flex-Rows --- */
    .dashboard-scroll { padding: 0.6rem; }
    .dashboard-container { gap: 0.5rem; }
    .dashboard-row {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
        flex: unset !important;
        margin-bottom: 0 !important;
    }
    .dashboard-kachel {
        width: 100% !important;
        height: auto !important;
        min-height: 90px !important;
        padding: 0.6rem !important;
        flex-direction: column !important;
        text-align: center !important;
    }
    .dashboard-kachel-empty { width: 100% !important; height: 90px !important; }
    .kachel-icon        { font-size: 1.6rem !important; }
    .kachel-title       { font-size: 0.72rem !important; }
    .kachel-description { font-size: 0.62rem !important; }
    .kachel-modul-id    { font-size: 0.55rem !important; }

    /* --- Login-Seite --- */
    .login-page      { padding: 0; align-items: flex-start; }
    .login-container { padding: 1rem; max-width: 100%; }
    .login-box       { padding: 1.25rem; border-radius: 8px; }
    .login-header h1 { font-size: 1.3rem; }

    /* --- Datentabellen: Kompaktere Schrift + Abstände --- */
    .data-table             { font-size: 0.75rem; }
    .data-table th,
    .data-table td          { padding: 0.35rem 0.4rem; }

    /* Sub-Row Mobile: 3-Spalten-Grid statt Desktop-Flex */
    .action-subrow td {
        padding: 0.5rem 0.4rem;
        background: #eef4ff;
        border-bottom: 2px solid #c7d9f5;
    }
    .action-subrow .td-actions-inner {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px;
        width: calc(100vw - 1.6rem);
        max-width: calc(100vw - 1.6rem);
    }
    /* btn-bft in Sub-Row Mobile: kompaktere Grösse */
    .action-subrow .td-actions-inner .btn-bft {
        width: 100% !important;
        justify-content: center !important;
        height: 34px !important;
        font-size: 0.72rem !important;
        padding: 0 8px !important;
        gap: 5px !important;
    }
    /* Auch ausserhalb Sub-Row verkleinern (z.B. M059, M061 Tabellenzeilen) */
    .btn-bft {
        height: 36px;
        font-size: 0.78rem;
        padding: 0 10px;
        gap: 6px;
    }
    .btn-icon {
        width: 16px;
        height: 16px;
    }
    /* Legacy btn-action (für Module die noch nicht umgestellt) */
    .btn-action {
        display: flex !important;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 0 0.75rem !important;
        font-size: 0.85rem !important;
        min-height: 44px;
        min-width: 0;
        width: 100%;
        border-radius: 7px !important;
        margin: 0 !important;
        box-sizing: border-box;
    }
    .btn-action-label { font-size: 0.85rem; font-weight: 500; }

    /* --- Modale Formulare: Vollbild (Stufe 2) --- */
    .modal-overlay,
    .modal-overlay-top {
        align-items: flex-start !important;
        padding: 0 !important;
    }
    .modal-container,
    .modal-container-wide {
        width:  100vw !important;
        max-width: 100vw !important;
        height: calc(100svh - 48px) !important;
        max-height: none !important;
        border-radius: 0 !important;
        padding: 0.75rem !important;
        margin: 0 !important;
        overflow-y: auto !important;
    }

    /* --- Flash-Nachrichten nach unten (über Bottom-Nav) --- */
    .flash-messages {
        top: auto; bottom: 64px;
        left: 8px; right: 8px;
        max-width: none;
    }

    /* --- Tabs: horizontal scrollbar --- */
    .tab-bar { overflow-x: auto; flex-wrap: nowrap; }
    .tab-btn { white-space: nowrap; font-size: 0.78rem; padding: 0.35rem 0.55rem; }

    /* --- Buttons in Tabellen: Touch-freundlich --- */
    .btn-sm, .btn-sm-md { padding: 0.35rem 0.6rem; font-size: 0.75rem; }

    /* --- Fahrten-Formular: Responsive Grids (§ 23) --- */
    /* Modal: Vollbild, kein Rand */
    .bft-form-modal-inner {
        padding: 0.75rem !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        max-height: calc(100svh - 48px) !important;
    }
    /* Basisdaten: 2-spaltig (Datum | Uhrzeit), Wochentag versteckt */
    .bft-grid-basisdaten    { grid-template-columns: 1fr 1fr; }
    #weekday-display,
    [id^="wp-weekday-"]     { display: none; }
    .bft-status-field       { grid-column: 1 / -1; }  /* Status volle Breite */
    /* Wegpunkt: alle Spalten untereinander */
    .bft-grid-wegpunkt      { grid-template-columns: 1fr; }
    /* Alle Panels gleich breit: max-width:75% der Mittelspalten-Kinder aufheben */
    .bft-wp-middle-col > * { max-width: 100% !important; width: 100% !important; }
    /* Land kürzer, PLZ kürzer → mehr Platz für Ort */
    .bft-grid-address-lpo   { grid-template-columns: 45px 70px 1fr; }
    .bft-grid-wp-datetime   { grid-template-columns: 1fr 1fr; }
    /* Metriken: einspaltig */
    .bft-grid-metriken      { grid-template-columns: 1fr; }
}

/* ============================================================
   BREAKPOINT 481px–1280px — Tablet / kleiner Desktop
   Buttons wrappen erst nach 6 Stück (statt 3)
   ============================================================ */
@media (min-width: 481px) and (max-width: 1280px) {
    .td-actions-inner {
        grid-template-columns: repeat(6, auto);
    }
    .action-subrow .td-actions-inner {
        grid-template-columns: repeat(6, auto);
        max-width: none;
    }
    .action-subrow .td-actions-inner .btn-bft {
        width: auto;
    }
}

/* ============================================================
   BREAKPOINT < 300px — Galaxy Z Flip 7 Cover-Screen (~260px)
   ============================================================ */
@media (max-width: 300px) {
    /* 1-Spalte auf dem winzigen Cover-Screen */
    .dashboard-row {
        grid-template-columns: 1fr !important;
    }
    .dashboard-kachel { min-height: 72px !important; }
    .kachel-icon      { font-size: 1.3rem !important; }
}

/* ============================================================
   Hilfesystem — Info-Icon + Popup (help-popup.js)
   ============================================================ */
.help-icon {
    display: inline-block;
    color: #1e3c72;
    cursor: help;
    font-size: 0.95em;
    line-height: 1;
    vertical-align: baseline;
    opacity: 0.7;
    user-select: none;
}
.help-icon:hover,
.help-icon:focus { opacity: 1; outline: none; }

.help-popup {
    position: fixed;
    z-index: 3000;
    max-width: 320px;
    background: #e0f7fa;            /* eigene Tooltip-Farbe: helles Cyan */
    border: 1px solid #4dd0e1;
    border-left: 4px solid #0097a7;
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
    padding: 0.7rem 0.85rem;
    font-size: 0.85rem;
    line-height: 1.45;
    color: #0b3a4a;
}
.help-popup-title {
    font-weight: 700;
    color: #00697a;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}
.help-popup-body { white-space: pre-line; }
.help-popup-actions { margin-top: 0.6rem; text-align: right; }
.help-popup-more {
    background: #0097a7;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
.help-popup-more:hover { background: #00838f; }

@media (max-width: 600px) {
    .help-popup { max-width: 88vw; }
}

/* Tooltips global deaktiviert (System-Einstellung tooltips=Nein) */
.bft-tooltips-off .help-icon { display: none; }
