:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-alt: #f9fafb;
    --sidebar: #111318;
    --sidebar-text: #ffffff;
    --border: #e5e7eb;
    --text: #16181d;
    --muted: #777c87;
    --accent: #6d5dfc;
    --accent-soft: #eeecff;
    --success: #25a56a;
    --danger: #cf4545;

    --card-radius: 15px;
    --button-radius: 11px;

    --shadow: 0 20px 60px rgba(15, 23, 42, 0.08);

    --hero-image: none;
    --hero-overlay: none;

    --font-display:
        Inter,
        ui-sans-serif,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    --font-body:
        Inter,
        ui-sans-serif,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}


/* =========================================================
   THEMES
   ========================================================= */


/* 1 — Dark & Cinematic */

[data-theme="dark_cinematic"] {
    --bg: #080a0d;
    --surface: #111419;
    --surface-alt: #15191f;
    --sidebar: #07090b;
    --sidebar-text: #f7f7f8;
    --border: #242932;
    --text: #f4f4f5;
    --muted: #9096a0;
    --accent: #b99155;
    --accent-soft: #282117;
    --success: #49b784;
    --danger: #df6565;

    --card-radius: 12px;
    --button-radius: 9px;

    --shadow: 0 18px 55px rgba(0, 0, 0, 0.35);
}


/* 2 — Modern & Minimal */

[data-theme="modern_minimal"] {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-alt: #f9fafb;
    --sidebar: #ffffff;
    --sidebar-text: #181a1f;
    --border: #e5e7eb;
    --text: #16181d;
    --muted: #777c87;
    --accent: #6d5dfc;
    --accent-soft: #eeecff;
    --success: #25a56a;
    --danger: #cf4545;

    --card-radius: 15px;
    --button-radius: 11px;

    --shadow: 0 18px 50px rgba(15, 23, 42, 0.07);
}


/* 3 — Light & Professional */

[data-theme="light_professional"] {
    --bg: #f3f7fb;
    --surface: #ffffff;
    --surface-alt: #f7faff;
    --sidebar: #ffffff;
    --sidebar-text: #12213a;
    --border: #dce5ef;
    --text: #132238;
    --muted: #718096;
    --accent: #2563eb;
    --accent-soft: #eaf2ff;
    --success: #1f9d67;
    --danger: #c84b4b;

    --card-radius: 14px;
    --button-radius: 9px;

    --shadow: 0 18px 50px rgba(43, 68, 104, 0.08);
}


/* 4 — Creative & Cinematic */

[data-theme="creative_cinematic"] {
    --bg: #0c0c0d;
    --surface: #171718;
    --surface-alt: #1d1c1b;
    --sidebar: #101011;
    --sidebar-text: #f5f3ee;
    --border: #302d28;
    --text: #f5f2ec;
    --muted: #aaa49a;
    --accent: #c7a15f;
    --accent-soft: #2c2519;
    --success: #5ab285;
    --danger: #d66a61;

    --card-radius: 10px;
    --button-radius: 8px;

    --shadow: 0 22px 65px rgba(0, 0, 0, 0.42);
}


/* 5 — Dark Minimal / Pro */

[data-theme="dark_pro"] {
    --bg: #081019;
    --surface: #0e1721;
    --surface-alt: #121d29;
    --sidebar: #09111a;
    --sidebar-text: #f0f5fa;
    --border: #1d2a37;
    --text: #eff4f8;
    --muted: #8696a8;
    --accent: #536dfe;
    --accent-soft: #182448;
    --success: #3fb989;
    --danger: #de6262;

    --card-radius: 12px;
    --button-radius: 9px;

    --shadow: 0 20px 60px rgba(0, 0, 0, 0.30);
}


/* 6 — Elegant & Premium */

[data-theme="elegant_premium"] {
    --bg: #f4eee5;
    --surface: #fffaf3;
    --surface-alt: #f7f0e6;
    --sidebar: #eee4d7;
    --sidebar-text: #2b241e;
    --border: #ded1c1;
    --text: #2a231d;
    --muted: #8c7e70;
    --accent: #80623c;
    --accent-soft: #ece0cf;
    --success: #5a8c68;
    --danger: #a65252;

    --card-radius: 12px;
    --button-radius: 8px;

    --shadow: 0 18px 55px rgba(69, 49, 30, 0.10);

    --font-display:
        Georgia,
        "Times New Roman",
        serif;
}


/* =========================================================
   BASE
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
}

button,
input {
    font: inherit;
}


/* =========================================================
   LOGIN
   ========================================================= */

.login-body {
    min-height: 100vh;
    background:
        radial-gradient(
            circle at 10% 10%,
            rgba(109, 93, 252, 0.16),
            transparent 32%
        ),
        radial-gradient(
            circle at 90% 90%,
            rgba(45, 212, 191, 0.10),
            transparent 30%
        ),
        var(--bg);

    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.login-shell {
    width: 100%;
    max-width: 430px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 26px;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;

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

    color: white;
    font-size: 22px;
    font-weight: 800;

    background: linear-gradient(
        145deg,
        var(--accent),
        #5848e8
    );

    box-shadow: 0 12px 30px rgba(109, 93, 252, 0.28);
}

.brand-mark.small {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    font-size: 17px;
}

.brand-name {
    font-size: 19px;
    font-weight: 750;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
}

.login-card {
    padding: 36px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.login-heading h1 {
    margin: 4px 0 8px;
    font-size: 30px;
    letter-spacing: -0.04em;
    font-family: var(--font-display);
}

.login-heading p:last-child {
    margin: 0 0 26px;
    color: var(--muted);
    line-height: 1.55;
}

.eyebrow {
    margin: 0;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.14em;
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 18px;
}

.login-form label span {
    display: block;
    font-size: 13px;
    font-weight: 650;
    margin-bottom: 8px;
}

.login-form input {
    width: 100%;
    height: 48px;
    padding: 0 14px;

    border: 1px solid var(--border);
    border-radius: var(--button-radius);

    background: var(--surface-alt);
    color: var(--text);

    outline: none;
    transition: 0.18s ease;
}

.login-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.login-form button {
    height: 50px;
    margin-top: 3px;

    border: 0;
    border-radius: var(--button-radius);

    color: white;
    font-weight: 700;
    background: var(--accent);

    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.login-form button:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
}

.alert-error {
    padding: 12px 14px;
    margin-bottom: 18px;

    color: #922d2d;
    background: #fff0f0;
    border: 1px solid #ffd7d7;

    border-radius: 10px;
    font-size: 13px;
}


/* =========================================================
   DASHBOARD
   ========================================================= */

.dashboard-body {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
}

.sidebar {
    width: 255px;

    background: var(--sidebar);
    color: var(--sidebar-text);

    display: flex;
    flex-direction: column;

    position: fixed;
    inset: 0 auto 0 0;

    padding: 24px 18px 18px;

    border-right: 1px solid var(--border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;

    padding: 0 8px 25px;

    font-size: 18px;
    font-weight: 750;
}

.nav {
    display: grid;
    gap: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;

    color: var(--muted);
    text-decoration: none;

    padding: 11px 12px;
    border-radius: 9px;

    font-size: 14px;
    transition: 0.16s ease;
}

.nav-item:hover {
    color: var(--text);
    background: var(--surface-alt);
}

.nav-item.active {
    color: var(--text);
    background: var(--accent-soft);
}

.nav-icon {
    width: 20px;
    text-align: center;
    font-size: 17px;
}

.sidebar-user {
    margin-top: auto;

    padding: 16px 8px 3px;

    border-top: 1px solid var(--border);

    display: grid;
    grid-template-columns: 34px 1fr auto;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 34px;
    height: 34px;

    border-radius: 50%;

    background: var(--surface-alt);

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

    font-weight: 750;
    font-size: 13px;
}

.user-info {
    min-width: 0;
}

.user-info strong {
    display: block;
    font-size: 12px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info span {
    display: block;
    margin-top: 3px;

    color: var(--muted);
    font-size: 10px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-button {
    border: 0;
    background: transparent;
    color: var(--muted);

    font-size: 18px;
    cursor: pointer;
}

.logout-button:hover {
    color: var(--text);
}

.content {
    width: calc(100% - 255px);
    margin-left: 255px;

    padding: 36px 42px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-bottom: 32px;
}

.topbar h1 {
    margin: 4px 0 0;

    font-size: 27px;
    letter-spacing: -0.035em;

    font-family: var(--font-display);
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 8px 11px;

    border: 1px solid var(--border);
    background: var(--surface);

    border-radius: 999px;

    font-size: 12px;
    color: var(--muted);
}

.status-dot {
    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: var(--success);

    box-shadow: 0 0 0 4px rgba(37, 165, 106, 0.10);
}

.welcome {
    margin-bottom: 24px;
}

.welcome h2 {
    margin: 0 0 5px;

    font-size: 20px;
    letter-spacing: -0.02em;

    font-family: var(--font-display);
}

.welcome p {
    margin: 0;

    color: var(--muted);
    font-size: 13px;
}

.metrics {
    display: grid;

    grid-template-columns: repeat(4, minmax(0, 1fr));

    gap: 16px;
    margin-bottom: 24px;
}

.metric-card,
.panel {
    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--card-radius);

    box-shadow: var(--shadow);
}

.metric-card {
    padding: 20px;
}

.metric-label {
    color: var(--muted);

    font-size: 12px;
    margin-bottom: 14px;
}

.metric-value {
    font-size: 25px;
    font-weight: 730;

    letter-spacing: -0.04em;
}

.metric-note {
    margin-top: 6px;

    color: var(--muted);
    font-size: 11px;
}

.panel {
    min-height: 310px;
}

.panel-header {
    padding: 20px 22px;

    border-bottom: 1px solid var(--border);
}

.panel-header h3 {
    margin: 4px 0 0;

    font-size: 16px;
    font-family: var(--font-display);
}

.empty-state {
    min-height: 225px;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    text-align: center;
    color: var(--muted);
}

.empty-icon {
    font-size: 30px;
    color: var(--muted);
}

.empty-state h4 {
    margin: 12px 0 5px;

    color: var(--text);
}

.empty-state p {
    margin: 0;

    font-size: 13px;
}


/* =========================================================
   APPEARANCE
   ========================================================= */

.appearance-panel {
    overflow: hidden;
}

.theme-grid {
    display: grid;

    grid-template-columns: repeat(3, minmax(0, 1fr));

    gap: 18px;
    padding: 24px;
}

.theme-card {
    display: block;
    cursor: pointer;
}

.theme-card input {
    display: none;
}

.theme-preview {
    height: 170px;

    border: 2px solid transparent;
    border-radius: 14px;

    overflow: hidden;

    display: flex;

    transition: 0.18s ease;
}

.theme-card:hover .theme-preview {
    transform: translateY(-2px);
}

.theme-card input:checked + .theme-preview {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.preview-sidebar {
    width: 24%;
}

.preview-content {
    width: 76%;
    padding: 16px;
}

.preview-header {
    height: 14px;
    width: 55%;

    border-radius: 5px;

    margin-bottom: 18px;
}

.preview-cards {
    display: grid;

    grid-template-columns: repeat(3, 1fr);

    gap: 7px;
}

.preview-cards span {
    height: 38px;
    border-radius: 6px;
}

.preview-panel {
    height: 52px;

    border-radius: 7px;

    margin-top: 10px;
}

.theme-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 12px 4px 0;

    font-size: 13px;
}

.selected-badge {
    font-size: 10px;

    padding: 4px 7px;

    border-radius: 999px;

    background: var(--accent-soft);
    color: var(--accent);
}

.appearance-actions {
    padding: 0 24px 24px;
}

.appearance-actions button {
    border: 0;

    padding: 11px 18px;

    border-radius: var(--button-radius);

    background: var(--accent);
    color: white;

    font-weight: 700;
    cursor: pointer;
}


/* =========================================================
   THEME PREVIEW PALETTES
   ========================================================= */

.theme-preview-dark_cinematic {
    background: #101317;
}

.theme-preview-dark_cinematic .preview-sidebar {
    background: #07090b;
}

.theme-preview-dark_cinematic .preview-header,
.theme-preview-dark_cinematic .preview-cards span,
.theme-preview-dark_cinematic .preview-panel {
    background: #20252c;
}


.theme-preview-modern_minimal {
    background: #f7f8fa;
}

.theme-preview-modern_minimal .preview-sidebar {
    background: #ffffff;
}

.theme-preview-modern_minimal .preview-header,
.theme-preview-modern_minimal .preview-cards span,
.theme-preview-modern_minimal .preview-panel {
    background: #e5e7eb;
}


.theme-preview-light_professional {
    background: #edf4fb;
}

.theme-preview-light_professional .preview-sidebar {
    background: #ffffff;
}

.theme-preview-light_professional .preview-header,
.theme-preview-light_professional .preview-cards span,
.theme-preview-light_professional .preview-panel {
    background: #cbdcf0;
}


.theme-preview-creative_cinematic {
    background: #181512;
}

.theme-preview-creative_cinematic .preview-sidebar {
    background: #0e0d0c;
}

.theme-preview-creative_cinematic .preview-header,
.theme-preview-creative_cinematic .preview-cards span,
.theme-preview-creative_cinematic .preview-panel {
    background: #40362b;
}


.theme-preview-dark_pro {
    background: #0c1721;
}

.theme-preview-dark_pro .preview-sidebar {
    background: #081019;
}

.theme-preview-dark_pro .preview-header,
.theme-preview-dark_pro .preview-cards span,
.theme-preview-dark_pro .preview-panel {
    background: #1b2a38;
}


.theme-preview-elegant_premium {
    background: #f8f0e6;
}

.theme-preview-elegant_premium .preview-sidebar {
    background: #e9dfd1;
}

.theme-preview-elegant_premium .preview-header,
.theme-preview-elegant_premium .preview-cards span,
.theme-preview-elegant_premium .preview-panel {
    background: #ded0bf;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1000px) {
    .theme-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .metrics {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 680px) {
    .sidebar {
        width: 68px;

        padding-left: 10px;
        padding-right: 10px;
    }

    .sidebar-brand {
        justify-content: center;
    }

    .sidebar-brand > span,
    .nav-item {
        font-size: 0;
    }

    .nav-item {
        justify-content: center;
    }

    .nav-icon {
        font-size: 19px;
    }

    .sidebar-user {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .user-info,
    .logout-button {
        display: none;
    }

    .content {
        width: calc(100% - 68px);
        margin-left: 68px;

        padding: 25px 18px;
    }

    .metrics {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        gap: 12px;
    }
}

@media (max-width: 650px) {
    .theme-grid {
        grid-template-columns: 1fr;
    }

    .login-body {
        padding: 18px;
    }

    .login-card {
        padding: 26px;
    }
}
/* AAA 2.5K Production Theme Backgrounds
   Place images in /opt/aaa/app/static/themes/
   Append these rules after the existing app.css theme/component rules. */

[data-theme="dark_cinematic"] {
    --hero-image: url("/static/themes/dark-cinematic.jpg");
    --hero-overlay:
        linear-gradient(90deg, rgba(5,8,12,.74) 0%, rgba(5,8,12,.34) 55%, rgba(5,8,12,.54) 100%),
        linear-gradient(180deg, rgba(5,8,12,.05), rgba(5,8,12,.66));
}
[data-theme="modern_minimal"] {
    --hero-image: url("/static/themes/modern-minimal.jpg");
    --hero-overlay: linear-gradient(180deg, rgba(247,248,250,.24), rgba(247,248,250,.86));
}
[data-theme="light_professional"] {
    --hero-image: url("/static/themes/light-professional.jpg");
    --hero-overlay: linear-gradient(180deg, rgba(243,247,251,.20), rgba(243,247,251,.84));
}
[data-theme="creative_cinematic"] {
    --hero-image: url("/static/themes/creative-cinematic.jpg");
    --hero-overlay:
        linear-gradient(90deg, rgba(14,9,5,.70) 0%, rgba(14,9,5,.26) 55%, rgba(14,9,5,.54) 100%),
        linear-gradient(180deg, rgba(14,9,5,.04), rgba(14,9,5,.68));
}
[data-theme="dark_pro"] {
    --hero-image: url("/static/themes/dark-pro.jpg");
    --hero-overlay:
        linear-gradient(90deg, rgba(4,11,18,.70) 0%, rgba(4,11,18,.30) 55%, rgba(4,11,18,.60) 100%),
        linear-gradient(180deg, rgba(4,11,18,.04), rgba(4,11,18,.70));
}
[data-theme="elegant_premium"] {
    --hero-image: url("/static/themes/elegant-premium.jpg");
    --hero-overlay: linear-gradient(180deg, rgba(244,238,229,.18), rgba(244,238,229,.78));
}

.dashboard-body {
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    background: var(--bg);
}
.dashboard-body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background-image: var(--hero-image);
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    pointer-events: none;
}
.dashboard-body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: var(--hero-overlay);
    pointer-events: none;
}

[data-theme="dark_cinematic"] .metric-card,
[data-theme="dark_cinematic"] .panel,
[data-theme="creative_cinematic"] .metric-card,
[data-theme="creative_cinematic"] .panel,
[data-theme="dark_pro"] .metric-card,
[data-theme="dark_pro"] .panel {
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
[data-theme="modern_minimal"] .metric-card,
[data-theme="modern_minimal"] .panel,
[data-theme="light_professional"] .metric-card,
[data-theme="light_professional"] .panel,
[data-theme="elegant_premium"] .metric-card,
[data-theme="elegant_premium"] .panel {
    background: color-mix(in srgb, var(--surface) 89%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.sidebar {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
[data-theme="dark_cinematic"] .sidebar,
[data-theme="creative_cinematic"] .sidebar,
[data-theme="dark_pro"] .sidebar {
    background: color-mix(in srgb, var(--sidebar) 94%, transparent);
}
[data-theme="modern_minimal"] .sidebar,
[data-theme="light_professional"] .sidebar,
[data-theme="elegant_premium"] .sidebar {
    background: color-mix(in srgb, var(--sidebar) 96%, transparent);
}

/* =========================================================
   AAA BACKGROUND FIX
   ========================================================= */

.dashboard-body {
    background-color: var(--bg);

    background-image:
        var(--hero-overlay),
        var(--hero-image);

    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Disable the older pseudo-element background method */
.dashboard-body::before,
.dashboard-body::after {
    content: none !important;
}

/* =========================================================
   APPEARANCE CONTROLS
   ========================================================= */

.background-hidden {
    background-image: none !important;
    background-color: var(--bg) !important;
}

.background-hidden::before,
.background-hidden::after {
    content: none !important;
}


/* Hide photographic layer while preserving theme colors */

.dashboard-body.background-hidden {
    background-image: none !important;
}


/* Appearance helper */

.appearance-help {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
}


/* Background option */

.background-option {
    padding: 22px 24px 0;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;

    padding: 16px 18px;

    border: 1px solid var(--border);
    border-radius: var(--card-radius);

    background: var(--surface-alt);

    cursor: pointer;
}

.toggle-row strong {
    display: block;
    font-size: 13px;
}

.toggle-row span {
    display: block;

    margin-top: 4px;

    color: var(--muted);
    font-size: 11px;
}

.toggle-row input[type="checkbox"] {
    width: 42px;
    height: 22px;

    accent-color: var(--accent);

    cursor: pointer;
}
