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

:root {
    --sidebar: #1a1d23;
    --sidebar-hover: #2a2d35;
    --bg: #f0f2f5;
    --card: #fff;
    --primary: #3b82f6;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
}

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

.app {
    display: flex;
    width: 100%;
}

/* ── Sidebar ── */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.1);
    border-radius: 4px;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-header h1 {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
}

.sidebar-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

.sidebar-nav {
    padding: 12px 0;
}

.nav-link {
    display: block;
    padding: 12px 20px;
    color: #9ca3af;
    text-decoration: none;
    font-size: 15px;
    transition: all .15s;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-link.active {
    color: #fff;
    background: rgba(59,130,246,.15);
    border-left-color: var(--primary);
}

/* ── Sous-onglets ── */
.sub-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--card);
    border-radius: 10px;
    padding: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.sub-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all .15s;
}

.sub-tab:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sub-tab.active {
    background: var(--primary);
    color: #fff;
}

.subtab-content.hidden {
    display: none;
}

/* ── Main ── */
.main-content {
    flex: 1;
    padding: 24px 32px;
    max-width: calc(100% - 260px);
    overflow-x: hidden;
    margin-left: 260px;
}

/* ── Filtres ── */
.filters-bar {
    display: flex;
    gap: 12px;
    align-items: end;
    background: var(--card);
    padding: 16px 20px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.filter-group input,
.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--card);
    min-width: 140px;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* ── Boutons ── */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--bg);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #16a34a;
}

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

.kpi-card {
    background: var(--card);
    border-radius: 10px;
    padding: 20px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.kpi-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-change {
    font-size: 13px;
    margin-top: 4px;
}

.kpi-change.positive { color: var(--success); }
.kpi-change.negative { color: var(--danger); }

/* ── Graphiques ── */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--card);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.chart-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

.chart-card.full {
    grid-column: 1 / -1;
}

.chart-card canvas {
    max-height: 340px;
}

/* ── Tableaux ── */
.table-card {
    background: var(--card);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    margin-bottom: 24px;
}

.table-card .table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.table-card h3 {
    font-size: 15px;
    font-weight: 600;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 12px;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
}

table.dataTable {
    border-collapse: collapse;
    width: 100%;
}

table.dataTable thead th {
    background: var(--bg);
    font-weight: 600;
    font-size: 13px;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

table.dataTable tbody td {
    padding: 8px 12px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

/* ── Loading ── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

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

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

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

/* ── Alertes ── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ── Utilitaires ── */
.hidden { display: none !important; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
