:root {
  --bg: #0f172a;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #ea580c;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --card: #1e293b; --text: #f1f5f9; --muted: #94a3b8; --line: #334155; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 1.2em; margin: 0; }

.screen { position: fixed; inset: 0; }
.card { background: var(--card); color: var(--text); border-radius: 16px; padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); }

/* Connexion */
#login { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 16px; }
.login-card h1 { margin: 0; }
.login-card p { margin: 0; }
label { display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 14px; color: var(--muted); }
input[type=text], input[type=password], input[type=datetime-local] {
  font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--text); width: 100%; }

.btn { font-size: 15px; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn.success { background: var(--green); color: #fff; border-color: var(--green); }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; }

/* Carte */
#map { position: absolute; inset: 0; }
.topbar { position: absolute; top: calc(10px + var(--safe-top)); right: 10px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px; }
.fab { width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--card); color: var(--text);
  font-size: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.3); cursor: pointer; }
.fab.active { background: var(--primary); color: #fff; }
.conn { position: absolute; top: calc(14px + var(--safe-top)); left: 56px; z-index: 1000; font-size: 14px;
  color: var(--muted); background: var(--card); padding: 4px 10px; border-radius: 12px; }
.conn.on { color: var(--green); }
.conn.off { color: var(--red); }

/* Voiture style Waze (MapLibre) */
.car-marker { cursor: pointer; }
.car-body { width: 38px; height: 58px; transition: transform .35s ease-out; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }
.car-body svg { display: block; }
.car-marker .car-label { margin-top: 3px; font-weight: 700; border-radius: 10px; padding: 2px 8px; font-size: 12px; }
#btn-3d { font-size: 14px; font-weight: 800; }
.zoom-btn { font-size: 26px; font-weight: 700; line-height: 1; }
.zoomctl { position: absolute; right: 10px; z-index: 1000; display: flex; flex-direction: column; gap: 8px;
  transition: bottom .25s; }
/* Abonnement qui expire (comme Geo5lux) */
.sub-banner { position: absolute; left: 10px; right: 64px; top: calc(52px + var(--safe-top)); z-index: 1050;
  background: #dc2626; color: #fff; border-radius: 12px; padding: 10px 36px 10px 12px; font-size: 14px; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.sub-banner a { color: #fff; font-weight: 800; }
.sub-banner .close { position: absolute; right: 8px; top: 6px; background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }
.client { border: 1px solid var(--line); border-radius: 12px; padding: 12px; border-left: 5px solid var(--green); }
.client.soon { border-left-color: var(--orange); }
.client.expired, .client.disabled { border-left-color: var(--red); }
.client .item-top { align-items: center; }
.client .row2 { margin-top: 8px; }
.status-chip { font-size: 12px; font-weight: 700; border-radius: 8px; padding: 2px 8px; background: var(--line); }
.status-chip.ok { background: #dcfce7; color: #166534; }
.status-chip.soon { background: #ffedd5; color: #9a3412; }
.status-chip.expired { background: #fee2e2; color: #991b1b; }

/* Alerte radar (style Waze) */
.radar-alert { position: absolute; left: 50%; transform: translateX(-50%); top: calc(60px + var(--safe-top)); z-index: 1100;
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; border-radius: 16px;
  background: #fde047; color: #111; font-size: 17px; font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.35);
  white-space: nowrap; transition: background .2s, color .2s; }
.radar-alert .radar-icon { font-size: 22px; }
.radar-alert .radar-limit { width: 40px; height: 40px; border-radius: 50%; background: #fff; border: 5px solid #e11d2a;
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 900; color: #111; }
.radar-alert.over { background: #dc2626; color: #fff; animation: radarPulse .8s infinite; }
@keyframes radarPulse { 50% { transform: translateX(-50%) scale(1.06); } }
.history-bar:not(.hidden) ~ .radar-alert { top: calc(150px + var(--safe-top)); }

/* En-tete de liste + recherche */
.panel-head { display: flex; flex-direction: column; padding: 2px 4px 8px; }
.panel-head b { font-size: 16px; text-transform: uppercase; letter-spacing: .3px; }
.panel-head span { font-size: 12px; color: var(--muted); }
.search-box input { width: 100%; font-size: 15px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--text); margin-bottom: 8px; }
.counter { cursor: pointer; transition: transform .1s; }
.counter.active { outline: 2px solid var(--primary); }
.counter:active { transform: scale(.97); }
.device-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.device-meta b { color: var(--text); font-weight: 600; }
.device-right { text-align: right; white-space: nowrap; }
.device-right small { display: block; font-size: 11px; color: var(--muted); }
.sig { font-size: 11px; letter-spacing: -1px; }

/* Ordinateur (ecran large) : barre du haut + liste a gauche, comme Geo5lux */
.desk-nav { display: none; }
@media (min-width: 960px) {
  :root { --side: 380px; --nav: 52px; }
  .desk-nav { display: flex; position: absolute; top: 0; left: 0; right: 0; height: var(--nav); z-index: 1200;
    align-items: center; gap: 16px; padding: 0 16px; background: #111827; color: #e5e7eb; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
  .desk-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; color: #fff; width: calc(var(--side) - 32px); }
  .desk-brand img { width: 28px; height: 28px; border-radius: 6px; }
  .desk-links, .desk-right { display: flex; gap: 4px; }
  .desk-right { margin-left: auto; }
  .desk-nav button { background: none; border: 0; color: #e5e7eb; font-size: 14px; font-weight: 600; padding: 8px 12px;
    border-radius: 8px; cursor: pointer; }
  .desk-nav button:hover, .desk-nav button.on { background: #374151; color: #fde047; }
  body #main #map { top: var(--nav); }
  body #main .sheet { top: var(--nav); bottom: 0; left: 0; right: auto; width: var(--side); max-height: none !important;
    border-radius: 0; padding: 12px 14px 16px; box-shadow: 2px 0 10px rgba(0,0,0,.2); overflow-y: auto !important; }
  body #main .sheet.collapsed { max-height: none !important; overflow-y: auto !important; }
  body #main .sheet-handle { display: none; }
  body #main .topbar { top: calc(var(--nav) + 10px); }
  body #main .topbar #btn-menu { display: none; }
  body #main .livebar { top: calc(var(--nav) + 12px); left: calc(var(--side) + 56px); }
  body #main .maplibregl-ctrl-top-left { top: var(--nav); left: var(--side); }
  body #main .history-bar { top: calc(var(--nav) + 10px); left: calc(var(--side) + 10px); }
  body #main .sub-banner { top: calc(var(--nav) + 48px); left: calc(var(--side) + 10px); }
  body #main .radar-alert { left: calc(var(--side) + (100% - var(--side)) / 2); top: calc(var(--nav) + 56px); }
  body #main .history-bar:not(.hidden) ~ .radar-alert { top: calc(var(--nav) + 150px); }
  body #main .street { left: calc(var(--side) + (100% - var(--side)) / 2); }
  body #main .speedo { left: calc(var(--side) + 12px); }
  body .page { left: var(--side); top: var(--nav); box-shadow: -2px 0 10px rgba(0,0,0,.15); }
  body .toast { left: calc(var(--side) + (100% - var(--side)) / 2); }
}

/* Notifications */
.livebar { position: absolute; top: calc(14px + var(--safe-top)); left: 56px; z-index: 1000; display: flex; align-items: center; gap: 8px; }
.livebar .conn { position: static; }
.notif-btn { position: relative; border: none; background: var(--card); color: var(--text); font-size: 15px;
  padding: 4px 10px; border-radius: 12px; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 800; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px var(--card); }
.notif { border: 1px solid var(--line); border-left: 5px solid var(--red); border-radius: 12px; padding: 12px; }
.notif-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.notif-speed { font-size: 20px; font-weight: 900; color: var(--red); }
.notif-limit { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%;
  border: 4px solid #e11d2a; background: #fff; color: #111; font-weight: 900; font-size: 14px; flex: none; }
.notif-when { font-size: 15px; font-weight: 700; margin-top: 6px; }
.notif-when span { color: var(--muted); font-weight: 600; }
.notif .item-sub { margin-top: 4px; }
.notif .btn { margin-top: 10px; width: 100%; }
.notif.new { background: rgba(220, 38, 38, .06); }
.notif.theft { border-left-color: #7c3aed; }
.notif.info { border-left-color: var(--primary); }
.notif.info .notif-speed { color: var(--text); font-size: 17px; margin-top: 6px; }
details.item summary { cursor: pointer; list-style: none; }
details.item[open] summary { margin-bottom: 6px; }
.notif.theft .notif-speed { color: #7c3aed; font-size: 17px; }
.notif.maint { border-left-color: var(--green); }
.notif.maint .notif-speed { color: var(--text); font-size: 17px; }
.notif.maint.soon { border-left-color: var(--orange); }
.notif.maint.due { border-left-color: var(--red); }
.notif.maint.due .notif-when { color: var(--red); }
.pill { display: inline-block; background: var(--red); color: #fff; border-radius: 10px; padding: 1px 8px; font-size: 12px; margin-left: 6px; }

/* Texte arabe : police lisible, un peu plus grande, de droite a gauche */
.ar, .street-ar { font-family: "Noto Naskh Arabic", "Segoe UI", Tahoma, "Geeza Pro", "Arabic UI Text", sans-serif;
  unicode-bidi: isolate; direction: rtl; }
.ar { font-size: 1.12em; }
.street-ar { font-size: 19px; font-weight: 700; line-height: 1.35; margin-top: 2px; }
.device-name, .device-sub, .item-sub, .addr, .street-name, .street-sub { unicode-bidi: plaintext; }

/* Nom de la rue (style Waze) */
.street { position: absolute; left: 50%; transform: translateX(-50%); z-index: 1000; width: calc(100% - 140px); max-width: 560px; /* bande longue ; laisse libres les boutons a droite et la vitesse a gauche */
  background: #1f2a37; color: #fff; border-radius: 12px; padding: 5px 12px; text-align: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.35); pointer-events: none; transition: bottom .25s; }
.street-name { font-size: 13px; font-weight: 800; line-height: 1.25; display: flex; flex-wrap: wrap; justify-content: center; column-gap: 8px; }
.street-latin { overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.street-ar { font-size: 14px; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.street-sub { font-size: 11px; color: #9fd8ff; margin-top: 1px; line-height: 1.3; } /* adresse complete (quartier, ville), sur 2 lignes si besoin */
.street-sub:empty { display: none; }

/* Vitesse + limite (style Waze) */
.speedo { position: absolute; left: 12px; z-index: 1000; display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: bottom .25s; pointer-events: none; }
.limit-sign { width: 50px; height: 50px; border-radius: 50%; background: #fff; border: 6px solid #e11d2a;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.limit-sign b { color: #111; font-size: 18px; font-weight: 900; letter-spacing: -.5px; }
.limit-sign.blink { animation: blink 1s infinite; }
@keyframes blink { 50% { transform: scale(1.12); } }
/* Compteur de vitesse */
.speed-circle { width: 60px; height: 60px; border-radius: 50%; background: var(--card); color: var(--text);
  border: 4px solid var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,.3); display: flex; flex-direction: column;
  align-items: center; justify-content: center; transition: border-color .2s, background .2s; }
.speed-circle b { font-size: 20px; line-height: 1; }
.speed-circle small { font-size: 10px; font-weight: 600; color: var(--muted); }
.speed-circle.stopped { border-color: #94a3b8; }
.speed-circle.over { border-color: var(--red); background: var(--red); color: #fff; }
.speed-circle.over small { color: #fff; }
.maplibregl-ctrl-top-left { top: var(--safe-top); }
.maplibregl-popup-content { color: #0f172a; border-radius: 10px; }

/* Mini-fenetre d'une voiture sur la carte */
.car-pop .maplibregl-popup-content { padding: 12px 14px 10px; min-width: 240px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.car-pop .maplibregl-popup-close-button { font-size: 20px; width: 28px; height: 28px; color: #64748b; }
.cp-name { font-weight: 700; font-size: 15px; padding-right: 22px; margin-bottom: 4px; }
.cp-line { font-size: 13px; }
.cp-muted { color: #64748b; font-size: 12px; }
.cp-addr { font-size: 12px; color: #334155; margin: 6px 0; line-height: 1.35; }
.cp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.cp-grid div { background: #f1f5f9; border-radius: 8px; padding: 5px 6px; text-align: center; }
.cp-grid span { display: block; font-size: 10px; color: #64748b; }
.cp-grid b { font-size: 12px; }
.cp-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cp-btns button, .cp-btns a { border: none; background: #2563eb; color: #fff; border-radius: 8px; padding: 7px 4px;
  font-size: 12px; font-weight: 600; cursor: pointer; text-align: center; text-decoration: none; font-family: inherit;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-btns button:nth-child(2) { background: #0f172a; }
.cp-btns a { background: #16a34a; }
.cp-checks { display: flex; gap: 16px; margin-top: 8px; font-size: 13px; }
.cp-checks label { display: flex; flex-direction: row; align-items: center; gap: 6px; cursor: pointer; margin: 0; color: #0f172a; }
.cp-checks input { width: 16px; height: 16px; margin: 0; padding: 0; accent-color: #2563eb; }

/* Marqueur voiture */
.car-marker { display: flex; flex-direction: column; align-items: center; }
.car-arrow { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); color: #fff; font-size: 16px; }
.car-label { margin-top: 2px; background: rgba(15,23,42,.85); color: #fff; font-size: 11px; padding: 1px 6px;
  border-radius: 6px; white-space: nowrap; }

/* Panneau du bas */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1000; background: var(--card);
  border-radius: 18px 18px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,.25);
  max-height: 55vh; overflow-y: auto; padding: 6px 16px calc(16px + var(--safe-bottom)); transition: max-height .25s; }
.sheet.collapsed { max-height: 90px; overflow: hidden; }
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; cursor: pointer; }

.device { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.device:last-child { border-bottom: none; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.online { background: var(--green); }
.dot.offline { background: var(--red); }
.dot.unknown { background: var(--orange); }
.device-main { flex: 1; min-width: 0; }
.device-name { font-weight: 700; }
.device-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-speed { font-weight: 700; font-size: 15px; white-space: nowrap; }

.detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.detail-head h2 { margin: 0; font-size: 20px; flex: 1; }
.back { border: none; background: none; font-size: 22px; color: var(--text); cursor: pointer; padding: 4px 8px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 16px; font-weight: 700; margin-top: 2px; word-break: break-word; }
.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.actions .btn { width: 100%; }
.addr { font-size: 13px; color: var(--muted); margin: -4px 0 10px; }

/* Fiche d'un vehicule : version compacte, tout le tableau visible d'un coup */
.sheet:has(#device-detail:not(.hidden)):not(.collapsed) { max-height: 82vh; }
#device-detail .detail-head { margin-bottom: 4px; gap: 6px; }
#device-detail .detail-head h2 { font-size: 16px; }
#device-detail .addr { font-size: 12px; margin: 0 0 6px; }
/* Modele 6 : resume en 2 lignes + barre d'icones */
#device-detail .sum { margin-bottom: 6px; }
#device-detail .sum-line { font-size: 12px; line-height: 1.5; }
#device-detail .sum-line b { font-weight: 700; }
#device-detail .sum-odo { cursor: pointer; border-bottom: 1px dashed var(--muted); }
#device-detail .sum-sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
#device-detail .sum-park { color: #2563eb; font-weight: 600; }
#device-detail .ibar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px 0; border-top: 1px solid var(--line); padding-top: 6px; }
#device-detail .ibar > * { position: relative; background: none; border: 0; padding: 4px 0; color: var(--muted); font: inherit;
  font-size: 9.5px; text-align: center; text-decoration: none; cursor: pointer; border-radius: 8px; }
#device-detail .ibar > *:active { background: var(--line); }
#device-detail .ibar span { display: block; font-size: 17px; line-height: 1.2; margin-bottom: 1px; }
#device-detail .ibar .ib-red { color: #dc2626; }
#device-detail .ibar .ib-green { color: #16a34a; }
#device-detail .ibar .ib-on { color: #2563eb; font-weight: 700; }
#device-detail .ib-badge { position: absolute; top: 0; right: 18%; background: #dc2626; color: #fff; font-style: normal;
  font-size: 9px; border-radius: 999px; padding: 0 4px; line-height: 14px; }

/* Historique */
.history-bar { position: absolute; top: calc(10px + var(--safe-top)); left: 10px; right: 64px; z-index: 1000;
  background: var(--card); border-radius: 14px; padding: 10px 12px; box-shadow: 0 2px 10px rgba(0,0,0,.3);
  display: flex; flex-direction: column; gap: 8px; }
.history-info { font-size: 13px; }
.history-actions { display: flex; gap: 8px; }
#history-slider { width: 100%; }
.quick-range { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }

/* Modale */
.modal { position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,.5); display: flex;
  align-items: center; justify-content: center; padding: 16px; }
.modal-card { width: 100%; max-width: 380px; }
.modal-card h2 { margin-top: 0; font-size: 19px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
#modal-body label { margin-bottom: 10px; }

/* Toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(16px + var(--safe-top)); z-index: 4000;
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.4); max-width: calc(100vw - 32px); }

select { font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); width: 100%; }
input[type=number] { font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--text); width: 100%; }

/* Compteurs */
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px; }
.counter { border-radius: 12px; padding: 8px; text-align: center; font-size: 12px; color: var(--muted); border: 1px solid var(--line); }
.counter b { display: block; font-size: 20px; }
.counter.moving b { color: var(--green); }
.counter.stopped b { color: var(--primary); }
.counter.offline b { color: var(--red); }
.group-title { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin: 12px 4px 0; }

/* Menu */
.drawer-bg { position: fixed; inset: 0; z-index: 2500; background: rgba(0,0,0,.45); }
.drawer { position: absolute; top: 0; bottom: 0; left: 0; width: min(300px, 82vw); border-radius: 0 16px 16px 0;
  padding: calc(20px + var(--safe-top)) 12px 20px; display: flex; flex-direction: column; gap: 4px; }
.drawer-head { display: flex; gap: 12px; align-items: center; padding: 0 8px 16px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.drawer-head img { width: 44px; height: 44px; border-radius: 10px; }
.drawer-head .muted { font-size: 13px; word-break: break-all; }
.menu-item { text-align: left; background: none; border: none; color: var(--text); font-size: 16px; padding: 14px 10px;
  border-radius: 10px; cursor: pointer; }
.menu-item:active { background: var(--line); }
.danger-text { color: var(--red); margin-top: auto; }

/* Pages */
.page { position: fixed; inset: 0; z-index: 2000; background: var(--card); display: flex; flex-direction: column; }
.page-head { display: flex; align-items: center; gap: 6px; padding: calc(10px + var(--safe-top)) 10px 10px;
  border-bottom: 1px solid var(--line); }
.page-head h2 { margin: 0; font-size: 19px; }
.page-body { flex: 1; overflow-y: auto; padding: 16px 16px calc(24px + var(--safe-bottom)); }
.page-body > * + * { margin-top: 12px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; }
.tab { flex: 1; white-space: nowrap; padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  background: none; color: var(--text); font-weight: 600; cursor: pointer; font-size: 14px; }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
/* Telephone : les champs de date ne doivent pas depasser l'ecran */
input, select { min-width: 0; max-width: 100%; }
input[type=datetime-local] { font-size: 14px; padding: 10px 8px; }
.page-body { overflow-x: hidden; }
.item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; }
.item-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.item-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.item-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; background: var(--line); border-radius: 8px; padding: 3px 8px; }
.totals { background: var(--line); border-radius: 12px; padding: 12px; font-weight: 600; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px;
  border-bottom: 1px solid var(--line); }
.switch-row small { display: block; color: var(--muted); font-size: 12px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 30px; transition: .2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff;
  border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(20px); }
.inline { display: flex; gap: 8px; align-items: flex-end; }
.inline label { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; }

.leaflet-control-attribution { font-size: 9px; }
.leaflet-top.leaflet-left { top: var(--safe-top); }

/* Notifications push (page Notifications) */
.push-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; background: var(--card); }
.push-box.on { border-color: #2e7d32; }
.push-box small { color: var(--muted, #6b7280); }
.push-actions { display: flex; gap: 6px; }

/* Mode parking */
.park-marker { width: 26px; height: 26px; border-radius: 6px; background: #1565c0; color: #fff; font: 800 16px/26px system-ui, sans-serif;
  text-align: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.park-badge { display: inline-block; min-width: 18px; height: 18px; border-radius: 4px; background: #1565c0; color: #fff;
  font-size: 12px; font-weight: 800; line-height: 18px; text-align: center; vertical-align: 2px; }
.btn.park-on { background: #1565c0; color: #fff; border-color: #1565c0; }

/* Connexion : comptes enregistres sur cet appareil */
.saved-accounts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 4px 0 8px; }
.chip-account { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 18px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-account:hover { border-color: #2563eb; }
.link-small { background: none; border: none; color: var(--muted); font-size: 12px; text-decoration: underline; cursor: pointer; width: 100%; }
.small-list { margin: 6px 0 10px 18px; padding: 0; font-size: 14px; line-height: 1.5; }

/* Qualite du signal GPS / GSM */
.sig-hud { display: flex; align-items: center; gap: 10px; border: none; cursor: pointer; font: inherit; color: var(--text);
  background: var(--card); border-radius: 18px; padding: 5px 10px; box-shadow: 0 2px 8px rgba(0,0,0,.18); font-size: 13px; white-space: nowrap; }
.sig-mob { gap: 4px; padding: 5px 9px; }
#desk-nav .sig-hud { box-shadow: none; background: rgba(255,255,255,.08); color: inherit; margin-left: 6px; }
.sig-item { display: inline-flex; align-items: center; gap: 5px; }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 15px; vertical-align: -2px; }
.bars i { width: 4px; border-radius: 1px; background: rgba(127,127,127,.35); }
.bars.l4 i.on, .bars.l3 i.on { background: #16a34a; }
.bars.l2 i.on { background: #f59e0b; }
.bars.l1 i.on { background: #dc2626; }
.sig-h { margin: 10px 0 6px; display: flex; align-items: center; gap: 8px; }
.sig-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.sig-row b { text-align: right; }
@media (min-width: 960px) { .sig-mob { display: none !important; } }

/* kilometrage modifiable */
#odo-stat { cursor: pointer; }
#odo-stat .odo-edit { font-size: 12px; opacity: .7; }


/* video du trajet */
.video-progress { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom, 0px)); transform: translateX(-50%); z-index: 3000;
  width: min(360px, calc(100% - 32px)); background: var(--card, #1e293b); color: inherit; border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.vid-bar { height: 8px; border-radius: 4px; background: rgba(148,163,184,.25); overflow: hidden; margin: 8px 0; }
.vid-bar > div { height: 100%; background: #ff9800; transition: width .3s; }

/* compte demo */
.demo-box .btn { width: 100%; }
.demo-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 14px 0 10px; }
.demo-or::before, .demo-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.demo-pill { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(8px + var(--safe-bottom)); z-index: 1500;
  background: #7c3aed; color: #fff; border: 0; border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.3); cursor: pointer; }

/* Serveur (PC) eteint : bandeau en haut, l'application reste utilisable avec les dernieres donnees */
.server-down { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 6px); left: 50%; transform: translateX(-50%);
  z-index: 3000; max-width: calc(100% - 24px); background: #b45309; color: #fff; font-size: 12px; font-weight: 600;
  padding: 7px 12px; border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.3); text-align: center; pointer-events: none; }
