/* ══════════════════════════════════════════════════════════════
   CliOS — design system "app officielle"
   Surfaces pleines et sobres, hiérarchie typographique nette, une seule
   couleur d'accent (ambre du logo) réservée à l'actif / aux actions
   principales, couleurs système pour les états (ok / alerte / panne).
   Mobile : barre du haut + gros titre + tab bar pleine largeur.
   Desktop (≥ 768px) : barre latérale fixe.
   Les composants vivent ici ; Tailwind (static/tailwind.css, régénéré par
   `npm run build:css`) ne sert qu'à la mise en page.
   ══════════════════════════════════════════════════════════════ */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/static/vendor/inter/Inter-Variable.woff2') format('woff2');
}

:root {
    --bg: #0a0a0b;
    --surface: #141416;
    --surface-2: #1b1b1e;
    --surface-3: #252529;
    --line: rgba(255,255,255,0.07);
    --line-strong: rgba(255,255,255,0.12);
    --text: #f4f4f5;
    --text-2: #a1a1aa;
    --text-3: #71717a;
    --text-4: #52525b;

    --accent: #ffb84d;
    --accent-rgb: 255,184,77;
    --accent-ink: #1c1300;
    --accent-soft: rgba(255,184,77,0.14);
    /* Alias conservés pour le code existant qui lit encore ces variables */
    --accent-2: #ff8a5c;
    --accent-grad: var(--accent);
    --accent-tint: var(--accent-soft);

    --ok: #32d74b;     --ok-soft: rgba(50,215,75,0.14);
    --warn: #ffcc00;   --warn-soft: rgba(255,204,0,0.14);
    --danger: #ff453a; --danger-soft: rgba(255,69,58,0.14);
    --info: #0a84ff;   --info-soft: rgba(10,132,255,0.16);

    /* Rôles dérivés : surchargés par le thème clair (plus bas). --accent reste
       la couleur des remplissages (boutons, jauges) ; --accent-text sert quand
       l'ambre est utilisé comme couleur de TEXTE (illisible tel quel sur blanc).
       Idem --*-fill pour les remplissages d'état vs --ok/--warn/… pour le texte. */
    --accent-text: var(--accent);
    --info-text: #4da3ff;
    --ok-fill: var(--ok); --warn-fill: var(--warn); --danger-fill: var(--danger);
    --appbar-bg: rgba(10,10,11,0.82);
    --tabbar-bg: rgba(14,14,16,0.88);
    --sidebar-bg: #0e0e10;
    --hover-3: #2e2e33;
    --icon-neutral: #3a3a40;
    --code-bg: #0e0e10;
    --map-bg: #111113;
    --pending-text: #ffd59a;
    --shadow-strong: rgba(0,0,0,0.7);
    --shadow-soft: rgba(0,0,0,0.35);
    --chart-grid: rgba(255,255,255,0.06);
    --chart-muted: rgba(255,255,255,0.12);
    --chart-tick: #71717a;
    color-scheme: dark;

    --r-card: 16px;
    --r-ctl: 12px;
    --sidebar-w: 248px;
    --tabbar-h: 58px;
    --ease: cubic-bezier(.2,.8,.2,1);
}

/* ── Thème clair ──────────────────────────────────────────────────
   Activé par data-theme="light" sur <html>, posé avant le rendu par le
   script de partials/head.html (préférence Réglages > Apparence, stockée
   par appareil : sombre / clair / auto = suit le système). */
:root[data-theme="light"] {
    --bg: #f2f2f7;
    --surface: #ffffff;
    --surface-2: #f4f4f6;
    --surface-3: #e6e6ea;
    --line: rgba(0,0,0,0.08);
    --line-strong: rgba(0,0,0,0.14);
    --text: #18181b;
    --text-2: #52525b;
    --text-3: #71717a;
    --text-4: #a1a1aa;

    --accent-soft: rgba(255,170,40,0.18);
    --accent-text: #a35400;

    --ok: #1f7a35;     --ok-soft: rgba(52,199,89,0.16);
    --warn: #9a5b00;   --warn-soft: rgba(255,170,0,0.18);
    --danger: #d70015; --danger-soft: rgba(255,59,48,0.12);
    --info: #0062cc;   --info-soft: rgba(0,122,255,0.12);
    --info-text: #0062cc;
    --ok-fill: #34c759; --warn-fill: #ffb800; --danger-fill: #ff3b30;

    --appbar-bg: rgba(242,242,247,0.85);
    --tabbar-bg: rgba(249,249,251,0.9);
    --sidebar-bg: #fbfbfd;
    --hover-3: #dcdce1;
    --icon-neutral: #8e8e93;
    --code-bg: #f4f4f6;
    --map-bg: #e8e8ec;
    --pending-text: #7a4300;
    --shadow-strong: rgba(0,0,0,0.18);
    --shadow-soft: rgba(0,0,0,0.12);
    --chart-grid: rgba(0,0,0,0.07);
    --chart-muted: rgba(0,0,0,0.12);
    --chart-tick: #71717a;
    color-scheme: light;
}
/* Ombre douce des cartes : sans elle, blanc sur gris clair manque de relief */
:root[data-theme="light"] .card, :root[data-theme="light"] .list { box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
/* Utilitaires Tailwind "pensés sombre" encore présents dans les pages */
:root[data-theme="light"] .text-white { color: var(--text); }
:root[data-theme="light"] .hover\:text-white:hover { color: var(--text); }
:root[data-theme="light"] [class*="border-white/"] { border-color: var(--line); }
:root[data-theme="light"] [class*="bg-white/"] { background-color: rgba(0,0,0,0.04); }
:root[data-theme="light"] [class*="hover:bg-white/"]:hover { background-color: rgba(0,0,0,0.05); }
:root[data-theme="light"] [class*="bg-black/"] { background-color: var(--surface-2); }
:root[data-theme="light"] .bg-\[\#18181b\] { background-color: var(--surface-2); }
:root[data-theme="light"] .bg-\[\#1b1b1e\] { background-color: var(--surface-2); }
/* Curseurs natifs : avec un accent clair, Chrome assombrit la piste vide pour
   garder le contraste (piste noire sur fond blanc) — un accent plus soutenu
   en clair lui fait garder une piste claire. */
:root[data-theme="light"] input[type="range"] { accent-color: #d67a00 !important; }

/* Fondu enchaîné entre pages (View Transitions API, multi-documents) */
@view-transition { navigation: auto; }
::view-transition-group(root) { animation-duration: 180ms; }
@media (prefers-reduced-motion: reduce) {
    ::view-transition-group(root) { animation-duration: .01ms; }
}

html, body { background: var(--bg); }
body {
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-feature-settings: 'cv11', 'ss01';
    font-size: 15px;
    letter-spacing: -0.011em;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
::selection { background: rgba(var(--accent-rgb),0.3); }
input[type="range"] { accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* ── Structure ────────────────────────────────────────────────── */
.app-main {
    position: relative;
    padding-bottom: calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 768px) {
    .app-main { margin-left: var(--sidebar-w); padding-bottom: 48px; }
}
.page { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.page--narrow { max-width: 760px; }
.page--wide { max-width: 1360px; }
@media (min-width: 768px) { .page { padding: 0 32px; } }

/* Barre du haut (mobile) */
.appbar {
    position: sticky; top: 0; z-index: 50;
    padding-top: env(safe-area-inset-top, 0px);
    background: var(--appbar-bg);
    backdrop-filter: saturate(160%) blur(18px);
    -webkit-backdrop-filter: saturate(160%) blur(18px);
    border-bottom: 1px solid transparent;
    transition: border-color .2s ease;
}
.appbar.is-scrolled { border-bottom-color: var(--line); }
.appbar-inner { height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; }
.appbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); }
.appbar-back { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-text); font-weight: 500; font-size: 16px; min-height: 44px; }
.appbar-back i { font-size: 15px; }
.appbar-title { position: absolute; left: 50%; transform: translateX(-50%); font-size: 16px; font-weight: 600; opacity: 0; transition: opacity .2s ease; pointer-events: none; white-space: nowrap; }
.appbar.is-scrolled .appbar-title { opacity: 1; }
@media (min-width: 768px) { .appbar { display: none; } }

/* En-tête de page (gros titre) */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 6px 0 20px; }
.page-head h1 { font-size: 30px; line-height: 1.1; font-weight: 750; letter-spacing: -0.025em; color: var(--text); }
.page-head .page-sub { font-size: 14px; color: var(--text-3); margin-top: 4px; }
.page-crumb { display: none; font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.page-crumb a:hover { color: var(--text-2); }
@media (min-width: 768px) {
    .page-head { padding: 36px 0 24px; }
    .page-head h1 { font-size: 32px; }
    .page-crumb { display: block; }
}

/* Barre latérale (desktop) */
.sidebar {
    display: none;
    position: fixed; inset: 0 auto 0 0; z-index: 50;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--line);
    padding: 20px 14px;
    flex-direction: column;
}
@media (min-width: 768px) { .sidebar { display: flex; } }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; }
.sidebar-brand-name { font-weight: 750; font-size: 17px; letter-spacing: -0.02em; }
.sidebar-brand-sub { font-size: 12px; color: var(--text-3); }
.sidebar-section { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-4); padding: 16px 12px 6px; }
.side-link {
    display: flex; align-items: center; gap: 12px;
    height: 40px; padding: 0 12px; border-radius: 10px;
    color: var(--text-2); font-size: 14px; font-weight: 500;
    transition: background-color .15s ease, color .15s ease;
}
.side-link i { width: 18px; text-align: center; font-size: 15px; color: var(--text-3); transition: color .15s ease; }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.is-active { background: var(--surface-2); color: var(--text); }
.side-link.is-active i { color: var(--accent-text); }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Tab bar (mobile) */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: flex; justify-content: space-around; align-items: stretch;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--tabbar-bg);
    backdrop-filter: saturate(160%) blur(20px);
    -webkit-backdrop-filter: saturate(160%) blur(20px);
    border-top: 1px solid var(--line);
    touch-action: pan-y;
    -webkit-user-select: none; user-select: none;
    view-transition-name: tabbar;
}
@media (min-width: 768px) { .tabbar { display: none; } }
.tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    color: var(--text-3); font-size: 10.5px; font-weight: 500; letter-spacing: 0;
    transition: color .15s ease;
}
.tab i { font-size: 19px; }
.tab:active { opacity: .6; }
.tab.is-active { color: var(--accent-text); font-weight: 600; }

/* ── Surfaces ─────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
}
.card-pad { padding: 16px; }
@media (min-width: 768px) { .card-pad { padding: 20px; } }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 650; color: var(--text); letter-spacing: -0.015em; }
.card-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }
a.card, button.card { transition: background-color .15s ease, border-color .15s ease; }
a.card:hover, button.card:hover { background: var(--surface-2); border-color: var(--line-strong); }

.well {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-ctl);
}
a.well:hover, button.well:hover { background: var(--surface-3); }

.section-label {
    font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
    color: var(--text-3); padding: 0 4px 8px;
}
.section-note { font-size: 12.5px; color: var(--text-3); padding: 8px 4px 0; line-height: 1.45; }
.divider { height: 1px; background: var(--line); }

/* ── Liste groupée (façon réglages iOS) ───────────────────────── */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; min-height: 56px; }
a.row, button.row, label.row { cursor: pointer; transition: background-color .12s ease; }
a.row:hover, button.row:hover, label.row:hover { background: var(--surface-2); }
a.row:active, button.row:active { background: var(--surface-3); }
button.row { width: 100%; text-align: left; }
.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 500; color: var(--text); }
.row-sub { font-size: 13px; color: var(--text-3); margin-top: 1px; }
.row-value { font-size: 15px; color: var(--text-2); flex-shrink: 0; }
.row-chev { color: var(--text-4); font-size: 13px; flex-shrink: 0; }
.row-icon {
    width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; color: #fff; background: var(--icon-neutral);
}
.ic-accent { background: var(--accent); color: var(--accent-ink); }
.ic-blue   { background: #0a84ff; }
.ic-green  { background: #30b24a; }
.ic-orange { background: #ff9500; }
.ic-red    { background: #ff3b30; }
.ic-purple { background: #8e5cf0; }
.ic-teal   { background: #14a3b8; }
.ic-indigo { background: #5856d6; }
.ic-pink   { background: #e8457a; }
.ic-gray   { background: #636366; }
.ic-soft   { background: var(--surface-3); color: var(--text-2); }
.row-danger .row-title { color: var(--danger); }

/* ── Boutons ──────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px; border-radius: var(--r-ctl);
    font-size: 14px; font-weight: 600; white-space: nowrap;
    border: 1px solid transparent; cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease, transform .1s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #ffc46b; }
.btn-secondary { background: var(--surface-3); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: var(--hover-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: rgba(255,69,58,0.22); }
.btn-success { background: var(--ok-soft); color: var(--ok); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { height: 48px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-icon.btn-lg { width: 48px; }
.btn-round { border-radius: 9999px; }
.btn.is-on { background: var(--accent-soft); color: var(--accent-text); border-color: rgba(var(--accent-rgb),0.3); }

/* ── Champs ───────────────────────────────────────────────────── */
.input, .select, .textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-ctl);
    color: var(--text);
    font-size: 15px;
    padding: 0 14px;
    height: 44px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { height: auto; padding: 12px 14px; line-height: 1.45; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:focus, .select:focus, .textarea:focus { border-color: rgba(var(--accent-rgb),0.6); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.15); }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; }
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }

/* Interrupteur : <input type="checkbox" class="switch"> */
.switch {
    appearance: none; -webkit-appearance: none;
    width: 48px; height: 28px; border-radius: 9999px; flex-shrink: 0;
    background: var(--surface-3); position: relative; cursor: pointer;
    transition: background-color .2s ease; outline: none;
}
.switch::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 22px; height: 22px; border-radius: 9999px; background: #fff;
    box-shadow: 0 2px 4px var(--shadow-soft);
    transition: transform .22s var(--ease);
}
.switch:checked { background: var(--ok-fill); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .45; cursor: default; }
.switch:focus-visible { box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.3); }

/* Curseur : <input type="range" class="slider"> */
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; }
.slider::-webkit-slider-runnable-track { height: 4px; border-radius: 9999px; background: var(--surface-3); }
.slider::-moz-range-track { height: 4px; border-radius: 9999px; background: var(--surface-3); }
.slider::-moz-range-progress { height: 4px; border-radius: 9999px; background: var(--accent); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 9999px; background: #fff; box-shadow: 0 2px 6px var(--shadow-soft); }
.slider::-moz-range-thumb { width: 22px; height: 22px; border: none; border-radius: 9999px; background: #fff; box-shadow: 0 2px 6px var(--shadow-soft); }

/* Contrôle segmenté */
.seg { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; }
.seg > button, .seg > a {
    flex: 1; height: 32px; padding: 0 12px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-size: 13px; font-weight: 600; color: var(--text-3); white-space: nowrap;
    transition: background-color .15s ease, color .15s ease;
}
.seg > button:hover, .seg > a:hover { color: var(--text); }
.seg > .is-active { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 3px var(--shadow-soft); }
:root[data-theme="light"] .seg > .is-active { background: var(--surface); }

/* ── Données ──────────────────────────────────────────────────── */
.stat-label { font-size: 12.5px; font-weight: 500; color: var(--text-3); }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); line-height: 1.15; }
.stat-value.sm { font-size: 18px; }
.stat-unit { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 3px; letter-spacing: 0; }
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv dt, .kv .k { color: var(--text-3); }
.kv dd, .kv .v { color: var(--text); font-weight: 500; text-align: right; }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    height: 24px; padding: 0 10px; border-radius: 9999px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
    background: var(--surface-3); color: var(--text-2);
}
.badge-ok     { background: var(--ok-soft); color: var(--ok); }
.badge-warn   { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info   { background: var(--info-soft); color: var(--info-text); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.dot { width: 8px; height: 8px; border-radius: 9999px; background: currentColor; display: inline-block; flex-shrink: 0; }

.t-ok { color: var(--ok); } .t-warn { color: var(--warn); } .t-danger { color: var(--danger); }
.t-info { color: var(--info-text); } .t-accent { color: var(--accent-text); }
.t-1 { color: var(--text); } .t-2 { color: var(--text-2); } .t-3 { color: var(--text-3); } .t-4 { color: var(--text-4); }

.empty { padding: 40px 20px; text-align: center; color: var(--text-3); font-size: 14px; }
.empty i { display: block; font-size: 28px; color: var(--text-4); margin-bottom: 12px; }

/* Témoin (feux, portes…) : carré neutre, teinté quand actif */
.ind {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); border: 1px solid var(--line);
    color: var(--text-4); font-size: 15px;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.ind.on-amber { background: var(--warn-soft); color: var(--warn); border-color: rgba(255,204,0,0.25); }
.ind.on-green { background: var(--ok-soft); color: var(--ok); border-color: rgba(50,215,75,0.25); }
.ind.on-blue  { background: var(--info-soft); color: var(--info-text); border-color: rgba(10,132,255,0.3); }
.ind.on-orange{ background: rgba(255,149,0,0.15); color: #ff9f0a; border-color: rgba(255,149,0,0.28); }
.ind.on-red   { background: var(--danger-soft); color: var(--danger); border-color: rgba(255,69,58,0.3); }
.ind.on-white { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.2); }
:root[data-theme="light"] .ind.on-white { background: rgba(0,0,0,0.08); color: var(--text); border-color: rgba(0,0,0,0.2); }
:root[data-theme="light"] .ind.on-orange { color: #b35c00; }
.ind.ok       { color: var(--ok); }
.ind-label { font-size: 11px; color: var(--text-3); text-align: center; line-height: 1.2; }

/* Média (flux caméra, carte) */
.media { background: #000; border: 1px solid var(--line); border-radius: var(--r-ctl); overflow: hidden; }

code, .mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: .9em; }

/* Cible tactile minimale (HIG : 44px) */
.tap-target { min-height: 44px; min-width: 44px; }
.safe-top { padding-top: env(safe-area-inset-top, 0); }

/* ── Statut de connexion (voir updateStatusBadge dans common.js) ─── */
.status-badge {
    display: inline-flex; align-items: center; gap: 7px;
    height: 28px; padding: 0 11px; border-radius: 9999px;
    font-size: 12.5px; font-weight: 600;
    background: var(--surface-2); color: var(--text-3);
    transition: background-color .2s ease, color .2s ease;
}
.status-badge-dot { width: 7px; height: 7px; border-radius: 9999px; background: currentColor; display: inline-block; }
.status-badge.is-online { background: var(--ok-soft); color: var(--ok); }
.status-badge.is-online .status-badge-dot { animation: pulse 2.4s ease-in-out infinite; }
.status-badge.is-offline { background: var(--danger-soft); color: var(--danger); }
.status-fresh { font-size: 11.5px; color: var(--text-4); white-space: nowrap; }
@keyframes pulse { 50% { opacity: .35; } }

/* ── Feuilles et modales ──────────────────────────────────────── */
body.sheet-open { overflow: hidden; }
.sheet-backdrop {
    position: fixed; inset: 0; z-index: 70;
    background: rgba(0,0,0,0.55);
    opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 71;
    max-height: 92vh; overflow-y: auto;
    background: var(--surface);
    border-top: 1px solid var(--line-strong);
    border-radius: 20px 20px 0 0;
    padding: 10px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    visibility: hidden;
    transition: transform .32s cubic-bezier(.16,1,.3,1), visibility 0s linear .32s;
}
.sheet.open { transform: translateY(0); visibility: visible; transition: transform .32s cubic-bezier(.16,1,.3,1); }
@media (min-width: 768px) {
    .sheet { left: 50%; right: auto; bottom: 24px; width: 440px; margin-left: calc(var(--sidebar-w) / 2 - 220px); border-radius: 20px; border: 1px solid var(--line-strong); transform: translateY(calc(100% + 40px)); }
}
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto 16px; }

.confirm-modal {
    position: fixed; inset: 0; z-index: 80;
    display: flex; align-items: center; justify-content: center; padding: 24px;
    background: rgba(0,0,0,0.55);
    opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.confirm-modal.open { opacity: 1; pointer-events: auto; }
.confirm-modal-card {
    width: 100%; max-width: 340px;
    background: var(--surface-2); border: 1px solid var(--line-strong);
    border-radius: 18px; padding: 22px 20px 18px;
    box-shadow: 0 30px 60px -20px var(--shadow-strong);
    transform: scale(0.95); transition: transform .2s cubic-bezier(.16,1,.3,1);
}
.confirm-modal.open .confirm-modal-card { transform: scale(1); }
.confirm-modal-message { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.4; margin-bottom: 18px; text-align: center; }
.confirm-modal-actions { display: flex; gap: 10px; }
.confirm-modal-actions .btn { flex: 1; }
@media (prefers-reduced-motion: reduce) {
    .confirm-modal, .confirm-modal-card, .sheet { transition-duration: .01ms; }
}

/* Pull-to-refresh (voir initPullToRefresh dans common.js) */
#ptr-indicator {
    position: fixed; top: 0; left: 50%; z-index: 60;
    width: 34px; height: 34px; margin-left: -17px;
    transform: translateY(-46px); opacity: 0;
    background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--accent-text); pointer-events: none;
}
#ptr-indicator i { transition: transform .15s ease; }
#ptr-indicator.ptr-ready i { transform: rotate(180deg); }
#ptr-indicator.ptr-loading i { animation: ptrSpin .7s linear infinite; }
@keyframes ptrSpin { to { transform: rotate(360deg); } }

/* Écran de chargement */
#page-loader {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg); opacity: 1; transition: opacity .25s ease;
}
#page-loader.done { opacity: 0; pointer-events: none; }
#page-loader svg { width: 2.75rem; height: 2.75rem; animation: page-loader-pulse 1.1s ease-in-out infinite; }
@keyframes page-loader-pulse { 0%, 100% { transform: scale(0.88); opacity: .5; } 50% { transform: scale(1); opacity: 1; } }

/* Bannière "nouvelle version disponible" (voir watchForUpdates dans common.js) */
#sw-update-banner {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 9998;
    display: flex; align-items: center; gap: 14px;
    background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 14px;
    padding: 10px 10px 10px 16px; box-shadow: 0 16px 36px -12px var(--shadow-strong);
    color: var(--text); font-size: 14px; font-weight: 500; max-width: calc(100vw - 32px);
}
#sw-update-banner button { background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 7px 14px; font-weight: 600; font-size: 13px; white-space: nowrap; }
@media (max-width: 767px) { #sw-update-banner { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px)); } }

/* Bandeau "réglages en attente" (voir renderPendingBanner dans common.js) */
#pending-changes-banner {
    display: none; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; padding-top: calc(9px + env(safe-area-inset-top, 0px));
    background: var(--accent-soft); border-bottom: 1px solid rgba(var(--accent-rgb),0.25);
    color: var(--pending-text); font-size: 13px; font-weight: 500; text-align: center;
}
#pending-changes-banner.show { display: flex; }
@media (min-width: 768px) { #pending-changes-banner { margin-left: var(--sidebar-w); } }

/* <details> repliable sans la flèche native */
.disclosure > summary { list-style: none; cursor: pointer; -webkit-user-select: none; user-select: none; outline: none; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary .chevron { display: inline-block; transition: transform .2s ease; }
.disclosure[open] > summary .chevron { transform: rotate(90deg); }

/* Repère bref quand on saute vers une carte (scrollToCard) */
@keyframes flashHighlight { 0%, 100% { border-color: var(--line); } 35% { border-color: rgba(var(--accent-rgb),0.6); } }
.flash-highlight { animation: flashHighlight .9s ease; }

/* Wireframe pour une donnée sans capteur réel derrière */
.skeleton { background: repeating-linear-gradient(135deg, transparent 0 10px, var(--line) 10px 20px); border: 1px dashed var(--line-strong); border-radius: var(--r-card); color: var(--text-3); }
.skeleton-tag { background: var(--surface-3); color: var(--text-3); }

/* Fondu d'entrée discret du contenu */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page { animation: fadeIn .3s var(--ease) both; }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } }

/* Scrollbar sobre (desktop) */
@media (min-width: 768px) {
    ::-webkit-scrollbar { width: 10px; height: 10px; }
    ::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--bg); }
    ::-webkit-scrollbar-track { background: transparent; }
}

/* ── Compatibilité : anciennes classes encore produites par du JS de page ── */
.glass { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.glass-well { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-ctl); }
.glass-btn { background: var(--surface-3); border: 1px solid var(--line); color: var(--text); transition: background-color .15s ease; }
.glass-btn:hover { background: var(--hover-3); }
.glass-btn:active { transform: scale(0.97); }
.icon-chip { background: var(--accent-soft); color: var(--accent-text); }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: #ffc46b; }

/* ── Composants de l'accueil (réutilisables) ─────────────────── */
/* Pastille d'état principale (vue d'ensemble du véhicule) */
.status-icon {
    width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 19px;
    background: var(--surface-2); color: var(--text-3);
    transition: background-color .25s ease, color .25s ease;
}
.status-icon.tone-good   { background: var(--ok-soft); color: var(--ok); }
.status-icon.tone-warn   { background: var(--warn-soft); color: var(--warn); }
.status-icon.tone-active { background: var(--accent-soft); color: var(--accent-text); }
.status-icon.tone-danger { background: var(--danger-soft); color: var(--danger); }

/* Jauge linéaire */
.meter { height: 6px; border-radius: 9999px; background: var(--surface-3); overflow: hidden; }
.meter-fill { height: 100%; border-radius: inherit; background: var(--accent); transition: width .5s cubic-bezier(.16,1,.3,1); }
.meter-fill.is-low { background: var(--danger-fill); }

/* Action rapide (icône + libellé) */
.qa {
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    padding: 4px 0; color: var(--text-2); cursor: pointer;
}
.qa-icon {
    width: 52px; height: 52px; border-radius: 16px;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
    background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
    transition: background-color .15s ease, color .15s ease, transform .1s ease;
}
.qa:hover .qa-icon { background: var(--surface-3); }
.qa:active .qa-icon { transform: scale(0.94); }
.qa-label { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; text-align: center; line-height: 1.2; }
.qa.is-active .qa-icon { background: var(--danger-soft); border-color: rgba(255,69,58,0.3); color: var(--danger); }
.qa.is-active .qa-label { color: var(--danger); }

/* Élément de liste sélectionné (trajets) */
.trip-item.is-selected { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }

/* Leaflet aux couleurs de l'appli */
.leaflet-container { background: var(--map-bg); font-family: inherit; }
.leaflet-bar a, .leaflet-bar a:hover { background: var(--surface-2); color: var(--text); border-bottom-color: var(--line); }
.leaflet-control-attribution { background: var(--appbar-bg) !important; color: var(--text-4) !important; }
.leaflet-control-attribution a { color: var(--text-3) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface-2); color: var(--text); }
