/* ═══════════════════════════════════════════
   TradeForge Terminal — Design System v2
   Dark professional trading dashboard
   ═══════════════════════════════════════════ */

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; overflow: hidden; }

/* ── Design Tokens ─────────────────────────── */
:root {
    --bg:        #060912;
    --surface:   #0b0f1a;
    --card:      #0f1420;
    --border:    #1a2235;
    --border-lt: #232d42;
    --text:      #e2e8f0;
    --text-2:    #94a3b8;
    --text-3:    #8899b0;
    --accent:    #3b82f6;
    --accent-glow: rgba(59,130,246,.15);
    --profit:    #10b981;
    --profit-bg: rgba(16,185,129,.10);
    --loss:      #ef4444;
    --loss-bg:   rgba(239,68,68,.10);
    --hold:      #f59e0b;
    --radius:    10px;
    --radius-sm: 6px;
    --sidebar-w: 230px;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
}

/* ── Layout ────────────────────────────────── */
body { display: flex; height: 100vh; }

#sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 1.25rem 0;
    z-index: 10;
}

#main {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 1.5rem 2rem 3rem;
    scroll-behavior: smooth; overscroll-behavior: contain;
}

/* ── Sidebar ───────────────────────────────── */
.sidebar-brand {
    display: flex; align-items: center; gap: .75rem;
    padding: 0 1.25rem 1.25rem; border-bottom: 1px solid var(--border);
    margin-bottom: .75rem;
}
.logo {
    width: 38px; height: 38px; border-radius: var(--radius-sm);
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .95rem; letter-spacing: -.02em;
    box-shadow: 0 0 20px var(--accent-glow);
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 1rem; color: var(--text); letter-spacing: -.01em; }
.brand-sub  { font-size: .7rem; color: var(--accent); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 .6rem; }

.nav-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .7rem; border-radius: var(--radius-sm);
    color: var(--text-2); font-size: .82rem; font-weight: 500;
    cursor: pointer; text-decoration: none; transition: all .15s;
    position: relative;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.03); }
.nav-item.active { color: var(--text); background: rgba(255,255,255,.06); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: -4px; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; background: var(--accent); border-radius: 2px; }
.nav-item svg { opacity: .55; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; color: var(--accent); }
.nav-badge { margin-left: auto; font-size: .68rem; padding: 1px 7px; border-radius: 99px; background: var(--border); color: var(--text-2); font-family: var(--font-mono); }

.sidebar-footer {
    padding: .75rem 1.25rem 0; border-top: 1px solid var(--border);
    margin-top: .5rem; font-size: .72rem; display: flex; flex-direction: column; gap: .35rem;
}
.status-row { display: flex; align-items: center; justify-content: space-between; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.status-dot.online { background: var(--profit); box-shadow: 0 0 6px var(--profit); }
.status-dot.error { background: var(--loss); }
.text-mono { font-family: var(--font-mono); font-size: .7rem; color: var(--text-3); }

/* ── Panels ────────────────────────────────── */
.panel { display: none; }
.panel.active { display: block; animation: fadeSlide .25s ease; }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem;
}
.panel-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
.panel-actions { display: flex; align-items: center; gap: .6rem; }

/* ── Cards ─────────────────────────────────── */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.15rem;
    transition: border-color .2s;
    min-width: 0;
}
.card:hover { border-color: var(--border-lt); }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: .85rem; gap: .5rem;
}
.card-header h3 { font-size: .8rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--text-2); }

/* ── KPIs ──────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: .75rem; margin-bottom: 1.25rem; }
.kpi {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem 1.15rem;
    display: flex; flex-direction: column; gap: .15rem;
    transition: border-color .2s;
}
.kpi:hover { border-color: var(--border-lt); }
.kpi-label { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.kpi-value { font-size: 1.4rem; font-weight: 800; color: var(--text); font-family: var(--font-mono); letter-spacing: -.02em; }
.kpi-sub { font-size: .68rem; color: var(--text-3); }

/* ── Tables ────────────────────────────────── */
.table-wrap { width: 100%; min-width: 0; overflow-x: auto; max-height: 380px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .75rem; }
th { text-align: left; padding: .45rem .6rem; font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card); z-index: 1; }
td { padding: .4rem .6rem; border-bottom: 1px solid rgba(26,34,53,.5); font-family: var(--font-mono); font-size: .72rem; white-space: nowrap; }
#trades-positions table { min-width: 920px; }
#trades-history table { min-width: 1120px; }
tr:hover td { background: rgba(255,255,255,.015); }

/* ── Table meta ─────────────────────────────── */
.table-info {
    padding: .35rem .6rem .5rem;
    font-size: .68rem;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
}
.table-info strong { color: var(--text); }
.data-table { width: 100%; border-collapse: collapse; font-size: .75rem; }
.data-table th, .data-table td {
    padding: .4rem .6rem;
    border-bottom: 1px solid rgba(26,34,53,.5);
}
.data-table th {
    font-size: .65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--text-3);
    position: sticky; top: 0; background: var(--card); z-index: 1;
}
.data-table td { font-size: .72rem; font-family: var(--font-mono); white-space: nowrap; }
.data-table tr:hover td { background: rgba(255,255,255,.015); }

/* ── Badges ────────────────────────────────── */
.phase-badge {
    font-size: .65rem; font-weight: 700; padding: 2px 10px; border-radius: 99px;
    background: rgba(59,130,246,.12); color: var(--accent); letter-spacing: .02em;
}
.status-badge {
    font-size: .65rem; font-weight: 700; padding: 3px 12px; border-radius: 99px;
    background: var(--profit-bg); color: var(--profit);
    display: flex; align-items: center; gap: 5px;
}
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--profit); }
.status-badge.error { background: var(--loss-bg); color: var(--loss); }
.status-badge.error::before { background: var(--loss); }
.status-badge.warn { background: rgba(245,158,11,.12); color: var(--hold); }
.status-badge.warn::before { background: var(--hold); }

/* ── Trade status badges ───────────────────── */
.badge {
    display: inline-block; font-size: .7rem; font-weight: 600;
    padding: 2px 7px; border-radius: var(--radius-sm);
    line-height: 1.4;
}
.badge-open { background: rgba(59,130,246,.12); color: var(--accent); border: 1px solid rgba(59,130,246,.25); }
.badge-closed { background: rgba(100,116,139,.10); color: var(--text-2); border: 1px solid var(--border); }

/* ── Select ────────────────────────────────── */
.select-mini {
    background: var(--card); color: var(--text); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: .35rem .6rem; font-size: .75rem;
    font-family: var(--font-mono); cursor: pointer; outline: none;
}
.select-mini:focus { border-color: var(--accent); }

/* ── Buttons ───────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .45rem .9rem; border-radius: var(--radius-sm);
    font-size: .75rem; font-weight: 600; border: 1px solid var(--border);
    background: var(--card); color: var(--text-2); cursor: pointer;
    transition: all .15s;
}
.btn:hover { border-color: var(--border-lt); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { box-shadow: 0 0 16px var(--accent-glow); }
.btn-outline { background: transparent; border-color: var(--border-lt); color: var(--text-2); }
.btn-outline:hover { border-color: var(--accent); color: var(--text); }
.btn-sm { padding: .3rem .6rem; font-size: .7rem; }

/* ── Chart Container ───────────────────────── */
.chart-container { height: 320px; position: relative; overflow: hidden; }
.chart-container canvas { width: 100% !important; }

/* ── Sell Quality ──────────────────────────── */
.sell-quality { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.sq-item { display: flex; flex-direction: column; gap: .15rem; padding: .7rem; background: rgba(255,255,255,.02); border-radius: var(--radius-sm); border: 1px solid rgba(26,34,53,.4); }
.sq-label { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.sq-value { font-size: 1.1rem; font-weight: 800; font-family: var(--font-mono); }

/* ── Models Grid ───────────────────────────── */
.models-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .75rem; }
.model-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem 1.15rem;
    display: flex; flex-direction: column; gap: .6rem;
    transition: border-color .2s; animation: fadeSlide .35s ease both;
}
.model-card:hover { border-color: var(--border-lt); }
.model-card-quarantined { border-color: var(--loss) !important; background: rgba(239,68,68,.06); }
.model-card-quarantined:hover { border-color: var(--loss) !important; }
.model-card-header { display: flex; align-items: center; justify-content: space-between; }
.model-name { font-weight: 700; font-size: .85rem; }
.model-pair { font-size: .65rem; color: var(--text-3); font-family: var(--font-mono); }
.model-weight { font-family: var(--font-mono); font-size: .8rem; font-weight: 700; color: var(--accent); }
.model-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; font-size: .68rem; }
.model-stat { display: flex; justify-content: space-between; color: var(--text-2); }
.model-stat span:last-child { font-family: var(--font-mono); color: var(--text); }

/* ── Factual learning summary bar ────────────── */
.factual-summary {
    margin-bottom: 1rem;
    padding: .6rem 1rem;
    background: var(--surface);
    border-radius: var(--radius-sm);
    font-size: .75rem;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
    border: 1px solid var(--border);
}

/* ── Ensemble Weights Bar Chart ──────────────── */
.ensemble-weights-section {
    margin-bottom: 1rem;
    padding: .75rem 1rem;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.ensemble-weights-title {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-3);
    margin-bottom: .5rem;
}
.weight-bar-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .3rem;
    font-size: .68rem;
}
.weight-bar-label {
    min-width: 80px;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text);
    text-transform: capitalize;
}
.weight-bar-track {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,.06);
    border-radius: 4px;
    overflow: hidden;
}
.weight-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .4s ease;
}
.weight-bar-value {
    min-width: 48px;
    text-align: right;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent);
}

/* ── Indicator Grid ────────────────────────── */
.indicator-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.indicator-item {
    padding: .55rem .7rem; background: rgba(255,255,255,.02);
    border-radius: var(--radius-sm); border: 1px solid rgba(26,34,53,.3);
    display: flex; flex-direction: column; gap: .1rem;
}
.ind-label { font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.ind-value { font-size: .8rem; font-weight: 700; font-family: var(--font-mono); }

/* ── Colors ────────────────────────────────── */
.text-buy { color: var(--profit); font-weight: 700; }
.text-sell { color: var(--loss); font-weight: 700; }
.text-hold { color: var(--hold); font-weight: 700; }
.text-muted { color: var(--text-3); }
.text-sm { font-size: .72rem; }
.text-accent { color: var(--accent); }
.text-warn { color: var(--hold); font-weight: 700; }

.bg-buy { background: var(--profit-bg); }
.bg-sell { background: var(--loss-bg); }

/* ── Markets Grid ──────────────────────────── */
.markets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .6rem;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    padding-right: 4px;
}
.market-tile {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .6rem .8rem;
    display: flex;
    flex-direction: column;
    gap: .45rem;
    transition: border-color .2s;
    animation: fadeSlide .25s ease both;
}
.market-tile:hover { border-color: var(--border-lt); }
.market-tile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .4rem;
}
.market-symbol {
    font-weight: 700;
    font-size: .78rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}
.market-exchange {
    font-size: .6rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .03em;
}
.market-last {
    font-family: var(--font-mono);
    font-size: .72rem;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}
.market-tile-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .2rem .6rem;
    font-size: .65rem;
}
.market-stat {
    display: flex;
    justify-content: space-between;
    color: var(--text-2);
}
.market-stat span:first-child {
    color: var(--text-3);
}
.market-stat span:last-child {
    font-family: var(--font-mono);
    color: var(--text);
}

/* ── Market search / filter ────────────────── */
.markets-search {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .75rem;
    flex-wrap: wrap;
}
.search-input {
    flex: 1;
    min-width: 180px;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .4rem .7rem;
    font-size: .75rem;
    font-family: var(--font-mono);
    outline: none;
    transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-3); }
.markets-show-more {
    text-align: center;
    padding: .6rem 0 .2rem;
}

/* ── Markets table ─────────────────────────── */
.markets-table-wrap {
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.markets-table-wrap th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card);
}
.stale-row {
    opacity: 0.6;
}
.stale-row:hover {
    opacity: 0.85;
}
.stale-badge {
    color: var(--hold);
    font-size: .65rem;
    cursor: help;
}

/* ── Diagnostic: services status grid ───────── */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .5rem;
}
.service-status {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .7rem;
    background: rgba(255,255,255,.02);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(26,34,53,.3);
    font-size: .72rem;
}
.service-status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--text-3);
}
.service-status-dot.running { background: var(--profit); box-shadow: 0 0 6px var(--profit); }
.service-status-dot.stopped { background: var(--loss); }
.service-status-dot.degraded { background: var(--hold); }
.service-status-name { font-weight: 600; color: var(--text); }
.service-status-info { margin-left: auto; font-size: .65rem; color: var(--text-3); font-family: var(--font-mono); }
/* ── Utilities ─────────────────────────────── */
.grid-2col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; margin-bottom: .75rem; }
.trades-grid { grid-template-columns: minmax(0, 1fr); }
.mt-4 { margin-top: 1rem; }
.empty-state { padding: 2rem; text-align: center; color: var(--text-3); font-size: .8rem; }

/* ── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-lt); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Responsive ────────────────────────────── */
/* Mobile hamburger + overlay — hidden on desktop */
#hamburger {
    display: none; position: fixed; top: 12px; left: 12px; z-index: 100;
    width: 38px; height: 38px; border-radius: var(--radius-sm);
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text-2); cursor: pointer; align-items: center; justify-content: center;
}
#hamburger svg { pointer-events: none; }
#overlay {
    position: fixed; inset: 0; z-index: 49;
    background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .25s ease, visibility .25s ease;
}
#overlay.show { opacity: 1; visibility: visible; pointer-events: auto; }

/* ── ≥1200px: Desktop (default, no media query) ── */
/* Sidebar visible, KPIs 6-col, grilles 2-3 colonnes → tout est dans les règles de base */

/* ── 900–1199px: Tablette (sidebar réduite) ── */
@media (max-width: 1199px) {
    :root { --sidebar-w: 190px; }
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
    .grid-2col { grid-template-columns: 1fr; }
    .models-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
    .indicator-grid { grid-template-columns: repeat(2, 1fr); }
    .panel-title { font-size: 1.2rem; }
    #main { padding: 1.25rem 1.25rem 2.5rem; }
    .markets-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); max-height: none; }
    .services-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
    .search-input { min-width: 150px; }
}

/* ── 768–899px: Petit écran (sidebar overlay + hamburger) ── */
@media (max-width: 899px) {
    #hamburger { display: flex; }
    #sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
        width: 260px; min-width: 260px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,.5);
        overflow-y: auto; overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }
    #sidebar.open { transform: translateX(0); }
    #main { padding: 3.8rem 1rem 2rem; margin-top: 0; }
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
    .markets-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .chart-container { height: 260px; }
    .sell-quality { grid-template-columns: 1fr 1fr; }
    .indicator-grid { grid-template-columns: repeat(2, 1fr); }
    .panel-header { margin-bottom: .85rem; }
    .panel-title { font-size: 1.1rem; }
    .card { padding: .9rem; min-width: 0; }
}

/* ── ≤767px: Mobile (KPIs 2-col, layouts empilés, polices agrandies) ── */
@media (max-width: 767px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
    .kpi { padding: .75rem .85rem; }
    .kpi-value { font-size: 1.2rem; }
    .kpi-label { font-size: .7rem; }
    .kpi-sub { font-size: .72rem; }
    .indicator-grid { grid-template-columns: repeat(2, 1fr); }
    .ind-label { font-size: .65rem; }
    .chart-container { height: 220px; }
    .sell-quality { grid-template-columns: 1fr; }
    .panel-title { font-size: 1.05rem; }
    #main { padding: 3.8rem .85rem 2rem; }
    .card { padding: .85rem; }
    .btn { padding: .38rem .7rem; font-size: .72rem; }
    .phase-badge, .status-badge { font-size: .68rem; padding: 2px 8px; }
    .market-tile { padding: .5rem .6rem; }
    .market-symbol { max-width: 110px; font-size: .74rem; }
    .market-exchange { font-size: .65rem; }
    .market-tile-stats { grid-template-columns: 1fr 1fr; gap: .15rem .4rem; font-size: .68rem; }
    .market-last { font-size: .74rem; }
    .markets-search { gap: .35rem; }
    .search-input { min-width: 130px; font-size: .72rem; padding: .38rem .55rem; }
    .models-grid { grid-template-columns: 1fr; }
    .model-stats { font-size: .7rem; }
    .services-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .service-status { font-size: .74rem; }
    .sq-label { font-size: .68rem; }
    .sq-value { font-size: 1.15rem; }
    .factual-summary { font-size: .76rem; gap: 1rem; }
    /* Tables : scroll horizontal, polices lisibles */
    .table-wrap { max-height: 320px; }
    th { font-size: .7rem; padding: .38rem .45rem; }
    td { font-size: .74rem; padding: .32rem .45rem; }
    table { font-size: .74rem; }
    .data-table th, .data-table td { padding: .32rem .45rem; }
    .data-table { font-size: .74rem; }
    .table-info { font-size: .7rem; }
}

/* ── ≤420px: Très petit mobile (tout empilé, 1 colonne) ── */
@media (max-width: 420px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi { padding: .8rem .9rem; }
    .kpi-value { font-size: 1.15rem; }
    .kpi-label { font-size: .72rem; }
    .kpi-sub { font-size: .74rem; }
    .indicator-grid { grid-template-columns: 1fr; }
    .ind-label { font-size: .68rem; }
    #main { padding: 3.8rem .6rem 2rem; }
    .chart-container { height: 180px; }
    .panel-title { font-size: 1rem; }
    .models-grid { grid-template-columns: 1fr; }
    .markets-grid { grid-template-columns: 1fr; max-height: none; }
    .model-stats { grid-template-columns: 1fr; font-size: .72rem; }
    .market-tile-stats { grid-template-columns: 1fr; font-size: .7rem; }
    .market-symbol { max-width: none; font-size: .76rem; }
    .market-exchange { font-size: .68rem; }
    .services-grid { grid-template-columns: 1fr; }
    .markets-search { flex-direction: column; align-items: stretch; }
    .search-input { min-width: 0; font-size: .74rem; }
    .table-wrap { max-height: 280px; }
    th { font-size: .72rem; padding: .35rem .4rem; }
    td { font-size: .76rem; padding: .32rem .4rem; }
    table { font-size: .76rem; }
    .data-table th, .data-table td { padding: .32rem .4rem; }
    .data-table { font-size: .76rem; }
    .table-info { font-size: .72rem; }
    .btn { padding: .4rem .75rem; font-size: .74rem; }
    .card { padding: .75rem; min-width: 0; }
    .phase-badge, .status-badge { font-size: .7rem; }
    .sq-label { font-size: .7rem; }
    .sq-value { font-size: 1.2rem; }
    .service-status { font-size: .76rem; }
    .factual-summary { flex-direction: column; gap: .35rem; font-size: .78rem; }
    .weight-bar-label { min-width: 65px; }
}
