:root {
  --brand: #0069D0;
  --brand-sky: #03A9F4;
  --green: #73C70F;
  --green-text: #336F07;
  --green-bg: #EEF8E3;
  --navy: #0D2A4A;
  --ink: #33414F;
  --muted: #5E6B78;
  --surface: #FFFFFF;
  --surface-muted: #F1F5FA;
  --tint: #E6F0FB;
  --border: #DCE4EE;
  --warn: #C2410C;
  --warn-text: #A2400A;
  --warn-bg: #FDEBDD;
  --grey-bg: #EEF1F4;
  --grey-text: #4A5562;
  --radius-md: 12px;
  --radius-lg: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--surface-muted); color: var(--ink); font-family: 'Poppins', system-ui, sans-serif; font-size: 14px; line-height: 1.45; }
button, input, select { font-family: inherit; font-size: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--brand-sky); outline-offset: 2px; }
h1, h2, h3 { color: var(--navy); margin: 0; }
.muted { color: var(--muted); }
.eyebrow { font-size: 12px; line-height: 16px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: #3A7F08; }
.accent { color: var(--brand); }

/* ---------- en-tête ---------- */
.top { background: var(--navy); padding: 10px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { height: 42px; width: auto; display: block; }
.brand .sep { width: 1px; height: 30px; background: rgba(255,255,255,.2); }
.brand span { color: #fff; font-weight: 600; font-size: 15px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; }
.tab { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 0; background: transparent; color: #C9D6E5; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.tab[aria-pressed="true"] { background: #fff; color: var(--navy); }
.tab .badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--warn); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.top-right { display: flex; align-items: center; gap: 12px; color: #C9D6E5; font-size: 13px; }
.src { display: inline-flex; align-items: center; gap: 6px; }
.src i { width: 9px; height: 9px; border-radius: 999px; display: inline-block; background: #8FA3B8; }
.src i.ok { background: #8FD63A; }
.src i.ko { background: #F97316; }
.logout { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.3); background: transparent; color: #fff; cursor: pointer; }
.demo-badge { padding: 5px 12px; border-radius: 999px; background: rgba(143,214,58,.16); color: #8FD63A; font-size: 12px; font-weight: 600; }

main { width: 100%; max-width: 1600px; margin: 0 auto; padding: 18px 24px 28px; display: flex; flex-direction: column; gap: 16px; }
.view[hidden] { display: none !important; }

/* ---------- indicateurs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 16px; }
.kpi b { display: block; font-size: 24px; line-height: 30px; color: var(--navy); }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi.warn { background: var(--warn-bg); border-color: #F6C9A6; }
.kpi.warn b, .kpi.warn span { color: var(--warn-text); }

/* ---------- carte + colonnes ---------- */
.row3 { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.col-left { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.col-map { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.col-right { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card h2 { font-size: 17px; line-height: 24px; font-weight: 600; }
.card h3 { font-size: 15px; line-height: 22px; font-weight: 600; }
#map { width: 100%; height: 600px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: #EEF3F8; z-index: 0; overflow: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); align-items: center; }
.legend i { width: 12px; height: 12px; border-radius: 999px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

.search { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-muted); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; height: 40px; outline: none; color: var(--ink); }
.vlist { display: flex; flex-direction: column; gap: 8px; }
.vitem { width: 100%; text-align: left; cursor: pointer; display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: var(--radius-md); border: 2px solid var(--border); background: #fff; }
.vitem[aria-pressed="true"] { border-color: var(--brand); background: #F5F9FE; }
.num { flex: none; width: 32px; height: 32px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.num.big { width: 44px; height: 44px; font-size: 16px; }
.vbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vline { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.vname { font-weight: 600; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.small { font-size: 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { flex: none; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.btn { min-height: 44px; border-radius: var(--radius-md); border: 1px solid var(--border); background: #fff; color: var(--navy); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 140px; }
.stats3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface-muted); border-radius: var(--radius-md); padding: 10px; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat b { font-size: 15px; color: var(--navy); }
.stats2 .stat b { font-size: 19px; }
.box { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px; }
.box span { display: block; font-size: 12px; color: var(--muted); }
.box b { color: var(--navy); }
.day-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--border); }
.day-item .t { flex: none; width: 92px; font-size: 12px; font-weight: 600; color: var(--navy); }
.empty { padding: 14px; border-radius: var(--radius-md); background: var(--surface-muted); color: var(--muted); font-size: 13px; }
.info { padding: 12px; border-radius: var(--radius-md); background: var(--tint); color: var(--navy); font-size: 12px; line-height: 18px; }

/* marqueurs MapLibre */
.mk { width: 34px; height: 34px; border-radius: 999px; border: 3px solid #fff; display: flex; align-items: center; justify-content: center; font: 700 14px/1 'Poppins', system-ui, sans-serif; box-shadow: 0 2px 6px rgba(13,42,74,.3); cursor: pointer; }
.mk.sel { width: 42px; height: 42px; box-shadow: 0 0 0 6px rgba(0,105,208,.25); }
.mk-depot { width: 30px; height: 30px; border-radius: 8px; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(13,42,74,.3); }
.mk-dest { background: var(--navy); color: #fff; padding: 4px 10px; border-radius: 8px; font: 600 12px 'Poppins', sans-serif; white-space: nowrap; display: inline-block; }
.mk-urgent { background: var(--warn); }
.maplibregl-map { font-family: 'Poppins', system-ui, sans-serif; }
.hist-tip .maplibregl-popup-content { font: 600 12px 'Poppins', sans-serif; padding: 4px 8px; }

/* ---------- planning ---------- */
.gantt-wrap { overflow-x: auto; }
.gantt { min-width: 960px; }
.g-row { display: flex; border-top: 1px solid var(--border); }
.g-label { flex: none; width: 230px; display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 4px; }
.g-track { position: relative; flex: 1; height: 112px; }
.g-head .g-track { height: 26px; }
.g-hour { position: absolute; top: 0; transform: translateX(-50%); font-size: 12px; color: var(--muted); white-space: nowrap; }
.g-line { position: absolute; top: 0; bottom: 0; width: 1px; background: #EEF2F6; }
.g-plan { position: absolute; top: 12px; height: 28px; border-radius: 6px; border: 1px solid #9DBFE6; background: var(--tint); color: var(--navy); font-size: 11px; line-height: 26px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-plan.late { border-color: var(--warn); background: var(--warn-bg); }
.g-org { position: absolute; top: 44px; height: 8px; border-radius: 999px; background: #0D2A4A; }
.g-orgtime { position: absolute; top: 54px; font-size: 10px; line-height: 14px; font-weight: 600; color: #0D2A4A; white-space: nowrap; }
.g-real { position: absolute; top: 72px; height: 8px; border-radius: 999px; background: var(--brand); }
.g-real.current { background: var(--green); }
.g-gps { position: absolute; top: 82px; font-size: 10px; line-height: 14px; font-weight: 600; color: #0069D0; white-space: nowrap; }
.g-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--warn); }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.datein { min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: #fff; color: var(--navy); }

/* ---------- alertes ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--navy); font-weight: 600; font-size: 13px; cursor: pointer; }
.filter[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.alert { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--border); }
.alert .ic { flex: none; width: 40px; height: 40px; border-radius: 999px; display: flex; align-items: center; justify-content: center; }
.alert .head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.alert .head b { color: var(--navy); }
.alert .head time { margin-left: auto; font-weight: 600; color: var(--muted); font-size: 13px; }
.alert-dismiss { min-height: 36px; padding: 0 12px; flex: none; }

.assoc-vehicles { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.assoc-choice { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--navy); cursor: pointer; }
.assoc-choice input { width: 16px; height: 16px; }
table.setup { width: 100%; border-collapse: collapse; font-size: 13px; }
table.setup th, table.setup td { text-align: left; padding: 8px; border-top: 1px solid var(--border); }
table.setup th { color: var(--muted); font-weight: 600; }
code { background: var(--surface-muted); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

.report-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.report-form label { display: flex; flex-direction: column; gap: 4px; }
.report-kpis { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 8px; }
.report-kpis div { background: var(--surface-muted); border-radius: var(--radius-md); padding: 10px 12px; }
.report-kpis b { display: block; font-size: 22px; color: var(--navy); }
.report-kpis .warn b { color: var(--warn-text); }

footer { padding: 14px 24px; border-top: 1px solid var(--border); background: #fff; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
footer .filet { display: inline-block; width: 28px; height: 4px; border-radius: 4px; background: var(--green); margin-right: 8px; vertical-align: middle; }

/* ---------- connexion ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--navy); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 24px; padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.login-card .logo-box { background: var(--navy); border-radius: var(--radius-lg); padding: 16px; display: flex; justify-content: center; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; color: var(--navy); font-size: 13px; }
.login-card input { min-height: 46px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.login-error { padding: 10px 12px; border-radius: var(--radius-md); background: var(--warn-bg); color: var(--warn-text); font-size: 13px; }

@media print {
  .top, .kpis, #view-map, #view-planning, #view-alertes, #view-reglages, footer, .no-print { display: none !important; }
  #view-rapport { display: block !important; }
  body, main { background: #fff; }
}
@media (max-width: 720px) {
  main { padding: 14px 12px 24px; }
  .top { padding: 10px 12px; }
  #map { height: 420px; }
}
