:root {
    --primary: #075e63;
    --primary-dark: #06484d;
    --accent: #22c7d6;
    --bg: #f3f7fa;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --hero-a: #082f49;
    --hero-b: #0f766e;
}

body.theme-blue {
    --primary: #1d4ed8;
    --primary-dark: #172554;
    --accent: #38bdf8;
    --bg: #eff6ff;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --hero-a: #0f172a;
    --hero-b: #2563eb;
}

body.theme-emerald {
    --primary: #047857;
    --primary-dark: #064e3b;
    --accent: #34d399;
    --bg: #ecfdf5;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --hero-a: #052e16;
    --hero-b: #059669;
}

body.theme-purple {
    --primary: #6d28d9;
    --primary-dark: #3b0764;
    --accent: #a78bfa;
    --bg: #f5f3ff;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --hero-a: #2e1065;
    --hero-b: #7c3aed;
}

body.theme-light {
    --primary: #2563eb;
    --primary-dark: #1e3a8a;
    --accent: #60a5fa;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #111827;
    --muted: #64748b;
    --hero-a: #334155;
    --hero-b: #2563eb;
}

body.theme-dark {
    --primary: #14b8a6;
    --primary-dark: #071a1d;
    --accent: #22d3ee;
    --bg: #0b1220;
    --card: #111c2e;
    --text: #e6edf7;
    --muted: #9aabc0;
    --hero-a: #071a1d;
    --hero-b: #123b45;
}

body.dashboard-page {
    background: var(--bg) !important;
    color: var(--text);
}

.dashboard-sidebar {
    background:
        radial-gradient(circle at 24px 24px, color-mix(in srgb, var(--accent) 28%, transparent), transparent 190px),
        linear-gradient(180deg, var(--primary-dark) 0%, #10263c 48%, #07111f 100%) !important;
}

.sidebar-logo,
.metric-icon,
.crm-stat-card i {
    background: linear-gradient(135deg, var(--primary), var(--accent)) !important;
}

.dashboard-hero,
.crm-hero {
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--hero-a) 96%, black), color-mix(in srgb, var(--hero-b) 92%, black)),
        linear-gradient(90deg, var(--primary-dark), var(--primary)) !important;
}

.btn-primary,
.quick-action.primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.btn-outline-primary {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
}

.btn-outline-primary:hover,
.mobile-bottom-nav a.active,
.mobile-bottom-nav a:hover,
.mobile-bottom-nav summary:hover {
    background: color-mix(in srgb, var(--accent) 16%, white) !important;
    color: var(--primary) !important;
}

.data-panel,
.chart-card,
.crm-stat-card,
.metric-card,
.mobile-data-card {
    background: var(--card) !important;
    color: var(--text);
}

body.theme-dark .filter-panel,
body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark .input-group-text,
body.theme-dark .modal-content,
body.theme-dark .dropdown-menu,
body.theme-dark .table {
    background-color: #111c2e !important;
    border-color: #2a3a50 !important;
    color: #e6edf7 !important;
}

body.theme-dark .form-control::placeholder {
    color: #7e91aa;
}

body.theme-dark .table > :not(caption) > * > *,
body.theme-dark .dashboard-table th,
body.theme-dark .text-muted,
body.theme-dark small {
    border-color: #26364b !important;
    color: var(--muted) !important;
}

body.theme-dark .dashboard-table td,
body.theme-dark h1,
body.theme-dark h2,
body.theme-dark h3,
body.theme-dark h4,
body.theme-dark strong,
body.theme-dark label {
    color: var(--text) !important;
}

body.theme-dark .metric-card span,
body.theme-dark .crm-stat-card span,
body.theme-dark .section-title p,
body.theme-dark .search-result-card p {
    color: #aebdd0 !important;
}

body.theme-dark .metric-card,
body.theme-dark .crm-stat-card,
body.theme-dark .search-result-card,
body.theme-dark .dashboard-global-search {
    border-color: #31435a !important;
}

body.theme-dark .mobile-bottom-nav,
body.theme-dark .mobile-more-panel {
    background: #111c2e !important;
    border-color: #2a3a50 !important;
}

body.theme-dark .btn-light,
body.theme-dark .btn-outline-secondary {
    background: #17253a;
    border-color: #34465e;
    color: #e6edf7;
}

body.theme-dark .alert-info {
    background: #102d3a;
    color: #c7f4ff;
}

.eyebrow,
.sidebar-group-label,
.sidebar-nav a i {
    color: var(--accent) !important;
}

.theme-switcher {
    display: grid;
    gap: .35rem;
}

.theme-switcher label {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 800;
}

.theme-switcher select {
    border: 1px solid rgba(148, 163, 184, .35);
    border-radius: 12px;
    font-size: .82rem;
    padding: .45rem .65rem;
}

.mobile-bottom-nav {
    display: none !important;
}

@media (max-width: 768px) {
    body.dashboard-page {
        padding-bottom: 78px !important;
    }

    .mobile-bottom-nav {
        align-items: center !important;
        background: rgba(255, 255, 255, .98) !important;
        border-top: 1px solid #dbe6f1 !important;
        bottom: 0 !important;
        box-shadow: 0 -12px 32px rgba(15, 23, 42, .14) !important;
        display: grid !important;
        gap: .18rem !important;
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
        left: 0 !important;
        margin: 0 !important;
        padding: .42rem .5rem calc(.55rem + env(safe-area-inset-bottom)) !important;
        position: fixed !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        z-index: 2147483000 !important;
    }

    .mobile-bottom-nav a,
    .mobile-bottom-nav summary {
        align-items: center !important;
        background: transparent !important;
        border: 0 !important;
        border-radius: 13px !important;
        color: #64748b !important;
        display: flex !important;
        flex-direction: column !important;
        font-size: .68rem !important;
        font-weight: 800 !important;
        gap: .16rem !important;
        justify-content: center !important;
        line-height: 1.1 !important;
        min-height: 48px !important;
        padding: .25rem !important;
        text-align: center !important;
        text-decoration: none !important;
        white-space: nowrap !important;
    }

    .mobile-bottom-nav a.active,
    .mobile-bottom-nav a:hover,
    .mobile-bottom-nav summary:hover {
        background: color-mix(in srgb, var(--accent) 16%, white) !important;
        color: var(--primary) !important;
    }

    .mobile-bottom-nav i {
        display: block !important;
        font-size: 1.04rem !important;
        line-height: 1 !important;
        margin: 0 !important;
    }

    .mobile-more-menu {
        display: block !important;
        position: relative !important;
    }

    .mobile-more-menu summary {
        cursor: pointer !important;
        list-style: none !important;
    }

    .mobile-more-menu summary::-webkit-details-marker,
    .mobile-more-menu summary::marker {
        display: none !important;
        content: "" !important;
    }

    .mobile-more-panel {
        background: #fff !important;
        border: 1px solid #dbe6f1 !important;
        border-radius: 18px !important;
        bottom: 64px !important;
        box-shadow: 0 18px 42px rgba(15, 23, 42, .22) !important;
        display: none !important;
        gap: .15rem !important;
        padding: .55rem !important;
        position: absolute !important;
        right: 0 !important;
        width: min(230px, calc(100vw - 20px)) !important;
    }

    .mobile-more-menu[open] .mobile-more-panel {
        display: grid !important;
    }

    .mobile-more-panel a {
        align-items: center !important;
        flex-direction: row !important;
        font-size: .78rem !important;
        justify-content: flex-start !important;
        min-height: 38px !important;
        padding: .45rem .6rem !important;
        text-align: left !important;
    }

    .mobile-more-panel .theme-switcher {
        padding: .4rem .55rem !important;
    }
}
