:root {
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f9fafb;
  --card: #ffffff;
  --amber: #0e9f9a;        /* couleur de marque : turquoise océan (nom conservé pour ne pas toucher aux règles) */
  --amber-dark: #0b7f7b;
  --accent: #f97316;       /* accent : orange vif (destination, étoiles, total) */
  --brand-light: #2dd4bf;  /* turquoise clair, pour les fonds sombres */
  --green: #16a34a;
  --red: #dc2626;
  --blue: #2563eb;
  --tabbar-h: 58px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

.screen { position: fixed; inset: 0; }

/* ------------------------------------------------------------ connexion */
.auth {
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px);
  background: var(--ink); color: #fff; overflow: auto;
}
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-logo { border-radius: 20px; margin-bottom: 8px; }
.auth h1 { margin: 6px 0 4px; font-size: 32px; letter-spacing: -.5px; }
.auth h1 span, .brand span { color: var(--brand-light); }
.auth-tagline { margin: 0 0 22px; color: #9ca3af; font-size: 15px; }
.auth form { text-align: left; }
.auth label { display: block; margin: 14px 0 6px; font-size: 13px; color: #d1d5db; font-weight: 600; }
.auth input {
  width: 100%; height: 50px; padding: 0 14px; border-radius: 12px;
  border: 2px solid transparent; background: #fff; color: var(--ink); font-size: 17px;
}
.auth input:focus { outline: none; border-color: var(--amber); }
.hint { margin: 6px 2px 0; font-size: 12.5px; color: #9ca3af; }
.legal { margin: 18px 0 0; font-size: 12px; color: #6b7280; }
.error { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; background: #fee2e2; color: #991b1b; }
.auth .btn { margin-top: 18px; }

/* ------------------------------------------------------------ boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 18px; border: 0; border-radius: 14px;
  font-size: 16px; font-weight: 700; text-align: center; text-decoration: none;
  transition: transform .06s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.block, .auth .btn { width: 100%; }
.btn.primary { background: var(--amber); color: var(--ink); }
.btn.secondary { background: #eef0f3; color: var(--ink); }
.btn.danger { background: #fff; color: var(--red); border: 2px solid #fecaca; }
.btn.ghost { background: transparent; color: var(--muted); min-height: 40px; font-weight: 600; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn.success { background: var(--green); color: #fff; }

/* ------------------------------------------------------------ carte et barres */
.main { background: #e5e7eb; }
#map { position: absolute; inset: 0; z-index: 0; isolation: isolate; }
.leaflet-container { font-family: inherit; }

.topbar {
  position: absolute; z-index: 500; left: 10px; right: 10px;
  top: calc(var(--safe-top) + 10px);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 6px 6px 14px; border-radius: 18px;
  background: rgba(17, 24, 39, .94); color: #fff; box-shadow: 0 4px 18px rgba(0, 0, 0, .25);
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: -.3px; }
.modes { display: flex; gap: 4px; background: rgba(255, 255, 255, .1); padding: 3px; border-radius: 13px; }
.modes button {
  position: relative; border: 0; background: transparent; color: #d1d5db;
  padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 700;
}
.modes button.on { background: var(--amber); color: var(--ink); }
.dot {
  position: absolute; top: 3px; right: 3px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--red); border: 2px solid var(--ink);
}
.pill {
  position: absolute; z-index: 500; left: 50%; transform: translateX(-50%);
  top: calc(var(--safe-top) + 66px); padding: 6px 12px; border-radius: 999px;
  background: #fef3c7; color: #92400e; font-size: 13px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15); white-space: nowrap;
}
.fab {
  position: absolute; z-index: 500; right: 12px; top: calc(var(--safe-top) + 74px);
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25); font-size: 22px; color: var(--blue);
}

.sheet {
  position: absolute; z-index: 500; left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  max-height: 62vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 16px 16px; background: var(--card);
  border-radius: 22px 22px 0 0; box-shadow: 0 -6px 24px rgba(0, 0, 0, .18);
}
.sheet-grip {
  position: sticky; top: -18px; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: calc(100% + 32px); margin: -18px -16px 8px; padding: 12px 0 10px; border: 0;
  background: var(--card); border-radius: 22px 22px 0 0; touch-action: none; cursor: grab; font: inherit;
}
.sheet-grip-bar { display: block; width: 44px; height: 5px; border-radius: 5px; background: #d1d5db; }
.sheet-grip-txt { display: none; font-size: 12px; color: var(--muted); }
.sheet.min { max-height: none; overflow: hidden; padding-bottom: 0; }
.sheet.min > :not(.sheet-grip) { display: none; }
.sheet.min .sheet-grip { margin-bottom: 0; padding-bottom: 12px; }
.sheet.min .sheet-grip-txt { display: block; }
.sheet h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.2px; }
.sheet .sub { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.stack > * + * { margin-top: 10px; }

.tabbar {
  position: absolute; z-index: 600; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: #fff; border-top: 1px solid var(--line);
}
.tabbar button {
  border: 0; background: transparent; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  font-size: 11.5px; font-weight: 700; color: var(--muted);
}
.tabbar button span { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabbar button.on { color: var(--ink); }
.tabbar button.on span { filter: none; opacity: 1; }

.view {
  position: absolute; z-index: 550; left: 0; right: 0; top: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  overflow-y: auto; background: var(--bg);
  padding: calc(var(--safe-top) + 18px) 16px 24px;
}
.view h1 { margin: 0 0 14px; font-size: 24px; letter-spacing: -.3px; }

/* ------------------------------------------------------------ composants */
.place {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px;
  background: #fff; text-align: left;
}
.place .ico { flex: none; width: 12px; height: 12px; border-radius: 50%; }
.place .ico.from { background: var(--green); }
.place .ico.to { background: var(--accent); border-radius: 3px; }
.place .txt { flex: 1; min-width: 0; }
.place .lbl { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.place .val { display: block; font-size: 15.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place .act { flex: none; border: 0; background: #eef0f3; border-radius: 10px; padding: 6px 10px; font-size: 13px; font-weight: 700; }
.place.active { border-color: var(--amber); }

.searchbar { display: flex; gap: 8px; }
.searchbar input {
  flex: 1; min-width: 0; height: 48px; padding: 0 14px; font-size: 16px;
  border: 2px solid var(--line); border-radius: 14px; background: #fff;
}
.searchbar input:focus { outline: none; border-color: var(--amber); }
.searchbar .btn { min-height: 48px; padding: 0 16px; }

.results { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.results li button {
  display: block; width: 100%; text-align: left; border: 0; background: #fff;
  padding: 12px 14px; font-size: 14.5px; border-bottom: 1px solid var(--line);
}
.results li:last-child button { border-bottom: 0; }
.results li button:active { background: #f3f4f6; }
.results .muted { padding: 12px 14px; font-size: 14px; color: var(--muted); }

.card { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: #fff; }
.card.accent { background: #f0fdfa; border-color: #99f6e4; }
.estimate { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.price { font-size: 30px; font-weight: 800; letter-spacing: -.8px; line-height: 1.1; }
.price small { font-size: 15px; font-weight: 700; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.meta { color: var(--ink-2); font-size: 14px; line-height: 1.5; text-align: right; }
.meta b { color: var(--ink); }
.nearby { margin-top: 8px; font-size: 13.5px; font-weight: 600; }
.nearby.ok { color: var(--green); }
.nearby.none { color: #b45309; }

.driver { display: flex; align-items: center; gap: 12px; }
.avatar {
  flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--ink); color: var(--brand-light);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px;
}
.driver .who { flex: 1; min-width: 0; }
.driver .nm { font-weight: 800; font-size: 17px; }
.driver .car { font-size: 14px; color: var(--ink-2); }
.plate {
  display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 6px;
  background: #fef3c7; border: 1px solid #fcd34d; font-weight: 800; font-size: 13.5px; letter-spacing: .6px;
}
.rating { color: #b45309; font-weight: 700; font-size: 14px; }

.status { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.status .big { font-size: 19px; font-weight: 800; letter-spacing: -.2px; }
.spinner {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid #e5e7eb; border-top-color: var(--amber); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stars { display: flex; justify-content: center; gap: 6px; margin: 10px 0 4px; }
.stars button { border: 0; background: transparent; font-size: 40px; line-height: 1; padding: 2px 4px; color: #d1d5db; }
.stars button.on { color: var(--accent); }
.center { text-align: center; }

.req { border: 2px solid var(--line); border-radius: 16px; padding: 12px; background: #fff; }
.req .top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.req .who { font-weight: 800; }
.req .pr { font-weight: 800; font-size: 19px; }
.req .path { margin: 6px 0 10px; font-size: 13.5px; color: var(--ink-2); line-height: 1.45; }
.req .path b { color: var(--ink); }
.empty { text-align: center; color: var(--muted); padding: 10px 0 4px; font-size: 14.5px; }
.pulse { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--green); margin-right: 8px; animation: pulse 1.4s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .6); } 100% { box-shadow: 0 0 0 12px rgba(22, 163, 74, 0); } }

/* formulaires (profil, véhicule) */
.field { margin: 0 0 12px; }
.field label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.field input {
  width: 100%; height: 48px; padding: 0 14px; font-size: 16px;
  border: 2px solid var(--line); border-radius: 12px; background: #fff;
}
.field input:focus { outline: none; border-color: var(--amber); }
.field input[disabled] { background: #f3f4f6; color: var(--muted); }
.section { margin: 0 0 20px; }
.section h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }

/* historique */
.seg { display: flex; gap: 4px; padding: 4px; margin-bottom: 14px; border-radius: 14px; background: #e5e7eb; }
.seg button { flex: 1; border: 0; background: transparent; padding: 10px; border-radius: 10px; font-weight: 700; font-size: 14.5px; color: var(--ink-2); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.total { display: flex; justify-content: space-between; align-items: center; padding: 14px; margin-bottom: 14px; border-radius: 16px; background: var(--ink); color: #fff; }
.total b { font-size: 22px; color: var(--accent); }
.trip { padding: 14px; margin-bottom: 10px; border-radius: 16px; background: #fff; border: 1px solid var(--line); }
.trip .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.trip .date { font-size: 13px; color: var(--muted); }
.trip .pr { font-weight: 800; font-size: 17px; }
.trip .route { margin: 6px 0 8px; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.completed { background: #dcfce7; color: #166534; }
.badge.cancelled { background: #fee2e2; color: #991b1b; }

/* messages */
.toast {
  position: fixed; z-index: 2000; left: 50%; transform: translateX(-50%);
  top: calc(var(--safe-top) + 70px); /* sous la barre du haut : ne masque jamais les boutons d'action */
  max-width: calc(100% - 28px); padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: #fff; font-size: 14.5px; font-weight: 600; text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
.toast.err { background: #991b1b; }
.toast.ok { background: #166534; }

/* marqueurs de carte */
.mk {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .4);
}
.mk-me { background: var(--blue); animation: mkpulse 2s ease-out infinite; }
@keyframes mkpulse { 0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, .5), 0 1px 6px rgba(0, 0, 0, .4); } 100% { box-shadow: 0 0 0 16px rgba(37, 99, 235, 0), 0 1px 6px rgba(0, 0, 0, .4); } }
.mk-from { background: var(--green); }
.mk-to { background: var(--accent); border-radius: 6px; }
.mk-car { background: #fff; font-size: 20px; }
.mk-car-sm { background: #fff; font-size: 15px; opacity: .95; }
.mk-req { background: var(--green); color: #fff; font-size: 13px; font-weight: 800; }

@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; width: 460px; transform: translateX(-50%); border-radius: 22px 22px 0 0; }
  .view { padding-left: calc(50% - 280px); padding-right: calc(50% - 280px); }
}

.fine { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.center .fine { text-align: center; }
.live { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: #ecfdf5; color: #065f46; font-weight: 700; font-size: 14.5px; }

/* course simple / groupée */
.kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kind {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px; text-align: left;
  border: 2px solid var(--line); border-radius: 14px; background: #fff;
}
.kind.on { border-color: var(--amber); background: #f0fdfa; }
.kind .kt { font-weight: 800; font-size: 15px; }
.kind .kp { font-weight: 800; font-size: 18px; letter-spacing: -.3px; }
.kind .ks { font-size: 12px; color: var(--muted); }
.tag { display: inline-block; margin: 0 0 10px; padding: 3px 10px; border-radius: 999px; background: #ede9fe; color: #5b21b6; font-size: 12.5px; font-weight: 700; }
.badge.group { background: #ede9fe; color: #5b21b6; margin-right: 6px; }
.badge.acc { background: #dbeafe; color: #1e40af; }
.subtitle { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.pax .path { margin-bottom: 8px; }
.pax > * + * { margin-top: 10px; }
.stepper { display: flex; align-items: center; gap: 14px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 14px; background: #fff; }
.stepper .lbl { flex: 1; font-weight: 700; font-size: 14.5px; }
.stepper button { width: 40px; height: 40px; border: 0; border-radius: 12px; background: var(--amber); font-size: 22px; font-weight: 800; }
.stepper button[disabled] { opacity: .4; }
.stepper b { min-width: 22px; text-align: center; font-size: 20px; }
.mk-cli { background: #fff; font-size: 16px; }

/* prix proposé par le client */
.offer { padding: 12px; border: 2px solid var(--amber); border-radius: 14px; background: #fff; }
.offer .lbl { margin: 0 0 8px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.offer .row { display: flex; align-items: center; gap: 8px; }
.offer .row button { flex: none; width: 46px; height: 46px; border: 0; border-radius: 12px; background: var(--amber); font-size: 24px; font-weight: 800; }
.offer .row button[disabled] { opacity: .4; }
.offer .row input { flex: 1; min-width: 0; height: 46px; padding: 0 8px; border: 2px solid var(--line); border-radius: 12px; text-align: center; font-size: 22px; font-weight: 800; }
.offer .row input:focus { outline: none; border-color: var(--amber); }
.offer .cur { flex: none; font-weight: 700; color: var(--muted); }
.offer .hint { font-weight: 600; color: var(--ink-2); }
.cmp { margin: 6px 0 0; padding: 6px 10px; border-radius: 10px; font-size: 13px; font-weight: 700; }
.cmp.up { background: #dcfce7; color: #166534; }
.cmp.down { background: #fef3c7; color: #92400e; }
.cmp.same { background: #eef0f3; color: var(--ink-2); }

/* envoi des pièces du chauffeur */
.doc { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid #e5e7eb; border-radius: 14px; background: #fff; }
.doc.sent { border-color: #a7f3d0; background: #f0fdf9; }
.doc-state { font-size: 22px; }
.doc-name { flex: 1; font-weight: 700; font-size: 14.5px; }
.doc .btn { padding: 8px 14px; font-size: 14px; white-space: nowrap; }

/* vérification de la plaque par le client */
.plate-check { border: 2px solid #f59e0b; background: #fffbeb; display: flex; flex-direction: column; gap: 10px; }
.pc-title { font-weight: 800; font-size: 16px; text-align: center; }
.pc-plate {
  align-self: center; padding: 8px 22px; border-radius: 10px; background: #fff; border: 3px solid #111827;
  font-weight: 900; font-size: 28px; letter-spacing: 2px; text-align: center;
}
.plate-ok { padding: 10px 12px; border-radius: 12px; background: #ecfdf5; color: #065f46; font-size: 14.5px; }

/* solde du chauffeur */
.balance .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.balance .lbl { font-weight: 700; color: var(--ink-2); }
.balance .amt { font-size: 22px; font-weight: 800; }
.balance.low { border: 2px solid #fca5a5; background: #fef2f2; }
.mv { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.mv .num { font-weight: 800; white-space: nowrap; }
.mv .num.neg { color: #b91c1c; }
.mv .num.pos { color: #047857; }

/* suivi en direct du chauffeur pendant la course */
#follow-chip {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 78px); z-index: 650;
  border: 0; border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); max-width: calc(100vw - 32px);
}
#follow-chip.live { background: #065f46; color: #fff; pointer-events: none; }
#follow-chip.paused { background: #2563eb; color: #fff; cursor: pointer; }

.auth-tabs { display: flex; gap: 6px; background: rgba(255,255,255,.08); padding: 4px; border-radius: 14px; margin: 0 0 14px; }
.auth-tabs button { flex: 1; border: 0; border-radius: 10px; min-height: 40px; font: inherit; font-weight: 700; background: transparent; color: #cbd5e1; }
.auth-tabs button.on { background: var(--amber); color: var(--ink); }
.consent { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 12px; font-size: 14px; line-height: 1.4; color: #cbd5e1; }
.consent input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--amber); }
.consent a { color: var(--brand-light); }
.req-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.btn.call { display: flex; align-items: center; justify-content: center; gap: 4px; text-decoration: none; margin-top: 10px; }
