:root {
    --primary: #4361ee;
    --secondary: #3f37c9;
    --accent: #4895ef;

    /* Dark Theme Default */
    --bg-main: #0f172a;
    --bg-card: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    /* Brighter for dark mode labels */
    --table-color: transparent;
    --table-text: #f8fafc;
}

body.light-mode {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border-color: rgba(0, 0, 0, 0.1);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    /* Darker for light mode labels */
    --table-color: transparent;
    --table-text: #1e293b;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

.text-muted {
    color: var(--text-secondary) !important;
}

.sidebar .nav-link {
    color: var(--text-secondary) !important;
    transition: all 0.3s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: var(--primary) !important;
    font-weight: 600;
}

.dashboard-container {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    padding: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.4s ease, border-color 0.4s ease;
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.kpi-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(45deg, #4cc9f0, #4361ee);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.kpi-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.chart-container {
    height: 350px;
}

.sidebar {
    height: 100vh;
    width: 280px;
    position: fixed;
    border-right: 1px solid var(--border-color);
    padding: 2rem;
}

.main-content {
    margin-left: 280px;
}

.custom-input {
    background-color: var(--bg-main) !important;
    /* Not transparent to avoid mix-up with background text */
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px;
}

.custom-input:focus {
    background-color: var(--bg-main) !important;
    color: var(--text-primary) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 0.25rem rgba(67, 97, 238, 0.25) !important;
}

.custom-input::placeholder {
    color: var(--text-secondary) !important;
    opacity: 0.7;
}

/* Force text visibility on autofill */
.custom-input:-webkit-autofill,
.custom-input:-webkit-autofill:hover,
.custom-input:-webkit-autofill:focus,
.custom-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 100px var(--bg-main) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
}

.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.upload-zone:hover {
    border-color: var(--primary);
}

.btn-premium {
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 0.8rem;
    padding: 0.8rem 1.5rem;
    font-weight: 600;
    transition: opacity 0.3s ease;
}

.btn-premium:hover {
    opacity: 0.9;
    color: white;
}

@media (max-width: 992px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        padding: 1rem;
    }

    .sidebar .nav {
        flex-direction: row;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
    }

    .sidebar .nav-link {
        white-space: nowrap;
    }

    .main-content {
        margin-left: 0;
    }

    .dashboard-container {
        padding: 1rem;
    }

    header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    header>div:last-child {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }
}

@media (max-width: 576px) {
    .kpi-value {
        font-size: 1.8rem;
    }

    .chart-container {
        height: 250px;
    }
}

.table-custom {
    color: var(--table-text) !important;
}

.table-custom th,
.table-custom td {
    border-bottom-color: var(--border-color);
}