/* ====== Custom Date Picker (Admin-Override) ====== */
.date-picker {
    position: absolute;
    z-index: 9999;
    width: 260px;
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 8px;
}
.date-picker.hidden { display: none; }
.date-picker-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 6px;
}
.date-picker-header .nav-btn {
    background: transparent; color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 8px; padding: 2px 6px; cursor: pointer;
}
.date-picker-header .month-label { font-weight: 600; font-size: 0.9rem; }
.date-picker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.date-picker-weekday { font-size: 0.7rem; color: var(--text-muted); text-align: center; }
.date-picker-day {
    text-align: center; padding: 6px 0; cursor: pointer;
    border-radius: 8px; border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
}
.date-picker-day:hover { background: rgba(123,92,255,0.18); }
.date-picker-day.is-today { outline: 1px dashed rgba(123,92,255,0.8); }
.date-picker-day.is-other { opacity: 0.45; }
.date-picker-day.is-selected { background: rgba(123,92,255,0.3); border-color: rgba(123,92,255,0.5); }

.icon-button { 
    background: rgba(255,255,255,0.04);
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.icon-button.small { padding: 6px; font-size: 0.9rem; }
.icon-button svg { width: 18px; height: 18px; display: block; }
.icon-button:hover { 
    border-color: rgba(123,92,255,0.6);
    color: var(--accent-soft);
    box-shadow: 0 0 0 2px rgba(123,92,255,0.18) inset;
}

/* ===========================
   BACK-TO-TOP (Floating Button)
=========================== */
#back-to-top {
    position: fixed;
    right: calc(18px + env(safe-area-inset-right, 0px));
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    z-index: 95; /* unter Modals (100/240), über Content */

    width: 44px;
    height: 44px;
    border-radius: 14px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 1px solid rgba(123,92,255,0.35);
    background: rgba(7, 10, 26, 0.78);
    backdrop-filter: blur(10px);
    box-shadow: 0 18px 45px rgba(0,0,0,0.55);

    color: var(--text-main);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;

    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity .15s ease, transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

#back-to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

#back-to-top:hover {
    border-color: rgba(123,92,255,0.7);
    box-shadow: 0 18px 45px rgba(0,0,0,0.6), 0 0 0 2px rgba(123,92,255,0.18) inset;
}

#back-to-top:active {
    transform: translateY(1px);
}

/* ========== BASIS-STIL ========== */

:root {
    --bg: #050816;
    --bg-dark: #050816; /* Fix: wurde in Scrollbar genutzt */
    --bg-card: #101426;
    --accent: #7b5cff;
    --accent-soft: #5bd1ff;
    --text-main: #f5f5f7;
    --text-muted: #a3a5c4;
    --error: #ff5c7b;
    --radius: 12px;
    --shadow: 0 18px 45px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; }

/* ===========================
   OVERSCROLL / BACKGROUND FIX
   Verhindert "weißen Flash" bei Pull-to-refresh/Overscroll,
   indem auch das Root-Element immer dunkel ist.
=========================== */
html {
    height: 100%;
    background: var(--bg-dark);
}

/* neue Utility-Klassen passend zum HTML */
.hidden { display: none !important; }      /* kompatibel zu deinem alten Code */
.is-hidden { display: none !important; }   /* neu im HTML */
.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

/* ===========================
    GLOBAL CUSTOM SCROLLBAR
=========================== */
::-webkit-scrollbar {
    width: 10px;
    background: rgba(5, 6, 21, 0.3);
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent), var(--accent-soft));
    border-radius: 10px;
    box-shadow: 0 0 8px rgba(123, 92, 255, 0.7);
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--accent-soft), var(--accent));
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

/* Firefox (nur für spezifische Container, wie bei dir) */
.custom-options,
.admin-modal-content textarea {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-soft) var(--bg-dark);
}

/* Chrome / Edge / Opera */
.custom-options::-webkit-scrollbar,
.admin-modal-content textarea::-webkit-scrollbar { width: 10px; }

.custom-options::-webkit-scrollbar-track,
.admin-modal-content textarea::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.custom-options::-webkit-scrollbar-thumb,
.admin-modal-content textarea::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-soft) 100%);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.custom-options::-webkit-scrollbar-thumb:hover,
.admin-modal-content textarea::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--accent-soft) 0%, var(--accent) 100%);
    box-shadow: 0 0 10px rgba(91, 209, 255, 0.6);
}

body {
    margin: 0;
    height: 100%;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: var(--bg-dark);
    background-image: radial-gradient(circle at top, #151b3b 0, var(--bg) 55%);
    color: var(--text-main);
    padding: 24px;

    /* FIX: kein flex-centering mehr */
}


.app-container {
    width: 100%;
    max-width: 1480px;
    background: rgba(5, 8, 22, 0.9);
    border-radius: 20px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255,255,255,0.06);
    padding: 24px 28px 28px;
     margin: 0 auto;          /* Horizontal zentrieren */
    backdrop-filter: blur(18px);
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.title { font-size: 1.6rem; font-weight: 600; }
.subtitle { font-size: 0.9rem; color: var(--text-muted); }

.badge {
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(123, 92, 255, 0.12);
    color: var(--accent-soft);
    font-size: 0.8rem;
    border: 1px solid rgba(123, 92, 255, 0.4);
}

/* Globale Fehlermeldung oben */
.app-error {
    margin: 8px 0 14px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 92, 123, 0.6);
    background: rgba(255, 92, 123, 0.12);
    color: var(--error);
    font-size: 0.85rem;
}

/* ========== LIZENZ-STATUSBAR OBEN ========== */
.license-bar {
    margin-bottom: 18px;
    padding: 10px 14px;
    border-radius: 12px;
    background: radial-gradient(circle at left, rgba(123,92,255,0.25), rgba(5,8,22,0.95));
    border: 1px solid rgba(123,92,255,0.6);
    box-shadow: 0 12px 30px rgba(0,0,0,0.6);
}

.license-bar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.license-bar-bottom {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.license-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(7,10,26,0.9);
    border: 1px solid rgba(255,255,255,0.16);
    color: var(--accent-soft);
}
.license-badge::before { content: "●"; font-size: 0.6rem; }

/* Farbvarianten je nach Tier */
.license-badge.tier-trial { border-color: rgba(91,209,255,0.7); color: var(--accent-soft); }
.license-badge.tier-lite { border-color: rgba(123,92,255,0.8); color: #e2d8ff; }
.license-badge.tier-pro { border-color: rgba(255,215,128,0.8); color: #ffe8a3; }
.license-badge.tier-enterprise { border-color: rgba(137,255,179,0.85); color: #b6ffd7; }
.license-badge.tier-free { border-color: rgba(190,190,190,0.6); color: #f0f0f0; }

.license-customer { font-size: 0.8rem; color: var(--text-muted); }

.license-usage-text { font-size: 0.78rem; color: var(--text-muted); }

.license-usage-progress {
    position: relative;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255,255,255,0.06);
    overflow: hidden;
}

.license-usage-bar {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-soft));
    transition: width 0.25s ease-out;
}

/* ========== LAYOUT (JETZT 3 SPALTEN) ========== */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 320px) minmax(0, 1.6fr) minmax(0, 360px);
    gap: 22px;
    align-items: start;
}

/* Mobile Layout: Spalten untereinander */
@media (max-width: 767px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Desktop Layout (>=1200px): Zwei Spalten (Upload/Analyse links, Module/Support rechts) */
@media (min-width: 1200px) {
    .layout {
        display: grid;
        grid-template-columns: minmax(0, 1.6fr) minmax(0, 360px);
        grid-auto-rows: minmax(0, auto);
        gap: 22px;
        align-items: start;
    }
    /* Linke Spalte: Upload/History (oben) */
    .layout > section.card:nth-of-type(1) { grid-column: 1; grid-row: 1; }
    /* Linke Spalte: OCR/AI (unten) */
    .layout > section.card:nth-of-type(2) { grid-column: 1; grid-row: 2; }
    /* Rechte Spalte: Module/Support (spannt beide Zeilen) */
    .layout > aside.module-section { grid-column: 2; grid-row: 1 / span 2; }

    /* Rechte Spalte als Flex-Column; Module-Block bevorzugt wachsen lassen */
    aside.module-section {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        max-height: none;     /* keine harte Deckelung der Aside-Höhe */
        overflow: visible;    /* kein globales Scrollen auf Aside-Ebene */
    }

    /* Modul-Liste: bevorzugt wachsen, aber viewport-gebundene Max-Höhe und eigener Scroll */
    aside.module-section .module-list-wrapper {
        flex: 1 1 auto;
        max-height: calc(100vh - 260px);
        overflow-y: auto;
        overflow-x: hidden;
    }
}

/* Tablet Layout (768px–1199px): Zwei Spalten mit Wrap-freundlicher Breite */
@media (max-width: 1199px) and (min-width: 768px) {
    .layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 320px);
        grid-auto-rows: minmax(0, auto);
        gap: 18px;
        align-items: start;
    }
    .layout > section.card:nth-of-type(1) { grid-column: 1; grid-row: 1; }
    .layout > section.card:nth-of-type(2) { grid-column: 1; grid-row: 2; }
    .layout > aside.module-section { grid-column: 2; grid-row: 1 / span 2; }
}

/* Header Responsiveness */
/* Tablet Layout */
@media (max-width: 1199px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}
/* Mobile Layout */
@media (max-width: 767px) {
    body { padding: 16px; font-size: 15px; }
    .title { font-size: 1.4rem; }
    .subtitle { font-size: 0.85rem; }
    /* Rechte Header-Seite (Buttons) nicht überlaufen lassen */
    .header > div:last-child {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px !important;
        justify-content: flex-start;
    }
}

/* Lizenz-Status-Bar Responsiveness */
/* Mobile Layout */
@media (max-width: 767px) {
    .license-bar { padding: 10px; }
    .license-bar-top { flex-direction: column; align-items: flex-start; gap: 8px; }
    .license-usage-text { font-size: 0.74rem; }
    .license-usage-progress { height: 8px; }
}

/* Cards & Panels: Mobile Full-Width Comfort */
@media (max-width: 767px) {
    .card { padding: 16px; }
}

/* AI Controls: Buttons und Inputs auf kleinen Screens umbruchfähig */
/* Tablet Layout */
@media (max-width: 1199px) {
    .ai-controls { flex-wrap: wrap; gap: 10px; }
}
/* Mobile Layout */
@media (max-width: 767px) {
    .ai-controls { flex-wrap: wrap; }
    .ai-controls > * { flex: 1 1 180px; }
    .ai-controls .btn-small { width: 100%; }
    .ai-controls select.ai-select { width: 100%; min-width: 0; }
}

/* JSON-Ausgabe: Scrollbar statt Layoutbruch */
.ai-output { max-height: 360px; overflow-y: auto; }
@media (max-width: 767px) { .ai-output { max-height: 240px; } }

/* Welcome Overlay: Mobile-Optimierung */
/* Mobile Layout */
@media (max-width: 767px) {
    #welcome-overlay .modal-dialog { width: calc(100% - 2rem); max-width: 100%; margin: 1rem; }
    #welcome-overlay .btn, #welcome-overlay .btn-secondary { width: 100%; }
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    border: 1px solid rgba(255,255,255,0.06);
}

.card-title {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 6px;
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* ========== UPLOAD-BEREICH ========== */
.dropzone {
    border-radius: var(--radius);
    border: 1.5px dashed rgba(123,92,255,0.7);
    background: rgba(16,20,45,0.9);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s ease-out;
    user-select: none;
}

.dropzone.dragover {
    background: rgba(123,92,255,0.12);
    transform: translateY(-1px);
    box-shadow: 0 0 0 1px rgba(123,92,255,0.4);
}

.dropzone-icon { font-size: 2rem; margin-bottom: 8px; }
.dropzone-main { font-size: 0.95rem; }
.dropzone-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

.dropzone-link {
    text-decoration: underline;
    color: var(--accent-soft);
}

.file-input { display: none; }

.file-info {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: left;
    word-break: break-all;
}

.btn {
    margin-top: 12px;
    width: 100%;
    padding: 10px 14px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    color: white;
    font-weight: 500;
    cursor: pointer;
    font-size: 0.95rem;
    transition: 0.15s ease-out;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.btn:disabled {
    opacity: 0.6;
    cursor: default;
    box-shadow: none;
    transform: none;
}

.btn-secondary {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.16);
    background: rgba(7, 10, 26, 0.9);
    color: var(--text-main);
    font-size: 0.78rem;
    cursor: pointer;
    transition: 0.15s ease-out;
    white-space: nowrap;
}

.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.04); }
.btn-secondary:disabled { opacity: 0.5; cursor: default; }

/* PDF-Button: visuell als "nicht verfügbar" markieren, aber klickbar lassen */
#aiPdfBtn.pdf-unavailable {
    opacity: 0.55;
    filter: grayscale(15%);
}
#aiPdfBtn.pdf-unavailable:hover {
    transform: none;
    box-shadow: none;
}

.btn-small {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.16);
    background: rgba(7, 10, 26, 0.9);
    color: var(--text-main);
    font-size: 0.78rem;
    cursor: pointer;
    transition: 0.15s ease-out;
    white-space: nowrap;
}

.btn-small:hover:not(:disabled) {
    background: rgba(123,92,255,0.2);
    border-color: rgba(123,92,255,0.6);
}

.btn-small:disabled { opacity: 0.5; cursor: default; }

/* Danger-Variante für kritische Aktionen */
.btn-danger {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,92,123,0.5);
    background: rgba(60, 10, 20, 0.9);
    color: #ffd6de;
    font-size: 0.78rem;
    cursor: pointer;
    transition: 0.15s ease-out;
    white-space: nowrap;
}
.btn-danger:hover:not(:disabled) {
    background: rgba(255,92,123,0.15);
    border-color: rgba(255,92,123,0.8);
}
.btn-danger:disabled { opacity: 0.5; cursor: default; }

.status {
    min-height: 18px;
    margin-top: 8px;
    font-size: 0.8rem;
}

.status.error { color: var(--error); }
.status.ok { color: var(--accent-soft); }

.divider {
    margin: 14px 0 10px;
    border: none;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ========== HISTORY ========== */
.history-header {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 2px;
}

.history-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.history-list {
    max-height: 180px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(7, 10, 26, 0.95);
}

.history-empty { font-size: 0.8rem; color: var(--text-muted); padding: 8px 10px; }

.history-item {
    padding: 8px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.history-item:last-child { border-bottom: none; }
.history-item:hover { background: rgba(123,92,255,0.12); }

.history-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta { font-size: 0.7rem; color: var(--text-muted); }

/* ========== TABLE (Meine Dokumente) ========== */
.table-wrapper {
    margin-top: 10px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    /* Begrenze die Höhe und erlaube Scrollen, damit die Seite nicht wächst */
    max-height: 220px;
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(7,10,26,0.95);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.table thead th {
    text-align: left;
    padding: 8px 10px;
    background: rgba(255,255,255,0.04);

/* Read-only Plan-Badge im Header */
.header-plan-badge {
    display: inline-flex;
}

/* ===== Flatpickr – Dark Theme Anpassungen zum App-Design ===== */
.flatpickr-calendar {
    background: rgba(7, 10, 26, 0.98);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.flatpickr-months, .flatpickr-weekdays {
    background: rgba(7, 10, 26, 0.98);
    color: var(--text-main);
}
.flatpickr-day {
    color: var(--text-main);
}
.flatpickr-day:hover {
    background: rgba(91, 209, 255, 0.10);
}
.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange {
    background: rgba(91, 209, 255, 0.35);
    border-color: rgba(91, 209, 255, 0.55);
    color: #fff;
}
.flatpickr-weekdays .flatpickr-weekday {
    color: var(--text-muted);
}
.flatpickr-current-month .cur-month, .flatpickr-current-month .numInputWrapper input {
    color: var(--text-main);
}
.flatpickr-time input, .flatpickr-time .numInputWrapper span.arrowUp, .flatpickr-time .numInputWrapper span.arrowDown {
    color: var(--text-main);
}
.flatpickr-day.today {
    border-color: rgba(255,255,255,0.35);
}
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.table tbody tr:hover {
    background: rgba(123,92,255,0.12);
}

/* ========== ERGEBNIS-BEREICH ========== */
.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.8rem;
}

.pill {
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
}

.pill strong { color: var(--accent-soft); }

.textarea-wrapper {
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(7, 10, 26, 0.95);
    padding: 10px;
    height: 260px;
    overflow: auto;
    font-family: "JetBrains Mono", "Consolas", monospace;
    font-size: 0.82rem;
    line-height: 1.4;
    white-space: pre-wrap;
    resize: vertical;
    min-height: 260px;
}

.placeholder { color: var(--text-muted); font-size: 0.85rem; }

.result-text {
    white-space: pre-wrap;
    font-family: "JetBrains Mono", "Consolas", monospace;
    font-size: 0.82rem;
    line-height: 1.4;
}

.footer {
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

/* Support-Link Styling: passend zur Dark/Accent-Optik */
#support-mailto,
#support-mailto:visited {
    color: var(--accent-soft);
    text-decoration: none;
    border-bottom: 1px dashed rgba(91, 209, 255, 0.45);
    transition: color .15s ease, border-color .15s ease, text-shadow .15s ease;
}
#support-mailto:hover,
#support-mailto:focus {
    color: #e2d8ff;
    border-bottom-color: var(--accent);
    text-shadow: 0 0 6px rgba(91, 209, 255, 0.4);
    outline: none;
}

/* ========== AI-ANALYSE ========== */
.ai-section {
    margin-top: 16px;
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(7, 10, 26, 0.9);
    padding: 10px 10px 8px;
}

.ai-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.ai-title { font-size: 0.9rem; font-weight: 500; }
.ai-subtitle { font-size: 0.75rem; color: var(--text-muted); }

.ai-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.ai-select {
    padding: 5px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(7, 10, 26, 0.95);
    color: var(--text-main);
    font-size: 0.78rem;
}

.ai-output {
    margin-top: 6px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(3, 6, 20, 0.95);
    padding: 8px 10px;
    font-family: "JetBrains Mono", "Consolas", monospace;
    font-size: 0.78rem;
    line-height: 1.4;
    max-height: 360px;
    overflow: auto;
    resize: vertical;
    min-height: 260px;
}

/* ========== MODULE (RECHTS ALS ASIDE-CARD) ========== */
.module-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    border: 1px solid rgba(255,255,255,0.06);

    /* Basis: Flex-Column für Inhalte */
    display: flex;
    flex-direction: column;
    /* Standard: kein hartes Max-Height, damit Tablet/Mobile nicht eingeschränkt sind */
}

/* Scroll-Wrapper bekommt explizit dunklen Background,
   damit bei Container-Overscroll nie ein heller Default durchscheint. */
.module-list-wrapper {
    background-color: var(--bg-card);
}


.module-section h3 {
    margin: 0 0 6px 0;
    font-size: 1rem;
    font-weight: 600;
}

.module-section p {
    margin: 0 0 12px 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Cards inside module list (dein bestehendes Schema) */
.module-list {
    display: grid;
    grid-template-columns: 1fr; /* im rechten Aside eine Spalte, wirkt sauberer */
    gap: 14px;
}

.module-card {
    background: rgba(255,255,255,0.05);
    padding: 14px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
}

.module-card.disabled {
    opacity: 0.4;
    border-color: rgba(255,80,80,0.3);
}

.module-card h4 { margin: 0 0 6px; }
.module-card button { margin-top: 8px; }

/* ============================================
   Scrollbarer Bereich für die Module (rechte Seite)
   ============================================ */

.module-list-wrapper {
    /* Basis: normaler Flow; Desktop regelt Höhe separat */
    padding-right: 6px;
    margin-top: 10px;
}


/* Scrollbar Styling (optional, schöner) */
.module-list-wrapper::-webkit-scrollbar {
    width: 8px;
}

.module-list-wrapper::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 8px;
}

.module-list-wrapper::-webkit-scrollbar-track {
    background: transparent;
}


/* ========== LICENSE PLANS (UNTEN) ========== */
.license-plans-section {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.license-plans-title {
    margin: 0 0 4px;
    font-size: 1.05rem;
    font-weight: 500;
}

.license-plans-subtitle {
    margin: 0 0 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.license-plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.license-plan-card {
    background: rgba(7,10,26,0.95);
    border-radius: 14px;
    padding: 12px 12px 10px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 10px 26px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
/* Support / Kontakt: weniger runde Ecken nur für diese Box */
#support-card { border-radius: 10px; }
/* Inputs im Support-Block: kleinere Rundung und volle Breite */
#support-card .ai-search { border-radius: 10px; width: 100%; max-width: 100%; display: block; }

.license-plan-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
}

.license-plan-name { font-size: 0.9rem; font-weight: 500; }
.license-plan-price { font-size: 0.85rem; color: var(--accent-soft); }
.license-plan-docs { font-size: 0.78rem; color: var(--text-muted); }

.license-plan-features {
    list-style: none;
    padding-left: 0;
    margin: 6px 0 4px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.license-plan-features li::before {
    content: "✓";
    margin-right: 5px;
    color: var(--accent-soft);
}

.license-plan-badge-current {
    align-self: flex-start;
    margin-top: 2px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    background: rgba(123,92,255,0.25);
    border: 1px solid rgba(123,92,255,0.6);
    color: var(--text-main);
}

.license-plan-button {
    margin-top: 4px;
    align-self: flex-start;
    padding: 6px 10px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.15s ease-out;
}

.license-plan-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.license-plan-button:disabled {
    opacity: 0.6;
    cursor: default;
    background: rgba(255,255,255,0.06);
}

/* ========== UPGRADE-MODAL ========== */
.upgrade-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upgrade-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
}

.upgrade-modal-dialog {
    position: relative;
    max-width: 420px;
    width: 100%;
    padding: 16px 18px 14px;
    border-radius: 18px;
    background: radial-gradient(circle at top, rgba(123,92,255,0.25), #050816);
    border: 1px solid rgba(123,92,255,0.6);
    box-shadow: 0 22px 55px rgba(0,0,0,0.8);
    z-index: 101;
}

.upgrade-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.upgrade-modal-header h3 { margin: 0; font-size: 1rem; }

.upgrade-modal-close {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
}

.upgrade-modal-close:hover { color: var(--text-main); }

.upgrade-modal-body {
    font-size: 0.82rem;
    color: var(--text-main);
}

.upgrade-modal-description { margin: 0 0 6px; }

.upgrade-modal-features {
    list-style: none;
    padding-left: 0;
    margin: 4px 0 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.upgrade-modal-features li::before {
    content: "✓";
    margin-right: 5px;
    color: var(--accent-soft);
}

.upgrade-modal-highlight {
    margin-top: 4px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(5, 8, 22, 0.9);
    border: 1px solid rgba(255,255,255,0.12);
}

.upgrade-modal-price {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--accent-soft);
}

.upgrade-modal-note {
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.upgrade-modal-footer {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ========== AUTH VIEW ========== */
.auth-view {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-dialog {
    position: relative;
    max-width: 420px;
    width: 100%;
    padding: 18px 18px 16px;
    border-radius: 18px;
    background: radial-gradient(circle at top, rgba(123,92,255,0.25), #050816);
    border: 1px solid rgba(123,92,255,0.6);
    box-shadow: 0 22px 55px rgba(0,0,0,0.8);
    z-index: 201;
}

.auth-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input {
    padding: 10px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(7, 10, 26, 0.95);
    color: var(--text-main);
    font-size: 0.9rem;
}
/* ===== Module: Selected State (C1.2) ===== */
.module-card.selected {
    border-color: rgba(91, 209, 255, 0.55);
    box-shadow: 0 0 0 2px rgba(91, 209, 255, 0.10);
    background: rgba(91, 209, 255, 0.06);
}

.module-card .module-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(7,10,26,0.7);
    color: var(--text-muted);
    margin-top: 8px;
}

/* =========================
   C1.3 – AI Output UI
========================= */

.ai-tools-row{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  margin-top:8px;
  flex-wrap:wrap;
}

.ai-tabs{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}

.ai-tab{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.16);
  background: rgba(7, 10, 26, 0.9);
  color: var(--text-main);
  font-size:0.78rem;
  cursor:pointer;
  transition:0.15s ease-out;
}

.ai-tab:hover{
  background: rgba(123,92,255,0.18);
  border-color: rgba(123,92,255,0.6);
}

.ai-tab.is-active{
  background: linear-gradient(135deg, rgba(123,92,255,0.35), rgba(91,209,255,0.18));
  border-color: rgba(91,209,255,0.55);
}

.ai-tools{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}

.ai-search{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.18);
  background: rgba(7, 10, 26, 0.95);
  color: var(--text-main);
  font-size:0.78rem;
  min-width: 180px;
}

.ai-warning{
  margin-top:10px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,92,123,0.35);
  background: rgba(255,92,123,0.08);
  color: #ffd6de;
  font-size:0.82rem;
}

.ai-panel{
  margin-top:10px;
}

.ai-fields-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap:10px;
}

.ai-field-card{
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.08);
  background: rgba(3, 6, 20, 0.65);
  padding:10px 10px 8px;
}

.ai-field-key{
  font-size:0.74rem;
  color: var(--text-muted);
  margin-bottom:4px;
}

.ai-field-value{
  font-size:0.82rem;
  line-height:1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-field-empty{
  opacity:0.6;
  font-style: italic;
}

.ai-summary{
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.08);
  background: rgba(3, 6, 20, 0.65);
  padding:12px;
  font-size:0.85rem;
  line-height:1.5;
}

/* =========================================
   C1.3 – Zusätzliche Styles für Re-Analyse
========================================= */

/* Button "Neu analysieren" – eigene Farbnote */
#aiReanalyzeBtn {
    border-color: rgba(91, 209, 255, 0.35);
}

#aiReanalyzeBtn:hover:not(:disabled) {
    background: rgba(91, 209, 255, 0.18);
    border-color: rgba(91, 209, 255, 0.6);
}

/* Status: läuft */
.status.loading {
    color: var(--accent-soft);
    opacity: 0.85;
}

/* Status: neu analysiert */
.status.reanalyzed {
    color: #7effb2;
    font-weight: 500;
}

/* Kleine Animation optional (kannst du entfernen wenn du es nicht willst) */
@keyframes aiPulse {
    0%   { opacity: 0.55; }
    50%  { opacity: 1; }
    100% { opacity: 0.55; }
}

.status.loading {
    animation: aiPulse 1.4s infinite ease-in-out;
}

/* ============================
    Modul-Auswahl — OFFIZIELLER VELI DASHBOARD STYLE
   ============================ */

.module-card {
    transition: 0.22s ease-out;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

/* Hover (nur wenn NICHT selected) */
.module-card:hover:not(.selected-module) {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}

/* ============================
    SELECTED — Premium Glow Style
   ============================ */
.module-card.selected-module {
    background: rgba(123, 92, 255, 0.12); /* violett transparent */
    border: 1px solid var(--accent);      /* kräftiges Violett */

    box-shadow:
        0 0 12px rgba(123, 92, 255, 0.45),
        0 0 24px rgba(123, 92, 255, 0.25);

    transform: translateY(-3px);
    transition: 0.25s ease;
}

/* Hover auf bereits ausgewähltem Modul → Glow verstärken */
.module-card.selected-module:hover {
    box-shadow:
        0 0 16px rgba(123, 92, 255, 0.55),
        0 0 32px rgba(123, 92, 255, 0.35);
    transform: translateY(-4px);
}

/* ============================
   Toast Notifications (Top-Right)
   ============================ */
.toast-container{
    position: fixed;
    top: 18px;
    right: 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none; /* Klicks gehen durch, Buttons innen erlauben */
}

.toast{
    pointer-events: auto;
    min-width: 220px;
    max-width: 380px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(7,10,26,0.95);
    box-shadow: 0 12px 30px rgba(0,0,0,0.55);
    color: var(--text-main);
    font-size: 0.85rem;
    transform: translateX(20px);
    opacity: 0;
    transition: transform .25s ease, opacity .25s ease;
}

.toast.show{
    transform: translateX(0);
    opacity: 1;
}

.toast.hide{
    transform: translateX(20px);
    opacity: 0;
}

.toast.success{ border-color: rgba(91,209,255,0.5); }
.toast.error{ border-color: rgba(255,92,123,0.5); color: #ffd6de; }

/* ========== INFO-CARD (Onboarding) ========== */
.info-card{
    margin-top: 14px;
    background: rgba(7,10,26,0.95);
    border-radius: 14px;
    padding: 12px 12px 10px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 10px 26px rgba(0,0,0,0.6);
}
.info-card-title{
    margin: 0 0 6px;
    font-size: 0.95rem;
    font-weight: 600;
}
.info-card-subtitle{
    margin: 0 0 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.info-card-list{
    margin: 0 0 8px 18px;
    padding-left: 0;
    font-size: 0.82rem;
}
.info-card-list li{ margin-bottom: 6px; }
.info-card-note{
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ========== GENERIC MODAL (Admin Users) ========== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 240; /* über Auth-View (200/201) */
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
}

.modal-dialog {
    position: relative;
    max-width: 1100px;   /* etwas breiter, damit kein Horizontal-Scroll */
    width: 96%;
    padding: 16px 18px 14px;
    border-radius: 18px;
    background: radial-gradient(circle at top, rgba(123,92,255,0.25), #050816);
    border: 1px solid rgba(123,92,255,0.6);
    box-shadow: 0 22px 55px rgba(0,0,0,0.8);
    z-index: 241;
    /* Scroll-fähiger Dialog: begrenze Höhe und erlaube inneres Scrollen */
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.icon-button {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
}
.icon-button:hover { color: var(--text-main); }

.modal-body {
    font-size: 0.85rem;
    color: var(--text-main);
    /* Inhalt scrollt, Header bleibt sichtbar */
    overflow-y: auto;
    overflow-x: auto; /* Horizontal-Scroll ermöglichen */
    padding-right: 6px;
    flex: 1;
    min-height: 0; /* wichtig für korrektes Scrollen in Flex-Containern */
}

.text-muted { color: var(--text-muted); }
.small { font-size: 0.78rem; }
.text-right { text-align: right; }
.link-button { background: none; border: 0; color: #5bd1ff; cursor: pointer; padding: 0; }
.link-button:hover { text-decoration: underline; }

/* ========== Admin Users Table ========== */
.admin-users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin-top: 8px;
}

.admin-users-table thead th {
    text-align: left;
    padding: 8px 10px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.admin-users-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: middle;
}

/* Aktionen nebeneinander anordnen */
.admin-users-table td.actions {
    display: flex;
    align-items: center;
    gap: 8px;
    /* verhindern, dass Buttons umbrechen */
    white-space: nowrap;
}

.admin-users-table tbody tr:hover {
    background: rgba(123,92,255,0.12);
}

.admin-users-table select,
.admin-users-table input[type="date"],
.admin-users-table input[type="text"],
.admin-users-table input[type="checkbox"],
.admin-users-table button {
    font-size: 0.82rem;
}

/* Einheitliche Checkbox im App-Design */
.ai-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(7, 10, 26, 0.95);
    display: inline-block;
    position: relative;
    cursor: pointer;
}
.ai-checkbox:hover { border-color: rgba(255,255,255,0.28); }
.ai-checkbox:focus { outline: none; box-shadow: 0 0 0 2px rgba(91,209,255,0.25); }
.ai-checkbox:checked {
    background: var(--accent-soft);
    border-color: var(--accent-soft);
}
.ai-checkbox:checked::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -56%);
    font-size: 14px;
    color: #0b1226;
    font-weight: 700;
}
