/* =============================================================
   TT Lizenzserver - Stylesheet (Mobile-First)
   Funktioniert flüssig auf Smartphone, Tablet, Desktop.
   Keine externen CDN-Abhängigkeiten.
   ============================================================= */

:root {
    --bg:           #f4f5f7;
    --surface:      #ffffff;
    --surface-alt:  #fafbfc;
    --text:         #1a1d23;
    --muted:        #6b7280;
    --border:       #e5e7eb;
    --primary:      #2563eb;
    --primary-dark: #1d4ed8;
    --success:      #16a34a;
    --warning:      #d97706;
    --danger:       #dc2626;
    --radius:       10px;
    --radius-sm:    6px;
    --shadow:       0 1px 2px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
    margin: 0; padding: 0; min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px; line-height: 1.5;
    color: var(--text); background: var(--bg);
    -webkit-text-size-adjust: 100%;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 8px; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; }
code, pre, .mono { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }

/* =============================================================
   AUTH (Login + 2FA)
   ============================================================= */
.auth-body {
    min-height: 100vh; padding: 20px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
.auth-card {
    background: var(--surface);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    padding: 32px 24px;
    width: 100%; max-width: 420px;
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-logo { font-size: 44px; margin-bottom: 10px; }
.auth-brand h1 { font-size: 20px; margin: 0; }
.auth-sub { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.totp-input {
    text-align: center; font-size: 24px !important;
    letter-spacing: 8px; font-family: monospace;
}

/* =============================================================
   APP-LAYOUT (Mobile-First: Drawer von LINKS + FAB, Desktop: feste Sidebar)
   ============================================================= */
.app { min-height: 100vh; }
/* Kein 'overflow-x:hidden' auf body - das wuerde mobiles horizontales
   Scrollen unterbinden. Stattdessen sorgen wir dafuer, dass Container
   nicht ueberlaufen, und schalten bei einzelnen breiten Inhalten
   (Tabellen, Codebox) einen lokalen horizontalen Scrollbalken ein. */

/* Sidebar / Topbar - auf Mobile ein Slide-In-Drawer von LINKS */
.topbar {
    background: #1e293b; color: #e2e8f0;
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 280px; max-width: 85vw;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 16px rgba(0,0,0,.25);
    overflow-y: auto;
    overscroll-behavior: contain;
}
body.nav-open .topbar { transform: translateX(0); }

.topbar-brand {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid #334155;
    gap: 10px;
}
.brand-link {
    color: inherit;
    text-decoration: none !important;
    flex: 1; min-width: 0;
    border-radius: var(--radius-sm);
    padding: 4px 6px; margin: -4px -6px;
    transition: background 0.12s;
}
.brand-link:hover { background: rgba(255,255,255,.05); }
.brand-name { font-weight: 700; color: #fff; font-size: 15px; line-height: 1.3; }
.brand-sub { color: #94a3b8; font-size: 11px; margin-top: 2px; }

.menu-close {
    background: transparent; border: none; color: #94a3b8;
    width: 36px; height: 36px;
    font-size: 18px; cursor: pointer;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.menu-close:hover { background: rgba(255,255,255,.05); color: #fff; }

.nav-list {
    display: flex; flex-direction: column;
    padding: 10px 8px;
    gap: 1px;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; color: #cbd5e1; border-radius: var(--radius-sm);
    font-size: 14px; text-decoration: none !important;
    transition: background 0.12s;
}
.nav-item:hover { background: #334155; color: #fff; }
.nav-item.active { background: #2563eb; color: #fff; }
.nav-icon { width: 18px; text-align: center; opacity: .9; }
.nav-item-bottom {
    margin-top: 10px;
    border-top: 1px solid rgba(255,255,255,.08);
    padding-top: 14px;
    margin-top: auto;
}

.user-chip {
    padding: 12px 16px;
    border-top: 1px solid #334155;
    display: flex; align-items: center; gap: 10px;
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: #2563eb; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
}
.user-name { color: #fff; font-size: 13px; font-weight: 500; }

.logout-form { padding: 0 14px 12px; }
.logout-btn {
    width: 100%; padding: 8px 12px;
    background: transparent; color: #cbd5e1;
    border: 1px solid #475569; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 13px;
}
.logout-btn:hover { background: #334155; color: #fff; border-color: #64748b; }

.brand-footer {
    padding: 8px 16px 14px;
    font-size: 11px; color: rgba(255,255,255,.4);
    text-align: center; line-height: 1.4;
}

/* Backdrop hinter dem Drawer */
.nav-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    opacity: 0; pointer-events: none;
    z-index: 55;
    transition: opacity 0.25s ease;
}
body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

/* Mobile-Header: schlank, sticky, oben */
.mobile-header {
    background: #1e293b; color: #e2e8f0;
    padding: 12px 16px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 40;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    /* Safe-area fuer iPhone-Notch */
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
}
.mh-brand {
    color: inherit;
    text-decoration: none !important;
    flex: 1; min-width: 0;
    border-radius: var(--radius-sm);
    padding: 4px 6px; margin: -4px -6px;
    transition: background 0.12s;
}
.mh-brand:hover { background: rgba(255,255,255,.05); }
.mh-title {
    font-weight: 700; color: #fff; font-size: 15px;
}
.mh-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: #2563eb; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
}

/* Floating Action Button - unten rechts (analog JTL-Backend) */
.fab {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: calc(20px + env(safe-area-inset-right));
    width: 56px; height: 56px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(37,99,235,.4);
    cursor: pointer;
    z-index: 70;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s, background 0.2s;
    padding: 0;
    line-height: 1;
}
.fab:hover { background: #1d4ed8; transform: scale(1.05); }
.fab:active { transform: scale(0.95); }
/* Icon kommt allein aus dem ::before-Pseudo - kein Text im <span>! */
.fab-icon { display: inline-block; font-size: 24px; line-height: 1; }
.fab-icon::before { content: '☰'; }
body.nav-open .fab { background: #475569; }
body.nav-open .fab-icon::before { content: '✕'; font-size: 22px; }

/* Verstecke den alten Hamburger-Toggle vollstaendig - wird durch FAB ersetzt */
.menu-toggle { display: none; }

.main { flex: 1 1 auto; padding: 16px; min-width: 0; }
.container { max-width: 1280px; margin: 0 auto; min-width: 0; }

.page-header { margin-bottom: 18px; }
.page-sub { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.page-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* =============================================================
   Cards / Sections
   ============================================================= */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px; gap: 10px; flex-wrap: wrap;
}
.section-title {
    font-size: 13px; font-weight: 600; margin: 18px 0 10px;
    padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.section-title:first-child { margin-top: 0; }

/* Stat-Grid */
.stat-grid {
    display: grid; gap: 12px;
    /* min(140px, 100%) verhindert Overflow auf sehr schmalen Viewports:
       Wenn 100% kleiner als 140px ist, faellt das Grid auf eine Spalte. */
    grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
    min-width: 0;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
    min-width: 0;
}
.stat-num { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label {
    color: var(--muted); font-size: 11px; margin-top: 6px;
    text-transform: uppercase; letter-spacing: .04em;
}

/* =============================================================
   PWA-Install-Banner (slide-in unten)
   ============================================================= */
.tt-pwa-banner {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 20px; right: 20px;
    max-width: 480px;
    margin: 0 auto;
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0,0,0,.3);
    padding: 14px 16px;
    display: flex; align-items: center; gap: 12px;
    z-index: 80;
    transform: translateY(calc(100% + 40px));
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
}
.tt-pwa-banner.is-visible { transform: translateY(0); opacity: 1; }
.tt-pwa-icon {
    font-size: 28px; line-height: 1;
    flex-shrink: 0;
}
.tt-pwa-text { flex: 1; min-width: 0; }
.tt-pwa-title {
    font-weight: 600; color: #fff; font-size: 14px; margin-bottom: 3px;
}
.tt-pwa-body {
    font-size: 12px; color: #94a3b8; line-height: 1.4;
}
.tt-pwa-body strong { color: #cbd5e1; }
.tt-pwa-actions {
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.tt-pwa-btn-primary {
    background: #2563eb; color: #fff;
    border: none; border-radius: 6px;
    padding: 7px 12px; font-size: 13px; font-weight: 500;
    cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}
.tt-pwa-btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.tt-pwa-btn-primary:disabled { opacity: .5; cursor: wait; }
.tt-pwa-btn-ghost {
    background: transparent; color: #94a3b8;
    border: 1px solid #475569; border-radius: 6px;
    padding: 7px 10px; font-size: 12px; cursor: pointer;
}
.tt-pwa-btn-ghost:hover { background: rgba(255,255,255,.05); color: #cbd5e1; }
.tt-pwa-btn-close {
    background: transparent; color: #64748b;
    border: none; cursor: pointer;
    width: 28px; height: 28px;
    border-radius: 50%; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
}
.tt-pwa-btn-close:hover { background: rgba(255,255,255,.05); color: #cbd5e1; }

/* Wenn das Banner sichtbar ist, FAB etwas hoeher schieben damits nicht
   ueberlappt. */
.tt-pwa-banner.is-visible ~ .fab,
body:has(.tt-pwa-banner.is-visible) .fab {
    bottom: calc(110px + env(safe-area-inset-bottom));
}

/* iOS-Banner ist eine Anleitung, kein Button - bekommt mehr Breite */
@media (max-width: 480px) {
    .tt-pwa-banner {
        flex-wrap: wrap;
    }
    .tt-pwa-actions { width: 100%; justify-content: flex-end; }
    .tt-pwa-icon { display: none; }   /* Platzsparen auf sehr schmalen Screens */
}

/* Standalone-Modus: spezielle Anpassungen sobald die App installiert ist */
body.pwa-installed .tt-pwa-banner { display: none !important; }
/* Optionaler "App-Modus"-Hinweis fuer Debug: kleine Pille im Header. */
body.pwa-installed .mobile-header::after {
    content: 'APP';
    margin-left: auto;
    margin-right: 8px;
    font-size: 9px;
    font-weight: 700;
    color: #2563eb;
    background: rgba(37,99,235,.15);
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: .05em;
}

/* =============================================================
   Tabellen + Code-Boxen bekommen einen horizontalen Scrollbalken
   wenn ihr Inhalt zu breit fuer den Viewport ist - statt das Layout
   zu sprengen oder das ganze Portal horizontal scrollen zu lassen.
   ============================================================= */
@media (max-width: 979px) {
    /* Cards: Inhalt darf bei Bedarf horizontal scrollen */
    .card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    pre, .codebox { overflow-x: auto; max-width: 100%; }
    /* Stats-Grid und Stats-Cards duerfen nicht laenger als der Viewport sein */
    .stat-grid, .stat-card { max-width: 100%; }
}

/* Mobile Card-Layout fuer .table:
   Statt horizontalem Scroll wird jede Zeile zu einer eigenen Karte,
   Spalten stapeln sich vertikal. Header wird ausgeblendet.
   Ausnahmen: .table-keep = klassische Tabelle beibehalten (mit h-Scroll).

   Dieses Muster wird bewusst breit ausgerollt: es wirkt auf ALLE
   Tabellen in .card oder .main auf schmalen Viewports, egal ob mit
   class="table" oder inline-styled. Damit ist die Ansicht
   ueberall konsistent.
   */
@media (max-width: 720px) {
    /* v1.5.54: LESBARER auf Mobile.
       Basis-Schriftgroesse: 16px (bessere Lesbarkeit als 15px, verhindert
       auch iOS-Auto-Zoom beim Antippen von Inputs). */
    html, body { font-size: 16px !important; }

    /* Sicherstellen dass die Seite auf Mobile immer scrollbar ist. */
    html, body {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: auto;
    }
    .app, .main { overflow: visible; max-width: 100vw; }
    .container { max-width: 100%; overflow: visible; }

    /* Bessere Titel-Groesse */
    h1 { font-size: 22px !important; line-height: 1.3; }
    h2 { font-size: 17px !important; line-height: 1.3; }
    h3 { font-size: 15px !important; }
    .page-sub { font-size: 14px !important; color: #64748b; }

    /* Card-Tabellen: 15px statt 12/13px - gut lesbar */
    .main table:not(.table-keep) {
        display: block; width: 100%; min-width: 0;
        border-collapse: collapse;
        font-size: 15px;
    }
    .main table:not(.table-keep) thead { display: none; }
    .main table:not(.table-keep) tbody { display: block; }
    .main table:not(.table-keep) tr {
        display: block;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 14px 16px;
        box-shadow: 0 1px 3px rgba(0,0,0,.04);
    }
    .main table:not(.table-keep) tr:last-child { margin-bottom: 0; }
    .main table:not(.table-keep) td {
        display: block;
        padding: 6px 0 !important;
        border: none !important;
        text-align: left !important;
        white-space: normal !important;
        word-break: break-word;
        overflow-wrap: anywhere;
        max-width: 100%;
        font-size: 15px;
        line-height: 1.5;
    }
    .main table:not(.table-keep) td:first-child {
        font-weight: 700;
        font-size: 16px;
        margin-bottom: 6px;
        padding-bottom: 8px !important;
        border-bottom: 1px solid #f1f5f9 !important;
    }
    /* Wenn eine Zelle ein data-label-Attribut traegt, das Label vorschalten */
    .main table:not(.table-keep) td[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: #64748b;
        font-size: 12px;
        text-transform: uppercase;
        display: block;
        margin-bottom: 3px;
        letter-spacing: 0.03em;
    }

    /* Cards: horizontales Scrolling wenn zu breit, vertikal ueber die Seite */
    .card {
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        padding: 16px !important;
    }
    /* Dashboard-Scroll-Container: begrenzte Hoehe fuer inneres Scrolling */
    .dash-scroll {
        max-height: 60vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
    }
    .card.dash-card { padding: 14px !important; }
    .card.dash-card > .card-head { margin-bottom: 12px; }
    .card.dash-card .card-head h2 { font-size: 16px !important; }

    /* Buttons: groesserer Tap-Bereich (min 44x44 nach iOS-Standard) */
    .btn {
        min-height: 44px;
        padding: 10px 18px !important;
        font-size: 15px !important;
    }
    .btn-sm { min-height: 36px; padding: 8px 14px !important; font-size: 14px !important; }

    /* Inputs: min 16px damit iOS nicht zoomt */
    input, textarea, select {
        font-size: 16px !important;
        min-height: 44px;
    }
    input[type="checkbox"], input[type="radio"] {
        min-height: auto;
        width: 20px; height: 20px;
    }

    /* Badges leserlicher */
    .badge {
        white-space: normal;
        word-break: break-word;
        display: inline-block;
        font-size: 12px !important;
        padding: 4px 10px !important;
    }
    /* mono/small Klassen auf Mobile leserlicher */
    .main table:not(.table-keep) .mono {
        word-break: break-all;
        font-size: 13px;
    }
    /* Verschluesselte oder lange Codes/IDs: kleinere Schrift + break */
    .main table:not(.table-keep) a,
    .main table:not(.table-keep) code {
        word-break: break-all;
        overflow-wrap: anywhere;
    }
    /* Filter-Formulare kompakter */
    .filter-row { grid-template-columns: 1fr !important; gap: 12px; }
    .filter-cell { min-width: 0; }
    /* Page-Header auf Mobile: Aktionen unter den Titel legen */
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header > div:last-child { margin-top: 10px; }
    /* Sub-Nav horizontal scrollbar auf Mobile */
    .subnav { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .subnav-item { padding: 12px 16px !important; font-size: 14px !important; }
    /* Alerts leserlicher */
    .alert { padding: 14px 16px !important; font-size: 14px !important; }
}

/* =============================================================
   Forms
   ============================================================= */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.field-label .req { color: var(--danger); }
input[type="text"], input[type="password"], input[type="email"],
input[type="search"], input[type="date"], input[type="number"],
input[type="datetime-local"], input[type="time"], input[type="url"],
input[type="tel"],
select, textarea {
    width: 100%; padding: 11px 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font: inherit; font-size: 15px;  /* 16px+ verhindert Auto-Zoom iOS */
    color: var(--text); background: var(--surface, #fff);
    line-height: 1.4;
    box-sizing: border-box;
    min-height: 44px;
    /* Native-Browser-Look unterdruecken (vor allem fuer datetime-local) */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Lizenzportal ist Light-only - sonst override't das System-Dark
       das datetime-local-Picker-Rendering und es sieht inkonsistent aus. */
    color-scheme: light;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* Picker-Indicator: rechtsbuendig, dezent */
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: .55;
    padding: 4px;
    margin-right: 2px;
}
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
.check-row {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 8px 0; cursor: pointer;
}
.check-row input { margin-top: 3px; width: 18px; height: 18px; }
.form-actions {
    margin-top: 18px; padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex; gap: 10px; flex-wrap: wrap;
}

/* =============================================================
   Buttons
   ============================================================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
    text-decoration: none !important; min-height: 42px;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-sm { padding: 6px 12px; min-height: 32px; font-size: 13px; }
.btn-block { width: 100%; }

/* v1.5.91: Universelle Utility fuer Button-Gruppen.
 * Nutzung: <div class="tt-actions">...buttons/forms...</div>
 * Alle direkten Kinder werden mit sauberem Gap horizontal angeordnet und
 * duerfen bei Platzmangel umbrechen. Formulare werden inline behandelt. */
.tt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.tt-actions > form { margin: 0; }
.tt-actions > form > .btn { width: 100%; }

/* v1.5.91: Fallback fuer <td>-Zellen mit mehreren Buttons/Forms als DIREKTE
 * Kinder (ohne .tt-actions-Wrapper). Kleiner Abstand zwischen den Elementen
 * damit sie nicht aneinander kleben. Greift NICHT wenn schon ein Wrapper-DIV
 * drin ist (z.B. .tt-action-grid in der Versions-Tabelle). */
td > .btn + .btn,
td > .btn + form,
td > form + .btn,
td > form + form { margin-left: 6px; }
td > form { display: inline-block; }

/* =============================================================
   Tables - auf Mobile als Cards umstrukturiert
   ============================================================= */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    text-align: left; padding: 12px; font-size: 13.5px;
    border-bottom: 1px solid var(--border); vertical-align: top;
}
.table th {
    color: var(--muted); font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .03em; background: var(--surface-alt);
}
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Mobile: Tabelle als Cards */
@media (max-width: 720px) {
    .table-mobile, .table-mobile thead, .table-mobile tbody,
    .table-mobile tr, .table-mobile th, .table-mobile td {
        display: block; width: 100%; padding: 0; border: 0;
    }
    .table-mobile thead { display: none; }
    .table-mobile tr {
        padding: 12px; margin-bottom: 10px;
        border: 1px solid var(--border); border-radius: var(--radius-sm);
        background: var(--surface);
    }
    .table-mobile td {
        padding: 4px 0; border-bottom: 1px dashed var(--border);
    }
    .table-mobile td:last-child { border-bottom: 0; }
    .table-mobile td::before {
        content: attr(data-label) ":";
        color: var(--muted); font-size: 11px; text-transform: uppercase;
        display: block; margin-bottom: 2px;
    }
}

/* =============================================================
   Badges + Alerts
   ============================================================= */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }

.alert {
    padding: 12px 16px; border-radius: var(--radius-sm);
    margin-bottom: 16px; font-size: 14px;
    border-left: 4px solid;
}
.alert-error   { background: #fee2e2; color: #991b1b; border-color: var(--danger); }
.alert-warning { background: #fef3c7; color: #92400e; border-color: var(--warning); }
.alert-success { background: #dcfce7; color: #166534; border-color: var(--success); }
.alert-info    { background: #dbeafe; color: #1e40af; border-color: var(--primary); }

/* =============================================================
   Filterbar
   ============================================================= */
.filter-bar {
    display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.filter-bar select, .filter-bar input[type="search"] {
    flex: 1 1 140px; min-width: 0; padding: 8px 10px; font-size: 14px;
}
.filter-bar button { white-space: nowrap; }

/* Sonstiges */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.link  { color: var(--primary); }
.codebox {
    background: #0f172a; color: #e2e8f0; padding: 12px 14px;
    border-radius: var(--radius-sm); overflow-x: auto; font-size: 12px;
    word-break: break-all;
}
.audit-dl {
    display: flex; flex-direction: column; gap: 2px;
    font-size: 12px; line-height: 1.45;
}
.audit-dl-k {
    display: inline-block;
    min-width: 90px;
    color: var(--muted, #64748b);
    font-weight: 500;
    margin-right: 4px;
}
.audit-dl code {
    background: var(--surface-alt, #f1f5f9);
    padding: 1px 5px; border-radius: 3px;
    font-size: 11.5px;
}
.key-display {
    font-family: monospace; font-size: 16px;
    background: var(--surface-alt); padding: 10px 14px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    word-break: break-all; user-select: all;
}

/* =============================================================
   Tablet (≥720px)
   ============================================================= */
@media (min-width: 720px) {
    h1 { font-size: 26px; }
    .main { padding: 24px; }
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .stat-num { font-size: 34px; }
    .card { padding: 22px; }
}

/* =============================================================
   Desktop (≥980px) - permanente Sidebar, FAB versteckt
   ============================================================= */
@media (min-width: 980px) {
    .app { display: flex; flex-direction: row; }
    .topbar {
        /* Aus dem Drawer-Modus zurueck zur klassischen festen Sidebar */
        position: sticky; top: 0;
        transform: none !important;
        width: 220px; flex: 0 0 220px;
        height: 100vh; max-height: 100vh;
        box-shadow: none;
        border-right: 1px solid #334155;
    }
    .menu-close { display: none; }
    .mobile-header { display: none; }
    .fab { display: none; }
    .nav-backdrop { display: none; }
    .main { padding: 28px 32px; flex: 1; min-width: 0; }
    .container { padding: 0; }
}
