/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-w: 240px;
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #2563eb;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    line-height: 1.5;
    font-size: 14px;
}

/* === Sidebar === */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}
.sidebar-header small {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-links {
    list-style: none;
    padding: 12px 8px;
    flex: 1;
}
.nav-links li { margin: 2px 0; }
.nav-links a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all .15s ease;
}
.nav-links a:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}
.nav-links li.active a {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}
.nav-icon {
    font-size: 10px;
    width: 20px;
    text-align: center;
}

/* === Content === */
.content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
}

.content-header {
    padding: 24px 32px 0;
}
.content-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.content-body {
    padding: 20px 32px 40px;
}

/* === KPI Cards === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.kpi-card .kpi-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}
.kpi-card .kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.kpi-card .kpi-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* === Chart Cards === */
.chart-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}
.chart-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.chart-container {
    position: relative;
    width: 100%;
}
.chart-container.chart-lg { height: 400px; }
.chart-container.chart-md { height: 320px; }
.chart-container.chart-sm { height: 260px; }

/* === Grids === */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}
.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

/* === Tables === */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 2px solid var(--border);
    background: #f8fafc;
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }

.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .rank {
    width: 40px;
    text-align: center;
    font-weight: 700;
    color: var(--text-muted);
}

/* === Badges === */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1d4ed8; }

/* === Progress Bar === */
.progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar .fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width .3s ease;
}

/* === Variation indicator === */
.variation {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 600;
}
.variation.up { color: var(--success); }
.variation.down { color: var(--danger); }

/* === YoY Table === */
.yoy-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.yoy-table th, .yoy-table td {
    padding: 8px 10px;
    text-align: center;
    border: 1px solid var(--border);
}
.yoy-table th {
    background: var(--sidebar-bg);
    color: #fff;
    font-weight: 600;
    font-size: 12px;
}
.yoy-table td {
    font-variant-numeric: tabular-nums;
}
.yoy-table .year-label {
    background: #f8fafc;
    font-weight: 700;
    text-align: left;
    padding-left: 12px;
}
.yoy-table .highlight { background: #eff6ff; font-weight: 600; }
.yoy-table .low-cell { background: #fef2f2; }

/* === Responsive === */
@media (max-width: 1200px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
    .sidebar { display: none; }
    .content { margin-left: 0; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .content-header { padding: 16px 16px 0; }
    .content-body { padding: 12px 16px 24px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
