:root {
    --primary: #2563eb;
    --primary-d: #1d4ed8;
    --primary-l: #dbeafe;
    --bg: #f1f5f9;
    --panel: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-mute: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
    --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--primary); text-decoration: none; }

/* ---------- Boot ---------- */
.boot {
    min-height: 100vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 16px; color: var(--text-mute);
}
.boot-spinner, .spinner {
    width: 34px; height: 34px; border: 3px solid var(--primary-l);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin .8s linear infinite;
}
.spinner.sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    height: 60px; background: var(--panel); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 24px; gap: 16px;
    position: sticky; top: 0; z-index: 500;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.topbar .brand .logo {
    width: 30px; height: 30px; border-radius: 8px; background: var(--primary);
    display: grid; place-items: center; color: #fff;
}
.topbar .brand small { font-weight: 500; color: var(--text-mute); font-size: 12px; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 13px; color: var(--text-mute); }
.topbar .btn-ghost {
    background: transparent; border: 1px solid var(--border); color: var(--text);
    padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 500;
}
.topbar .btn-ghost:hover { background: var(--bg); }

/* ---------- Sidebar layout ---------- */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; flex-shrink: 0; background: var(--panel);
    border-right: 1px solid var(--border);
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; padding: 18px 14px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; padding: 6px 8px 20px; }
.sidebar-brand .logo {
    width: 30px; height: 30px; border-radius: 8px; background: var(--primary);
    display: grid; place-items: center; color: #fff; flex-shrink: 0;
}
.sidebar-brand small { font-weight: 500; color: var(--text-mute); font-size: 12px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 12px;
    border: none; background: transparent; border-radius: 10px;
    font-size: 14px; font-weight: 600; color: var(--text-mute); text-align: left; width: 100%;
    transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-l); color: var(--primary-d); }
.nav-item svg { flex-shrink: 0; }
.sidebar-foot { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.sidebar-user { font-size: 12px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }

.sidebar-logout {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px;
    border: 1px solid transparent; background: transparent;
    color: var(--text-mute); font-size: 13.5px; font-weight: 600;
    cursor: pointer; text-align: left; width: 100%;
    transition: background .15s, color .15s, border-color .15s;
}
.sidebar-logout:hover {
    background: #fef2f2; color: #dc2626; border-color: #fecaca;
}
.sidebar-logout svg { flex-shrink: 0; }
.main { flex: 1; min-width: 0; }

@media (max-width: 820px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: column; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .nav-item { width: auto; }
}

/* ---------- Real-time / agents / alerts ---------- */
.live-map-el { height: calc(100vh - 200px); min-height: 440px; width: 100%; }

/* Vue Temps réel plein écran (style EasyTrack Manager) */
.live-view { position: relative; height: 100vh; width: 100%; overflow: hidden; }
@media (max-width: 820px) {
    /* Sur mobile la sidebar est au-dessus : on soustrait sa hauteur approx. */
    .live-view { height: calc(100vh - 160px); min-height: 480px; }
}
.live-map-full { position: absolute; inset: 0; }
.live-map-full .leaflet-container { background: #e5e7eb; }

.live-toolbar {
    position: absolute; top: 14px; right: 14px; z-index: 500;
    display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.live-tool {
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
    background: #fff; color: var(--text); display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.live-tool:hover { color: var(--primary); }
.live-tool.on { color: var(--primary); border-color: var(--primary); }
.live-menu {
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,.16); padding: 6px; min-width: 170px;
    display: flex; flex-direction: column; gap: 2px;
}
.live-menu-item {
    text-align: left; padding: 8px 12px; border-radius: 7px; border: none;
    background: transparent; font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer;
}
.live-menu-item:hover { background: var(--bg); }
.live-menu-item.active { background: var(--primary); color: #fff; }

.live-topleft {
    position: absolute; top: 14px; left: 14px; z-index: 500;
    display: flex; gap: 8px; align-items: center;
}
.live-badge-demo {
    background: #fef3c7; color: #92400e; border: 1px solid #fde68a;
    padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.live-alert-wrap { position: relative; }
.btn.alert-launch {
    display: inline-flex; align-items: center; gap: 6px;
    background: #dc2626; color: #fff; border: 1px solid #b91c1c;
    padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 700;
    cursor: pointer; box-shadow: 0 2px 8px rgba(220,38,38,.35);
}
.btn.alert-launch:hover { background: #b91c1c; }

.alert-menu {
    position: absolute; top: 40px; left: 0; min-width: 320px;
    background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 8px; z-index: 600;
}
.alert-menu-title { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #6b7280; padding: 6px 8px; }
.alert-menu-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; }
.alert-menu-row:hover { background: #f9fafb; }
.alert-menu-name { flex: 1; font-size: 13px; font-weight: 600; color: #111827; }
.alert-menu-name em { font-style: normal; color: #6b7280; font-weight: 400; }
.alert-menu-btn {
    border: 1px solid #e5e7eb; background: #fff; color: #374151;
    padding: 4px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer;
}
.alert-menu-btn.sos { border-color: #fecaca; color: #b91c1c; }
.alert-menu-btn.sos:hover { background: #fef2f2; }
.alert-menu-btn.fall { border-color: #fed7aa; color: #c2410c; }
.alert-menu-btn.fall:hover { background: #fff7ed; }

.live-alert-banner {
    position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
    z-index: 700; display: flex; align-items: center; gap: 12px;
    background: #dc2626; color: #fff; padding: 10px 14px; border-radius: 12px;
    box-shadow: 0 8px 24px rgba(220,38,38,.45);
    animation: alertBannerPulse 1.2s ease-in-out infinite;
    cursor: pointer; max-width: 90vw;
}
.live-alert-banner .lab-ico { display: flex; align-items: center; }
.live-alert-banner .lab-title { font-weight: 700; font-size: 14px; }
.live-alert-banner .lab-sub { font-size: 11px; opacity: .85; }
.live-alert-banner .lab-dismiss {
    background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.5);
    color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.live-alert-banner .lab-dismiss:hover { background: rgba(255,255,255,.3); }

@keyframes alertBannerPulse {
    0%, 100% { box-shadow: 0 8px 24px rgba(220,38,38,.45), 0 0 0 0 rgba(220,38,38,.7); }
    50%      { box-shadow: 0 8px 24px rgba(220,38,38,.55), 0 0 0 12px rgba(220,38,38,0); }
}

/* Marker pulsé quand un promoteur est en alerte. */
.leaflet-interactive.marker-alert {
    animation: markerAlertPulse 1s ease-in-out infinite;
    transform-origin: center;
}
@keyframes markerAlertPulse {
    0%, 100% { stroke: #fff; stroke-width: 3; filter: drop-shadow(0 0 0 rgba(220,38,38,.9)); }
    50%      { stroke: #fecaca; stroke-width: 5; filter: drop-shadow(0 0 8px rgba(220,38,38,.9)); }
}

/* Badges "plaque + vitesse" repris du EasyTrack Manager */
.plate-badge-container { background: transparent !important; border: none !important; }
.plate-speed-container {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px; white-space: nowrap;
}
.plate-badge {
    background: rgba(15, 23, 42, .88); color: #fff;
    padding: 3px 8px; border-radius: 5px; font-size: 11px; font-weight: 700;
    box-shadow: 0 1px 4px rgba(0,0,0,.25); font-family: inherit;
}
.imei-badge { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; letter-spacing: .02em; }
.dmap-panel {
    position: absolute; top: 14px; left: 14px; z-index: 500;
    width: 280px; max-height: calc(100% - 28px); overflow: auto;
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,.14);
}
.dmap-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--border); }
.dmap-title { font-size: 14px; font-weight: 700; }
.dmap-sub { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.dmap-list { display: flex; flex-direction: column; padding: 6px; }
.dmap-row {
    display: flex; align-items: flex-start; gap: 8px; text-align: left;
    border: none; background: transparent; padding: 8px; border-radius: 8px; cursor: pointer;
}
.dmap-row:hover, .dmap-row.on { background: var(--bg); }
.dmap-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.dmap-imei { display: block; font: 11px/1.3 ui-monospace, Menlo, monospace; font-weight: 700; color: var(--text); }
.dmap-meta { display: block; font-size: 11px; color: var(--text-mute); margin-top: 2px; }
.dmap-empty { padding: 16px 10px; color: var(--text-mute); font-size: 13px; text-align: center; }
@media (max-width: 820px) {
    .dmap-panel { width: calc(100% - 28px); max-height: 38%; }
}
.speed-badge {
    background: #22c55e; color: #fff;
    padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 700;
}
.speed-badge.parked { background: #2563eb; }

/* Badge de statut (Actif / Arrêt / Hors ligne) sur la carte temps réel */
.status-badge {
    color: #fff; padding: 2px 7px; border-radius: 4px;
    font-size: 10px; font-weight: 700; letter-spacing: .2px;
}

/* Popup Leaflet enrichi pour un promoteur */
.live-popup-wrap .leaflet-popup-content-wrapper { border-radius: 12px; padding: 4px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.live-popup-wrap .leaflet-popup-content { margin: 10px 14px; }
.live-popup .lp-head { display: flex; align-items: center; gap: 10px; }
.live-popup .lp-swatch { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.live-popup .lp-name { font-size: 14px; font-weight: 700; color: #0f172a; line-height: 1.1; }
.live-popup .lp-team { font-size: 11px; color: #64748b; margin-top: 2px; }
.live-popup .lp-status {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 8px; font-size: 12px; font-weight: 700;
}
.live-popup .lp-dot { width: 8px; height: 8px; border-radius: 50%; }
.live-popup .lp-rows { margin-top: 10px; padding-top: 10px; border-top: 1px solid #e5e7eb; display: flex; flex-direction: column; gap: 4px; }
.live-popup .lp-rows > div { display: flex; justify-content: space-between; font-size: 12px; color: #64748b; }
.live-popup .lp-rows b { color: #0f172a; font-weight: 600; }

/* Sur la vue temps réel, on veut ignorer le padding du <main> */
.main:has(.live-view) { display: block; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.status-dot.online { background: var(--success); }
.status-dot.offline { background: #cbd5e1; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .4; margin-right: 2px; vertical-align: middle; }
.live-dot.on { opacity: 1; }
.agent-label { background: transparent !important; border: none !important; text-align: center; }
.agent-label span {
    display: inline-block; background: var(--panel); color: var(--text);
    border: 1px solid var(--border); border-left-width: 3px;
    padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 600;
    box-shadow: var(--shadow); white-space: nowrap;
}
.table-card { padding: 0; overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
    text-align: left; padding: 12px 16px; font-size: 11px; text-transform: uppercase;
    letter-spacing: .5px; color: var(--text-mute); border-bottom: 1px solid var(--border); background: var(--bg);
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table .td-name { font-weight: 600; }
.data-table .td-sub { font-size: 12px; color: var(--text-mute); font-weight: 400; margin-top: 2px; }
.data-table .td-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--text-mute); }
.data-table tr.row-clickable { cursor: pointer; transition: background .12s; }
.data-table tr.row-clickable:hover { background: var(--bg); }
.positions-card { margin-top: 16px; }
.positions-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 16px 0;
}
.positions-head h3 { margin: 0; font-size: 16px; }
.positions-scroll { max-height: 70vh; overflow: auto; }
.positions-card .data-table { min-width: 860px; }

/* Barres horizontales de répartition (pays, browsers, etc.) */
.stat-row { margin-bottom: 10px; }
.stat-row:last-child { margin-bottom: 0; }
.stat-row-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.stat-row-label { color: var(--text); font-weight: 500; }
.stat-row-val { color: var(--text-mute); font-variant-numeric: tabular-nums; }
.stat-row-val em { font-style: normal; font-size: 11px; }
.stat-row-bar {
    background: var(--bg); height: 6px; border-radius: 3px; overflow: hidden;
}
.stat-row-bar span { display: block; height: 100%; border-radius: 3px; transition: width .3s; }

/* Mini graphique en barres (timeline) */
.mini-bars {
    display: flex; align-items: flex-end; gap: 4px; height: 100px;
    padding: 6px 0;
}
.mini-bar {
    flex: 1; height: 100%; display: flex; align-items: flex-end;
    background: transparent; border-radius: 4px;
}
.mini-bar span {
    display: block; width: 100%; background: linear-gradient(180deg, #2563eb 0%, #60a5fa 100%);
    border-radius: 4px 4px 2px 2px; min-height: 3px;
}

/* Boîte affichant l'URL de partage */
.link-box {
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px; color: var(--text-mute); word-break: break-all; line-height: 1.5;
}
.alert-card .alert-rows { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.alert-card .alert-rows > div { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-mute); }
.alert-card .alert-rows b { color: var(--text); }

/* Cartes "fonctions à venir" (Appel d'urgence, personne au sol) */
.alert-card.feature { padding: 18px 20px; }
.alert-card.feature .cc-top { display: flex; align-items: center; justify-content: space-between; }
.alert-card.feature .cc-title { font-size: 16px; font-weight: 700; margin-top: 14px; }
.alert-card.feature .alert-desc { margin-top: 8px; font-size: 13.5px; line-height: 1.5; color: var(--text-mute); }
.alert-ico {
    width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    background: #fee2e2; color: #dc2626;
}
.badge.soon { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }

.container { max-width: 1200px; margin: 0 auto; padding: 28px 24px 60px; width: 100%; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    background: var(--primary); color: #fff; border: none;
    padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600;
    transition: background .15s;
}
.btn:hover { background: var(--primary-d); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* ---------- Login ---------- */
.login-wrap {
    min-height: 100vh; display: grid; place-items: center;
    background: radial-gradient(1200px 600px at 20% -10%, #dbeafe, transparent),
                radial-gradient(1000px 500px at 100% 0%, #fce7f3, transparent), var(--bg);
    padding: 24px;
}
.login-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: 20px;
    box-shadow: var(--shadow-lg); padding: 36px; width: 100%; max-width: 420px;
}
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card p.sub { color: var(--text-mute); font-size: 14px; margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
    width: 100%; padding: 12px 14px; border: 1px solid var(--border);
    border-radius: 10px; font-size: 15px; outline: none; transition: border .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-l); }
.otp-input { letter-spacing: 8px; text-align: center; font-size: 22px !important; font-weight: 700; }
.login-error {
    background: #fee2e2; color: #991b1b; border-radius: 9px; padding: 10px 12px;
    font-size: 13px; margin-bottom: 14px;
}
.login-hint { font-size: 12px; color: var(--text-mute); margin-top: 14px; text-align: center; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h2 { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.page-head p { color: var(--text-mute); font-size: 14px; margin-top: 2px; }
.page-head .spacer { flex: 1; }

/* ---------- Campaign cards ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.card {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
}
.camp-card { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.camp-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.camp-card .cc-top { padding: 18px 18px 12px; }
.camp-card .cc-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.camp-card .cc-client { font-size: 13px; color: var(--text-mute); margin-top: 2px; }
.camp-card .cc-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.camp-card .cc-foot {
    border-top: 1px solid var(--border); padding: 12px 18px; display: flex;
    justify-content: space-between; font-size: 13px; color: var(--text-mute);
}

.badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
    border-radius: 999px; font-size: 12px; font-weight: 600;
    background: var(--bg); color: var(--text-mute); border: 1px solid var(--border);
}
.badge.active { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge.done { background: var(--primary-l); color: var(--primary-d); border-color: #bfdbfe; }
.badge.demo { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge.dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Empty ---------- */
.empty {
    text-align: center; padding: 60px 20px; color: var(--text-mute);
    background: var(--panel); border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* ---------- Review ---------- */
.review-grid { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
@media (max-width: 960px) { .review-grid { grid-template-columns: 1fr; } }

.map-card { padding: 0; overflow: hidden; }
#map { height: 560px; width: 100%; }
.map-toolbar {
    display: flex; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border);
    align-items: center; flex-wrap: wrap;
}
.seg { display: inline-flex; background: var(--bg); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
    border: none; background: transparent; padding: 6px 12px; border-radius: 7px;
    font-size: 13px; font-weight: 500; color: var(--text-mute);
}
.seg button.on { background: var(--panel); color: var(--primary-d); box-shadow: var(--shadow); }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.kpi-grid-wide { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* Onglets de la review campagne */
.tabbar {
    display: inline-flex; gap: 4px; background: var(--bg); border: 1px solid var(--border);
    border-radius: 11px; padding: 4px; margin-bottom: 18px;
}
.tabbar button {
    border: none; background: transparent; padding: 8px 18px; border-radius: 8px;
    font-size: 14px; font-weight: 600; color: var(--text-mute); cursor: pointer;
    transition: background .15s, color .15s;
}
.tabbar button:hover { color: var(--text); }
.tabbar button.on { background: var(--panel); color: var(--primary-d); box-shadow: var(--shadow); }

/* Grille de graphiques statistiques */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 16px; }
.stat-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px;
}
.stat-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 12px; }
.stat-canvas { position: relative; width: 100%; }
.stat-canvas canvas { width: 100% !important; }
.kpi {
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
}
.kpi .k-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-mute); font-weight: 600; }
.kpi .k-value { font-size: 22px; font-weight: 800; margin-top: 4px; }
.kpi .k-sub { font-size: 12px; color: var(--text-mute); }

.panel-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-mute); margin: 4px 0 10px; }

.promoter-row {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--panel);
    cursor: pointer; transition: border .15s, background .15s;
}
.promoter-row:hover { border-color: var(--primary); }
.promoter-row.off { opacity: .45; }
.promoter-row .swatch { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.promoter-row .p-name { font-weight: 600; font-size: 14px; }
.promoter-row .p-stats { font-size: 12px; color: var(--text-mute); }
.promoter-row .spacer { flex: 1; }
.promoter-row.clickable:hover { border-color: var(--primary); background: #f9fafb; }
.promoter-row .p-chev { color: #cbd5e1; font-size: 20px; font-weight: 300; line-height: 1; margin-top: 2px; }

/* ---------- Détail promoteur ---------- */
.promoter-detail { }
.promoter-detail-head {
    display: flex; align-items: center; gap: 14px; margin: 10px 0 18px;
}
.promoter-detail-head .swatch.big { width: 22px; height: 22px; border-radius: 50%; }
.promoter-detail-grid {
    display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px;
    align-items: start;
}
.promoter-detail-grid .map-card #map { height: 560px; }
.promoter-side { display: flex; flex-direction: column; }
.promoter-side .kpi-grid.promoter-kpi { grid-template-columns: 1fr 1fr; gap: 10px; }
.day-list { display: flex; flex-direction: column; gap: 8px; }
.day-row {
    border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--panel);
}
.day-row .day-date { font-weight: 600; font-size: 13px; margin-bottom: 6px; color: #111827; }
.day-row .day-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 12px; }
.day-row .day-metrics > div { display: flex; justify-content: space-between; }
.day-row .day-metrics span { color: var(--text-mute); }
.day-row .day-metrics b { color: #111827; font-weight: 600; }

@media (max-width: 900px) {
    .promoter-detail-grid { grid-template-columns: 1fr; }
    .promoter-detail-grid .map-card #map { height: 380px; }
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1000;
    display: grid; place-items: center; padding: 20px;
}
.modal {
    background: var(--panel); border-radius: 18px; box-shadow: var(--shadow-lg);
    width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal.modal-wide { max-width: 720px; }

.zone-picker { display: grid; gap: 10px; }
.zone-search-wrap { position: relative; }
.zone-suggest {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
    background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
    box-shadow: var(--shadow-lg); max-height: 220px; overflow-y: auto;
}
.zone-suggest button {
    display: block; width: 100%; text-align: left; padding: 10px 12px;
    border: none; background: transparent; font-size: 13px; cursor: pointer;
}
.zone-suggest button:hover { background: var(--primary-l); color: var(--primary); }
.zone-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.zone-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
    background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0;
}
.zone-chip button {
    border: none; background: transparent; color: #047857; font-size: 14px;
    line-height: 1; cursor: pointer; padding: 0;
}
.zone-map-preview {
    height: 200px; border-radius: 12px; border: 1px solid var(--border);
    overflow: hidden; background: #e2e8f0;
}
.zone-map-preview.tall {
    height: min(52vh, 480px);
    min-height: 280px;
}
.zone-pop-summary {
    font-size: 12px; color: var(--text-mute); line-height: 1.45;
}
.zone-pop-summary strong { color: var(--text); font-weight: 700; }

/* ---------- Wizard nouvelle campagne ---------- */
.wizard-page {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    padding: 22px 28px 0;
    max-width: 1100px;
}
.wizard-top { margin-bottom: 8px; }
.wizard-top-title h2 { font-size: 26px; font-weight: 800; letter-spacing: -.4px; margin-top: 4px; }
.wizard-top-title p { color: var(--text-mute); font-size: 14px; margin-top: 2px; }

.wizard-steps {
    display: flex; gap: 8px; flex-wrap: wrap;
    margin: 18px 0 20px;
}
.wizard-step-dot {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--panel);
    font-size: 13px; color: var(--text-mute); font-weight: 600;
}
.wizard-step-dot .num {
    width: 22px; height: 22px; border-radius: 999px;
    display: grid; place-items: center; font-size: 12px;
    background: var(--bg); color: var(--text-mute);
}
.wizard-step-dot.on {
    border-color: var(--primary); background: var(--primary-l); color: var(--primary-d);
}
.wizard-step-dot.on .num { background: var(--primary); color: #fff; }
.wizard-step-dot.done {
    border-color: #a7f3d0; background: #ecfdf5; color: #047857;
}
.wizard-step-dot.done .num { background: #10b981; color: #fff; }
.wizard-step-dot .lbl { white-space: nowrap; }

.wizard-body { flex: 1; padding-bottom: 96px; }
.wizard-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 16px; box-shadow: var(--shadow); padding: 22px 24px;
}
.wizard-card-head { margin-bottom: 18px; }
.wizard-card-head h3 { font-size: 18px; font-weight: 700; }
.wizard-card-head p { color: var(--text-mute); font-size: 14px; margin-top: 4px; }
.wizard-fields .field input,
.wizard-fields .field textarea,
.wizard-zones .field input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 10px; font-size: 14px; outline: none; background: var(--panel);
}
.wizard-fields .field textarea { resize: vertical; min-height: 72px; }
.wizard-device-list { max-height: 360px; overflow-y: auto; }

.wizard-recap { display: grid; gap: 10px; }
.recap-row {
    display: grid; grid-template-columns: 160px 1fr; gap: 12px;
    padding: 10px 12px; border-radius: 10px; background: var(--bg);
    font-size: 14px;
}
.recap-row span { color: var(--text-mute); font-weight: 500; }
.recap-row strong { font-weight: 650; color: var(--text); }
.recap-obj { align-items: start; }

.wizard-foot {
    position: sticky; bottom: 0; z-index: 40;
    display: flex; align-items: center; gap: 12px;
    margin: 0 -28px; padding: 14px 28px;
    background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
}
.wizard-foot .spacer { flex: 1; }
.wizard-foot .btn:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 720px) {
    .wizard-page { padding: 16px 16px 0; }
    .wizard-foot { margin: 0 -16px; padding: 12px 16px; }
    .wizard-step-dot .lbl { display: none; }
    .recap-row { grid-template-columns: 1fr; gap: 2px; }
    .zone-map-preview.tall { height: 42vh; min-height: 220px; }
}
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h3 { font-size: 18px; font-weight: 700; }
.modal-head .spacer { flex: 1; }
.modal-head .x { background: transparent; border: none; font-size: 22px; color: var(--text-mute); line-height: 1; }
.modal-body { padding: 22px 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

.checkbox-row {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 10px; margin-bottom: 8px; cursor: pointer;
}
.checkbox-row.on { border-color: var(--primary); background: var(--primary-l); }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--primary); }

.select, .modal .field input, .modal .field select, .modal .field textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 10px; font-size: 14px; outline: none; background: var(--panel);
}
.modal .field textarea { resize: vertical; min-height: 60px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Coverage legend ---------- */
.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-mute); }
.legend .bar {
    height: 8px; width: 120px; border-radius: 999px;
    background: linear-gradient(90deg, #2563eb, #22d3ee, #a3e635, #facc15, #ef4444);
}

.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-mute); margin-bottom: 12px; }
.back-link:hover { color: var(--primary); }

/* ---------- Export dropdown ---------- */
.export-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 600;
    background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
    box-shadow: var(--shadow-lg); overflow: hidden; min-width: 180px;
}
.export-menu button {
    display: block; width: 100%; text-align: left; padding: 10px 14px;
    border: none; background: transparent; font-size: 14px; color: var(--text);
}
.export-menu button:hover { background: var(--primary-l); color: var(--primary-d); }

/* ---------- Shared view banner ---------- */
.shared-banner {
    background: var(--primary); color: #fff; padding: 10px 24px;
    display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 500;
}
.shared-banner .spacer { flex: 1; }
.shared-banner a { color: #fff; text-decoration: underline; font-weight: 600; }
.btn.sm svg { margin-right: 2px; }

.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--text); color: #fff; padding: 12px 20px; border-radius: 10px;
    font-size: 14px; z-index: 2000; box-shadow: var(--shadow-lg);
}

/* ---------- PIN / QR promoteurs ---------- */
.pin-chip {
    display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700; letter-spacing: 2px; background: var(--primary-l); color: var(--primary-d);
    padding: 3px 10px; border-radius: 8px; font-size: 13px;
}
.pin-qr-panel {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px;
}
@media (max-width: 720px) { .pin-qr-panel { grid-template-columns: 1fr; } }
.pin-box, .qr-box {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
}
.pin-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-mute); }
.pin-value {
    font-size: 42px; font-weight: 800; letter-spacing: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--primary-d); line-height: 1;
}
.pin-help { font-size: 13px; color: var(--text-mute); margin: 0; }
.qr-img { width: 160px; height: 160px; border-radius: 12px; border: 1px solid var(--border); background: #fff; }

/* ---------- Proofs ---------- */
.proof-marker { background: transparent !important; border: none !important; }
.proof-marker-dot {
    display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
    background: #db2777; box-shadow: 0 2px 8px rgba(219,39,119,.45); border: 2px solid #fff;
    cursor: pointer;
}
.proof-map-hint { font-size: 12.5px; color: var(--text-mute); padding: 10px 16px 14px; margin: 0; }
.proof-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.proof-filters button {
    border: 1px solid var(--border); background: var(--panel); border-radius: 999px;
    padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--text-mute);
}
.proof-filters button.on { background: var(--primary-l); color: var(--primary-d); border-color: transparent; }
.proof-gallery {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px;
}
.proof-card {
    border: 1px solid var(--border); background: var(--panel); border-radius: var(--radius);
    overflow: hidden; text-align: left; padding: 0; box-shadow: var(--shadow);
    transition: transform .12s, box-shadow .12s; cursor: pointer;
}
.proof-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.proof-card-img {
    aspect-ratio: 1; background: #e2e8f0 center/cover no-repeat;
}
.proof-card-body { padding: 12px 14px 14px; }
.proof-card-name { font-weight: 700; font-size: 14px; }
.proof-card-camp { font-size: 12px; color: var(--primary-d); margin-top: 2px; }
.proof-card-meta {
    display: flex; flex-direction: column; gap: 2px; margin-top: 6px;
    font-size: 12px; color: var(--text-mute);
}
.proof-lightbox {
    position: fixed; inset: 0; z-index: 3000; background: rgba(15,23,42,.72);
    display: flex; align-items: center; justify-content: center; padding: 24px;
}
.proof-lightbox-card {
    position: relative; background: #fff; border-radius: 16px; overflow: hidden;
    max-width: min(640px, 100%); width: 100%; box-shadow: var(--shadow-lg);
}
.proof-lightbox-card img { display: block; width: 100%; max-height: 70vh; object-fit: contain; background: #0f172a; }
.proof-lightbox-x {
    position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: none;
    border-radius: 50%; background: rgba(15,23,42,.55); color: #fff; font-size: 22px; line-height: 1; z-index: 2;
}
.proof-lightbox-meta { padding: 16px 18px 18px; }
.plm-name { font-weight: 800; font-size: 17px; }
.plm-sub { color: var(--text-mute); font-size: 13.5px; margin-top: 4px; }
.plm-coords { font-family: ui-monospace, monospace; font-size: 12px; color: var(--text-mute); margin-top: 8px; }

.tabbar button.tab-ico { display: inline-flex; align-items: center; gap: 7px; }
.tabbar button.tab-ico svg { flex-shrink: 0; }

.replay-wrap { position: relative; }
.replay-wrap #replay-map { height: 560px; width: 100%; }
.replay-controls {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-top: 1px solid var(--border); background: #fff;
}
.replay-play {
    width: 40px; height: 40px; border: none; border-radius: 50%;
    background: #3b82f6; color: #fff; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; cursor: pointer;
}
.replay-play:hover { background: #2563eb; }
.replay-speed {
    border: none; background: var(--bg); border-radius: 8px; padding: 6px 10px;
    font-size: 12px; font-weight: 800; color: var(--text); min-width: 40px; cursor: pointer;
}
.replay-range { flex: 1; accent-color: #3b82f6; }
.replay-time { font-size: 13px; font-weight: 600; color: var(--text-mute); min-width: 52px; text-align: right; }
.custom-marker { background: none !important; border: none !important; }
.replay-badge-wrap { background: none !important; border: none !important; }
.replay-badge {
    display: flex; flex-direction: column; gap: 3px; transform: translate(14px, -10px);
}
.replay-badge .rb-name {
    background: #fff; border-left: 3px solid #2563eb; border-radius: 6px;
    padding: 3px 8px; font-size: 12px; font-weight: 700; box-shadow: 0 2px 8px rgba(15,23,42,.12);
    white-space: nowrap;
}
.replay-badge .rb-meta { display: flex; align-items: center; gap: 5px; }
.replay-badge .rb-speed {
    display: inline-flex; align-items: center; gap: 4px; color: #fff;
    border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 700; width: fit-content;
    box-shadow: 0 2px 8px rgba(15,23,42,.18);
}
.replay-badge .rb-batt {
    display: inline-flex; align-items: center; background: #0f172a; color: #fff;
    border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 700;
    box-shadow: 0 2px 8px rgba(15,23,42,.18); white-space: nowrap;
}
