/* RouteFlow — interface mobile, une main, lisible en plein jour. */
:root {
  --bg: #f6f7f5; --surface: #ffffff; --surface-2: #eef1ee; --text: #14201d; --muted: #5b6763; --line: #d9dfdb;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #ccebe7;
  --ok: #15803d; --ok-ink: #ffffff; --ok-soft: #dcfce7; --warn: #a16207; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --voice: #4338ca; --voice-ink: #ffffff; --voice-soft: #e0e7ff;
  --radius: 14px; --tap: 52px;
  color-scheme: light;
}
:root[data-theme="dark"] {
    --bg: #0e1513; --surface: #16201d; --surface-2: #1d2a26; --text: #e8efec; --muted: #9aa8a3; --line: #2a3833;
    --accent: #2dd4bf; --accent-ink: #062a26; --accent-soft: #134e48;
    --ok: #4ade80; --ok-ink: #052e16; --voice: #a5b4fc; --voice-ink: #1e1b4b; --voice-soft: #26265a; --ok-soft: #14361f; --warn: #fbbf24; --warn-soft: #3b2f0b; --bad: #f87171; --bad-soft: #3f1515;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1513; --surface: #16201d; --surface-2: #1d2a26; --text: #e8efec; --muted: #9aa8a3; --line: #2a3833;
    --accent: #2dd4bf; --accent-ink: #062a26; --accent-soft: #134e48;
    --ok: #4ade80; --ok-ink: #052e16; --voice: #a5b4fc; --voice-ink: #1e1b4b; --voice-soft: #26265a; --ok-soft: #14361f; --warn: #fbbf24; --warn-soft: #3b2f0b; --bad: #f87171; --bad-soft: #3f1515;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom); }
#app { max-width: 640px; margin: 0 auto; }
main { padding-block: 12px 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 6px; }
h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
p { margin: 4px 0; }
a { color: var(--accent); }
.pad { padding: 16px; }
.muted { color: var(--muted); } .small { font-size: .88rem; }
.bad { color: var(--bad); } .warn { color: var(--warn); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; } .row > * { flex: 1; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
ul.plain, ol.plain { list-style: none; padding: 0; margin: 0; }

/* En-têtes */
.brand { display: flex; gap: 12px; align-items: center; padding: 20px 16px 8px; }
.brand h1 { font-size: 1.5rem; margin: 0; } .brand p { color: var(--muted); margin: 0; }
.logo { width: 48px; height: 48px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; letter-spacing: -.5px; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 4px; padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.bar h1 { font-size: 1.15rem; margin: 0; }
.bar-back { width: var(--tap); height: var(--tap); display: grid; place-items: center; font-size: 2rem; text-decoration: none; color: var(--text); }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card > * + * { margin-top: 10px; }
.card.inset { background: var(--surface-2); }
.hero h2 { font-size: 1.25rem; }
.eyebrow { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
details.card summary { list-style: none; cursor: pointer; } details.card summary::-webkit-details-marker { display: none; }
details.card summary h3 { display: inline; } details.card summary::after { content: " ▾"; color: var(--muted); }

/* Statistiques */
.stats3, .stats2 { display: grid; gap: 8px; } .stats3 { grid-template-columns: repeat(3, 1fr); } .stats2 { grid-template-columns: repeat(3, 1fr); }
.stats3 > div, .stats2 > div { background: var(--surface-2); border-radius: 10px; padding: 10px 8px; text-align: center; }
.stats3 b, .stats2 b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stats3 span, .stats2 span { font-size: .75rem; color: var(--muted); }
.stats2 .bad b { color: var(--bad); }

/* Boutons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 10px 16px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; text-align: center; cursor: pointer; width: 100%; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-success { background: var(--ok); border-color: var(--ok); color: var(--ok-ink); }
.btn-danger { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-xl { min-height: 64px; font-size: 1.12rem; }
.btn-small { min-height: 42px; padding: 6px 12px; font-size: .92rem; width: auto; }
.btn.active { border-color: var(--accent); background: var(--accent-soft); }
.btn[disabled] { opacity: .5; }
.file-btn { cursor: pointer; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .btn-ghost { grid-column: 1 / -1; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Formulaires */
label { display: block; font-weight: 600; font-size: .92rem; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; min-height: 48px; padding: 10px 12px; font: inherit; font-weight: 400; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; }
textarea { min-height: 120px; resize: vertical; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
label.check input { width: 24px; min-height: 24px; height: 24px; margin: 0; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Onglets */
.tabs { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.tabs button { flex: 1; min-height: 44px; border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--muted); border-radius: 9px; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }

/* Tableau d'aperçu */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; font-size: .82rem; } th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }

/* Anomalies */
.issue { border-left: 4px solid var(--warn); background: var(--surface); padding: 10px 12px; border-radius: 8px; margin-bottom: 8px; }
.issue > * + * { margin-top: 6px; }
.issue-error { border-left-color: var(--bad); }
.note, .banner { background: var(--warn-soft); padding: 10px 12px; border-radius: 10px; font-size: .92rem; }
.banner { background: var(--accent-soft); } .banner.warn { background: var(--warn-soft); color: var(--text); }
.banner > * + * { margin-top: 8px; }

/* Prochain arrêt */
.next { border: 2px solid var(--accent); }
.next-addr { display: block; font-size: 1.4rem; font-weight: 700; color: var(--text); text-decoration: none; }
.next-addr small, .addr small { display: block; font-size: .9rem; font-weight: 400; color: var(--muted); }
.addr-big { font-size: 1.5rem; }

/* Liste des arrêts */
.stops li, .load li { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.stops li > a { flex: 1; display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: inherit; text-decoration: none; min-height: 60px; }
.stops li.is-final { opacity: .55; }
.load li { padding: 10px 12px; } .load li > span:nth-child(2) { flex: 1; } .load small { display: block; color: var(--muted); font-size: .8rem; }
.num { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .9rem; }
.addr { flex: 1; min-width: 0; font-weight: 600; }
.reorder { display: flex; flex-direction: column; gap: 4px; padding-right: 8px; }
.chip { flex: none; display: inline-block; font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip-in_progress { background: var(--accent-soft); color: var(--accent); }
.chip-done { background: var(--ok-soft); color: var(--ok); }
.chip-failed { background: var(--bad-soft); color: var(--bad); }
.chip-postponed { background: var(--warn-soft); color: var(--warn); }
.tag { font-size: .7rem; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }

/* Bilan */
.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* Carte */
.map { height: 58vh; min-height: 320px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.pin { background: #fff; color: #14201d; border: 2px solid #0f766e; border-radius: 50%; display: grid !important; place-items: center; font: 700 12px system-ui; box-shadow: 0 1px 3px rgb(0 0 0 / .3); }
.pin-next { background: #0f766e; color: #fff; transform: scale(1.25); z-index: 1000 !important; }
.pin-done { opacity: .45; } .pin-depot { background: #fbbf24; border-color: #a16207; font-size: 16px; }
video#scanVideo { width: 100%; border-radius: var(--radius); }

/* Superpositions */
.busy { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .55); display: grid; place-content: center; justify-items: center; gap: 16px; color: #fff; font-weight: 600; padding: 24px; text-align: center; }
.busy[hidden] { display: none; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgb(255 255 255 / .3); border-top-color: #fff; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 60; max-width: 600px; margin: 0 auto;
  background: var(--text); color: var(--bg); padding: 14px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 4px 16px rgb(0 0 0 / .25); }
dialog { border: 0; border-radius: 16px; padding: 20px; max-width: 520px; width: calc(100% - 32px); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog form > * + * { margin-top: 12px; }
@media (max-width: 380px) { .grid-form { grid-template-columns: 1fr; } .row3 { grid-template-columns: 1fr 1fr; } }

/* Copilote vocal */
.btn-voice { background: var(--voice-soft); border-color: var(--voice); color: var(--text); }
.safety { font-size: .85rem; font-weight: 600; background: var(--warn-soft); padding: 8px 12px; border-radius: 10px; }
.cp-next .cp-addr { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.cp-answer { min-height: 96px; font-size: 1.2rem; line-height: 1.4; font-weight: 600; }
.cp-answer .cp-you { font-size: .9rem; color: var(--muted); font-weight: 500; }
.mic { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 20px; text-align: center; width: 176px; height: 176px; margin: 8px auto; border-radius: 50%; border: 0;
  background: var(--voice); color: var(--voice-ink); font: 700 .95rem/1.2 system-ui, sans-serif; cursor: pointer; box-shadow: 0 6px 20px rgb(0 0 0 / .2); }
.mic span { font-size: 3rem; line-height: 1; }
.mic.is-on { background: var(--bad); color: #fff; animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.06); } }
.pulse { animation: breathe 1.2s ease-in-out 4; }
@media (prefers-reduced-motion: reduce) { .mic.is-on, .pulse { animation: none; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { min-height: 44px; padding: 8px 14px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: 600 .9rem system-ui, sans-serif; }
.cp-log li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.tag-ok { background: var(--ok-soft); color: var(--ok); } .tag-warn { background: var(--warn-soft); color: var(--warn); }
.issue-ok { border-left-color: var(--ok); }
.note-item { border-left: 4px solid var(--voice); padding-left: 10px; }
.note-item > * + * { margin-top: 6px; }
.tabs { overflow-x: auto; } .tabs button { white-space: nowrap; padding: 0 10px; }
form.row > .btn-small { flex: none; min-width: 64px; }
