/* ==========================================================================
   PassDrive — Front office client
   Concept : "parking de nuit" — fond nuit, un seul accent couleur phare,
   plaques d'immatriculation dessinées comme les vraies.
   ========================================================================== */
:root {
  --night: #0a0d12;
  --night-2: #0f141b;
  --panel: #141b24;
  --panel-2: #1a2330;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #eaf0f6;
  --muted: #8b98a8;
  --beam: #ffc861;          /* couleur des phares */
  --beam-soft: rgba(255, 200, 97, 0.14);
  --ice: #82c7ff;
  --ok: #5fe0a0;
  --ok-soft: rgba(95, 224, 160, 0.12);
  --danger: #ff7a7a;
  --danger-soft: rgba(255, 122, 122, 0.12);
  --font: "Archivo", "Heebo", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --radius: 18px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(130, 199, 255, 0.07), transparent 60%),
    radial-gradient(800px 400px at 50% 110%, rgba(255, 200, 97, 0.05), transparent 60%),
    var(--night);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { max-width: 100%; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--beam); outline-offset: 3px; border-radius: 6px; }

.display { font-stretch: 125%; font-weight: 800; letter-spacing: -0.01em; line-height: 1.05; text-wrap: balance; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }

/* --- Structure ------------------------------------------------------------ */
.app { max-width: 560px; margin: 0 auto; padding-inline: 18px; padding-block: 0 110px; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding-block: 16px; background: linear-gradient(var(--night) 60%, transparent);
}
.wordmark { display: flex; align-items: center; gap: 10px; text-decoration: none; font-stretch: 125%; font-weight: 800; letter-spacing: .02em; }
.wordmark svg { width: 28px; height: 28px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line-strong);
  font-weight: 700; font-size: 14px;
}

.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 4px; padding: 6px;
  background: rgba(20, 27, 36, 0.82); backdrop-filter: blur(16px);
  border: 1px solid var(--line-strong); border-radius: 999px; z-index: 20;
}
.tabbar a, .tabbar button {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px;
  text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 600;
  background: none; border: 0; cursor: pointer; transition: color .2s, background .2s;
}
.tabbar a.on { background: var(--panel-2); color: var(--text); }
.tabbar a:hover, .tabbar button:hover { color: var(--text); }
.tabbar svg { width: 18px; height: 18px; }
.tabbar form { margin: 0; }

/* --- Messages ----------------------------------------------------------- */
.flash { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash div { padding: 12px 16px; border-radius: 12px; font-size: 14px; background: var(--panel); border: 1px solid var(--line); }
.flash .success { border-color: rgba(95, 224, 160, .35); color: var(--ok); }
.flash .error { border-color: rgba(255, 122, 122, .35); color: var(--danger); }

/* --- Apparition en cascade ------------------------------------------------ */
.rise { animation: rise .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* --- Plaques d'immatriculation ------------------------------------------ */
.plate {
  display: inline-flex; align-items: stretch; height: 30px; border-radius: 5px; overflow: hidden;
  border: 1.5px solid #1b1b1b; box-shadow: 0 2px 0 rgba(0,0,0,.35);
  font-family: var(--font); font-stretch: 75%; font-weight: 700; font-size: 18px; letter-spacing: .04em;
  color: #111; white-space: nowrap;
}
.plate .band {
  width: 20px; background: #1d3fa6; color: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; padding-bottom: 2px; font-size: 9px; font-stretch: 100%;
  letter-spacing: 0;
}
.plate .band i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px dotted #ffd84a; margin-bottom: auto; margin-top: 4px; }
.plate .num { display: flex; align-items: center; padding: 0 10px; background: #fff; }
.plate.il .num { background: #f7c900; }
.plate.lg { height: 44px; font-size: 27px; }
.plate.lg .band { width: 28px; font-size: 11px; }
.plate.lg .band i { width: 13px; height: 13px; }

/* --- Logos de marque ----------------------------------------------------- */
.logo-chip {
  width: 56px; height: 56px; border-radius: 16px; flex-shrink: 0;
  background: #f4f6f8; display: grid; place-items: center; padding: 8px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.logo-chip img { width: 100%; height: 100%; object-fit: contain; }
.logo-chip.xl { width: 84px; height: 84px; border-radius: 24px; padding: 12px; }

/* --- Garage --------------------------------------------------------------- */
.hello { padding-block: 18px 22px; display: flex; flex-direction: column; gap: 6px; }
.hello h1 { margin: 0; font-size: clamp(30px, 8vw, 40px); }
.cars { display: flex; flex-direction: column; gap: 12px; }
.car-card {
  display: flex; align-items: center; gap: 16px; padding: 16px; text-decoration: none;
  background: linear-gradient(180deg, var(--panel), var(--night-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: transform .35s var(--ease), border-color .35s, box-shadow .35s;
}
.car-card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: 0 18px 40px -20px rgba(0,0,0,.8); }
.car-card .info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.car-card .name { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.car-card .name small { color: var(--muted); font-weight: 500; }
.car-card .go { color: var(--muted); transition: transform .35s var(--ease), color .35s; }
.car-card:hover .go { transform: translateX(4px); color: var(--beam); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; width: fit-content; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.ok { color: var(--ok); background: var(--ok-soft); }
.status.ok::before { animation: blink 2.4s infinite; }
.status.off { color: var(--muted); background: rgba(255,255,255,.05); }
.status.wait { color: var(--beam); background: var(--beam-soft); }
.status.bad { color: var(--danger); background: var(--danger-soft); }
@keyframes blink { 50% { opacity: .35; } }

.empty { text-align: center; padding: 48px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }

.notice {
  display: flex; gap: 14px; align-items: center; padding: 14px 16px; margin-bottom: 16px;
  border-radius: 14px; background: var(--beam-soft); border: 1px solid rgba(255, 200, 97, .3); text-decoration: none;
}
.notice strong { display: block; color: var(--beam); }
.notice span { font-size: 14px; color: var(--muted); }

/* --- Page véhicule : la scène ------------------------------------------- */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 14px; padding-block: 4px 12px; }
.vehicle-head { display: flex; align-items: center; gap: 16px; }
.vehicle-head h1 { margin: 0; font-size: clamp(24px, 6.5vw, 32px); }
.vehicle-head .sub { color: var(--muted); font-size: 14px; }

.stage {
  position: relative; margin-top: 22px; border-radius: 28px; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #18212d 0%, var(--night-2) 70%);
  border: 1px solid var(--line); padding: 28px 18px 26px;
  display: flex; flex-direction: column; align-items: center; gap: 22px;
}
.stage::after { /* sol réfléchissant */
  content: ""; position: absolute; left: 10%; right: 10%; bottom: 168px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}

.car-svg { width: min(100%, 360px); height: auto; overflow: visible; }
.car-svg .body { fill: #1f2a37; stroke: #3a4757; stroke-width: 1.5; }
.car-svg .glass { fill: #0d1219; stroke: #3a4757; stroke-width: 1.2; }
.car-svg .grille { fill: #0b0f15; }
.car-svg .lamp { fill: #3a4452; transition: fill .4s; }
.car-svg .beam { fill: url(#beamGrad); opacity: 0; transform-origin: center top; transition: opacity .5s; }
.car-svg .wheel { fill: #07090c; }
.car-svg .lockpad { transition: transform .5s var(--ease); }
.car-svg .shackle { fill: none; stroke: var(--muted); stroke-width: 3; stroke-linecap: round; transition: transform .5s var(--ease), stroke .3s; }
.car-svg .lockbody { fill: var(--muted); transition: fill .3s; }

.stage.unlocked .lamp { fill: var(--beam); filter: drop-shadow(0 0 10px var(--beam)); }
.stage.unlocked .beam { opacity: .55; animation: beamOn 1.2s var(--ease); }
.stage.unlocked .shackle { transform: translate(6px, -6px) rotate(18deg); stroke: var(--ok); transform-box: fill-box; transform-origin: left bottom; }
.stage.unlocked .lockbody { fill: var(--ok); }
@keyframes beamOn { 0% { opacity: 0; } 15% { opacity: .9; } 30% { opacity: .2; } 45% { opacity: .9; } 100% { opacity: .55; } }

/* Bouton "maintenir pour ouvrir et démarrer" */
.hold {
  position: relative; width: 148px; height: 148px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 50% 35%, #263243, #121923 70%);
  box-shadow: 0 0 0 1px var(--line-strong), 0 20px 40px -18px #000, inset 0 1px 0 rgba(255,255,255,.08);
  color: var(--text); display: grid; place-items: center; user-select: none; -webkit-user-select: none;
  touch-action: none; transition: transform .2s var(--ease);
}
.hold:active { transform: scale(.97); }
.hold:disabled { cursor: not-allowed; opacity: .45; }
.hold .ring { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); transform: rotate(-90deg); }
.hold .ring circle { fill: none; stroke-width: 4; }
.hold .ring .track { stroke: rgba(255,255,255,.06); }
.hold .ring .prog { stroke: var(--beam); stroke-linecap: round; stroke-dasharray: 490; stroke-dashoffset: 490; filter: drop-shadow(0 0 6px var(--beam)); }
.hold .label { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.hold .label svg { width: 36px; height: 36px; }
.hold .pulse { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--ok); opacity: 0; pointer-events: none; }

.stage.checking .hold .label svg { animation: spin 1.1s linear infinite; }
.stage.unlocked .hold { box-shadow: 0 0 0 1px rgba(95,224,160,.5), 0 0 60px -10px rgba(95,224,160,.45); }
.stage.unlocked .hold .pulse { animation: ripple 1.6s var(--ease) 3; }
.stage.error .hold { animation: shake .5s; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ripple { from { opacity: .8; transform: scale(1); } to { opacity: 0; transform: scale(1.9); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.stage-status { min-height: 48px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.stage-status strong { font-size: 17px; }
.stage-status span { color: var(--muted); font-size: 14px; }
.stage.unlocked .stage-status strong { color: var(--ok); }
.stage.error .stage-status strong { color: var(--danger); }

/* Cartes d'information */
.cards { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card .k { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.card .v { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card .v.mono { font-family: var(--mono); font-size: 15px; }

.section-title { margin: 28px 0 10px; font-size: 13px; font-family: var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 400; }
.logs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.logs li { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.logs li:last-child { border-bottom: 0; }
.logs .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.logs .dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.logs .dot.bad { background: var(--danger); }
.logs .when { margin-inline-start: auto; color: var(--muted); font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.logs .what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Écrans d'authentification ------------------------------------------ */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 32px 22px; text-align: center; }
.auth h1 { margin: 0; font-size: clamp(32px, 9vw, 46px); }
.auth p { margin: 0; color: var(--muted); max-width: 34ch; }
.auth .wordmark { font-size: 15px; }

.scanner { position: relative; width: 168px; height: 168px; display: grid; place-items: center; }
.scanner .corners { position: absolute; inset: 0; }
.scanner .corners path { fill: none; stroke: var(--beam); stroke-width: 3; stroke-linecap: round; }
.scanner .print { width: 96px; height: 96px; }
.scanner .print path { fill: none; stroke: var(--ice); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 160; stroke-dashoffset: 160; animation: draw 2.4s var(--ease) forwards; animation-delay: calc(var(--i) * 120ms); }
.scanner .bar { position: absolute; left: 18px; right: 18px; height: 2px; top: 18px; background: linear-gradient(90deg, transparent, var(--beam), transparent); box-shadow: 0 0 14px var(--beam); animation: scan 2.6s ease-in-out infinite; }
.scanner.busy .bar { animation-duration: .9s; }
.scanner.done .print path { stroke: var(--ok); }
.scanner.done .bar { display: none; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes scan { 0%, 100% { top: 18px; } 50% { top: calc(100% - 20px); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px 24px; border-radius: 14px; border: 0; cursor: pointer; text-decoration: none;
  font-weight: 700; font-size: 16px; transition: transform .2s var(--ease), box-shadow .3s, background .3s;
}
.btn.primary { background: var(--beam); color: #1a1405; box-shadow: 0 10px 30px -10px rgba(255, 200, 97, .6); }
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -10px rgba(255, 200, 97, .75); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line-strong); }
.btn:disabled { opacity: .5; cursor: progress; transform: none; }
.btn svg { width: 20px; height: 20px; }
.btn.block { width: 100%; }
.auth .actions { display: flex; flex-direction: column; gap: 12px; width: min(100%, 340px); }
.auth .link { color: var(--muted); font-size: 14px; }
.auth .link a { color: var(--beam); }
.feedback { min-height: 22px; font-size: 14px; color: var(--danger); }
.feedback.ok { color: var(--ok); }

/* --- Formulaires ---------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 16px; width: 100%; text-align: left; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--text); font: inherit; font-size: 16px;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus { outline: none; border-color: var(--beam); box-shadow: 0 0 0 4px var(--beam-soft); }
.field .err, .errorlist { color: var(--danger); font-size: 13px; margin: 0; padding: 0; list-style: none; }
.row-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }

.captures { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.capture {
  position: relative; aspect-ratio: 1.586; max-width: 100%; border-radius: 14px; overflow: hidden; cursor: pointer;
  border: 1.5px dashed var(--line-strong); background: var(--panel);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); font-size: 13px; font-weight: 600; transition: border-color .3s, color .3s;
}
.capture:hover { border-color: var(--beam); color: var(--beam); }
.capture svg { width: 28px; height: 28px; }
.capture input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.capture img.preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.capture.filled { border-style: solid; border-color: var(--ok); }
.capture .tag { position: absolute; inset-inline-start: 8px; bottom: 8px; background: rgba(0,0,0,.65); color: #fff; padding: 2px 8px; border-radius: 6px; font-size: 11px; z-index: 1; }

.license-card {
  position: relative; border-radius: 20px; padding: 20px; overflow: hidden;
  background: linear-gradient(135deg, #f6d9e3 0%, #e7eef9 55%, #dff0e6 100%); color: #1a1f2b;
  aspect-ratio: 1.586; max-width: 100%; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 24px 50px -24px rgba(0,0,0,.9);
}
.license-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.55) 45%, transparent 60%); transform: translateX(-100%); animation: sheen 3.5s 1s var(--ease) infinite; }
@keyframes sheen { 40%, 100% { transform: translateX(100%); } }
.license-card .t { font-stretch: 125%; font-weight: 800; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.license-card .n { font-family: var(--mono); font-size: 18px; font-weight: 600; }
.license-card .meta { display: flex; justify-content: space-between; font-size: 13px; gap: 10px; }
.license-card .meta b { display: block; font-size: 15px; }

@media (max-width: 380px) {
  .cards, .captures, .row-2 { grid-template-columns: minmax(0, 1fr); }
  .tabbar a span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* --- Langues : drapeaux + sens de lecture (hébreu = droite à gauche) ----- */
.topbar-end { display: flex; align-items: center; gap: 10px; }
.flag { width: 22px; height: 15px; border-radius: 3px; flex-shrink: 0; box-shadow: 0 0 0 1px rgba(255,255,255,.18); overflow: hidden; display: block; }
.lang { position: relative; }
.lang summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 7px;
  padding: 7px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-strong);
  font-family: var(--mono); font-size: 12px; font-weight: 600; transition: border-color .2s;
}
.lang summary::-webkit-details-marker { display: none; }
.lang summary:hover { border-color: var(--beam); }
.lang .chev { transition: transform .3s var(--ease); color: var(--muted); }
.lang[open] .chev { transform: rotate(180deg); }
.lang-menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); z-index: 30; margin: 0;
  min-width: 180px; padding: 6px; display: flex; flex-direction: column; gap: 2px;
  background: rgba(20, 27, 36, .96); backdrop-filter: blur(16px);
  border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 24px 50px -20px #000;
  transform-origin: top right; animation: pop .25s var(--ease);
}
[dir="rtl"] .lang-menu { transform-origin: top left; }
@keyframes pop { from { opacity: 0; transform: scale(.92) translateY(-6px); } }
.lang-menu button {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; border-radius: 10px;
  background: none; color: var(--text); cursor: pointer; font-size: 15px; text-align: start;
}
.lang-menu button:hover { background: var(--panel-2); }
.lang-menu button.on { background: var(--beam-soft); color: var(--beam); font-weight: 700; }
.lang-menu button .flag { width: 26px; height: 18px; }
.auth-lang { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); inset-inline-end: 16px; z-index: 30; }

[dir="rtl"] .flip { transform: scaleX(-1); }
[dir="rtl"] .car-card:hover .go { transform: scaleX(-1) translateX(4px); }
[dir="rtl"] .display { font-stretch: 100%; letter-spacing: 0; }
[dir="rtl"] .eyebrow, [dir="rtl"] .section-title, [dir="rtl"] .card .k { letter-spacing: .04em; }

/* --- Application installable (PWA) ---------------------------------------- */
.auth-lang { display: flex; align-items: center; gap: 8px; }
.install-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(255, 200, 97, .45); background: var(--beam-soft); color: var(--beam);
  font-size: 12.5px; font-weight: 700; animation: chipIn .5s var(--ease);
}
.install-chip:hover { background: rgba(255, 200, 97, .22); }
@keyframes chipIn { from { opacity: 0; transform: scale(.8); } }
@media (max-width: 380px) { .install-chip span { display: none; } }

.install {
  position: fixed; z-index: 50; left: 12px; right: 12px; margin: 0 auto; max-width: 520px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  padding: 18px; border-radius: 24px; display: flex; flex-direction: column; gap: 14px;
  background: linear-gradient(180deg, #1b2431, #121922); border: 1px solid var(--line-strong);
  box-shadow: 0 30px 80px -20px #000, 0 0 0 1px rgba(255, 200, 97, .08);
  transform: translateY(calc(100% + 40px)); transition: transform .45s var(--ease);
}
.install.show { transform: none; }
.install-head { display: flex; align-items: center; gap: 14px; }
.install-head > div { flex: 1; min-width: 0; }
.install-head h2 { margin: 0; font-size: 18px; font-stretch: 112%; }
.install-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.install-icon { width: 56px; height: 56px; border-radius: 14px; box-shadow: 0 8px 20px -8px #000; flex-shrink: 0; }
.install-close { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; align-self: flex-start; }
.install-later { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px; }
.install[data-mode="android"] .install-ios, .install[data-mode="ios"] .install-android { display: none; }
.install-ios { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.install-ios li { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.install-ios li > span:last-child { min-width: 0; }
.install-ios .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--beam); color: #1a1405; font-weight: 800; font-size: 13px; }
.install-ios b { color: var(--text); }
.ios-share { width: 20px; height: 20px; vertical-align: -4px; color: var(--ice); }
.ios-arrow { justify-content: center; color: var(--beam); animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(6px); } }
.install-toast {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); top: calc(16px + env(safe-area-inset-top, 0px));
  padding: 12px 18px; border-radius: 12px; background: var(--ok); color: #05210f; font-weight: 700; font-size: 14px;
  box-shadow: 0 16px 40px -14px #000; animation: rise .5s var(--ease);
}

/* Ouverte depuis l'écran d'accueil : plein écran, on respecte l'encoche */
@media (display-mode: standalone) {
  .topbar { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
  .install-chip { display: none !important; }
  body { overscroll-behavior-y: none; -webkit-user-select: none; user-select: none; }
  input, textarea { -webkit-user-select: text; user-select: text; }
}

/* --- Liaison Bluetooth avec le boîtier : voyant rouge / orange / vert ----- */
.link {
  --led: var(--danger);
  margin-top: 20px; display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border-radius: 18px; background: var(--panel); border: 1px solid var(--line);
  transition: border-color .4s;
}
.link[data-state="green"] { --led: var(--ok); border-color: rgba(95, 224, 160, .35); }
.link[data-state="orange"] { --led: var(--beam); border-color: rgba(255, 200, 97, .3); }
.link[data-state="red"] { border-color: rgba(255, 122, 122, .3); }
.led {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; background: var(--led);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--led) 18%, transparent), 0 0 14px var(--led);
  transition: background .4s, box-shadow .4s;
}
.link[data-state="green"] .led { animation: breathe 2.6s ease-in-out infinite; }
.link[data-state="orange"] .led { animation: blinkLed .7s steps(2, jump-none) infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--led) 10%, transparent), 0 0 22px var(--led); } }
@keyframes blinkLed { 50% { opacity: .25; } }
.link-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.link-text b { font-size: 15px; }
.link[data-state="green"] .link-text b { color: var(--ok); }
.link[data-state="red"] .link-text b { color: var(--danger); }
.link-text small { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.link-btn {
  flex-shrink: 0; padding: 9px 14px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--beam); color: #1a1405; font-weight: 800; font-size: 13px;
}
.link-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; padding-inline: 4px; font-size: 12.5px; color: var(--muted); }
.link-tools label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.link-tools input { accent-color: var(--beam); }
.link-tools button { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 12.5px; }

.keycard { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; position: relative; overflow: hidden; }
.keycard-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.keycard small { font-size: 12.5px; }
.btn-renew {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid rgba(255, 200, 97, .45); background: var(--beam-soft); color: var(--beam); font-weight: 800; font-size: 13.5px;
}
.btn-renew svg { width: 17px; height: 17px; }
.btn-renew:disabled { opacity: .4; cursor: not-allowed; }
.keycard.sent { animation: keySent 1.2s var(--ease); }
.keycard.sent::after {
  content: ""; position: absolute; top: 50%; left: 0; width: 40%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--beam)); box-shadow: 0 0 10px var(--beam);
  animation: sendLine 1s var(--ease) forwards;
}
@keyframes keySent { 30% { border-color: var(--beam); box-shadow: 0 0 30px -8px rgba(255, 200, 97, .6); } }
@keyframes sendLine { from { transform: translateX(-100%); opacity: 1; } to { transform: translateX(260%); opacity: 0; } }
.statuses { display: flex; gap: 6px; flex-wrap: wrap; }

/* --- Démarrage du moteur : bouton son + voiture qui vibre au ralenti ------- */
.stage { position: relative; }
.engine-sound {
  position: absolute; top: 14px; inset-inline-end: 14px; z-index: 2; width: 36px; height: 36px;
  border-radius: 50%; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
  display: grid; place-items: center; cursor: pointer;
}
.engine-sound svg { width: 18px; height: 18px; }
.engine-sound .mute, .engine-sound.off .on { display: none; }
.engine-sound.off .mute { display: block; color: var(--muted); }
.stage.running .car-svg { animation: idle .09s linear infinite; }
.stage.running .car-svg .body { filter: drop-shadow(0 6px 18px rgba(255, 200, 97, .25)); }
@keyframes idle { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(.6px, -.8px); } 50% { transform: translate(-.5px, .5px); } 75% { transform: translate(.4px, .7px); } }

/* --- Photo du modèle exact (Wikimedia Commons) ----------------------------- */
.car-photo {
  position: relative; margin: 0; width: 100%; aspect-ratio: 16 / 10; max-width: 100%;
  border-radius: 20px; overflow: hidden; background: var(--night-2);
  box-shadow: 0 24px 50px -24px #000, inset 0 0 0 1px var(--line);
}
.car-photo img { width: 100%; height: 100%; object-fit: cover; display: block; filter: brightness(.82) saturate(1.05); transition: filter .6s var(--ease); }
.car-photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(10, 13, 18, .75)); pointer-events: none; }
.photo-glow {
  position: absolute; inset: 0; opacity: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(60% 45% at 50% 70%, rgba(255, 200, 97, .45), transparent 70%);
  mix-blend-mode: screen; transition: opacity .5s;
}
.lockbadge {
  position: absolute; z-index: 2; top: 12px; inset-inline-start: 12px; width: 26px; height: 36px;
  padding: 5px; box-sizing: content-box; border-radius: 12px; background: rgba(10, 13, 18, .7); backdrop-filter: blur(6px);
}
.lockbadge .shackle { fill: none; stroke: var(--muted); stroke-width: 3; stroke-linecap: round; transition: transform .5s var(--ease), stroke .3s; transform-box: fill-box; transform-origin: left bottom; }
.lockbadge .lockbody { fill: var(--muted); transition: fill .3s; }
.stage.unlocked .car-photo img { filter: brightness(1.05) saturate(1.1); }
.stage.unlocked .photo-glow { opacity: 1; animation: beamOn 1.2s var(--ease); }
.stage.unlocked .lockbadge .shackle { transform: translate(5px, -5px) rotate(18deg); stroke: var(--ok); }
.stage.unlocked .lockbadge .lockbody { fill: var(--ok); }
.stage.running .car-photo { animation: idle .09s linear infinite; }
.photo-credit { align-self: stretch; text-align: end; margin-top: -14px; font-size: 10.5px; color: var(--muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-credit:hover { color: var(--text); text-decoration: underline; }
.stage::after { display: none; }

.car-thumb { width: 92px; height: 64px; border-radius: 12px; overflow: hidden; flex-shrink: 0; background: var(--night-2); box-shadow: inset 0 0 0 1px var(--line); }
.car-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 380px) { .car-thumb { display: none; } }

/* --- Position GPS de la voiture -------------------------------------------- */
.map-card { margin-top: 14px; padding: 14px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.map-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.map-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.map-text .k { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.map-text b { font-size: 16px; }
.map-text small { color: var(--muted); font-size: 12.5px; }
.map { height: 240px; max-width: 100%; border-radius: 14px; overflow: hidden; background: var(--night-2); z-index: 0; }
.map-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.map-actions a { flex: 1; min-width: 140px; text-align: center; padding: 10px; border-radius: 10px; border: 1px solid var(--line-strong); color: var(--text); text-decoration: none; font-weight: 700; font-size: 13.5px; }
.map-actions a:hover { border-color: var(--beam); color: var(--beam); }
.map-note { margin: 0; font-size: 12px; color: var(--muted); }
.leaflet-container { font-family: var(--font); background: var(--night-2); }
.leaflet-control-attribution { background: rgba(10, 13, 18, .7) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.car-pin { position: relative; }
.pin-dot { position: absolute; inset: 8px; border-radius: 50%; background: var(--beam); color: #1a1405; display: grid; place-items: center; box-shadow: 0 0 0 3px rgba(10, 13, 18, .9), 0 6px 16px rgba(0, 0, 0, .6); }
.pin-dot svg { width: 16px; height: 16px; }
.pin-pulse { position: absolute; inset: 0; border-radius: 50%; background: rgba(255, 200, 97, .35); animation: pinPulse 2s ease-out infinite; }
@keyframes pinPulse { from { transform: scale(.5); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }

.plan { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--ice); background: rgba(130, 199, 255, .1); border: 1px solid rgba(130, 199, 255, .25); }

/* --- Aide (tickets) ---------------------------------------------------------- */
.field textarea, .field select { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); font: inherit; font-size: 16px; resize: vertical; }
.field textarea:focus, .field select:focus { outline: none; border-color: var(--beam); box-shadow: 0 0 0 4px var(--beam-soft); }
.ticket-row { display: flex; align-items: center; gap: 12px; width: 100%; text-decoration: none; }
.ticket-row .status { margin-inline-start: auto; }
.thread { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.bubble { max-width: 86%; padding: 12px 14px; border-radius: 16px; display: flex; flex-direction: column; gap: 4px; font-size: 14.5px; }
.bubble p { margin: 0; overflow-wrap: anywhere; }
.bubble small { color: var(--muted); font-size: 11px; font-family: var(--mono); }
.bubble.mine { align-self: flex-end; background: var(--beam-soft); border: 1px solid rgba(255, 200, 97, .25); border-end-end-radius: 4px; }
.bubble.agency { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line-strong); border-end-start-radius: 4px; }
.bubble.agency b { color: var(--ice); font-size: 12.5px; }
.btn.ghost.block { width: 100%; }

/* --- Permis : photos + modification ------------------------------------------ */
.license-photos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.license-photos a { position: relative; display: block; aspect-ratio: 1.586; border-radius: 14px; overflow: hidden; border: 1px solid var(--line-strong); background: var(--panel); }
.license-photos img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s var(--ease); }
.license-photos a:hover img { transform: scale(1.04); }
.license-photos .tag { position: absolute; inset-inline-start: 8px; bottom: 8px; background: rgba(0,0,0,.65); color: #fff; padding: 2px 8px; border-radius: 6px; font-size: 11px; }
.edit-license { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.edit-license > summary { list-style: none; cursor: pointer; }
.edit-license > summary::-webkit-details-marker { display: none; }
.edit-license[open] > summary { border-color: var(--beam); color: var(--beam); }
.edit-note { margin: 10px 0; font-size: 13.5px; }
