.stats-page {
    padding: 20px 16px 10px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ── Bouton retour (base mobile) ── */
.stats-back-btn {
    background: rgba(68, 85, 102, 0.2);
    border: 1px solid rgba(68, 85, 102, 0.3);
    color: var(--text-primary);
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    margin-bottom: 16px;
}
.stats-back-btn:hover { background: rgba(68, 85, 102, 0.3); }

/* wrapper valeur+label dans les KPI cards (mobile : ignoré, pc : flex column) */
.stat-overview-text { display: contents; }

.stats-page-header {
    text-align: center;
    margin-bottom: 32px;
}



.stats-page-header h1 {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stats-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.stats-overview-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.stat-overview-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(68, 85, 102, 0.2);
    text-align: center;
    transition: all 0.3s ease;
}

.stat-overview-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    border-color: var(--primary);
}

.stat-overview-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.stat-overview-value {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), #00c9ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
    line-height: 1.2;
}

.stat-overview-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 32px;
}

.stats-chart-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(68, 85, 102, 0.2);
    position: relative;
    overflow: hidden;
}

.stats-chart-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats-chart-card canvas {
    max-width: 100% !important;
    height: auto !important;
    max-height: 300px !important;
}

@media (min-width: 768px) {
    .stats-page { padding: 40px 24px 10px; }
    .stats-page-header h1 { font-size: 40px; }
    .stats-subtitle { font-size: 16px; }
    .stats-overview-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
    .stats-charts-grid { grid-template-columns: repeat(2, 1fr); gap: 24px; }
    .stats-chart-card canvas { max-height: 350px !important; }
}

/* ── PC Layout ≥ 1024px ─────────────────────────── */
@media (min-width: 768px) {

    /* ── Page wrapper ── */
    .stats-page {
        padding: 48px 56px 80px;
        display: flex;
        flex-direction: column;
        gap: 32px;
    }

    /* ── Header : bouton + titre côte à côte ── */
    .stats-page-header {
        display: flex;
        align-items: center;
        gap: 24px;
        text-align: left;
        margin-bottom: 0;
        padding-bottom: 28px;
        border-bottom: 1px solid rgba(68, 85, 102, 0.15);
    }

    .stats-back-btn {
        flex-shrink: 0;
        background: rgba(68, 85, 102, 0.15);
        border: 1px solid rgba(68, 85, 102, 0.3);
        color: var(--text-primary);
        padding: 10px 18px;
        border-radius: 10px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;
        transition: all 0.2s ease;
        white-space: nowrap;
    }
    .stats-back-btn:hover {
        background: rgba(68, 85, 102, 0.28);
        transform: translateX(-3px);
    }

    .stats-header-text { flex: 1; }
    .stats-page-header h1 { font-size: 40px; margin-bottom: 4px; }
    .stats-subtitle { font-size: 15px; }

    /* ── KPI Cards : 3 colonnes × 2 lignes ── */
    .stats-overview-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        margin-bottom: 0;
        position: static; /* annule le sticky précédent */
        max-height: none;
        overflow: visible;
    }

    .stat-overview-card {
        padding: 20px 22px;
        text-align: left;
        display: flex;
        align-items: center;
        gap: 16px;
        border-radius: 16px;
    }

    .stat-overview-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    }

    .stat-overview-icon {
        font-size: 30px;
        margin-bottom: 0;
        flex-shrink: 0;
        width: 52px;
        height: 52px;
        background: rgba(255, 255, 255, 0.06);
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* wrapper valeur + label */
    .stat-overview-text { display: flex; flex-direction: column; }
    .stat-overview-value { font-size: 28px; margin-bottom: 2px; }
    .stat-overview-label { font-size: 11px; }

    /* ── Charts : grille 2 colonnes ── */
    .stats-charts-grid {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        margin-bottom: 0;
        align-content: start;
        align-self: auto;
    }

    /* Activité mensuelle → pleine largeur (en haut) */
    .stats-chart-monthly {
        grid-column: 1 / -1;
    }
    .stats-chart-monthly canvas { max-height: 160px !important; }

    /* Films par décennie → pleine largeur (en bas) */
    .stats-chart-decades {
        grid-column: 1 / -1;
    }
    .stats-chart-decades canvas { max-height: 160px !important; }

    /* Genres + Notes → côte à côte */
    .stats-chart-card { padding: 24px; border-radius: 18px; }
    .stats-chart-title { font-size: 15px; margin-bottom: 16px; }
    .stats-chart-card canvas { max-height: 300px !important; }
}

@media (max-width: 480px) {
    .stats-page { padding: 16px 12px 10px; }
    .stats-page-header h1 { font-size: 26px; }
    .stats-subtitle { font-size: 13px; }
    .stats-overview-grid { gap: 10px; }
    .stat-overview-card { padding: 16px 12px; }
    .stat-overview-icon { font-size: 28px; margin-bottom: 8px; }
    .stat-overview-value { font-size: 26px; }
    .stat-overview-label { font-size: 10px; }
    .stats-charts-grid { gap: 16px; }
    .stats-chart-card { padding: 16px; }
    .stats-chart-title { font-size: 16px; }
    .stats-chart-card canvas { max-height: 250px !important; }
}

@media (max-width: 360px) {
    .stats-page { padding: 12px 8px 5px; }
    .stats-page-header h1 { font-size: 22px; }
    .stats-overview-grid { gap: 8px; }
    .stat-overview-card { padding: 12px 8px; }
    .stat-overview-icon { font-size: 24px; }
    .stat-overview-value { font-size: 22px; }
    .stats-chart-card { padding: 12px; }
    .stats-chart-title { font-size: 14px; }
    .stats-chart-card canvas { max-height: 220px !important; }
}

.stats-loading {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.stats-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 24px;
    animation: spin 1s linear infinite;
}

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

.stats-loading-text { font-size: 16px; font-weight: 600; }

.stats-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.stats-empty-icon { font-size: 72px; margin-bottom: 24px; opacity: 0.5; }
.stats-empty-title { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 12px; }
.stats-empty-text { font-size: 16px; margin-bottom: 24px; }

.stats-error { text-align: center; padding: 80px 20px; }
.stats-error-icon { font-size: 72px; margin-bottom: 24px; }
.stats-error-title { font-size: 24px; font-weight: 700; color: #ef4444; margin-bottom: 12px; }
.stats-error-text { font-size: 16px; color: var(--text-secondary); margin-bottom: 24px; }