/* ═══════════════════════════════════════════════════════════════════════════
   ENTANA — système visuel
   Voir STYLE.md. Terre rouge de Madagascar, encre profonde, gris chauds.
   Un seul accent. Chiffres tabulaires partout. Aucun emoji.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light dark;

  /* Surfaces */
  --papier: #fbfaf7;
  --papier-2: #f4f2ed;
  --surface: #ffffff;
  --surface-2: #f8f6f2;
  --voile: rgba(20, 22, 26, 0.42);

  /* Encre */
  --encre: #14161a;
  --encre-2: #5a5f68;
  --encre-3: #8b9098;

  /* Traits */
  --trait: #e6e2da;
  --trait-fort: #d3cec3;

  /* Accent unique — latérite */
  --laterite: #d2560e;
  --laterite-fonce: #a8410a;
  --laterite-voile: rgba(210, 86, 14, 0.09);
  --laterite-trait: rgba(210, 86, 14, 0.28);

  /* États */
  --zafy: #16794c;
  --zafy-voile: rgba(22, 121, 76, 0.1);
  --vanille: #b7791f;
  --vanille-voile: rgba(183, 121, 31, 0.12);
  --cramoisi: #9f1239;
  --cramoisi-voile: rgba(159, 18, 57, 0.09);

  /* Typographie */
  --police: ui-sans-serif, 'Segoe UI Variable Display', 'Segoe UI', Inter, Roboto, system-ui,
    -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --police-chiffres: var(--police);

  --t-12: 0.75rem;
  --t-13: 0.8125rem;
  --t-15: 0.9375rem;
  --t-17: 1.0625rem;
  --t-21: 1.3125rem;
  --t-26: 1.625rem;
  --t-33: 2.0625rem;
  --t-41: 2.5625rem;
  --t-52: 3.25rem;

  /* Rythme */
  --e-1: 0.25rem;
  --e-2: 0.5rem;
  --e-3: 0.75rem;
  --e-4: 1rem;
  --e-5: 1.5rem;
  --e-6: 2rem;
  --e-7: 3rem;
  --e-8: 4rem;
  --e-9: 6rem;

  /* Rayons */
  --r-2: 4px;
  --r-3: 6px;
  --r-4: 10px;
  --r-5: 14px;
  --r-plein: 999px;

  /* Ombres — discrètes, jamais empilées */
  --ombre-1: 0 1px 2px rgba(20, 22, 26, 0.05);
  --ombre-2: 0 2px 8px rgba(20, 22, 26, 0.06), 0 1px 2px rgba(20, 22, 26, 0.04);
  --ombre-3: 0 12px 32px rgba(20, 22, 26, 0.1), 0 2px 6px rgba(20, 22, 26, 0.05);
  --ombre-accent: 0 8px 24px rgba(210, 86, 14, 0.18);

  /* Mouvement */
  --courbe: cubic-bezier(0.32, 0.72, 0, 1);
  --courbe-douce: cubic-bezier(0.4, 0, 0.2, 1);
  --duree-1: 140ms;
  --duree-2: 240ms;
  --duree-3: 340ms;
  --duree-4: 520ms;

  --largeur: 1120px;
  --barre-h: 60px;
}

[data-theme='sombre'],
:root:not([data-theme='clair']) {
  /* remplacé plus bas par la media query ; ce bloc n'agit que si data-theme est posé */
}

[data-theme='sombre'] {
  --papier: #0f1113;
  --papier-2: #141719;
  --surface: #16191c;
  --surface-2: #1c2024;
  --voile: rgba(0, 0, 0, 0.6);
  --encre: #f2f0ec;
  --encre-2: #a2a8b2;
  --encre-3: #767d87;
  --trait: #262b30;
  --trait-fort: #333a41;
  --laterite: #f97316;
  --laterite-fonce: #fb8b3c;
  --laterite-voile: rgba(249, 115, 22, 0.12);
  --laterite-trait: rgba(249, 115, 22, 0.34);
  --zafy: #34d399;
  --zafy-voile: rgba(52, 211, 153, 0.13);
  --vanille: #e8b33c;
  --vanille-voile: rgba(232, 179, 60, 0.14);
  --cramoisi: #fb7185;
  --cramoisi-voile: rgba(251, 113, 133, 0.13);
  --ombre-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --ombre-2: 0 2px 8px rgba(0, 0, 0, 0.45);
  --ombre-3: 0 16px 40px rgba(0, 0, 0, 0.55);
  --ombre-accent: 0 8px 24px rgba(249, 115, 22, 0.22);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='clair']) {
    --papier: #0f1113;
    --papier-2: #141719;
    --surface: #16191c;
    --surface-2: #1c2024;
    --voile: rgba(0, 0, 0, 0.6);
    --encre: #f2f0ec;
    --encre-2: #a2a8b2;
    --encre-3: #767d87;
    --trait: #262b30;
    --trait-fort: #333a41;
    --laterite: #f97316;
    --laterite-fonce: #fb8b3c;
    --laterite-voile: rgba(249, 115, 22, 0.12);
    --laterite-trait: rgba(249, 115, 22, 0.34);
    --zafy: #34d399;
    --zafy-voile: rgba(52, 211, 153, 0.13);
    --vanille: #e8b33c;
    --vanille-voile: rgba(232, 179, 60, 0.14);
    --cramoisi: #fb7185;
    --cramoisi-voile: rgba(251, 113, 133, 0.13);
    --ombre-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --ombre-2: 0 2px 8px rgba(0, 0, 0, 0.45);
    --ombre-3: 0 16px 40px rgba(0, 0, 0, 0.55);
    --ombre-accent: 0 8px 24px rgba(249, 115, 22, 0.22);
  }
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--papier);
  color: var(--encre);
  font-family: var(--police);
  font-size: var(--t-15);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-synthesis-weight: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(var(--t-33), 5.2vw, var(--t-52));
}
h2 {
  font-size: clamp(var(--t-26), 3.4vw, var(--t-33));
}
h3 {
  font-size: var(--t-21);
  letter-spacing: -0.015em;
}
h4 {
  font-size: var(--t-17);
  letter-spacing: -0.01em;
}

:focus-visible {
  outline: 2px solid var(--laterite);
  outline-offset: 2px;
  border-radius: var(--r-2);
}

::selection {
  background: var(--laterite);
  color: #fff;
}

/* ─── Utilitaires typographiques ─────────────────────────────────────────── */

.chiffres,
.montant,
.compteur,
td.num,
th.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

.sourdine {
  color: var(--encre-2);
}
.sourdine-2 {
  color: var(--encre-3);
}

.etiquette {
  font-size: var(--t-12);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--encre-3);
}

.chapo {
  font-size: clamp(var(--t-17), 2vw, var(--t-21));
  color: var(--encre-2);
  line-height: 1.5;
  max-width: 58ch;
}

.lisible {
  max-width: 68ch;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── Structure ──────────────────────────────────────────────────────────── */

.conteneur {
  width: 100%;
  max-width: var(--largeur);
  margin-inline: auto;
  padding-inline: var(--e-5);
}

@media (max-width: 640px) {
  .conteneur {
    padding-inline: var(--e-4);
  }
}

.section {
  padding-block: clamp(var(--e-6), 6vw, var(--e-9));
}

/* Chaque variante est autonome : `.pile-3` seul empile déjà, sans `.pile`. */
.pile,
.pile-2,
.pile-3,
.pile-5,
.pile-6 {
  display: flex;
  flex-direction: column;
}
.pile {
  gap: var(--e-4);
}
.pile-2 {
  gap: var(--e-2);
}
.pile-3 {
  gap: var(--e-3);
}
.pile-5 {
  gap: var(--e-5);
}
.pile-6 {
  gap: var(--e-6);
}

.rang {
  display: flex;
  align-items: center;
  gap: var(--e-3);
}
.rang-2 {
  gap: var(--e-2);
}
.rang-entre {
  justify-content: space-between;
}
.rang-souple {
  flex-wrap: wrap;
}

.pousse {
  margin-left: auto;
}

/* ─── Barre supérieure ───────────────────────────────────────────────────── */

.barre {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--barre-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--papier) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--trait);
}

.barre .conteneur {
  display: flex;
  align-items: center;
  gap: var(--e-4);
  min-width: 0;
}

/*
 * Sur un téléphone d'entrée de gamme — 360 px de large, l'appareil le plus
 * courant du marché visé — la marque, le compte à rebours et trois liens ne
 * tiennent pas sur une ligne. La barre passe alors sur deux lignes plutôt que
 * de déborder : rien ne sort de l'écran, tout reste atteignable au pouce.
 */
@media (max-width: 760px) {
  .barre {
    height: auto;
    padding-block: var(--e-2);
  }

  .barre .conteneur {
    flex-wrap: wrap;
    row-gap: var(--e-2);
    column-gap: var(--e-2);
  }

  .barre-liens {
    margin-left: auto;
    justify-content: flex-end;
    gap: var(--e-1);
  }

  /* Côté client, la navigation descend dans la barre du bas : la barre du haut
     garde la marque, le compte à rebours et le thème, sur une seule ligne. */
  .barre-client .lien-barre {
    display: none;
  }

  body {
    padding-bottom: 68px;
  }
}

@media (max-width: 400px) {
  .rebours {
    font-size: var(--t-12);
    padding-inline: 8px;
  }

  .marque {
    font-size: var(--t-15);
  }
}

.marque {
  display: inline-flex;
  align-items: center;
  gap: var(--e-2);
  font-weight: 600;
  font-size: var(--t-17);
  letter-spacing: -0.03em;
}

.marque-signe {
  width: 26px;
  height: 26px;
  flex: none;
  color: var(--laterite);
}

.marque-texte {
  color: var(--encre);
}

.barre-liens {
  display: flex;
  align-items: center;
  gap: var(--e-1);
  margin-left: auto;
}

.lien-barre {
  padding: var(--e-2) var(--e-3);
  border-radius: var(--r-3);
  font-size: var(--t-13);
  font-weight: 500;
  color: var(--encre-2);
  white-space: nowrap;
  transition: background var(--duree-1) var(--courbe-douce), color var(--duree-1) var(--courbe-douce);
}

.lien-barre:hover {
  background: var(--surface-2);
  color: var(--encre);
}

.lien-barre[aria-current='page'] {
  color: var(--encre);
  background: var(--surface-2);
}

/*
 * Barre de navigation basse — mobile uniquement, côté client.
 * Sur un téléphone tenu d'une main, la navigation se met sous le pouce, pas
 * en haut de l'écran. Masquée par défaut, révélée par la media query mobile.
 */
.barre-basse {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: color-mix(in srgb, var(--papier) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-top: 1px solid var(--trait);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.barre-basse a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 550;
  color: var(--encre-3);
  transition: color var(--duree-1) var(--courbe-douce);
}

.barre-basse a[aria-current='page'] {
  color: var(--laterite);
}

/*
 * L'affichage mobile se déclare ICI, après `display: none`, et non dans la
 * media query générale plus haut dans le fichier : à spécificité égale, c'est
 * la dernière règle du fichier qui gagne, media query ou pas. Déclarée avant,
 * elle était écrasée et la barre restait invisible sur tous les écrans.
 */
@media (max-width: 760px) {
  .barre-basse {
    display: grid;
  }
}

/* ─── Boutons ────────────────────────────────────────────────────────────── */

.bouton {
  --fond: var(--encre);
  --texte: var(--papier);
  --bordure: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--e-2);
  height: 44px; /* seuil tactile : en dessous, on rate le bouton au pouce */
  padding-inline: var(--e-4);
  border-radius: var(--r-3);
  border: 1px solid var(--bordure);
  background: var(--fond);
  color: var(--texte);
  font-size: var(--t-15);
  font-weight: 550;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition:
    transform var(--duree-1) var(--courbe),
    box-shadow var(--duree-2) var(--courbe),
    background var(--duree-1) var(--courbe-douce),
    opacity var(--duree-1) linear;
}

.bouton:hover:not(:disabled) {
  transform: translateY(-1px);
}
.bouton:active:not(:disabled) {
  transform: translateY(0);
}
/*
 * Un bouton désactivé n'est pas un bouton délavé : en baissant l'opacité de
 * l'accent, on obtenait un orange pâle qui se lit comme un défaut d'affichage.
 * État neutre franc, donc — et l'écran dit toujours à côté ce qui manque.
 */
.bouton:disabled {
  background: var(--surface-2);
  color: var(--encre-3);
  border-color: var(--trait);
  box-shadow: none;
  cursor: not-allowed;
}

.bouton:disabled:hover {
  transform: none;
}

.bouton-primaire {
  --fond: var(--laterite);
  --texte: #fff;
  box-shadow: var(--ombre-1);
}
.bouton-primaire:hover:not(:disabled) {
  --fond: var(--laterite-fonce);
  box-shadow: var(--ombre-accent);
}

.bouton-secondaire {
  --fond: var(--surface);
  --texte: var(--encre);
  --bordure: var(--trait-fort);
  box-shadow: var(--ombre-1);
}
.bouton-secondaire:hover:not(:disabled) {
  --fond: var(--surface-2);
}

.bouton-fantome {
  --fond: transparent;
  --texte: var(--encre-2);
}
.bouton-fantome:hover:not(:disabled) {
  --fond: var(--surface-2);
  --texte: var(--encre);
}

.bouton-danger {
  --fond: transparent;
  --texte: var(--cramoisi);
  --bordure: color-mix(in srgb, var(--cramoisi) 34%, transparent);
}
.bouton-danger:hover:not(:disabled) {
  --fond: var(--cramoisi-voile);
}

.bouton-grand {
  height: 52px;
  padding-inline: var(--e-5);
  font-size: var(--t-17);
  border-radius: var(--r-4);
}

.bouton-large {
  width: 100%;
}

.bouton-icone {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-3);
  color: var(--encre-2);
}
.bouton-icone:hover {
  background: var(--surface-2);
  color: var(--encre);
}

/* ─── Cartes ─────────────────────────────────────────────────────────────── */

.carte {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-5);
  box-shadow: var(--ombre-1);
}

.carte-corps {
  padding: var(--e-5);
}

.carte-entete {
  padding: var(--e-4) var(--e-5);
  border-bottom: 1px solid var(--trait);
  display: flex;
  align-items: center;
  gap: var(--e-3);
}

.carte-pied {
  padding: var(--e-4) var(--e-5);
  border-top: 1px solid var(--trait);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-5) var(--r-5);
}

@media (max-width: 640px) {
  .carte-corps,
  .carte-entete,
  .carte-pied {
    padding: var(--e-4);
  }
}

/* ─── Les deux portes ────────────────────────────────────────────────────── */

.portes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--e-4);
}

@media (max-width: 800px) {
  .portes {
    grid-template-columns: 1fr;
  }
}

.porte {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--e-4);
  padding: clamp(var(--e-5), 3vw, var(--e-6));
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-5);
  overflow: hidden;
  isolation: isolate;
  transition:
    transform var(--duree-2) var(--courbe),
    border-color var(--duree-2) var(--courbe),
    box-shadow var(--duree-3) var(--courbe);
}

.porte::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(120% 100% at 100% 0%, var(--laterite-voile), transparent 62%);
  opacity: 0;
  transition: opacity var(--duree-3) var(--courbe);
}

.porte:hover,
.porte:focus-visible {
  transform: translateY(-3px);
  border-color: var(--laterite-trait);
  box-shadow: var(--ombre-3);
}

.porte:hover::before,
.porte:focus-visible::before {
  opacity: 1;
}

.porte-numero {
  font-size: var(--t-12);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--laterite);
}

.porte-titre {
  font-size: clamp(var(--t-21), 2.6vw, var(--t-26));
  font-weight: 600;
  letter-spacing: -0.02em;
}

.porte-texte {
  color: var(--encre-2);
  font-size: var(--t-15);
}

.porte-illustration {
  height: 92px;
  color: var(--laterite);
  opacity: 0.9;
}

.porte-pied {
  display: flex;
  align-items: center;
  gap: var(--e-2);
  margin-top: auto;
  padding-top: var(--e-3);
  border-top: 1px solid var(--trait);
  font-size: var(--t-13);
  font-weight: 550;
  color: var(--encre);
}

.porte-fleche {
  width: 16px;
  height: 16px;
  transition: transform var(--duree-2) var(--courbe);
}

.porte:hover .porte-fleche {
  transform: translateX(4px);
}

/* ─── Pastilles ──────────────────────────────────────────────────────────── */

.pastille {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding-inline: 9px;
  border-radius: var(--r-plein);
  font-size: var(--t-12);
  font-weight: 550;
  letter-spacing: -0.005em;
  background: var(--surface-2);
  color: var(--encre-2);
  border: 1px solid var(--trait);
  white-space: nowrap;
}

.pastille-point {
  width: 6px;
  height: 6px;
  border-radius: var(--r-plein);
  background: currentColor;
  flex: none;
}

.pastille-succes {
  background: var(--zafy-voile);
  color: var(--zafy);
  border-color: color-mix(in srgb, var(--zafy) 24%, transparent);
}
.pastille-attente {
  background: var(--vanille-voile);
  color: var(--vanille);
  border-color: color-mix(in srgb, var(--vanille) 26%, transparent);
}
.pastille-progres {
  background: var(--laterite-voile);
  color: var(--laterite);
  border-color: var(--laterite-trait);
}
.pastille-echec {
  background: var(--cramoisi-voile);
  color: var(--cramoisi);
  border-color: color-mix(in srgb, var(--cramoisi) 26%, transparent);
}

/* ─── Compte à rebours ───────────────────────────────────────────────────── */

.rebours {
  display: inline-flex;
  align-items: center;
  gap: var(--e-2);
  padding: 5px 11px 5px 9px;
  border-radius: var(--r-plein);
  border: 1px solid var(--trait);
  background: var(--surface);
  font-size: var(--t-13);
  color: var(--encre-2);
  white-space: nowrap; /* « 17 h 28 min » ne doit jamais se casser dans sa pilule */
}

.rebours-pouls {
  position: relative;
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: var(--r-plein);
  background: var(--zafy);
}

.rebours-pouls::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: var(--r-plein);
  border: 1px solid currentColor;
  color: var(--zafy);
  opacity: 0;
  animation: pouls 2.4s var(--courbe-douce) infinite;
}

.rebours.urgent .rebours-pouls,
.rebours.urgent .rebours-pouls::after {
  background: var(--laterite);
  color: var(--laterite);
}

.rebours.urgent .rebours-pouls::after {
  background: none;
}

.rebours strong {
  color: var(--encre);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

@keyframes pouls {
  0% {
    opacity: 0.9;
    transform: scale(0.85);
  }
  70% {
    opacity: 0;
    transform: scale(1.9);
  }
  100% {
    opacity: 0;
    transform: scale(1.9);
  }
}

.bandeau-cloture {
  display: flex;
  align-items: center;
  gap: var(--e-4);
  flex-wrap: wrap;
  padding: var(--e-4) var(--e-5);
  border-radius: var(--r-5);
  border: 1px solid var(--laterite-trait);
  background: linear-gradient(180deg, var(--laterite-voile), transparent);
}

.bandeau-cloture .grand-compteur {
  font-size: clamp(var(--t-26), 4vw, var(--t-41));
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--encre);
}

/* ─── Formulaires ────────────────────────────────────────────────────────── */

.champ {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.champ-libelle {
  font-size: var(--t-13);
  font-weight: 550;
  letter-spacing: 0.01em;
  color: var(--encre);
}

.champ-aide {
  font-size: var(--t-12);
  color: var(--encre-3);
}

.champ-erreur {
  font-size: var(--t-12);
  color: var(--cramoisi);
  display: flex;
  align-items: center;
  gap: 5px;
}

.saisie,
.selection,
.zone {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--trait-fort);
  border-radius: var(--r-3);
  font-size: var(--t-15);
  color: var(--encre);
  transition:
    border-color var(--duree-1) var(--courbe-douce),
    box-shadow var(--duree-1) var(--courbe-douce),
    background var(--duree-1) var(--courbe-douce);
}

.saisie::placeholder,
.zone::placeholder {
  color: var(--encre-3);
}

.saisie:focus,
.selection:focus,
.zone:focus {
  outline: none;
  border-color: var(--laterite);
  box-shadow: 0 0 0 3px var(--laterite-voile);
}

.saisie[aria-invalid='true'],
.selection[aria-invalid='true'] {
  border-color: var(--cramoisi);
}

.saisie.chiffres {
  font-variant-numeric: tabular-nums;
}

.zone {
  min-height: 88px;
  resize: vertical;
  line-height: 1.5;
}

.selection {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--encre-2) 50%),
    linear-gradient(135deg, var(--encre-2) 50%, transparent 50%);
  background-position: calc(100% - 16px) 19px, calc(100% - 11px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.groupe-champs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--e-4);
}

.champ-prefixe {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--trait-fort);
  border-radius: var(--r-3);
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--duree-1) var(--courbe-douce), box-shadow var(--duree-1) var(--courbe-douce);
}

.champ-prefixe:focus-within {
  border-color: var(--laterite);
  box-shadow: 0 0 0 3px var(--laterite-voile);
}

.champ-prefixe .saisie {
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.champ-prefixe .saisie:focus {
  box-shadow: none;
}

.champ-prefixe-texte {
  display: flex;
  align-items: center;
  padding-inline: 12px;
  background: var(--surface-2);
  border-right: 1px solid var(--trait);
  font-size: var(--t-13);
  font-weight: 550;
  color: var(--encre-2);
  white-space: nowrap;
}

.champ-suffixe-texte {
  display: flex;
  align-items: center;
  padding-inline: 12px;
  background: var(--surface-2);
  border-left: 1px solid var(--trait);
  font-size: var(--t-13);
  font-weight: 550;
  color: var(--encre-2);
}

/* Choix segmenté (retrait / livraison, devise…) */
.segments {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--trait);
  border-radius: var(--r-4);
}

.segment {
  padding: 7px 14px;
  border-radius: var(--r-3);
  font-size: var(--t-13);
  font-weight: 550;
  color: var(--encre-2);
  transition: background var(--duree-1) var(--courbe-douce), color var(--duree-1) var(--courbe-douce);
}

.segment[aria-pressed='true'] {
  background: var(--surface);
  color: var(--encre);
  box-shadow: var(--ombre-1);
}

/* Cases de choix riches */
.choix {
  display: flex;
  gap: var(--e-3);
  padding: var(--e-4);
  border: 1px solid var(--trait-fort);
  border-radius: var(--r-4);
  background: var(--surface);
  text-align: left;
  width: 100%;
  transition:
    border-color var(--duree-1) var(--courbe),
    background var(--duree-1) var(--courbe),
    transform var(--duree-1) var(--courbe);
}

.choix:hover {
  border-color: var(--trait-fort);
  background: var(--surface-2);
}

.choix[aria-pressed='true'] {
  border-color: var(--laterite);
  background: var(--laterite-voile);
}

.choix-marque {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 2px;
  border-radius: var(--r-plein);
  border: 1.5px solid var(--trait-fort);
  display: grid;
  place-items: center;
  transition: border-color var(--duree-1) var(--courbe);
}

.choix[aria-pressed='true'] .choix-marque {
  border-color: var(--laterite);
}

.choix[aria-pressed='true'] .choix-marque::after {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: var(--r-plein);
  background: var(--laterite);
}

/* ─── Facture / devis ────────────────────────────────────────────────────── */

.facture {
  display: flex;
  flex-direction: column;
}

.facture-ligne {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--e-2) var(--e-4);
  padding: var(--e-3) 0;
  border-bottom: 1px dashed var(--trait);
}

.facture-ligne:last-of-type {
  border-bottom: none;
}

.facture-libelle {
  font-size: var(--t-15);
  font-weight: 500;
}

.facture-detail {
  grid-column: 1 / -1;
  font-size: var(--t-12);
  color: var(--encre-3);
  margin-top: -4px;
  max-width: 52ch;
}

.facture-montant {
  font-size: var(--t-15);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.facture-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--e-4);
  margin-top: var(--e-4);
  padding-top: var(--e-4);
  border-top: 2px solid var(--encre);
}

.facture-total-libelle {
  font-size: var(--t-17);
  font-weight: 600;
}

.facture-total-montant {
  font-size: clamp(var(--t-26), 4vw, var(--t-41));
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

/* Barre de répartition des coûts */
.repartition {
  display: flex;
  height: 8px;
  border-radius: var(--r-plein);
  overflow: hidden;
  background: var(--surface-2);
}

.repartition-part {
  height: 100%;
  transition: width var(--duree-4) var(--courbe);
}

.repartition-part[data-cle='produit'] {
  background: var(--laterite);
}
.repartition-part[data-cle='commission'] {
  background: color-mix(in srgb, var(--laterite) 62%, var(--papier));
}
.repartition-part[data-cle='fret'] {
  /* Brun chaud, pas le gris bleuté de l'encre : la palette n'admet aucun bleu. */
  background: #8a6a52;
}
.repartition-part[data-cle='douane'] {
  background: var(--vanille);
}
.repartition-part[data-cle='dossier'] {
  background: var(--encre-3);
}
.repartition-part[data-cle='remise'] {
  background: var(--zafy);
}

.legende {
  display: flex;
  flex-wrap: wrap;
  gap: var(--e-2) var(--e-4);
  font-size: var(--t-12);
  color: var(--encre-2);
}

.legende-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legende-puce {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: none;
}

/* ─── Frise de suivi ─────────────────────────────────────────────────────── */

.frise {
  display: grid;
  gap: 0;
}

.frise-etape {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: var(--e-3);
  padding-bottom: var(--e-5);
  position: relative;
}

.frise-etape:last-child {
  padding-bottom: 0;
}

.frise-marque {
  position: relative;
  width: 28px;
  display: flex;
  justify-content: center;
}

.frise-point {
  width: 14px;
  height: 14px;
  margin-top: 4px;
  border-radius: var(--r-plein);
  border: 2px solid var(--trait-fort);
  background: var(--surface);
  z-index: 1;
  transition: all var(--duree-2) var(--courbe);
}

.frise-etape:not(:last-child) .frise-marque::after {
  content: '';
  position: absolute;
  top: 20px;
  bottom: -22px;
  width: 2px;
  background: var(--trait);
}

.frise-etape[data-etat='faite'] .frise-point {
  background: var(--zafy);
  border-color: var(--zafy);
}

.frise-etape[data-etat='faite'] .frise-marque::after {
  background: var(--zafy);
}

.frise-etape[data-etat='encours'] .frise-point {
  border-color: var(--laterite);
  background: var(--laterite);
  box-shadow: 0 0 0 4px var(--laterite-voile);
}

.frise-etape[data-etat='echec'] .frise-point {
  border-color: var(--cramoisi);
  background: var(--cramoisi);
}

.frise-nom {
  font-weight: 550;
  font-size: var(--t-15);
}

.frise-etape[data-etat='avenir'] .frise-nom {
  color: var(--encre-3);
}

.frise-date {
  font-size: var(--t-12);
  color: var(--encre-3);
  font-variant-numeric: tabular-nums;
}

/* ─── Catalogue ──────────────────────────────────────────────────────────── */

.grille-catalogue {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: var(--e-4);
}

.produit {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-5);
  transition:
    transform var(--duree-2) var(--courbe),
    border-color var(--duree-2) var(--courbe),
    box-shadow var(--duree-2) var(--courbe);
}

.produit:hover {
  transform: translateY(-2px);
  border-color: var(--trait-fort);
  box-shadow: var(--ombre-2);
}

.produit-vignette {
  /* 16/9 et non 4/3 : la vignette ne montre pas la marchandise, elle ne doit
     donc pas dominer la fiche. La place revient aux deux chiffres. */
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
  border-bottom: 1px solid var(--trait);
  display: grid;
  place-items: center;
  color: var(--laterite);
  overflow: hidden;
}

/* Cible le SEUL motif de fond. Sans cette précision, toute icône posée dans la
   vignette était étirée à pleine taille — un petit pictogramme d'illustration
   devenait un glyphe géant, et se lisait comme une image qui n'a pas chargé. */
.produit-vignette > .vignette-motif > svg {
  width: 100%;
  height: 100%;
}

.produit-corps {
  display: flex;
  flex-direction: column;
  gap: var(--e-2);
  padding: var(--e-4);
  flex: 1;
}

.produit-nom {
  font-weight: 600;
  font-size: var(--t-15);
  letter-spacing: -0.01em;
}

.produit-soustitre {
  font-size: var(--t-12);
  color: var(--encre-3);
}

.produit-marge {
  margin-top: auto;
  padding-top: var(--e-3);
  border-top: 1px dashed var(--trait);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--e-2);
}

.produit-marge-valeur {
  font-size: var(--t-21);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--zafy);
}

.produit-marge-label {
  font-size: var(--t-12);
  color: var(--encre-3);
}

.filtres {
  display: flex;
  gap: var(--e-2);
  flex-wrap: wrap;
}

.filtre {
  height: 36px; /* plancher tactile des actions secondaires */
  padding-inline: 13px;
  border-radius: var(--r-plein);
  border: 1px solid var(--trait);
  background: var(--surface);
  font-size: var(--t-13);
  font-weight: 500;
  color: var(--encre-2);
  transition: all var(--duree-1) var(--courbe-douce);
}

.filtre:hover {
  border-color: var(--trait-fort);
  color: var(--encre);
}

/* L'état actif porte l'accent unique du produit, pas un noir plein : la terre
   rouge est la seule couleur d'action de toute l'interface. */
.filtre[aria-pressed='true'] {
  background: var(--laterite);
  border-color: var(--laterite);
  color: #fff;
}

/* ─── Tableaux (admin) ───────────────────────────────────────────────────── */

.tableau-boite {
  overflow-x: auto;
  border: 1px solid var(--trait);
  border-radius: var(--r-5);
  background: var(--surface);
}

table.tableau {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-13);
}

.tableau th {
  position: sticky;
  top: 0;
  text-align: left;
  font-weight: 600;
  font-size: var(--t-12);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--encre-3);
  background: var(--surface-2);
  padding: 10px var(--e-4);
  border-bottom: 1px solid var(--trait);
  white-space: nowrap;
}

.tableau td {
  padding: 11px var(--e-4);
  border-bottom: 1px solid var(--trait);
  vertical-align: middle;
}

.tableau tbody tr:last-child td {
  border-bottom: none;
}

.tableau tbody tr {
  transition: background var(--duree-1) linear;
}

.tableau tbody tr:hover {
  background: var(--surface-2);
}

.tableau .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tableau-vide {
  padding: var(--e-7) var(--e-4);
  text-align: center;
  color: var(--encre-3);
}

/* ─── Statistiques ───────────────────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--e-4);
}

.stat {
  padding: var(--e-4);
  border: 1px solid var(--trait);
  border-radius: var(--r-4);
  background: var(--surface);
}

.stat-valeur {
  font-size: var(--t-26);
  font-weight: 600;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-libelle {
  font-size: var(--t-12);
  color: var(--encre-3);
  margin-top: 2px;
}

/* ─── Paiement ───────────────────────────────────────────────────────────── */

.paiement-scene {
  display: grid;
  place-items: center;
  gap: var(--e-5);
  padding-block: var(--e-7);
  text-align: center;
}

.anneau {
  position: relative;
  width: 132px;
  height: 132px;
}

.anneau svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.anneau-piste {
  fill: none;
  stroke: var(--trait);
  stroke-width: 6;
}

.anneau-jauge {
  fill: none;
  stroke: var(--laterite);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--duree-3) linear, stroke var(--duree-2) var(--courbe);
}

.anneau.termine .anneau-jauge {
  stroke: var(--zafy);
}

.anneau-centre {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: var(--t-21);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.anneau-coche {
  width: 40px;
  height: 40px;
  color: var(--zafy);
}

.anneau-coche path {
  stroke-dasharray: 32;
  stroke-dashoffset: 32;
  animation: tracer var(--duree-4) var(--courbe) forwards;
}

@keyframes tracer {
  to {
    stroke-dashoffset: 0;
  }
}

.recu {
  border: 1px solid var(--trait);
  border-radius: var(--r-5);
  background: var(--surface);
  overflow: hidden;
}

.recu-entete {
  padding: var(--e-5);
  background: var(--surface-2);
  border-bottom: 1px dashed var(--trait-fort);
  text-align: center;
}

.recu-code {
  font-size: var(--t-33);
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.recu-dentelle {
  height: 12px;
  background: radial-gradient(circle at 6px 0, transparent 6px, var(--surface) 6px);
  background-size: 12px 12px;
  background-position: 0 -6px;
  border-bottom: 1px solid var(--trait);
}

/* ─── Modale ─────────────────────────────────────────────────────────────── */

.modale-fond {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: var(--e-4);
  background: var(--voile);
  backdrop-filter: blur(3px);
  animation: fondu var(--duree-2) var(--courbe-douce);
}

.modale {
  width: min(560px, 100%);
  max-height: min(86vh, 760px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-5);
  box-shadow: var(--ombre-3);
  animation: modale-entree var(--duree-3) var(--courbe);
}

@keyframes fondu {
  from {
    opacity: 0;
  }
}

@keyframes modale-entree {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
}

/* ─── Notifications ──────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  z-index: 100;
  bottom: var(--e-4);
  right: var(--e-4);
  display: flex;
  flex-direction: column;
  gap: var(--e-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--e-2);
  max-width: 380px;
  padding: 11px 14px;
  border-radius: var(--r-4);
  background: var(--encre);
  color: var(--papier);
  font-size: var(--t-13);
  font-weight: 500;
  box-shadow: var(--ombre-3);
  animation: toast-entree var(--duree-3) var(--courbe);
}

.toast[data-ton='succes'] {
  background: var(--zafy);
  color: #fff;
}
.toast[data-ton='erreur'] {
  background: var(--cramoisi);
  color: #fff;
}

@keyframes toast-entree {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
}

/* ─── Encadrés ───────────────────────────────────────────────────────────── */

.encadre {
  display: flex;
  gap: var(--e-3);
  padding: var(--e-4);
  border-radius: var(--r-4);
  border: 1px solid var(--trait);
  background: var(--surface-2);
  font-size: var(--t-13);
  color: var(--encre-2);
}

.encadre svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.encadre-accent {
  border-color: var(--laterite-trait);
  background: var(--laterite-voile);
  color: var(--encre);
}

.encadre-succes {
  border-color: color-mix(in srgb, var(--zafy) 26%, transparent);
  background: var(--zafy-voile);
}

.encadre-alerte {
  border-color: color-mix(in srgb, var(--cramoisi) 26%, transparent);
  background: var(--cramoisi-voile);
  color: var(--encre);
}

/* ─── Étapes de formulaire ───────────────────────────────────────────────── */

.jalons {
  display: flex;
  align-items: center;
  gap: var(--e-2);
  font-size: var(--t-12);
  color: var(--encre-3);
}

.jalon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.jalon-numero {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: var(--r-plein);
  border: 1px solid var(--trait-fort);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.jalon[data-etat='courant'] {
  color: var(--encre);
}

.jalon[data-etat='courant'] .jalon-numero {
  background: var(--laterite);
  border-color: var(--laterite);
  color: #fff;
}

.jalon[data-etat='fait'] .jalon-numero {
  background: var(--zafy);
  border-color: var(--zafy);
  color: #fff;
}

.jalon-trait {
  width: 22px;
  height: 1px;
  background: var(--trait-fort);
}

/* ─── Dépôt de fichier ───────────────────────────────────────────────────── */

.depot {
  display: grid;
  place-items: center;
  gap: var(--e-2);
  padding: var(--e-6) var(--e-4);
  border: 1.5px dashed var(--trait-fort);
  border-radius: var(--r-4);
  background: var(--surface-2);
  color: var(--encre-2);
  text-align: center;
  transition: border-color var(--duree-1) var(--courbe), background var(--duree-1) var(--courbe);
  cursor: pointer;
}

.depot:hover,
.depot.survol {
  border-color: var(--laterite);
  background: var(--laterite-voile);
}

.depot-apercu {
  position: relative;
  border-radius: var(--r-4);
  overflow: hidden;
  border: 1px solid var(--trait);
}

.depot-apercu img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: var(--surface-2);
}

/* ─── Animations d'entrée ────────────────────────────────────────────────── */

@keyframes monter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes glisser {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.vue {
  animation: glisser var(--duree-3) var(--courbe);
}

.cascade > * {
  animation: monter var(--duree-3) var(--courbe) backwards;
}

.cascade > *:nth-child(1) {
  animation-delay: 0ms;
}
.cascade > *:nth-child(2) {
  animation-delay: 40ms;
}
.cascade > *:nth-child(3) {
  animation-delay: 80ms;
}
.cascade > *:nth-child(4) {
  animation-delay: 120ms;
}
.cascade > *:nth-child(5) {
  animation-delay: 160ms;
}
.cascade > *:nth-child(6) {
  animation-delay: 200ms;
}
.cascade > *:nth-child(7) {
  animation-delay: 240ms;
}
.cascade > *:nth-child(8) {
  animation-delay: 280ms;
}

.squelette {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--papier-2) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: chatoyer 1.4s ease-in-out infinite;
  border-radius: var(--r-3);
}

@keyframes chatoyer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}

/* ─── Accessibilité du mouvement ─────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Impression du reçu ─────────────────────────────────────────────────── */

@media print {
  .barre,
  .toasts,
  .bouton,
  .bandeau-cloture {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .carte,
  .recu {
    border-color: #ccc;
    box-shadow: none;
  }
}
