:root {
    --bg-primary: #0b0f19;
    --bg-surface: #111827;
    --bg-card: #1f2937;
    --bg-card-hover: #283548;
    --border-subtle: #374151;
    --border-active: #4f46e5;
    
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --brand-primary: #6366f1;
    --brand-hover: #4f46e5;
    --brand-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.15);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: transparent;
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(11, 15, 25, 0.88) 0%, rgba(15, 23, 42, 0.92) 100%),
                url('../images/hero-3d-bg.jpg') center / cover no-repeat,
                #0b0f19;
}

[data-theme="light"] body::before {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.25) 50%, rgba(248, 250, 252, 0.55) 100%),
                url('../images/hero-3d-bg.jpg') center / cover no-repeat,
                #f8fafc;
}

a {
    color: var(--brand-primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #818cf8;
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: rgba(17, 24, 39, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.sidebar-brand {
    padding: 1.25rem 1.25rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-brand-title {
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.magnova-sidebar-logo {
    width: 2rem;
    height: 2rem;
    object-fit: contain;
    flex: 0 0 auto;
}

.sidebar-search-input:focus {
    border-color: var(--brand-primary) !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.sidebar-nav {
    padding: 1rem 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.nav-link.active {
    border-left: 3px solid var(--brand-primary);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.topbar {
    height: 64px;
    background-color: rgba(17, 24, 39, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.content-body {
    padding: 1.75rem 2rem;
    flex: 1;
}

/* Cards & Stats */
.card {
    background-color: rgba(31, 41, 55, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: rgba(31, 41, 55, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-active);
}

.stat-title {
    font-size: 0.825rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    margin-top: 0.35rem;
    color: var(--text-primary);
}

.stat-footer {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Tables */
.card-table {
    background-color: rgba(31, 41, 55, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
}

.table-responsive::-webkit-scrollbar {
    height: 6px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 4px;
}

table,
.table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 0.875rem;
    text-align: left;
    line-height: 1.5;
}

table th,
.table th,
.data-table th {
    background-color: rgba(255, 255, 255, 0.03);
    padding: 0.95rem 1.25rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
    vertical-align: middle;
}

table td,
.table td,
.data-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    vertical-align: middle;
    font-size: 0.875rem;
}

table tbody tr,
.table tbody tr,
.data-table tbody tr {
    transition: background-color 0.15s ease;
}

table tbody tr:hover td,
.table tbody tr:hover td,
.data-table tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.025);
}

table tbody tr:last-child td,
.table tbody tr:last-child td,
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: capitalize;
}

.badge-success { background-color: var(--success-bg); color: var(--success); }
.badge-warning { background-color: var(--warning-bg); color: var(--warning); }
.badge-danger { background-color: var(--danger-bg); color: var(--danger); }
.badge-info { background-color: var(--info-bg); color: var(--info); }

/* Buttons & Forms */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--brand-gradient);
    color: #fff;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-secondary {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--border-subtle);
}

.btn-danger {
    background-color: var(--danger);
    color: #fff;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Alerts */
.alert {
    padding: 0.85rem 1.15rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success { background-color: var(--success-bg); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.alert-danger { background-color: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }

.onboarding-page-header {
    margin-bottom: 1.8rem;
    padding-top: 0.2rem;
    position: relative;
    z-index: 1;
}

.onboarding-page-header h1 {
    font-size: clamp(3rem, 4vw, 5rem);
    line-height: 0.96;
    letter-spacing: -0.065em;
    font-weight: 800;
    margin: 0;
    color: #1d2b3a;
    text-shadow: none;
}

.onboarding-page-header p {
    margin-top: 0.9rem;
    font-size: 1.08rem;
    line-height: 1.6;
    color: #4a5d73;
    max-width: 56rem;
}

.onboarding-result-card,
.onboarding-form-card {
    max-width: 68rem;
    width: 100%;
    padding: 1.5rem 1.4rem 1.25rem;
    margin-bottom: 1.2rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 0.85rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 10px 25px rgba(15, 23, 42, 0.04);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.onboarding-result-card {
    padding-top: 1.2rem;
    padding-bottom: 1.15rem;
    border-top: 1px solid rgba(148, 163, 184, 0.22);
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(255, 255, 255, 0.03);
}

.onboarding-result-card h2,
.onboarding-form-card h2 {
    margin: 0 0 0.9rem;
    font-size: clamp(1.9rem, 2.4vw, 3rem);
    line-height: 1.1;
    letter-spacing: -0.045em;
    font-weight: 800;
    color: #1d2b3a;
}

.onboarding-result-card p,
.onboarding-form-card p {
    margin: 0;
}

.onboarding-result-card > p:first-of-type,
.onboarding-form-card > p:first-of-type {
    color: #4a5d73;
    font-size: 1.1rem;
    line-height: 1.55;
}

.onboarding-link-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 0.9rem;
    flex-wrap: wrap;
}

.onboarding-link-field {
    flex: 1 1 22rem;
    min-height: 3.15rem;
    padding: 0.8rem 1rem;
    border-radius: 0.6rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.4);
    color: #182535;
    font-size: 0.96rem;
    line-height: 1.4;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.onboarding-copy-btn {
    min-width: 9rem;
    height: 3.15rem;
    border-radius: 0.7rem;
    background: rgba(255, 255, 255, 0.34);
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #1d2b3a;
    font-weight: 700;
}

.onboarding-copy-btn:hover {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(148, 163, 184, 0.5);
}

.onboarding-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.5rem;
}

.onboarding-field-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
}

.onboarding-field-row label {
    min-width: 9.5rem;
    font-size: 1.15rem;
    line-height: 1.4;
    color: #1d2b3a;
    font-weight: 700;
}

.onboarding-field-row select,
.onboarding-email-row input {
    flex: 1 1 18rem;
    min-height: 3.15rem;
    padding: 0.8rem 0.95rem;
    border-radius: 0.6rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.4);
    color: #182535;
    font-size: 1rem;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}

.onboarding-field-row select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, rgba(31,41,55,0.8) 50%), linear-gradient(135deg, rgba(31,41,55,0.8) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 13px) calc(50% - 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 2.2rem;
}

.onboarding-field-row select:focus,
.onboarding-email-row input:focus {
    border-color: rgba(118, 104, 237, 0.8);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.12), inset 0 1px 0 rgba(255,255,255,0.4);
}

.onboarding-helper-text {
    margin-top: 0.1rem;
    color: #4a5d73;
    font-size: 0.96rem;
    line-height: 1.45;
}

.onboarding-submit-btn {
    width: fit-content;
    min-width: 13rem;
    min-height: 3.15rem;
    padding: 0.9rem 1.45rem;
    border-radius: 0.7rem;
    margin-top: 0.2rem;
    font-size: 1.06rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #7d73fa 0%, #a26cf5 100%);
    box-shadow: 0 12px 24px rgba(122, 103, 245, 0.22), inset 0 1px 0 rgba(255,255,255,0.3);
    color: #fff;
}

.onboarding-submit-btn:hover {
    filter: brightness(1.04);
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .onboarding-result-card,
    .onboarding-form-card {
        padding: 1.25rem 1rem 1rem;
        border-radius: 0.9rem;
    }

    .onboarding-page-header h1 {
        font-size: 2.5rem;
    }

    .onboarding-page-header p {
        font-size: 0.96rem;
    }

    .onboarding-field-row {
        align-items: stretch;
    }

    .onboarding-field-row label {
        width: 100%;
        min-width: 0;
    }

    .onboarding-field-row select,
    .onboarding-email-row input,
    .onboarding-link-field {
        width: 100%;
        flex-basis: 100%;
    }

    .onboarding-link-row {
        display: grid;
        grid-template-columns: 1fr;
    }

    .onboarding-copy-btn,
    .onboarding-submit-btn {
        width: 100%;
    }
}

/* Auth Layout */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    background: linear-gradient(180deg, rgba(11, 15, 25, 0.78) 0%, rgba(15, 23, 42, 0.88) 100%),
                url('../images/hero-3d-bg.jpg') center / cover no-repeat,
                #0b0f19;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background-color: rgba(17, 24, 39, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: 2.25rem;
    box-shadow: var(--shadow-lg), 0 0 30px rgba(99, 102, 241, 0.15);
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.magnova-auth-logo {
    display: block;
    width: 6rem;
    height: 6rem;
    object-fit: contain;
    margin: 0 auto 0.75rem;
}

.auth-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-brand p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Global Floating AI Copilot Robot Styles */
@keyframes copilotPing {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.8); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

@keyframes copilotFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.copilot-robot-ping {
    animation: copilotPing 2.2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

#copilotRobotBtn {
    animation: copilotFloat 3.5s ease-in-out infinite;
}

#copilotRobotBtn:hover {
    transform: scale(1.1) translateY(-3px) !important;
    box-shadow: 0 14px 28px -2px rgba(99, 102, 241, 0.65), 0 6px 14px rgba(0, 0, 0, 0.5) !important;
}

#copilotChatModal {
    animation: copilotSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes copilotSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Base Card Class */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Theme Transition Smoothing */
body,
.sidebar,
.topbar,
.card,
.stat-card,
.card-table,
.form-control,
.btn-secondary {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* ==========================================================================
   LIGHT MODE DESIGN SYSTEM
   ========================================================================== */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --border-subtle: #e2e8f0;
    --border-active: #6366f1;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --brand-primary: #4f46e5;
    --brand-hover: #4338ca;
    --brand-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    
    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.12);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.12);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.12);
    --info: #2563eb;
    --info-bg: rgba(37, 99, 235, 0.12);

    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] body {
    background-color: transparent;
    color: var(--text-primary);
}

[data-theme="light"] .sidebar {
    background-color: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right-color: #e2e8f0;
}

[data-theme="light"] .topbar {
    background-color: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom-color: #e2e8f0;
}

[data-theme="light"] .sidebar-search-input {
    background: rgba(241, 245, 249, 0.9) !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

[data-theme="light"] .sidebar-search-input::placeholder {
    color: #94a3b8 !important;
}

[data-theme="light"] .nav-link {
    color: #475569;
}

[data-theme="light"] .nav-link:hover,
[data-theme="light"] .nav-link.active {
    background-color: #f1f5f9;
    color: #0f172a;
}

[data-theme="light"] .card,
[data-theme="light"] .card-table,
[data-theme="light"] .stat-card {
    background-color: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-color: #e2e8f0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.07), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .card-header {
    border-bottom-color: #e2e8f0;
}

[data-theme="light"] table th,
[data-theme="light"] .table th,
[data-theme="light"] .data-table th {
    background-color: #f8fafc;
    color: #475569;
    border-bottom-color: #e2e8f0;
}

[data-theme="light"] table td,
[data-theme="light"] .table td,
[data-theme="light"] .data-table td {
    color: #0f172a;
    border-bottom-color: #f1f5f9;
}

[data-theme="light"] table tbody tr:hover td,
[data-theme="light"] .table tbody tr:hover td,
[data-theme="light"] .data-table tbody tr:hover td {
    background-color: #f8fafc;
}

[data-theme="light"] .form-control {
    background-color: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
}

[data-theme="light"] .form-control:focus {
    border-color: var(--brand-primary);
    background-color: #ffffff;
}

[data-theme="light"] .btn-secondary {
    background-color: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
}

[data-theme="light"] .btn-secondary:hover {
    background-color: #f1f5f9;
}

[data-theme="light"] #copilotChatModal {
    background: rgba(255, 255, 255, 0.98) !important;
    border-color: rgba(99, 102, 241, 0.35) !important;
    box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.15), 0 0 25px rgba(99, 102, 241, 0.12) !important;
}

[data-theme="light"] #copilotChatStream {
    background: #f8fafc !important;
}

[data-theme="light"] .copilot-point-card {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
}

[data-theme="light"] .auth-wrapper {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, rgba(248, 250, 252, 0.6) 100%),
                url('../images/hero-3d-bg.jpg') center / cover no-repeat,
                #f8fafc;
}

[data-theme="light"] .auth-card {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-color: rgba(226, 232, 240, 0.8);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   DESKTOP & MOBILE RESPONSIVE ADAPTATION SYSTEM
   ========================================================================== */

/* Sidebar Backdrop Overlay */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.28s ease;
    pointer-events: none;
}

.sidebar-backdrop.active {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Utility visibility classes */
.mobile-only-btn {
    display: none !important;
}

.mobile-close-btn {
    display: none !important;
    background: transparent;
    border: none;
    -webkit-text-fill-color: var(--text-secondary) !important;
    color: var(--text-secondary) !important;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: all 0.2s;
}

.mobile-close-btn:hover {
    -webkit-text-fill-color: var(--text-primary) !important;
    color: var(--text-primary) !important;
    background: rgba(255, 255, 255, 0.1);
}

/* Tablet & Mobile Breakpoints (<= 992px) */
@media (max-width: 992px) {
    .app-container {
        flex-direction: column;
        position: relative;
    }

    /* Off-canvas Mobile Drawer Sidebar */
    .sidebar {
        position: fixed !important;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        z-index: 10001 !important;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.28s ease !important;
        box-shadow: none;
        overflow-y: auto;
    }

    .sidebar.mobile-open {
        transform: translateX(0) !important;
        box-shadow: 12px 0 35px rgba(0, 0, 0, 0.6) !important;
    }

    /* Show Mobile Hamburger and Close Buttons */
    .mobile-only-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }

    .mobile-close-btn {
        display: inline-flex !important;
    }

    /* Table horizontal scroll safeguard */
    .card:has(table),
    .card-table {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Topbar adjustments */
    .topbar {
        padding: 0 1rem;
        height: 58px;
    }

    .main-content {
        width: 100%;
        min-width: 0;
    }

    .content-body {
        padding: 1.25rem 1rem;
    }

    /* Multi-column grid auto-stacking on tablets */
    .stats-grid,
    .grid-stats {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
        gap: 1rem !important;
    }
}

/* Mobile Phone Breakpoints (<= 768px) */
@media (max-width: 768px) {
    .topbar {
        padding: 0 0.75rem;
        height: 56px;
    }

    .tenant-badge {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.7rem;
    }

    #themeToggleText {
        display: none;
    }

    #themeToggleBtn {
        padding: 0.35rem 0.5rem !important;
    }

    .user-profile-meta {
        display: none !important;
    }

    /* Page headers & Action buttons wrap cleanly */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
        margin-bottom: 1.25rem !important;
    }

    .page-header h1 {
        font-size: 1.35rem !important;
    }

    .page-header p {
        font-size: 0.8rem !important;
    }

    /* Form & Stats Grids auto-stack into 1 responsive column */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr 1fr"],
    [style*="grid-template-columns: 360px 1fr"],
    [style*="grid-template-columns: repeat(auto-fit, minmax(320px, 1fr))"],
    [style*="grid-template-columns: repeat(auto-fit, minmax(240px, 1fr))"],
    [style*="grid-template-columns: repeat(auto-fit, minmax(220px, 1fr))"],
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .content-body {
        padding: 1rem 0.75rem !important;
    }

    .card {
        padding: 1.15rem !important;
        border-radius: var(--radius-sm);
    }

    .stat-card {
        padding: 1rem !important;
    }

    .stat-value {
        font-size: 1.5rem !important;
    }

    /* Tables */
    table th, .table th, .data-table th,
    table td, .table td, .data-table td {
        padding: 0.65rem 0.75rem !important;
        font-size: 0.78rem !important;
    }

    /* Kanban columns on mobile */
    .kanban-column {
        min-width: 250px !important;
    }

    /* Global AI Copilot Modal on Mobile */
    #copilotChatModal {
        width: calc(100vw - 20px) !important;
        right: 10px !important;
        left: 10px !important;
        bottom: 74px !important;
        height: calc(100vh - 100px) !important;
        max-height: none !important;
        border-radius: 14px !important;
    }

    #copilotFloatingContainer {
        bottom: 16px !important;
        right: 16px !important;
    }

    #copilotRobotBtn {
        width: 50px !important;
        height: 50px !important;
    }

    #copilotBtnIcon {
        font-size: 1.55rem !important;
    }
}

/* Small Phone Breakpoints (<= 480px) */
@media (max-width: 480px) {
    .stats-grid,
    .grid-stats {
        grid-template-columns: 1fr !important;
    }

    .auth-card {
        padding: 1.5rem !important;
    }

    .auth-brand h1 {
        font-size: 1.3rem !important;
    }

    .btn {
        font-size: 0.8rem;
        padding: 0.5rem 0.85rem;
    }
}

/* Lead creation form */
.lead-create-page {
    width: min(100%, 1080px);
    margin: 0 auto;
}

.lead-create-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.35rem;
}

.lead-create-header .btn {
    flex: 0 0 auto;
    margin-top: 0.2rem;
}

.lead-create-header h1 {
    margin: 0;
    font-size: clamp(1.65rem, 3vw, 2.15rem);
    line-height: 1.2;
    letter-spacing: -0.035em;
}

.lead-create-header p,
.lead-section-heading p {
    margin: 0.3rem 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.lead-create-card {
    position: relative;
    overflow: hidden;
    padding: clamp(1.25rem, 3vw, 2.15rem);
    background: linear-gradient(145deg, rgba(31, 41, 55, 0.97), rgba(17, 24, 39, 0.96));
    border-color: rgba(148, 163, 184, 0.24);
    border-radius: 1rem;
    box-shadow: 0 20px 50px rgba(2, 6, 23, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.lead-create-card::before {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: var(--brand-gradient);
    content: "";
    pointer-events: none;
}

.lead-form-section + .lead-form-section {
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    margin-top: 1.8rem;
    padding-top: 1.8rem;
}

.lead-form-section > h2,
.lead-section-heading h2 {
    margin: 0;
    font-size: 1.12rem;
    font-weight: 700;
    letter-spacing: -0.015em;
}

.lead-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.2rem 1.35rem;
    margin-top: 1.15rem;
}

.lead-form-field {
    min-width: 0;
    margin: 0;
}

.lead-form-field .form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 600;
}

.lead-form-field .form-label span {
    color: #f87171;
}

.lead-form-field .form-control {
    min-height: 3rem;
    border-color: rgba(148, 163, 184, 0.25);
    border-radius: 0.65rem;
    background-color: rgba(15, 23, 42, 0.62);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.lead-form-field .form-control:focus {
    border-color: rgba(129, 140, 248, 0.9);
    background-color: rgba(15, 23, 42, 0.85);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
}

.lead-phone-row,
.lead-alternate-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.lead-phone-row[hidden] {
    display: none;
}

.lead-phone-row .form-control,
.lead-alternate-row .form-control {
    min-width: 0;
    flex: 1;
}

.lead-phone-row .btn,
.lead-alternate-row .btn {
    min-height: 3rem;
    flex: 0 0 auto;
}

.lead-phone-row > .btn {
    min-width: 7.5rem;
    border-radius: 0.65rem;
}

.lead-otp-row {
    margin-top: 0.55rem;
}

.lead-inline-status {
    min-height: 1.25rem;
    margin-top: 0.35rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.lead-inline-status.is-success {
    color: var(--success);
}

.lead-inline-status.is-error {
    color: var(--danger);
}

.lead-section-heading,
.lead-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.lead-small-btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.78rem;
    white-space: nowrap;
}

.lead-alternate-list {
    display: grid;
    gap: 0.55rem;
    margin-top: 0.9rem;
    max-width: 48rem;
}

.lead-remove-number {
    min-width: 5.2rem;
    padding: 0.45rem 0.65rem;
    font-size: 0.78rem;
}

.lead-remove-number:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.lead-field-help {
    margin: 0.45rem 0 0;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.lead-field-help,
.lead-inline-status {
    line-height: 1.5;
}

.lead-label-row {
    margin-bottom: 0.45rem;
}

.lead-label-row .form-label {
    margin: 0;
}

.lead-offerings-heading {
    margin-bottom: 1.1rem;
}

.lead-selection-count {
    flex: 0 0 auto;
    padding: 0.3rem 0.65rem;
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.12);
    color: #c4b5fd;
    font-size: 0.76rem;
    font-weight: 700;
}

.lead-catalog-group + .lead-catalog-group {
    margin-top: 1rem;
}

.lead-catalog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.65rem;
}

.lead-catalog-header h3 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.lead-catalog-search {
    width: min(100%, 15rem);
    min-height: 2.3rem !important;
    padding: 0.45rem 0.65rem;
    font-size: 0.8rem;
}

.lead-catalog-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
}

.lead-catalog-option {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    min-width: 0;
    padding: 0.75rem 0.8rem;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 0.6rem;
    background: rgba(15, 23, 42, 0.28);
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.lead-catalog-option:hover {
    border-color: rgba(99, 102, 241, 0.45);
    color: var(--text-primary);
}

.lead-catalog-option:has(input:checked) {
    border-color: rgba(129, 140, 248, 0.65);
    background: rgba(99, 102, 241, 0.13);
    color: var(--text-primary);
}

.lead-catalog-option input {
    flex: 0 0 auto;
    margin: 0.15rem 0 0;
    accent-color: #818cf8;
}

.lead-catalog-option[hidden] {
    display: none;
}

.lead-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.7rem;
    margin-top: 1.8rem;
    padding-top: 1.35rem;
    border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.lead-submit-btn {
    min-width: 11rem;
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.22);
}

[data-theme="light"] .lead-create-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
    border-color: rgba(148, 163, 184, 0.35);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .lead-form-field .form-control {
    border-color: #cbd5e1;
    background-color: rgba(255, 255, 255, 0.92);
}

[data-theme="light"] .lead-form-field .form-control:focus {
    background-color: #fff;
}

[data-theme="light"] .lead-catalog-option {
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(248, 250, 252, 0.8);
}

[data-theme="light"] .lead-selection-count {
    color: #4338ca;
    background: rgba(99, 102, 241, 0.08);
}

.lead-modal {
    position: fixed;
    inset: 0;
    z-index: 10010;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.lead-modal.is-open {
    display: flex;
}

.lead-modal-card {
    width: min(100%, 440px);
    padding: 1.35rem;
    background: var(--bg-surface);
    border-color: var(--border-subtle);
}

.lead-modal-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.lead-modal-heading h2 {
    margin: 0;
    font-size: 1.1rem;
}

.lead-modal-close {
    padding: 0.1rem 0.45rem;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.lead-modal .lead-form-actions {
    margin-top: 1rem;
    padding-top: 0;
    border: 0;
}

@media (max-width: 700px) {
    .lead-form-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.95rem;
    }

    .lead-catalog-options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .lead-create-header {
        align-items: flex-start;
        gap: 0.65rem;
    }

    .lead-create-header .btn {
        padding: 0.45rem 0.6rem;
        font-size: 0.75rem;
    }

    .lead-section-heading,
    .lead-catalog-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .lead-catalog-search {
        width: 100%;
    }

    .lead-catalog-options {
        grid-template-columns: minmax(0, 1fr);
    }

    .lead-phone-row,
    .lead-alternate-row {
        flex-wrap: wrap;
    }

    .lead-phone-row .btn,
    .lead-alternate-row .btn {
        width: 100%;
    }

    .lead-form-actions {
        flex-direction: column-reverse;
    }

    .lead-form-actions > .btn,
    .lead-submit-btn {
        width: 100%;
    }
}
