/* =========================================================
   Gestion des déplacements — IKSD Consulting
   Inspiration : signalisation routière (bitume + marquage jaune)
   ========================================================= */
:root {
  --bitume: #1C2533;
  --bitume-2: #26313F;
  --marquage: #F2B705;
  --marquage-doux: #FCF1CC;
  --extra: #0F7A6E;
  --extra-doux: #D9F0EC;
  --ok: #1E7B3C;
  --ok-doux: #DCF2E3;
  --alerte: #B4410E;
  --alerte-doux: #FBE6DA;

  --fond: #F3F5F7;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --encre: #1C2533;
  --encre-2: #5A6573;
  --trait: #DDE2E8;
  --focus: #2F6FED;

  --rayon: 10px;
  --rayon-s: 6px;
  --ombre: 0 1px 2px rgba(28,37,51,.06), 0 4px 16px rgba(28,37,51,.05);

  --police: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --police-titre: 'Barlow Semi Condensed', 'Barlow', 'Arial Narrow', system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #11161E; --surface: #18202B; --surface-2: #1D2633;
    --encre: #E7EBF0; --encre-2: #9AA5B3; --trait: #2A3545;
    --marquage-doux: #3A3112; --extra: #3CC2AF; --extra-doux: #123631;
    --ok: #4CC777; --ok-doux: #143222; --alerte: #F08A54; --alerte-doux: #3A2016;
    --ombre: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #11161E; --surface: #18202B; --surface-2: #1D2633;
  --encre: #E7EBF0; --encre-2: #9AA5B3; --trait: #2A3545;
  --marquage-doux: #3A3112; --extra: #3CC2AF; --extra-doux: #123631;
  --ok: #4CC777; --ok-doux: #143222; --alerte: #F08A54; --alerte-doux: #3A2016;
  --ombre: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--police); font-size: 16px; line-height: 1.5;
  background: var(--fond); color: var(--encre);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--police-titre); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Structure ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.nav {
  background: var(--bitume); color: #DCE2EA; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 22px 16px 16px;
  /* La ligne de marquage : élément signature */
  background-image: repeating-linear-gradient(to bottom, var(--marquage) 0 22px, transparent 22px 40px);
  background-size: 4px 100%; background-repeat: no-repeat; background-position: right 0 top 0;
}
.marque { display: flex; gap: 12px; align-items: center; text-decoration: none; padding: 0 6px 22px; }
.marque-signe { width: 30px; height: 30px; background: var(--marquage); transform: rotate(45deg); border-radius: 4px; flex: none;
  box-shadow: inset 0 0 0 3px var(--bitume), inset 0 0 0 5px var(--marquage); }
.marque strong { display: block; font-family: var(--police-titre); font-size: 1.15rem; color: #fff; letter-spacing: .01em; }
.marque small { display: block; font-size: .82rem; color: #9FAABA; }
.nav nav { display: flex; flex-direction: column; gap: 2px; }
.nav nav a {
  display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: var(--rayon-s);
  text-decoration: none; color: #C3CBD6; font-weight: 500;
}
.nav nav a:hover { background: var(--bitume-2); color: #fff; }
.nav nav a.actif { background: var(--bitume-2); color: #fff; box-shadow: inset 3px 0 0 var(--marquage); }
.lib-court, .seul-mobile { display: none; }
.nav-pied { margin-top: auto; border-top: 1px solid #2E3A4A; padding-top: 14px; }
.moi { display: flex; gap: 10px; align-items: center; font-size: .92rem; color: #fff; padding: 0 6px 12px; }
.moi small { display: block; color: #9FAABA; font-size: .8rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--marquage); color: var(--bitume);
  display: grid; place-items: center; font-family: var(--police-titre); font-weight: 700; flex: none; }
.nav-actions { display: flex; gap: 6px; }
.btn-ghost { flex: 1; display: inline-flex; gap: 6px; align-items: center; justify-content: center;
  background: transparent; border: 1px solid #36435A; color: #C3CBD6; border-radius: var(--rayon-s);
  padding: 7px 8px; font: inherit; font-size: .88rem; cursor: pointer; text-decoration: none; }
.btn-ghost:hover { color: #fff; border-color: #56647C; }
.btn-ghost .ico { width: 17px; height: 17px; }

.contenu { padding: 30px clamp(16px, 3vw, 40px) 24px; min-width: 0; max-width: 1280px; width: 100%; }
.pied { margin-top: 40px; color: var(--encre-2); font-size: .85rem; }

/* ---------- En-têtes de page ---------- */
.entete { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.entete p { margin: 6px 0 0; color: var(--encre-2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid var(--trait); background: var(--surface); color: var(--encre);
  padding: 9px 15px; border-radius: var(--rayon-s); font: inherit; font-weight: 600; font-size: .95rem;
  cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap;
}
.btn:hover { border-color: var(--encre-2); }
.btn .ico { width: 18px; height: 18px; }
.btn-principal { background: var(--bitume); border-color: var(--bitume); color: #fff; }
:root[data-theme="dark"] .btn-principal { background: #E7EBF0; border-color: #E7EBF0; color: #11161E; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-principal { background: #E7EBF0; border-color: #E7EBF0; color: #11161E; } }
.btn-principal:hover { opacity: .92; }
.btn-route { background: var(--marquage); border-color: var(--marquage); color: #1C2533; }
.btn-route:hover { border-color: #D9A300; background: #F7C21C; }
.btn-extra { background: var(--extra-doux); border-color: transparent; color: var(--extra); }
.btn-danger { color: var(--alerte); }
.btn-danger:hover { border-color: var(--alerte); }
.btn-petit { padding: 6px 10px; font-size: .86rem; }
.lien-icone { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--rayon-s);
  color: var(--encre-2); border: 1px solid transparent; background: none; cursor: pointer; text-decoration: none; }
.lien-icone:hover { border-color: var(--trait); color: var(--encre); }
.lien-icone .ico { width: 18px; height: 18px; }

/* ---------- Blocs ---------- */
.bloc { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); box-shadow: var(--ombre); }
.bloc-tete { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--trait); flex-wrap: wrap; }
.bloc-corps { padding: 20px; }
.grille { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.pile > * + * { margin-top: 18px; }

/* ---------- Compteur de période (dashboard) ---------- */
.compteur {
  display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); overflow: hidden; box-shadow: var(--ombre);
}
.compteur > div { padding: 20px 22px; border-left: 1px solid var(--trait); }
.compteur > div:first-child { border-left: 0; background: var(--bitume); color: #fff; position: relative; }
.compteur > div:first-child::after {
  content: ""; position: absolute; left: 22px; right: 22px; bottom: 14px; height: 4px;
  background: repeating-linear-gradient(to right, var(--marquage) 0 26px, transparent 26px 44px);
}
.compteur .lib { font-size: .9rem; color: var(--encre-2); }
.compteur > div:first-child .lib { color: #AEB8C6; }
.compteur .val { font-family: var(--police-titre); font-weight: 600; font-size: 1.7rem; font-variant-numeric: tabular-nums; margin-top: 4px; }
.compteur > div:first-child .val { font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 700; margin-bottom: 14px; }
.compteur .sous { font-size: .85rem; color: var(--encre-2); }
.compteur > div:first-child .sous { color: #AEB8C6; }

/* ---------- Tableaux ---------- */
.table-defil { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--trait); vertical-align: middle; }
th { font-weight: 600; color: var(--encre-2); font-size: .85rem; background: var(--surface-2); white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td.d, th.d { text-align: right; }
td.c, th.c { text-align: center; }
tfoot td { font-weight: 700; background: var(--surface-2); border-bottom: 0; }
.motif { max-width: 420px; }
.total-bas { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; justify-content: flex-end;
  padding: 14px 20px; background: var(--surface-2); border-radius: 0 0 var(--rayon) var(--rayon); color: var(--encre-2); }
.total-bas strong { color: var(--encre); }
.total-bas-grand strong { font-family: var(--police-titre); font-size: 1.3rem; }
.motif small { display: block; color: var(--encre-2); }
.vide { padding: 34px 20px; text-align: center; color: var(--encre-2); }
.vide p { margin: 0 0 14px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.b-dep { background: var(--marquage-doux); color: #7A5A00; }
:root[data-theme="dark"] .b-dep { color: var(--marquage); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .b-dep { color: var(--marquage); } }
.b-extra { background: var(--extra-doux); color: var(--extra); }
.b-ok { background: var(--ok-doux); color: var(--ok); }
.b-attente { background: var(--surface-2); color: var(--encre-2); border: 1px solid var(--trait); }
.b-inactif { background: var(--alerte-doux); color: var(--alerte); }
.badge .ico { width: 13px; height: 13px; }

/* ---------- Formulaires ---------- */
.form { display: grid; gap: 16px; }
.form-ligne { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
label small, .aide { font-weight: 400; color: var(--encre-2); font-size: .85rem; }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=month], select, textarea {
  width: 100%; font: inherit; color: var(--encre); background: var(--surface);
  border: 1px solid var(--trait); border-radius: var(--rayon-s); padding: 10px 12px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(47,111,237,.18); }
textarea { min-height: 90px; resize: vertical; }
.montant-champ { position: relative; }
.montant-champ input { padding-right: 64px; font-family: var(--police-titre); font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.montant-champ span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--encre-2); font-size: .9rem; }
.case { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.case input { width: 18px; height: 18px; }
.filtres { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filtres > div { min-width: 160px; }
.filtres label { font-size: .82rem; margin-bottom: 4px; }
.saisie-type { display: flex; gap: 12px; align-items: center; margin-bottom: 4px; }
.saisie-type .pastille { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; }
.pastille.dep { background: var(--marquage); color: #1C2533; }
.pastille.extra { background: var(--extra-doux); color: var(--extra); }
.verrou { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--rayon-s); background: var(--ok-doux); color: var(--ok); font-size: .92rem; }

/* ---------- Messages ---------- */
.flash { padding: 12px 16px; border-radius: var(--rayon-s); margin-bottom: 18px; font-weight: 500; border: 1px solid transparent; }
.flash-ok { background: var(--ok-doux); color: var(--ok); }
.flash-erreur { background: var(--alerte-doux); color: var(--alerte); }
.flash-info { background: var(--marquage-doux); color: #6B4E00; }
:root[data-theme="dark"] .flash-info { color: var(--marquage); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .flash-info { color: var(--marquage); } }

/* ---------- Graphiques ---------- */
.graph { position: relative; height: 290px; }
.graph-petit { height: 250px; }

/* ---------- Navigation de période ---------- */
.periode-nav { display: inline-flex; align-items: center; border: 1px solid var(--trait); border-radius: var(--rayon-s); background: var(--surface); }
.periode-nav a { padding: 8px 12px; text-decoration: none; color: var(--encre-2); font-weight: 700; }
.periode-nav a:hover { color: var(--encre); }
.periode-nav strong { padding: 8px 6px; font-family: var(--police-titre); font-size: 1.05rem; min-width: 140px; text-align: center; }

/* ---------- Connexion ---------- */
.page-connexion { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.connexion-visuel {
  background: var(--bitume); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.connexion-visuel::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 8px; transform: translateX(-50%);
  background: repeating-linear-gradient(to bottom, var(--marquage) 0 48px, transparent 48px 84px);
  opacity: .9;
}
.connexion-visuel > * { position: relative; background: var(--bitume); padding: 6px 0; }
.connexion-visuel h1 { font-size: clamp(2.2rem, 4vw, 3.2rem); font-weight: 700; max-width: 12ch; }
.connexion-visuel p { color: #AEB8C6; max-width: 34ch; margin: 12px 0 0; }
.connexion-form { display: grid; place-items: center; padding: 32px 20px; }
.connexion-form .bloc { width: 100%; max-width: 380px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .compteur { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compteur > div:nth-child(3) { border-left: 0; }
  .compteur > div:nth-child(n+3) { border-top: 1px solid var(--trait); }
  .g-3-1 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav {
    position: fixed; z-index: 20; top: auto; bottom: 0; left: 0; right: 0; height: auto;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); flex-direction: row;
    background-image: none; border-top: 3px dashed var(--marquage);
  }
  .marque, .nav-pied, .lib-long { display: none; }
  .lib-court { display: inline; }
  .nav nav { flex-direction: row; justify-content: space-around; width: 100%; }
  .nav nav a { flex-direction: column; gap: 3px; padding: 6px 4px; font-size: .7rem; flex: 1; text-align: center; }
  .nav nav a.actif { box-shadow: inset 0 3px 0 var(--marquage); }
  .contenu { padding: calc(18px + env(safe-area-inset-top, 0px)) 14px 96px; }
  .g-2 { grid-template-columns: 1fr; }
  h1 { font-size: 1.55rem; }
  .page-connexion { grid-template-columns: 1fr; }
  .connexion-visuel { padding: 28px 22px; min-height: 0; }
  .connexion-visuel::before { left: auto; right: 22px; transform: none; }
  .connexion-visuel .masque-mobile { display: none; }
  .cacher-mobile { display: none; }
  .motif small.seul-mobile { display: block; }
  th, td { padding: 10px; }
}
@media (max-width: 520px) {
  .compteur { grid-template-columns: 1fr 1fr; }
  .compteur > div:first-child { grid-column: 1 / -1; }
  .compteur > div:nth-child(2) { border-left: 0; border-top: 1px solid var(--trait); }
  .compteur > div:nth-child(3) { border-left: 1px solid var(--trait); }
  .compteur > div:nth-child(4) { grid-column: 1 / -1; border-left: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
