/* ═══════════════════════════════════════════════════════════════
   AceModel Dashboard — Dark Tech Theme
   Premium CSS with glassmorphism, gradients, and micro-animations
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a1f2e;
    --bg-card-hover: #222838;
    --bg-glass: rgba(26, 31, 46, 0.7);
    --border: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(16, 185, 129, 0.3);
    --text-primary: #f0f4f8;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #10b981;
    --accent-light: #34d399;
    --accent-glow: rgba(16, 185, 129, 0.15);
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --purple: #8b5cf6;
    --sidebar-width: 240px;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    /* La marque et le pied ne se compriment pas quand la liste déborde: c'est
       la liste qui défile, eux restent lisibles en haut et en bas. */
    flex-shrink: 0;
}

.brand-icon { font-size: 28px; }
.brand-text { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.brand-version {
    font-size: 10px;
    font-weight: 700;
    background: var(--accent);
    color: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: auto;
}

/* La liste des sections défile toute seule quand elle dépasse la hauteur de
   l'écran. `min-height: 0` est la pièce indispensable: dans un conteneur flex
   en colonne, un enfant en `flex: 1` garde `min-height: auto`, donc il refuse
   de descendre sous la hauteur de son contenu — il débordait par le bas de la
   barre, qui est en `position: fixed`, et le septième bookmaker devenait
   inatteignable sur un écran de portable. Vaut pour le panneau glissant du
   mobile, qui est la même barre translatée. */
.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    /* Arrivé en bout de liste, la molette ne se propage pas à la page. */
    overscroll-behavior: contain;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid var(--border-accent);
}

.nav-icon { font-size: 18px; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}
.status-dot.online {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    /* Pas de padding en haut: la barre collante fournit cet espace, et un
       padding la ferait chevaucher le titre de section. */
    padding: 0 40px 32px;
    min-height: 100vh;
}

.section { display: none; animation: fadeIn 0.3s ease; }
.section.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
}

.section-header h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.header-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid var(--border-accent);
}

/* ── KPI Cards ───────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.kpi-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.kpi-card.accent {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.02));
    border-color: var(--border-accent);
}

.kpi-icon { font-size: 32px; }
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.kpi-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── MAE Breakdown ───────────────────────────────────────────── */
.mae-breakdown-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.mae-breakdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.mae-breakdown-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 0;
}

.mae-target-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.25);
}

.mae-breakdown-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.mae-tour-block {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.mae-tour-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.mae-tour-block.atp::before {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.mae-tour-block.wta::before {
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}

.mae-tour-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.mae-tour-badge {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.mae-tour-block.atp .mae-tour-badge { color: #60a5fa; }
.mae-tour-block.wta .mae-tour-badge { color: #a78bfa; }

.mae-tour-overall {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
}

.mae-tour-overall strong {
    color: var(--accent);
    font-size: 14px;
}

.mae-tour-overall-row {
    font-size: 12px;
    color: var(--text-muted);
    margin: 2px 0 10px;
}
.mae-tour-overall-row strong {
    color: var(--accent);
    font-size: 15px;
}

/* second row of tabs (view selector) sits tighter under the period tabs */
.mae-view-tabs { margin-top: 0; }

.mae-surface-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.mae-surface-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 12px;
    text-align: center;
    transition: var(--transition);
}

.mae-surface-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-1px);
}

.mae-surface-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    vertical-align: middle;
}

.mae-surface-dot.hard { background: #3b82f6; }
.mae-surface-dot.clay { background: #f59e0b; }
.mae-surface-dot.grass { background: #10b981; }

.mae-surface-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.mae-surface-value {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.mae-surface-value.good { color: var(--accent); }
.mae-surface-value.ok { color: var(--warning); }
.mae-surface-value.bad { color: var(--danger); }

/* Surface × sets matrix — compact, bold, mobile-safe (no horizontal scroll) */
.mae-matrix {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin-top: 8px;
}
.mae-matrix-h {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 2px 8px;
    text-align: center;
    white-space: nowrap;
}
.mae-matrix-h0 { text-align: left; width: 34%; }
.mae-matrix-surf {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    padding: 7px 4px;
    text-align: left;
    border-top: 1px solid var(--border);
}
.mae-matrix-v {
    font-size: 15px;
    font-weight: 800;
    text-align: center;
    padding: 7px 2px;
    letter-spacing: -0.4px;
    font-variant-numeric: tabular-nums;
    border-top: 1px solid var(--border);
}
.mae-matrix-v.good { color: var(--accent); }
.mae-matrix-v.ok { color: var(--warning); }
.mae-matrix-v.bad { color: var(--danger); }
.mae-matrix-v.na { color: var(--text-muted); opacity: 0.45; font-weight: 600; }
.mae-matrix-cap { font-size: 10px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.3px; }

.mae-surface-label {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

.mae-holdout-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    background: rgba(16,185,129,0.12);
    border: 1px solid rgba(16,185,129,0.3);
}

.mae-period-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    padding: 3px;
    width: fit-content;
}

.mae-period-tab {
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: transparent;
    transition: var(--transition);
    font-family: inherit;
}

.mae-period-tab.active {
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid var(--border-accent);
}

.mae-period-tab:hover:not(.active) {
    color: var(--text-primary);
}

/* ── Charts ──────────────────────────────────────────────────── */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

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

.chart-container { min-height: 240px; }

/* Feature bars */
.feat-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.feat-bar-label {
    width: 200px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feat-bar-track {
    flex: 1;
    height: 20px;
    background: rgba(255,255,255,0.04);
    border-radius: 4px;
    overflow: hidden;
}

.feat-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    transition: width 1s ease;
}

.feat-bar-val {
    width: 50px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Surface donut (simple) */
.surface-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.surface-item:last-child { border-bottom: none; }

.surface-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
}

.surface-dot.hard { background: #3b82f6; }
.surface-dot.clay { background: #f59e0b; }
.surface-dot.grass { background: #10b981; }

.surface-name { font-size: 14px; font-weight: 600; flex: 1; }
.surface-count { font-size: 13px; color: var(--text-muted); }
.surface-avg { font-size: 13px; font-weight: 700; color: var(--accent); }

/* ── Tables ──────────────────────────────────────────────────── */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    overflow-x: auto;
}

.table-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.data-table tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.data-table tbody tr:hover { background: var(--bg-card-hover); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-best {
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid var(--border-accent);
}

/* ── Prediction Section ──────────────────────────────────────── */
.predict-container { max-width: 900px; }

.predict-form {
    padding: 32px;
    margin-bottom: 32px;
}

.card-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.form-group {
    margin-bottom: 20px;
    flex: 1;
}

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

.form-group input, .form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-row {
    display: flex;
    gap: 16px;
    align-items: end;
}

.vs-divider {
    font-size: 20px;
    font-weight: 900;
    color: var(--accent);
    padding-bottom: 28px;
    flex-shrink: 0;
}

.btn-predict {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent), #059669);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-predict:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
}

.btn-predict:active { transform: translateY(0); }

/* Prediction Results */
.prediction-results { animation: fadeIn 0.4s ease; }
.hidden { display: none !important; }

.pred-header {
    text-align: center;
    margin-bottom: 24px;
}

.pred-header h2 { font-size: 22px; font-weight: 800; }
.pred-meta { margin-top: 8px; display: flex; gap: 8px; justify-content: center; }
.pred-meta .badge {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.pred-cards {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

.pred-player-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    transition: var(--transition);
}

.pred-player-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
}

.pred-player-name { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.pred-aces {
    font-size: 48px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -2px;
}
.pred-ci { font-size: 13px; color: var(--text-muted); margin-top: 8px; }

.pred-total-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0.04));
    border: 1px solid var(--border-accent);
    border-radius: var(--radius);
    padding: 28px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 120px;
}

.pred-total-label { font-size: 11px; font-weight: 700; color: var(--accent); letter-spacing: 1px; }
.pred-total-value { font-size: 42px; font-weight: 900; color: var(--accent); letter-spacing: -2px; }

.ou-table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.ou-table-container h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.over-highlight { color: var(--accent); font-weight: 700; }
.under-highlight { color: var(--danger); font-weight: 700; }

/* ── Players Section ─────────────────────────────────────────── */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.search-bar input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.search-bar input:focus { border-color: var(--accent); }

.search-bar select {
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

/* ── Model Info ──────────────────────────────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.info-card { padding: 28px; }
.info-card.full-width { grid-column: 1 / -1; }
.info-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.info-item span:first-child { color: var(--text-muted); }
.info-item span:last-child { font-weight: 600; }

.weights-bar {
    display: flex;
    height: 32px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    gap: 2px;
}

.weight-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    transition: var(--transition);
    position: relative;
}

.weight-segment:hover { filter: brightness(1.2); }

.weight-segment .weight-tooltip {
    position: absolute;
    bottom: 110%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
}

.weight-segment:hover .weight-tooltip { opacity: 1; }

/* Loading */
.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
}

.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

/* ── Mobile Nav Toggle ───────────────────────────────────────── */
.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px;
    transition: var(--transition);
}

.mobile-nav-toggle:hover {
    border-color: var(--accent);
    background: var(--bg-card);
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

.mobile-nav-toggle.open .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.mobile-nav-toggle.open .hamburger-line:nth-child(2) {
    opacity: 0;
}
.mobile-nav-toggle.open .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* ── Responsive: Tablet ─────────────────────────────────────── */
@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-row { grid-template-columns: 1fr; }
    .pred-cards { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
    .mae-breakdown-grid { grid-template-columns: 1fr; }
    .main-content { padding: 0 24px 24px; }
    .top-bar { padding: 14px 24px; margin: 0 -24px 20px; }
}

/* ── Responsive: Mobile ─────────────────────────────────────── */
@media (max-width: 768px) {
    /* Sidebar becomes slide-in overlay */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 150;
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
    }

    /* Show hamburger */
    .mobile-nav-toggle {
        display: flex;
    }

    /* Main content: no sidebar margin */
    .main-content {
        margin-left: 0;
        padding: 0 16px 16px;
        min-height: 100vh;
    }

    /* Section header */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 20px;
    }

    .section-header h1 {
        font-size: 22px;
    }

    /* KPI cards: 2 columns on mobile */
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 20px;
    }

    .kpi-card {
        padding: 16px;
        gap: 10px;
    }

    .kpi-icon { font-size: 24px; }
    .kpi-value { font-size: 20px; }
    .kpi-label { font-size: 11px; }

    /* MAE Breakdown */
    .mae-breakdown-section { padding: 16px; }

    .mae-breakdown-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .mae-surface-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .mae-surface-card { padding: 10px 8px; }
    .mae-surface-value { font-size: 18px; }
    .mae-surface-name { font-size: 10px; }

    .mae-matrix-v { font-size: 14px; padding: 7px 1px; }
    .mae-matrix-surf { font-size: 12px; padding: 7px 2px; }
    .mae-matrix-h { font-size: 10px; }

    .mae-period-tabs { width: 100%; justify-content: center; }

    /* Charts */
    .charts-row {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-bottom: 16px;
    }

    .chart-card { padding: 16px; }

    .feat-bar-label { width: 120px; font-size: 10px; }
    .feat-bar-val { width: 40px; font-size: 10px; }

    /* Tables */
    .table-card {
        padding: 12px;
        margin-bottom: 16px;
    }

    .data-table { font-size: 11px; }
    .data-table thead th { padding: 8px 10px; font-size: 10px; }
    .data-table tbody td { padding: 8px 10px; }

    /* Prediction */
    .predict-container { max-width: 100%; }

    .predict-form { padding: 20px; margin-bottom: 20px; }

    .form-row {
        flex-direction: column;
        align-items: stretch;   /* sinon les champs restent à demi-largeur */
        gap: 0;
    }

    .form-row .form-group { width: 100%; }

    .vs-divider {
        padding: 8px 0;
        text-align: center;
        font-size: 16px;
    }

    .pred-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .pred-player-card { padding: 20px; }
    .pred-aces { font-size: 36px; }
    .pred-total-card { padding: 20px; }
    .pred-total-value { font-size: 32px; }

    .ou-table-container { padding: 12px; }

    /* Players */
    .search-bar {
        flex-direction: column;
        gap: 8px;
    }

    /* Telegram */
    .info-grid { gap: 12px; }
    .info-card { padding: 20px; }

    /* Model info */
    .weights-bar { height: 24px; }
    .weight-segment { font-size: 9px; }
}

/* ── Responsive: Small Mobile ───────────────────────────────── */
@media (max-width: 480px) {
    .main-content {
        padding: 0 12px 12px;
    }

    .top-bar { margin: 0 -12px 14px; padding: 12px 12px 12px 68px; }

    .section-header h1 { font-size: 20px; }

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

    .kpi-card {
        padding: 12px;
        gap: 8px;
        flex-direction: column;
        text-align: center;
    }

    .kpi-icon { font-size: 20px; }
    .kpi-value { font-size: 18px; }

    .mae-breakdown-grid { grid-template-columns: 1fr; }

    .mae-tour-block { padding: 14px; }

    /* Smallest screens: drop the "sets" word (keep the number), shrink to fit */
    .mae-matrix-sw { display: none; }
    .mae-matrix-v { font-size: 13px; padding: 6px 0; }
    .mae-matrix-surf { font-size: 11px; padding: 6px 2px; }
    .mae-matrix-h { font-size: 10px; padding: 2px 0 6px; }
    .mae-matrix-h0 { width: 30%; }
    .mae-surface-dot { margin-right: 3px; }

    .mae-tour-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .mae-surface-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    .mae-surface-value { font-size: 16px; }
    .mae-surface-card { padding: 8px 4px; }

    /* Feature labels even shorter */
    .feat-bar-label { width: 80px; font-size: 9px; }
    .feat-bar-track { height: 16px; }

    .pred-aces { font-size: 32px; }
    .pred-total-value { font-size: 28px; }

    .btn-predict {
        padding: 14px;
        font-size: 14px;
    }

}

/* ── Touch & Interaction Improvements ────────────────────────── */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .nav-item { padding: 14px 16px; }
    .btn-predict { min-height: 52px; }
    .form-group input, .form-group select { padding: 14px 16px; min-height: 48px; }
    .mae-period-tab { padding: 8px 16px; }

    /* Disable hover effects on touch */
    .kpi-card:hover,
    .pred-player-card:hover,
    .mae-surface-card:hover {
        transform: none;
        box-shadow: none;
    }
}


/* ═══════════════════════════════════════════════════════════════
   Mise en page: barre collante, groupes de navigation, tables
   ═══════════════════════════════════════════════════════════════ */

/* ── Barre supérieure collante ───────────────────────────────── */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 40px;
    margin: 0 -40px 24px;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.top-bar-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
}

.lang-toggle {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 4px;
    display: flex;
    gap: 4px;
}

.lang-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: 16px;
    padding: 5px 14px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.82rem;
    transition: var(--transition);
}

.lang-btn.active { background: var(--bg-card); color: var(--text-primary); }
.lang-btn:hover { color: var(--text-primary); }

/* ── Groupes de navigation ───────────────────────────────────── */
.nav-group-label {
    padding: 18px 20px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.sidebar-nav > .nav-group-label:first-child { padding-top: 8px; }

/* ── En-tête de carte: titre à gauche, précision à droite ────── */
.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.card-head h3 { margin: 0; }

.card-hint {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Vue d'ensemble des scans (dashboard) ────────────────────── */
.scan-overview { display: grid; gap: 10px; }

.scan-row {
    display: grid;
    grid-template-columns: 1.2fr repeat(4, minmax(0, 1fr)) auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.scan-row:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
    transform: translateX(2px);
}

.scan-cell-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.scan-cell-value { font-size: 14px; font-weight: 600; }
.scan-cell-value.accent { color: var(--accent); }
.scan-book { font-size: 15px; font-weight: 700; }
.scan-book small { display: block; font-size: 11px; font-weight: 500; color: var(--text-muted); }

.scan-state {
    justify-self: end;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 11px;
    border-radius: 999px;
    white-space: nowrap;
}

.scan-state.on { background: var(--accent-glow); color: var(--accent); }
.scan-state.off { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); }

/* ── Rien ne doit déborder horizontalement ───────────────────── */
.main-content { overflow-x: hidden; }
.table-card { overflow-x: auto; }

/* ── Tables: en cartes empilées sur mobile ───────────────────── */
/* Une table à sept colonnes sur un téléphone force la page entière à
   défiler de côté. Chaque ligne devient une carte, et l'intitulé de
   colonne passe devant la valeur (rempli par stampTableLabels). */
@media (max-width: 768px) {
    .data-table:not(.compact) thead { display: none; }

    .data-table:not(.compact),
    .data-table:not(.compact) tbody,
    .data-table:not(.compact) tr,
    .data-table:not(.compact) td {
        display: block;
        width: 100%;
    }

    /* Deux champs par ligne: empiler un par ligne triple la hauteur de page */
    .data-table:not(.compact) tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 14px;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--bg-secondary);
        padding: 12px 14px;
        margin-bottom: 10px;
    }

    .data-table:not(.compact) tr:hover { background: var(--bg-secondary); }

    .data-table:not(.compact) td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        padding: 0;
        border: none;
        text-align: left;
        min-width: 0;
        word-break: break-word;
    }

    .data-table:not(.compact) td::before {
        content: attr(data-label);
        font-size: 9px;
        font-weight: 700;
        letter-spacing: 0.07em;
        text-transform: uppercase;
        color: var(--text-muted);
    }

    /* La première colonne est l'identité de la ligne: en titre, pleine largeur */
    .data-table:not(.compact) td:first-child {
        grid-column: 1 / -1;
        padding: 0 0 9px;
        border-bottom: 1px solid var(--border);
    }

    .data-table:not(.compact) td:first-child::before { display: none; }
    .data-table:not(.compact) td[data-label=""]::before { display: none; }

    .scan-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px 14px;
    }

    .scan-row .scan-book { grid-column: 1 / -1; }
    .scan-state { justify-self: start; }

    .top-bar {
        margin: 0 -16px 16px;
        padding: 14px 16px 14px 72px;   /* 72px: la place du bouton de navigation */
        min-height: 64px;
    }
}

/* ── Bouton "voir tout" sous une liste tronquée ──────────────── */
.btn-more {
    display: none;
    width: 100%;
    margin-top: 12px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-more:hover {
    border-color: var(--border-accent);
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

/* La ligne du modèle réellement servi ressort dans la comparaison */
.row-served td { background: rgba(16, 185, 129, 0.05); }
