:root {
  --navy: #0b1240;
  --blue: #2346d8;
  --blue-soft: #e8ecff;
  --orange: #f7a21b;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e3e6ef;
  --text: #0b1240;
  --muted: #5b6283;
  --danger: #9b1c1c;
  --danger-soft: #fde8e8;
  --success: #1f6b45;
  --success-soft: #e6f4ec;
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 Inter, system-ui, sans-serif; }
h1, h2, h3 { margin: 0; }
h1 { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 30px; letter-spacing: -0.5px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); margin: 4px 0 0; }
.brand { font-family: 'Space Grotesk', Inter, sans-serif; font-weight: 700; font-size: 22px; margin: 0; }
.brand span { color: var(--orange); }
.brand small { font-family: Inter, sans-serif; font-weight: 500; font-size: 13px; opacity: 0.75; }

/* Boutons et champs */
.btn { min-height: 44px; border-radius: 12px; border: 1px solid transparent; padding: 0 18px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: #1b37b4; }
.btn.ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #9fb0ff; outline-offset: 2px; }
input, select { width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); padding: 0 12px; font: inherit; color: var(--text); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.error { background: var(--danger-soft); color: var(--danger); border-radius: 12px; padding: 10px 14px; margin: 0; }
.success { background: var(--success-soft); color: var(--success); border-radius: 12px; padding: 10px 14px; margin: 0; font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); padding: 32px; display: flex; flex-direction: column; gap: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }

/* Mise en page : menu + contenu ; le menu passe au-dessus sur téléphone */
.layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.sidebar { flex: 1 1 220px; max-width: 260px; background: var(--navy); color: #fff; padding: 24px 16px; display: flex; flex-direction: column; gap: 6px; }
.sidebar .brand { padding: 0 12px 18px; }
.sidebar a { color: #fff; text-decoration: none; padding: 12px; border-radius: 10px; font-weight: 600; }
.sidebar a.active { background: rgba(255, 255, 255, 0.12); }
.sidebar .soon { color: #c9cee8; padding: 12px; font-size: 14px; }
.sidebar .btn { margin-top: auto; }
.content { flex: 999 1 560px; min-width: 0; padding: 32px; display: flex; flex-direction: column; gap: 18px; }
/* Dès que le menu ne tient plus à côté du contenu, il devient une barre horizontale en haut. */
@media (max-width: 900px) {
  .layout { align-content: flex-start; }
  .sidebar { flex-basis: 100%; max-width: none; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
  .sidebar .brand { padding: 0 12px 0 0; }
  .sidebar .soon { display: none; }
  .sidebar .btn { margin: 0 0 0 auto; }
  .content { padding: 20px 16px; }
}

.page-head { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-end; }
.page-head > div { max-width: 640px; }
.toolbar { display: flex; flex-direction: column; gap: 12px; }
.toolbar input { max-width: 480px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 38px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); padding: 0 14px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; }
.chip[aria-pressed='true'] { background: var(--navy); border-color: var(--navy); color: #fff; }

/* Tableau */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th { text-align: left; font-size: 12px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); padding: 14px 16px; border-bottom: 1px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid #eef0f5; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbff; }
.code-btn { white-space: nowrap; background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--blue); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; }
.small { font-size: 13px; color: var(--muted); }
.pill { display: inline-block; border-radius: 99px; padding: 4px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
/* Étapes : commande (0-2), entrepôt en Chine (3-4), en route (5), à Lomé (6-7), retiré (8). */
.pill.s0, .pill.s1, .pill.s2 { background: #f3e8ff; color: #6b21a8; }
.pill.s3, .pill.s4 { background: #fff1db; color: #7a4a00; }
.pill.s5 { background: var(--blue-soft); color: #1d35b0; }
.pill.s6, .pill.s7 { background: var(--success-soft); color: var(--success); }
.pill.s8 { background: #eef0f5; color: var(--muted); }

/* Fenêtres */
dialog { border: 0; border-radius: 20px; padding: 0; width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); color: var(--text); }
dialog::backdrop { background: rgba(11, 18, 64, 0.45); }
.form { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid .wide { grid-column: 1 / -1; }
@media (max-width: 560px) { .grid { grid-template-columns: minmax(0, 1fr); } }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0; }
.facts div { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.share { display: flex; flex-wrap: wrap; gap: 10px; }
.share a { display: inline-flex; align-items: center; min-height: 44px; border-radius: 12px; padding: 0 16px; background: var(--success-soft); color: var(--success); font-weight: 600; text-decoration: none; }

/* Frise */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { display: grid; grid-template-columns: 22px 1fr auto; gap: 12px; padding-bottom: 12px; position: relative; }
.timeline li::before { content: ''; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #c9cedd; background: #fff; margin-top: 2px; }
.timeline li.done::before { background: var(--blue); border-color: var(--blue); }
.timeline li.current::before { border: 6px solid var(--blue); width: 10px; height: 10px; }
.timeline li:not(:last-child)::after { content: ''; position: absolute; left: 10px; top: 24px; bottom: 0; width: 2px; background: var(--border); }
.timeline li.done:not(:last-child)::after { background: var(--blue); }
.timeline .t-title { font-weight: 600; }
.timeline .future .t-title, .timeline li.future { color: var(--muted); }
.timeline .t-note { font-size: 13px; color: var(--muted); }
.timeline .t-date { font-size: 13px; color: var(--muted); white-space: nowrap; }
.advance { border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }

/* Rubriques, compteur, agent connecté */
.section { display: flex; flex-direction: column; gap: 18px; }
.sidebar a[aria-current='page'] { background: rgba(255, 255, 255, 0.12); }
.sidebar a { color: #fff; text-decoration: none; padding: 12px; border-radius: 10px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.count { background: var(--orange); color: var(--navy); border-radius: 99px; padding: 1px 8px; font-size: 12px; font-weight: 700; }
.who { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 16px; }
.who span { color: #c9cee8; font-size: 13px; padding: 0 4px; }
@media (max-width: 900px) {
  .who { margin: 0 0 0 auto; flex-direction: row; align-items: center; padding: 0; }
  .sidebar a { padding: 10px; }
}

/* Photos */
.photos-block { display: flex; flex-direction: column; gap: 10px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photos figure { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); }
.photos figcaption { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.photos figcaption button { min-height: 32px; padding: 0 10px; font-size: 12px; }
.photo-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: end; }
.photo-form .error { grid-column: 1 / -1; }
input[type='file'] { padding: 10px; }
@media (max-width: 560px) { .photo-form { grid-template-columns: minmax(0, 1fr); } }
.message { background: var(--bg); border-radius: 12px; padding: 12px 14px; margin: 0; white-space: pre-wrap; }
.history { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.pill.r-nouveau { background: #fff1db; color: #7a4a00; }
.pill.r-en-cours { background: var(--blue-soft); color: #1d35b0; }
.pill.r-repondu { background: var(--success-soft); color: var(--success); }
.pill.r-clos, .pill.p-non-paye { background: #eef0f5; color: var(--muted); }
.pill.p-en-attente { background: #fff1db; color: #7a4a00; }
.pill.p-paye { background: var(--success-soft); color: var(--success); }
.pill.p-echoue { background: var(--danger-soft); color: var(--danger); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pill.c-ok { background: var(--success-soft); color: var(--success); }
.pill.c-wait { background: #fff1db; color: #7a4a00; }
.pill.c-none { background: #eef0f5; color: var(--muted); }
.row-actions .btn { padding: 6px 12px; font-size: 13px; }
.row-actions a { font-size: 13px; align-self: center; }
.row-actions .btn { min-height: 36px; padding: 0 12px; font-size: 13px; }

/* ---- AKOFA Drive ---- */
.warning { background: #fff1db; color: #7a4a00; border-radius: 12px; padding: 10px 14px; margin: 0; font-weight: 600; }
.warning a { color: inherit; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; }
.stat b { display: block; font-family: 'Space Grotesk', Inter, sans-serif; font-size: 26px; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.alert { border-color: var(--orange); background: #fffaf0; }
.live { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; }
@media (max-width: 1100px) { .live { grid-template-columns: minmax(0, 1fr); } }
.map { height: 520px; border-radius: 16px; border: 1px solid var(--border); background: #e8ecf3; z-index: 0; }
.map.small { height: 280px; }
.watch { padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: 520px; overflow: auto; }
.watch-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.watch-list li { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.watch-list li.late { border-color: var(--orange); background: #fffaf0; }
.watch-list .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; color: var(--muted); margin: 0; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #c9cedd; margin-left: 6px; }
.dot.available { background: #1f9d55; }
.dot.busy { background: var(--blue); }
.dot.pickup { background: var(--orange); }
.dot.dropoff { background: var(--navy); }
.table-wrap.flat { border: 0; }
table.compact { min-width: 520px; }
table.compact input { min-height: 40px; }
.pill.st-recherche { background: #fff1db; color: #7a4a00; }
.pill.st-acceptee, .pill.st-au-depart, .pill.st-recuperee, .pill.st-arrivee { background: var(--blue-soft); color: #1d35b0; }
.pill.st-livree { background: var(--success-soft); color: var(--success); }
.pill.st-annulee, .pill.k-refuse { background: #eef0f5; color: var(--muted); }
.pill.k-en-attente { background: #fff1db; color: #7a4a00; }
.pill.k-actif { background: var(--success-soft); color: var(--success); }
.pill.k-suspendu { background: var(--danger-soft); color: var(--danger); }
.code-big { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 28px; letter-spacing: 6px; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.docs figure { margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.docs img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); }
.detail { display: flex; flex-direction: column; gap: 16px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.inline-form label { flex: 1 1 220px; }
.leaflet-container { font: inherit; }
.nowrap { white-space: nowrap; }
