:root {
  --bg: #f1f4f9;
  --card: #ffffff;
  --text: #16202f;
  --muted: #5b6678;
  --line: #dde3ec;
  --primary: #1d4ed8;
  --primary-text: #ffffff;
  --good: #15803d;
  --bad: #c2410c;
  --warn: #a16207;
  --soft: #e8eefb;
  --nav: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1520;
    --card: #182131;
    --text: #e6ebf3;
    --muted: #97a3b6;
    --line: #2a3548;
    --primary: #4f7cf5;
    --good: #4ade80;
    --bad: #fb923c;
    --warn: #facc15;
    --soft: #1f2b40;
    --nav: #141c2a;
  }
  :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9); }
}
:root[data-theme="dark"] {
    --bg: #0f1520;
    --card: #182131;
    --text: #e6ebf3;
    --muted: #97a3b6;
    --line: #2a3548;
    --primary: #4f7cf5;
    --good: #4ade80;
    --bad: #fb923c;
    --warn: #facc15;
    --soft: #1f2b40;
    --nav: #141c2a;
  }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9); }


* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
h1 { font-size: 1.5rem; margin: 0 0 .6rem; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .3rem; }
p { margin: .3rem 0; }
small, .muted { color: var(--muted); }
b.good, .good { color: var(--good); }
b.bad, .bad { color: var(--bad); }
.error { color: var(--bad); min-height: 1.2em; }

button, select, input {
  font: inherit; color: inherit; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  padding: .5rem .75rem; min-height: 40px;
}
button { cursor: pointer; background: var(--soft); border-color: transparent; font-weight: 600; }
button.primary { background: var(--primary); color: var(--primary-text); }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .45; cursor: not-allowed; }
select, input { max-width: 100%; }
label { display: block; margin: .6rem 0; font-weight: 600; }
label input, label select { display: block; width: 100%; margin-top: .25rem; font-weight: 400; }

.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.card.narrow { width: 100%; max-width: 420px; }
.card.narrow input, .card.narrow button { width: 100%; margin-top: .5rem; }

header {
  position: sticky; top: 0; z-index: 1000; background: var(--primary); color: #fff; padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
}
.company { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpis { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .88rem; opacity: .95; }
.kpi { white-space: nowrap; }

main { max-width: 900px; margin: 0 auto; padding: 12px 16px calc(84px + env(safe-area-inset-bottom)); }
.tab { display: none; }
.tab.active { display: block; }

nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; display: grid; grid-template-columns: repeat(8, 1fr);
  background: var(--nav); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
nav button {
  background: none; border-radius: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 1.15rem; padding: 6px 0; min-height: 56px; font-weight: 500; color: var(--muted);
}
nav button span { font-size: .6rem; white-space: nowrap; }
nav button.active { color: var(--primary); }
nav button.active span { font-weight: 700; }

#map { height: 58vh; min-height: 300px; border-radius: 14px; border: 1px solid var(--line); z-index: 0; }
.truck-icon { font-size: 22px; line-height: 22px; text-align: center; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.truck-icon.broken { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.leaflet-popup-content { font: 14px/1.4 system-ui, sans-serif; }
.leaflet-popup-content button { margin-top: 6px; }

.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.log li.good { color: var(--good); }
.log li.bad { color: var(--bad); }
.log li small { display: block; color: var(--muted); }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row > * { flex: 0 1 auto; }
.grow { flex: 1 1 160px !important; }
.between { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.big { font-size: 1.25rem; font-weight: 700; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--soft); font-size: .8rem; font-weight: 600; }
.tag.contract { background: var(--primary); color: #fff; }
.tag.good { background: rgba(21,128,61,.12); }
.tag.bad { background: rgba(194,65,12,.12); }
.stars { color: #eab308; letter-spacing: 1px; }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; margin: 4px 0; }
.bar > div { height: 100%; background: var(--primary); }
.bar.wear > div { background: var(--warn); }
.bar.wear.high > div { background: var(--bad); }
.option { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.actions select { flex: 1 1 140px; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
.scroll { overflow-x: auto; }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; }
.spark { width: 100%; height: 60px; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 2000; max-width: 520px; margin: 0 auto;
  background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.toast.bad { background: var(--bad); color: #fff; }

.pin-dots { height: 48px; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 1.6rem; font-weight: 700; letter-spacing: .15em; border-bottom: 2px solid var(--line); margin: .6rem 0; }
.pin-dots .ph { color: var(--muted); font-size: 1rem; font-weight: 400; letter-spacing: 0; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: .5rem; }
.card.narrow .pad button { width: auto; margin: 0; font-size: 1.4rem; min-height: 58px; }

.events { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 4px; }
.event { flex: 0 0 auto; max-width: 240px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: .85rem; }
.event b { display: block; }
.event-icon { font-size: 20px; line-height: 20px; text-align: center; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
tr.me td { font-weight: 700; }
.chart { width: 100%; height: 160px; display: block; }
.legend { display: flex; gap: 14px; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 4px; }

.truck-badge { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; align-items: center; justify-content: center; font-size: 15px; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.bar.mood > div { background: var(--good); }
.bar.mood.low > div { background: var(--bad); }
.swatch { width: 38px; height: 38px; min-height: 38px; padding: 0; border-radius: 50%; border: 3px solid transparent; }
.swatch.on { border-color: var(--text); }
.icon-pick { font-size: 1.3rem; padding: 4px 10px; }
.icon-pick.on { outline: 3px solid var(--primary); }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; margin: .45rem 0; }
label.check input { width: 22px; height: 22px; min-height: 0; margin: 0; flex: 0 0 auto; display: inline-block; }

details { margin-top: 8px; }
details summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.avoid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0 10px; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; }
label.check input[type=radio] { width: 20px; height: 20px; }

.dilemma { border: 2px solid var(--primary); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.shot { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; margin: 0; }
.shot-truck { width: 100%; height: 70px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 40px; margin-bottom: 6px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.filters select { flex: 1 1 150px; }
.tag.flash { background: #f59e0b; color: #111; }
.dash .dash-row { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dash .dash-row:last-of-type { border-bottom: 0; }
button.mini { min-height: 30px; padding: 3px 10px; font-size: .82rem; margin-left: auto; }
.weather { display: flex; gap: 10px; overflow-x: auto; font-size: .82rem; padding-top: 8px; white-space: nowrap; color: var(--muted); }
.shot-truck.classic { background: linear-gradient(135deg, #92400e, #ca8a04); }

button.mini.danger { color: var(--bad); }

.papers { border: 2px dashed var(--warn); border-radius: 10px; padding: 6px 10px; }
.order { background: var(--soft); border-radius: 8px; padding: 8px; margin: 6px 0; font-size: .9rem; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 6px 0; }
label.inline select { flex: 1; min-height: 34px; padding: 4px 8px; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; color: inherit; background: var(--soft); border-radius: 10px; font-weight: 600; padding: 4px 10px; }
.cbar { display: grid; grid-template-columns: 110px 1fr; gap: 2px 8px; align-items: center; margin: 4px 0; }
.cbar small { grid-column: 2; }

.tacho { background: #111827; color: #a7f3d0; font-family: ui-monospace, Menlo, monospace; font-size: .85rem; padding: 10px; border-radius: 8px; margin: 6px 0; }
.actions.vertical { flex-direction: column; align-items: stretch; }
.trade { border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; margin-top: 6px; }
nav button { font-size: 1.05rem; }

.tacho-live { background: #0b1220; color: #e2e8f0; border-radius: 10px; padding: 10px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tacho-live small { color: #94a3b8; display: block; }
.tacho-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.tacho-icon { font-size: 28px; }
.tacho-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 8px; }
.tacho-grid b { font-size: 1.15rem; color: #67e8f9; display: block; }
.tacho-grid b.bad { color: #fca5a5; }
.tacho-bar { width: 100%; height: 14px; border-radius: 4px; display: block; }
.tacho-live .legend { color: #94a3b8; }

.cold { margin: 4px 0; font-size: .9rem; }
.cold.alarm { background: rgba(220,38,38,.12); border: 1px solid var(--bad); border-radius: 8px; padding: 6px 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hq-levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; text-align: center; margin-bottom: 8px; }
.hq-level { opacity: .35; } .hq-level.done { opacity: .7; } .hq-level.on { opacity: 1; font-weight: 700; }
.hq-level span { font-size: 26px; display: block; } .hq-level small { font-size: .65rem; }
.plan { margin-top: 8px; }
.plan-row { display: grid; grid-template-columns: 92px 1fr; gap: 6px; align-items: center; margin: 4px 0; }
.plan-name { font-size: .8rem; line-height: 1.2; overflow: hidden; } .plan-name small { display: block; color: var(--muted); }
.plan-days { display: grid; grid-template-columns: repeat(7, 1fr); font-size: .7rem; color: var(--muted); }
.plan-track { position: relative; height: 22px; background: repeating-linear-gradient(90deg, var(--soft) 0 calc(100%/7 - 1px), var(--line) calc(100%/7 - 1px) calc(100%/7)); border-radius: 4px; overflow: hidden; }
.plan-bar { position: absolute; top: 3px; bottom: 3px; border-radius: 3px; font-size: 11px; line-height: 16px; overflow: hidden; color: #fff; text-align: center; }
.plan-now { position: absolute; top: 0; bottom: 0; width: 2px; background: #dc2626; }

/* Sur iPhone, Safari zoome sur les champs écrits en moins de 16 px et ne dézoome pas. */
select, input, textarea { font-size: 16px !important; }
html, body { overflow-x: hidden; }

.theme-btn { background: rgba(255,255,255,.18); border: 0; color: inherit; border-radius: 999px; padding: 2px 8px; margin-left: 8px; font-size: .9rem; width: auto; min-height: 0; }
.log.book li { font-size: .85rem; }
a.button { display: inline-block; padding: 10px 14px; border-radius: 10px; background: var(--soft); color: var(--text); font-weight: 700; text-decoration: none; }
ol { padding-left: 20px; }
.cockpit { position: fixed; inset: 0; z-index: 3000; background: var(--bg); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.cockpit.hidden { display: none; }
.cockpit-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--primary); color: #fff; }
.cockpit-top .theme-btn { margin: 0; }
#ck-map { height: 38vh; min-height: 200px; }
#ck-body { flex: 1; overflow-y: auto; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
.ck-speed { display: flex; align-items: baseline; gap: 6px; justify-content: center; }
.ck-speed span { font-size: 3.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ck-activity { text-align: center; margin: 2px 0 12px; }
.ck-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ck-grid > div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; }
.ck-grid b { font-size: 1.15rem; }
.ck-grid small { color: var(--muted); }
.ck-line { margin-top: 8px; font-size: .92rem; }
.ck-truck { font-size: 28px; line-height: 34px; text-align: center; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }

/* Dessin du camion et pic saisonnier */
.truck-svg { width: 100%; max-width: 260px; height: auto; display: block; margin: 4px 0; }
.card.peak { border-left: 4px solid #16a34a; background: color-mix(in srgb, #16a34a 8%, var(--card, #fff)); }

/* Prix du gasoil par pays, agenda */
.fuel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; font-size: 0.85em; }
.agenda-day { padding: 6px 0; border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent); }
.agenda-day:first-of-type { border-top: 0; }
.interview { background: color-mix(in srgb, currentColor 5%, transparent); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; display: grid; gap: 4px; }
