:root {
  --bordeaux: #6B2142; --bordeaux-dark: #4A1530; --rose: #F6E9EF; --rose-txt: #F3DCE6;
  --bg: #FAF7F2; --card: #FFFFFF; --line: #EAE3DA; --line2: #D9D1C7;
  --ink: #1E1A1D; --muted: #5F5A5E; --night: #1E1A1D;
  --green: #1E6B32; --green-bg: #DFF1E2; --red: #9B1C1C; --red-bg: #F9E1E1; --red-soft: #FFF4F4;
  --orange: #8A4300; --orange-bg: #FCE9D6; --amber: #E8A15F;
  --violet: #4B3A86; --violet-bg: #ECE7F7; --yellow: #6E5200; --yellow-bg: #FAF0CF;
  --teal: #1F5F5B; --teal-bg: #E0F2F1; --grey-bg: #ECEAE7; --grey: #3F3B3E;
  --wa: #1F7A44;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, sans-serif; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; }
a { color: var(--bordeaux); }
button, input, select, textarea { font: inherit; color: inherit; }
.serif { font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.bold { font-weight: 700; }
.green { color: var(--green); } .red { color: var(--red); }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.wrap { max-width: 720px; margin: 0 auto; }
.wide { max-width: 1320px; margin: 0 auto; }
.pad { padding: 14px 16px; }
.page { padding-bottom: 96px; }

/* En-têtes */
.hdr { background: var(--bordeaux); color: #fff; padding: 18px 16px 14px; padding-top: max(18px, env(safe-area-inset-top)); }
.hdr.dark { background: var(--night); }
.hdr.light { background: #fff; color: var(--ink); border-bottom: 1px solid var(--line); padding: 8px; display: flex; align-items: center; gap: 4px; }
.hdr h1 { margin: 0; font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; font-size: 24px; }
.hdr .sub { font-size: 13px; color: var(--rose-txt); }
.hdr.dark .sub { color: #CFC8CC; }
.hdr-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: none; background: rgba(255,255,255,.15); color: inherit; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.hdr.light .icon-btn { background: transparent; }
.back { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }
.title { font-weight: 600; font-size: 17px; flex: 1; }

/* Segments et filtres */
.pills { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pill { flex: 1; min-width: 80px; height: 36px; border-radius: 18px; border: 1px solid rgba(255,255,255,.4); background: transparent; color: #fff; font-size: 13px; cursor: pointer; }
.pill.on { background: #fff; color: var(--bordeaux); font-weight: 600; border-color: #fff; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.fchip { flex: none; height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--line2); background: #fff; font-size: 13px; cursor: pointer; white-space: nowrap; }
.fchip.on { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; margin: 14px 16px 4px; background: #EDE6DC; border-radius: 12px; padding: 4px; }
.tab { height: 40px; border-radius: 9px; border: none; background: transparent; font-size: 14px; color: var(--grey); display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; text-decoration: none; }
.tab.on { background: #fff; font-weight: 700; color: var(--ink); }
.badge { background: var(--bordeaux); color: #fff; border-radius: 10px; padding: 1px 8px; font-size: 12px; font-weight: 700; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg button { height: 44px; border-radius: 10px; border: 1px solid var(--line2); background: #fff; font-size: 14px; cursor: pointer; }
.seg button.on { border: 2px solid var(--bordeaux); background: var(--rose); color: var(--bordeaux); font-weight: 600; }

/* Compteurs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 14px 16px 4px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.kpi b { font-size: 20px; }
.kpi span { font-size: 11px; color: var(--muted); }
.kpi.alert { background: var(--red-soft); border-color: #F1C9C9; }
.kpi.alert b { color: var(--red); }
.kgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kbig { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kbig b { font-size: 28px; }
.kbig.alert { background: var(--red-soft); border-color: #F1C9C9; }
.kbig.alert b { color: var(--red); }

/* Cartes */
.list { padding: 8px 16px; display: flex; flex-direction: column; gap: 10px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.card.tap { cursor: pointer; }
.card.hot { border: 2px solid var(--amber); }
.card.ghost { background: #F3EFEA; border-style: dashed; border-color: #CFC6BA; }
.card h3 { margin: 0; font-size: 16px; }
.section-title { padding: 14px 20px 4px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: none; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14px; }
.box { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.box h2 { margin: 0 0 10px; font-size: 16px; }
.note { background: #FFF8E6; border: 1px solid #EED9A0; border-radius: 12px; padding: 12px; }
.note .xs { color: var(--yellow); font-weight: 700; }
.rose { background: var(--rose); border-radius: 10px; padding: 12px 14px; color: var(--bordeaux-dark); }
.band-red { background: var(--red-soft); border-radius: 8px; padding: 6px 6px 6px 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.band-red span { font-size: 12px; color: var(--red); font-weight: 700; }
.linkok { font-size: 12px; color: var(--green); font-weight: 600; }

/* Statuts */
.chip { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 12px; white-space: nowrap; }
.s-disponible { background: var(--grey-bg); color: var(--grey); }
.s-prise { background: var(--violet-bg); color: var(--violet); }
.s-en_cours { background: var(--orange-bg); color: var(--orange); }
.s-livree { background: var(--green-bg); color: var(--green); }
.s-echouee { background: var(--red-bg); color: var(--red); }
.s-reportee { background: var(--yellow-bg); color: var(--yellow); }
.s-annulee { background: #E7E5E4; color: #57534E; }
.s-en_cours_expedition { background: var(--teal-bg); color: var(--teal); }
.s-expediee { background: var(--teal-bg); color: var(--teal); }

/* Boutons */
.btn { height: 48px; border-radius: 12px; border: none; background: var(--bordeaux); color: #fff; font-weight: 600; font-size: 15px; padding: 0 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.block { width: 100%; }
.btn.big { height: 56px; font-size: 17px; font-weight: 700; }
.btn.sm { height: 36px; font-size: 13px; padding: 0 12px; border-radius: 8px; }
.btn.green { background: var(--green); }
.btn.wa { background: var(--wa); }
.btn.amber { background: var(--amber); color: var(--ink); font-weight: 700; }
.btn.dark { background: var(--ink); }
.btn.outline { background: #fff; color: var(--grey); border: 1px solid var(--line2); }
.btn.outline-red { background: #fff; color: var(--red); border: 2px solid var(--red); }
.btn.outline-yellow { background: #fff; color: var(--yellow); border: 2px solid var(--yellow); }
.btn.outline-green { background: #fff; color: var(--green); border: 2px solid var(--green); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }
.actions3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.act { height: 64px; border-radius: 12px; background: #fff; border: 1px solid var(--line2); text-decoration: none; color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 13px; font-weight: 600; }
.linkbtn { background: none; border: none; color: var(--bordeaux); font-weight: 600; font-size: 14px; min-height: 44px; cursor: pointer; padding: 0; }
.bottom-bar { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 12px 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.fab { position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); height: 52px; padding: 0 20px; border-radius: 26px; background: var(--bordeaux); color: #fff; text-decoration: none; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; box-shadow: 0 6px 18px rgba(107,33,66,.35); z-index: 20; }

/* Formulaires */
form.stack, .form { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { min-height: 46px; border: 1px solid var(--line2); border-radius: 10px; padding: 0 12px; font-size: 16px; background: #fff; width: 100%; }
.field textarea { padding: 10px 12px; min-height: 80px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--bordeaux); outline-offset: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.radio { min-height: 52px; border-radius: 12px; border: 1px solid var(--line2); background: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; font-size: 15px; cursor: pointer; }
.radio:has(input:checked) { border: 2px solid var(--ink); font-weight: 600; }
.radio input { width: 20px; height: 20px; accent-color: var(--bordeaux); }
.money-input { display: flex; align-items: center; height: 60px; border: 2px solid var(--green); border-radius: 12px; background: #fff; padding: 0 14px; gap: 8px; }
.money-input input { flex: 1; border: none; font-size: 26px; font-weight: 700; background: transparent; min-width: 0; outline: none; }
.item-row { display: grid; grid-template-columns: 1fr 64px 40px; gap: 6px; align-items: center; }
.item-row input { min-height: 44px; border: 1px solid var(--line2); border-radius: 10px; padding: 0 10px; font-size: 15px; width: 100%; }
.okline { font-size: 12px; color: var(--green); font-weight: 600; }
.errline { font-size: 12px; color: var(--red); font-weight: 600; }

/* Navigation du bas */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding-bottom: env(safe-area-inset-bottom); z-index: 30; }
.nav a { height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; position: relative; }
.nav a.on { color: var(--bordeaux); font-weight: 600; }
.nav a .dot { position: absolute; top: 8px; right: calc(50% - 20px); background: var(--red); color: #fff; font-size: 10px; border-radius: 9px; padding: 0 5px; font-weight: 700; }

/* Avatars */
.av { border-radius: 50%; background: var(--rose-txt); color: var(--bordeaux); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; overflow: hidden; flex: none; object-fit: cover; }

/* Fenêtres */
.overlay { position: fixed; inset: 0; background: rgba(30,26,29,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); }
.sheet-hd { position: sticky; top: 0; background: #fff; border-bottom: 1px solid var(--line); padding: 12px 8px 12px 16px; display: flex; justify-content: space-between; align-items: center; z-index: 1; }
.sheet-hd b { font-size: 17px; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 20px; } }
.toast { position: fixed; left: 50%; top: max(16px, env(safe-area-inset-top)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 100; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

/* Tableau de bord */
.dash { padding: 20px 16px 100px; display: flex; flex-direction: column; gap: 20px; }
.dash-main { display: flex; flex-wrap: wrap; gap: 20px; align-items: stretch; }
.dash-map { flex: 999 1 520px; min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; }
.dash-side { flex: 1 1 300px; display: flex; flex-direction: column; gap: 12px; }
#map, .map { height: 440px; width: 100%; background: #EDE8DF; }
.alert-line { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; padding: 6px 0; }
.alert-line i { width: 10px; height: 10px; border-radius: 5px; background: var(--red); margin-top: 5px; flex: none; }
.alert-line i.o { background: #C2410C; }
.bar { height: 8px; border-radius: 4px; background: #F1ECE6; overflow: hidden; }
.bar > div { height: 8px; background: var(--bordeaux); border-radius: 4px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px; background: var(--bg); }
table.t td { padding: 10px; border-top: 1px solid var(--line); }
.scroll-x { overflow-x: auto; }
.drv-pin { display: flex; flex-direction: column; align-items: center; }
.drv-pin .av { border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.drv-pin .tag { background: #fff; border-radius: 8px; padding: 2px 8px; font-size: 12px; font-weight: 600; margin-top: 2px; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; align-items: end; height: 150px; }
.bars .col { display: flex; flex-direction: column; align-items: center; gap: 4px; justify-content: flex-end; height: 100%; }
.bars .col div { width: 100%; background: var(--green); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars-lbl { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; font-size: 11px; color: var(--muted); text-align: center; }
.report-img { width: 100%; border-radius: 16px; box-shadow: 0 6px 20px rgba(30,26,29,.12); display: block; }
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; gap: 18px; }
.login h1 { font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; color: var(--bordeaux); font-size: 34px; margin: 0; text-align: center; }
.gps { border-radius: 10px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; font-size: 13px; margin-top: 12px; }
.gps.on { background: #1F4D2E; } .gps.off { background: #5A2A10; }
.gps i { width: 10px; height: 10px; border-radius: 5px; background: #6EE08F; flex: none; }
.gps.off i { background: #F59E0B; }
.hdr-links { display: flex; gap: 8px; margin-top: 10px; }
.hdr-links a { flex: 1; height: 38px; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff; text-decoration: none; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.ev { font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; }
.dash-map #map { flex: 1; min-height: 440px; height: auto; }
