/* Dispatch Manarii — habillage. Mobile d'abord (iPhone), bureau à partir de 900 px. */
:root {
  --navy: #0b1f3b; --navy-2: #143263; --gold: #f5b301; --gold-2: #d99a00;
  --bg: #eef1f6; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e3e8ef;
  --ok: #16a34a; --warn: #dc2626; --amber: #f59e0b; --amber-bg: #fff4d6; --info-bg: #e8f0fe;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --top-h: 60px; --r: 16px; --shadow: 0 6px 24px rgba(15, 23, 42, .14);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { position: fixed; inset: 0; overflow: hidden; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
button { font: inherit; color: inherit; }
a { color: var(--navy-2); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Connexion ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 28px; background: linear-gradient(160deg, #0b1f3b, #143263); color: #fff; }
.login-box { max-width: 400px; text-align: center; }
.login-box img { border-radius: 22px; box-shadow: var(--shadow); }
.login-box h1 { font-size: 24px; margin: 16px 0 10px; }
.login-box p { margin: 8px 0; color: #dbe4f3; font-size: 16px; }
.login-error { color: #fecaca; font-weight: 600; }

/* ---------- En-tête ---------- */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
#top { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; padding: calc(var(--sat) + 8px) 12px 10px; background: var(--navy); color: #fff; min-height: calc(var(--top-h) + var(--sat)); }
.icon-btn { background: rgba(255,255,255,.1); color: #fff; border: 0; border-radius: 12px; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.icon-btn:active { background: rgba(255,255,255,.24); }
#bell-dot { position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px var(--navy); }
.date-btn { background: transparent; color: #fff; border: 0; display: flex; flex-direction: column; align-items: center; padding: 2px 10px; cursor: pointer; min-width: 132px; }
.date-btn span { font-weight: 800; font-size: 18px; letter-spacing: -.2px; }
.date-btn small { color: #b7c4dc; font-size: 13px; font-weight: 500; }
.avatar { width: 44px; height: 44px; border-radius: 50%; border: 2px solid #fff; background: var(--gold); color: #1a1a1a; font-weight: 800; font-size: 15px; cursor: pointer; }

/* ---------- Carte + panneau ---------- */
#main { flex: 1; position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #dbe4f3; }
.fab { position: absolute; right: 14px; top: 14px; width: 46px; height: 46px; border-radius: 50%; border: 0; background: #fff; color: var(--navy); box-shadow: 0 3px 12px rgba(0,0,0,.22); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; z-index: 5; }
.banner { position: absolute; left: 12px; right: 12px; top: 12px; background: #fff7ed; border: 1px solid #fdba74; color: #7c2d12; padding: 12px 14px; border-radius: 14px; font-size: 15px; z-index: 6; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow); }
.banner.bottom { top: auto; bottom: calc(160px + var(--sab)); background: var(--info-bg); border-color: #93c5fd; color: #1e3a8a; }
.banner button { border: 0; background: transparent; font-size: 18px; cursor: pointer; color: inherit; }

#sheet { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: var(--card); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 28px rgba(15,23,42,.18); display: flex; flex-direction: column; transition: height .28s cubic-bezier(.2,.8,.2,1); z-index: 4; padding-bottom: var(--sab); }
#sheet-grip { flex: 0 0 auto; }
#sheet-handle { display: block; width: 100%; background: transparent; border: 0; padding: 10px 0 6px; cursor: grab; touch-action: none; }
#sheet-handle span { display: block; width: 40px; height: 5px; border-radius: 3px; background: #cbd5e1; margin: 0 auto; }
#sheet-head { display: flex; align-items: center; gap: 10px; padding: 0 18px 8px; touch-action: none; }
.sheet-titles { display: flex; flex-direction: column; min-width: 0; }
#sheet-title { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.summary { color: var(--muted); font-size: 14px; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; margin-left: auto; flex: 0 0 auto; }
.conn.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(22,163,74,.18); }
.conn.off { background: var(--warn); }

.onboard { margin: 2px 14px 8px; padding: 8px 10px 8px 12px; border-radius: 12px; background: var(--info-bg); display: flex; align-items: center; gap: 10px; }
.onboard > svg { flex: 0 0 auto; color: var(--navy-2); }
.onboard-text { flex: 1; min-width: 0; font-size: 13px; color: #334155; line-height: 1.25; }
.onboard-text strong { display: block; font-size: 14px; color: var(--text); }
.onboard-later { border: 0; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; padding: 6px; }

.strip { flex: 0 0 auto; display: flex; gap: 8px; overflow-x: auto; padding: 2px 14px 8px; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.drv-chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 3px; width: 62px; background: transparent; border: 0; padding: 2px 0; cursor: pointer; }
.drv-chip .ava { position: relative; width: 42px; height: 42px; border-radius: 50%; background: var(--c, #64748b); color: #fff; font-weight: 800; font-size: 15px; display: flex; align-items: center; justify-content: center; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(15,23,42,.18); }
.drv-chip .ava::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; background: #94a3b8; }
.drv-chip.on .ava::after { background: var(--ok); }
.drv-chip.me .ava { box-shadow: 0 0 0 3px var(--gold); }
.drv-chip .nm { font-size: 12px; font-weight: 600; max-width: 64px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drv-chip .st { font-size: 11px; color: var(--muted); max-width: 64px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drv-chip.on .st { color: var(--ok); }

.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 12px 16px; }
.section { display: flex; align-items: center; gap: 8px; margin: 10px 4px 8px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.section .count { background: var(--bg); border-radius: 10px; padding: 1px 8px; font-weight: 700; }
.section button { margin-left: auto; border: 0; background: transparent; color: var(--navy-2); font-weight: 700; text-transform: none; letter-spacing: 0; font-size: 14px; cursor: pointer; }
.empty { padding: 30px 12px; text-align: center; color: var(--muted); font-size: 15px; }

.res { position: relative; display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; align-items: center; padding: 12px 12px 12px 14px; margin-bottom: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; box-shadow: 0 1px 3px rgba(15,23,42,.05); }
.res::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; border-radius: 0 4px 4px 0; background: var(--c, #cbd5e1); }
.res.free::before { background: var(--amber); }
.res.mine { border-color: color-mix(in srgb, var(--c) 50%, #fff); background: color-mix(in srgb, var(--c) 6%, #fff); }
.res.sel { box-shadow: 0 0 0 2px var(--gold); }
.res.past { opacity: .55; }
.res.next { border-color: var(--gold); }
.res:active { background: var(--bg); }
.res-time { display: flex; flex-direction: column; align-items: flex-start; }
.res-time b { font-size: 21px; font-weight: 800; letter-spacing: -.4px; line-height: 1.1; }
.res-time span { font-size: 12px; color: var(--muted); font-weight: 600; }
.res-time .nextlbl { font-size: 10px; color: var(--gold-2); font-weight: 800; text-transform: uppercase; letter-spacing: .3px; }
.res-body { min-width: 0; }
.res-from { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-to { font-size: 14px; color: #334155; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.res-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.emo { font-weight: 400; font-size: 14px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.free { background: var(--amber-bg); color: #92400e; }
.badge.drv { background: var(--c, #64748b); color: #fff; }
.badge.past { background: var(--bg); color: var(--muted); }
.badge.lite { background: var(--bg); color: #334155; font-weight: 600; }
.pinic { width: 18px; height: 18px; color: var(--muted); }
.pinic.no { opacity: .35; }

.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; font-size: 16px; cursor: pointer; background: var(--bg); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; }
.btn.primary { background: var(--gold); color: #1a1a1a; }
.btn.primary:active { background: var(--gold-2); }
.btn.danger { background: #fee2e2; color: #991b1b; }
.btn.ghost { background: transparent; color: var(--navy-2); }
.btn.small { padding: 8px 12px; font-size: 14px; min-height: 36px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
select.btn { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, #334155 50%), linear-gradient(135deg, #334155 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

/* ---------- Modales ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal-box { position: relative; background: #fff; width: 100%; max-height: 90%; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + var(--sab)); }
.modal-box.wide { max-width: 940px; }
.modal .close { position: absolute; right: 12px; top: 12px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--bg); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.modal .close svg { width: 18px; height: 18px; }

.card-head { display: flex; gap: 14px; align-items: flex-start; margin-right: 44px; }
.card-time { font-size: 30px; font-weight: 800; letter-spacing: -.8px; line-height: 1; color: var(--navy); }
.card-title { font-size: 19px; font-weight: 800; line-height: 1.25; }
.card-sub { font-size: 16px; color: #334155; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.cta { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 14px; }
.cta-row { display: flex; gap: 8px; }
.cta-row > * { flex: 1; }
.holder { padding: 10px 12px; border-radius: 12px; background: var(--bg); font-size: 15px; display: flex; align-items: center; gap: 8px; }
.contact-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.contact-grid > * { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 14px; background: var(--bg); color: var(--navy); text-decoration: none; font-size: 12px; font-weight: 700; border: 0; cursor: pointer; }
.contact-grid > .off { opacity: .4; pointer-events: none; }
.contact-grid svg { width: 24px; height: 24px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 8px 0; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
details.msg { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
details.msg summary { cursor: pointer; font-weight: 700; color: var(--navy-2); font-size: 15px; }
details.msg pre { white-space: pre-wrap; word-break: break-word; background: var(--bg); padding: 12px; border-radius: 12px; font: 14px/1.5 inherit; margin: 10px 0 0; }

.drv-head { display: flex; align-items: center; gap: 14px; margin-right: 44px; }
.drv-head .ava { width: 56px; height: 56px; border-radius: 50%; background: var(--c); color: #fff; font-weight: 800; font-size: 20px; display: flex; align-items: center; justify-content: center; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(15,23,42,.2); }
.drv-head h2 { margin: 0; font-size: 22px; }
.drv-head .st { color: var(--muted); font-size: 14px; }
.drv-head .st.on { color: var(--ok); font-weight: 600; }

.menu-list { display: flex; flex-direction: column; margin-top: 8px; }
.menu-list button { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 14px 8px; border: 0; border-bottom: 1px solid var(--line); background: transparent; font-size: 17px; cursor: pointer; }
.menu-list button:last-child { border-bottom: 0; }
.menu-list svg { width: 24px; height: 24px; color: var(--navy-2); flex: 0 0 auto; }
.menu-list small { display: block; color: var(--muted); font-size: 13px; }

/* ---------- Admin ---------- */
.admin table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin th, .admin td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin input[type=text], .admin input[type=tel], .admin select { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.admin input[type=color] { width: 44px; height: 36px; border: 0; padding: 0; background: transparent; }
.admin .keys { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); word-break: break-all; margin-top: 6px; }
.admin .add { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; margin: 12px 0; }
.admin .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.admin h3 { margin: 18px 0 8px; }
@media (max-width: 640px) { .admin .add { grid-template-columns: 1fr 1fr; } .admin table, .admin thead, .admin tbody, .admin tr, .admin td { display: block; } .admin thead { display: none; } .admin tr { border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 12px; } .admin td { border: 0; padding: 5px 0; } .admin td::before { content: attr(data-l); color: var(--muted); font-size: 12px; display: block; margin-bottom: 3px; } }

/* ---------- Toasts ---------- */
#toasts { position: fixed; top: calc(var(--sat) + var(--top-h) + 10px); left: 14px; right: 14px; z-index: 30; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--navy-2); color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow); font-size: 15px; font-weight: 600; pointer-events: auto; animation: toast-in .22s ease; }
.toast.warn { background: #b91c1c; }
.toast.ok { background: #15803d; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Marqueurs (contenu HTML des AdvancedMarker) ---------- */
.mk-drv { position: relative; width: 0; height: 0; }
.mk-drv .halo { position: absolute; left: -26px; top: -26px; width: 52px; height: 52px; border-radius: 50%; background: var(--c); opacity: .16; animation: halo 2.4s ease-out infinite; }
@keyframes halo { 0% { transform: scale(.7); opacity: .28; } 100% { transform: scale(1.35); opacity: 0; } }
.mk-drv .arrow { position: absolute; left: -8px; top: -38px; width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 14px solid var(--c); transform-origin: 8px 38px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.3)); }
.mk-drv .dot { position: absolute; left: -19px; top: -19px; width: 38px; height: 38px; border-radius: 50%; background: var(--c); color: #fff; display: flex; align-items: center; justify-content: center; border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.35); }
.mk-drv .dot svg { width: 20px; height: 20px; stroke-width: 2.2; }
.mk-drv .lbl { position: absolute; left: 24px; top: -14px; background: #fff; color: var(--text); border-radius: 10px; padding: 4px 8px; font-size: 13px; font-weight: 800; white-space: nowrap; box-shadow: 0 1px 5px rgba(0,0,0,.28); }
.mk-drv .lbl small { display: block; font-weight: 700; font-size: 12px; color: var(--c); }
.mk-drv .lbl small:empty { display: none; }
.mk-drv.off { opacity: .5; filter: grayscale(.9); }
.mk-drv.off .halo, .mk-drv.off .arrow { display: none; }
.mk-pin { position: relative; width: 0; height: 0; }
.mk-pin .body { position: absolute; left: -21px; top: -46px; width: 42px; height: 42px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--c, #64748b); border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.35); transition: transform .15s ease; }
.mk-pin .txt { position: absolute; left: -21px; top: -41px; width: 42px; text-align: center; color: #fff; font-weight: 800; font-size: 11px; line-height: 1.05; pointer-events: none; }
.mk-pin.free .body { background: var(--amber); }
.mk-pin.free .txt { color: #1a1a1a; }
.mk-pin.sel .body { transform: rotate(-45deg) scale(1.25); }
.mk-pin.past { opacity: .45; }

/* ---------- Bureau ---------- */
@media (min-width: 900px) {
  #main { display: grid; grid-template-columns: 420px 1fr; }
  #map { position: relative; grid-column: 2; }
  .fab { right: 20px; }
  .banner { left: 440px; right: 20px; }
  #sheet { position: relative; grid-column: 1; grid-row: 1; height: auto !important; border-radius: 0; box-shadow: none; border-right: 1px solid var(--line); }
  #sheet-grip { display: none; }
  #sheet-head { padding-top: 14px; }
  .banner.bottom { left: 440px; bottom: 20px; }
  .modal { align-items: center; }
  .modal-box { max-width: 560px; border-radius: 22px; }
}
