:root {
    --primary-dark: #0a1929;
    --primary-blue: #1a2942;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --bg-dark: #0d1b2a;
    --bg-card: #1b2838;
    --border-color: #2d3e50;
    --text-primary: #e3f2fd;
    --text-secondary: #94a3b8;
    --male-color: #42a5f5;
    --female-color: #ec407a;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-dark);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    overflow: hidden;
    height: 100vh;
    color: var(--text-primary);
}

/* Dashboard Container */
.dashboard-container {
    display: grid;
    grid-template-columns: 0px 1fr;
    grid-template-rows: 65px 1fr;
    height: 100vh;
    transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dashboard-container.sidebar-open {
    grid-template-columns: 280px 1fr;
}

/* Header */
.dashboard-header {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-dark) 100%);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    padding: 0 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 100;
    border-bottom: 2px solid rgba(59, 130, 246, 0.3);
}

.dashboard-title {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.dashboard-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.toggle-sidebar-btn {
    background: rgba(59, 130, 246, 0.15);
    border: 1.5px solid var(--accent-blue);
    color: var(--accent-blue);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-sidebar-btn:hover {
    background: var(--accent-blue);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Filter Sidebar */
.filter-sidebar {
    background: linear-gradient(180deg, var(--primary-blue) 0%, var(--bg-card) 100%);
    color: var(--text-primary);
    overflow-y: auto;
    border-right: 2px solid var(--border-color);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.3);
}

.sidebar-open .filter-sidebar {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-content {
    padding: 24px 20px;
}

.filter-sidebar h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 24px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-primary);
    padding-bottom: 12px;
    border-bottom: 3px solid var(--accent-blue);
}

.filter-group {
    margin-bottom: 20px;
}

.filter-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--primary-dark);
    color: var(--text-primary);
    transition: all 0.3s;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-select:hover {
    border-color: var(--accent-blue);
}

.filter-select option {
    background: var(--primary-dark);
    padding: 8px;
}

.btn-reset {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(220, 38, 38, 0.2) 100%);
    color: #f87171;
    border: 1.5px solid #ef4444;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 12px;
}

.btn-reset:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.active-filters {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid var(--accent-blue);
    border-radius: 12px;
    font-size: 0.75rem;
    margin: 4px;
    color: var(--accent-blue);
    font-weight: 500;
}

.filter-badge button {
    background: none;
    border: none;
    color: var(--accent-blue);
    cursor: pointer;
    padding: 0;
    font-size: 1.1rem;
    line-height: 1;
    font-weight: 700;
    transition: color 0.2s;
}

.filter-badge button:hover {
    color: #ef4444;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
    padding: 20px;
    background: var(--bg-dark);
    overflow-y: auto;
    height: calc(100vh - 65px);
}

/* KPI Row */
.kpi-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, 1fr) 1.8fr;
    gap: 16px;
    margin-bottom: 4px;
}

/* KPI Cards */
.kpi-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent-blue);
}

.kpi-card.kpi-primary::before {
    background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 100%);
}

.kpi-card.kpi-success::before {
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
}

.kpi-card.kpi-warning::before {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

.kpi-card.kpi-info::before {
    background: linear-gradient(90deg, #06b6d4 0%, #22d3ee 100%);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.kpi-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.kpi-content {
    flex: 1;
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 4px;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

/* Chart Cards */
.chart-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.3s;
}

.chart-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.gender-card {
    min-height: 200px;
}

.chart-large {
    grid-column: span 6;
    min-height: 400px;
}

.chart-medium {
    grid-column: span 6;
    min-height: 480px;
}

.chart-full {
    grid-column: 1 / -1;
    min-height: 500px;
}

/* Chart Header */
.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.chart-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.chart-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: 0.3px;
}

.chart-badge {
    font-size: 0.65rem;
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    padding: 4px 10px;
    border-radius: 10px;
    font-weight: 600;
    border: 1px solid var(--accent-blue);
    letter-spacing: 0.5px;
}

.chart-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0 0 12px 0;
    line-height: 1.4;
}

.chart-control {
    padding: 6px 12px;
    background: var(--primary-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-control:hover {
    border-color: var(--accent-blue);
}

.chart-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Chart Wrapper */
.chart-wrapper {
    flex: 1;
    position: relative;
    min-height: 0;
    overflow: visible;
    padding-bottom: 8px;
}

#chartF-container {
    height: 100%;
    min-height: 150px;
}

#chartA-container,
#chartB-container {
    height: 100%;
    min-height: 300px;
}

#chartC-container,
#chartD-container {
    height: 100%;
    min-height: 280px;
}

#chartE-container {
    height: 100%;
    min-height: 320px;
}

/* Placeholder */
.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-dark);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    height: 100%;
    text-align: center;
    padding: 32px;
    transition: all 0.3s;
}

.placeholder:hover {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.05);
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    filter: grayscale(0.5) opacity(0.7);
}

.placeholder-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.placeholder-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 280px;
}

/* Loading */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 27, 42, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 8px;
}

.loading-overlay.hidden {
    display: none;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-right-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Scrollbar Styling */
.dashboard-grid::-webkit-scrollbar,
.filter-sidebar::-webkit-scrollbar {
    width: 8px;
}

.dashboard-grid::-webkit-scrollbar-track,
.filter-sidebar::-webkit-scrollbar-track {
    background: var(--primary-dark);
}

.dashboard-grid::-webkit-scrollbar-thumb,
.filter-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.dashboard-grid::-webkit-scrollbar-thumb:hover,
.filter-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

/* Chart D Controls */
.chart-d-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.chart-d-btn {
    background: var(--primary-dark);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.chart-d-btn:hover {
    border-color: var(--accent-blue);
}

.chart-d-btn.active {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
}

.chart-d-spec {
    appearance: none;
    padding-right: 32px;
    background-image:
        linear-gradient(180deg, var(--primary-dark), var(--primary-dark)),
        url("data:image/svg+xml;utf8,<svg fill='%2394a3b8' height='16' viewBox='0 0 24 24' width='16' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: 0 0, right 10px center;
    background-size: 100% 100%, 16px;
}

.chart-d-spec option {
    background: var(--primary-dark);
    color: var(--text-primary);
}

/* Responsive Design */
@media (max-width: 1400px) {
    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .gender-card {
        grid-column: 1 / -1;
    }

    .chart-large,
    .chart-medium {
        grid-column: 1 / -1;
    }

    .dashboard-grid {
        gap: 12px;
        padding: 16px;
    }
}

@media (max-width: 992px) {
    .dashboard-container.sidebar-open {
        grid-template-columns: 240px 1fr;
    }

    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .kpi-card {
        padding: 16px;
    }

    .kpi-icon {
        font-size: 2rem;
    }

    .kpi-value {
        font-size: 1.6rem;
    }

    .dashboard-title h1 {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .dashboard-container.sidebar-open {
        grid-template-columns: 200px 1fr;
    }

    .dashboard-header {
        padding: 0 16px;
    }

    .dashboard-title h1 {
        font-size: 0.9rem;
        letter-spacing: 0.5px;
    }

    .toggle-sidebar-btn {
        padding: 8px 12px;
        font-size: 1rem;
    }

    .kpi-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .kpi-card {
        padding: 14px;
    }

    .kpi-icon {
        font-size: 1.8rem;
    }

    .kpi-value {
        font-size: 1.4rem;
    }

    .kpi-label {
        font-size: 0.7rem;
    }

    .chart-card {
        padding: 16px;
    }

    .chart-header h3 {
        font-size: 0.9rem;
    }

    .chart-subtitle {
        font-size: 0.75rem;
    }

    .dashboard-grid {
        gap: 10px;
        padding: 12px;
    }

    .chart-large,
    .chart-medium {
        min-height: 320px;
    }

    .chart-full {
        min-height: 350px;
    }
}

@media (max-width: 576px) {
    .dashboard-container.sidebar-open {
        grid-template-columns: 1fr;
        grid-template-rows: 65px auto 1fr;
    }

    .filter-sidebar {
        grid-column: 1;
        grid-row: 2;
        border-right: none;
        border-bottom: 2px solid var(--border-color);
        max-height: 300px;
    }

    .sidebar-content {
        padding: 16px;
    }

    .dashboard-grid {
        grid-row: 3;
    }

    .kpi-icon {
        font-size: 1.6rem;
    }

    .kpi-value {
        font-size: 1.3rem;
    }
}