/* Batacord : système de design. Variables, base, composants partagés.
   Couleur d'accent = --accent (orange chantier) : une entreprise pourra la surcharger plus tard (ex. :root[data-marque]). */


:root {
  /* Accent (personnalisable par entreprise) */
  --accent: #f26a0d;
  --accent-survol: #ff7a1f;
  --accent-sur: #1a1006;          /* texte posé SUR l'accent : contraste > 7 */
  --accent-texte: #b04600;        /* l'accent utilisé comme texte sur fond clair : contraste AA */
  --accent-doux: #fff2e8;
  --accent-doux-bord: #ffd2ae;

  /* Neutres : nuit (barre latérale) et papier (contenu) */
  --nuit: #0e1722;
  --nuit-2: #142030;
  --nuit-3: #1d2d42;
  --nuit-texte: #d9e1ec;
  --nuit-texte-doux: #9fb0c6;
  --papier: #f3f5f9;
  --carte: #ffffff;
  --encre: #101822;
  --encre-2: #3f4a5a;
  --encre-3: #586374;
  --trait: #dde3ec;
  --trait-fort: #bcc5d3;

  /* Tons de statut (texte, fond, bord) : toujours accompagnés d'un libellé */
  --ok: #14632f;       --ok-fond: #e1f5e8;       --ok-bord: #a9dcbb;
  --ok-clair: #0c5b57; --ok-clair-fond: #dcf4f2; --ok-clair-bord: #9fdad5;
  --info: #3730a3;     --info-fond: #e8e9fd;     --info-bord: #bcbff5;
  --attente: #2f4a66;  --attente-fond: #e2ecf6;  --attente-bord: #b3c9de;
  --alerte: #7c4a03;   --alerte-fond: #fdf1cc;   --alerte-bord: #ecd27a;
  --danger: #a6231a;   --danger-fond: #fde6e3;   --danger-bord: #f2b5ae;
  --neutre: #4a5565;   --neutre-fond: #e9edf3;   --neutre-bord: #cdd5e0;

  --police: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --police-titre: "Arial Narrow", "Segoe UI", Arial, system-ui, sans-serif;

  --rayon: 14px;
  --rayon-petit: 9px;
  --ombre-1: 0 1px 2px rgba(14, 23, 34, .06), 0 1px 1px rgba(14, 23, 34, .04);
  --ombre-2: 0 6px 18px -6px rgba(14, 23, 34, .18), 0 2px 4px rgba(14, 23, 34, .05);
  --ombre-3: 0 24px 48px -16px rgba(14, 23, 34, .35), 0 8px 16px -8px rgba(14, 23, 34, .2);
  --focus: 0 0 0 3px var(--papier), 0 0 0 5px #1b4fd8;
  --duree: 160ms;
  --hauteur-nav-basse: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--police); font-size: 1rem; line-height: 1.5; color: var(--encre); background: var(--papier);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; font-family: var(--police-titre); font-weight: 700; line-height: 1.08; letter-spacing: .005em; color: var(--encre); text-wrap: balance; }
h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 3rem); }
h2 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.1rem; }
p { margin: 0 0 1em; text-wrap: pretty; }
a { color: var(--accent-texte); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
small, .petit { font-size: .875rem; }
.doux { color: var(--encre-3); }
.gras { font-weight: 600; }
.nombre { font-variant-numeric: tabular-nums; }
.sr-seul { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

:focus-visible { outline: 3px solid #1b4fd8; outline-offset: 2px; border-radius: 4px; }
.sombre :focus-visible, .nuit :focus-visible { outline-color: #8fb0ff; }

.lien-evitement {
  position: absolute; left: 12px; top: -80px; z-index: 100; background: var(--encre); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--rayon-petit) var(--rayon-petit);
  transition: top var(--duree);
}
.lien-evitement:focus { top: 0; }

/* Icônes (sprite /static/img/icones.svg) */
.ico { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico-g { width: 1.6em; height: 1.6em; }

/* Boutons */
.btn {
  --b-fond: var(--carte); --b-texte: var(--encre); --b-bord: var(--trait-fort);
  display: inline-flex; align-items: center; justify-content: center; gap: .55em; min-height: 46px; padding: .6em 1.2em; border-radius: var(--rayon-petit);
  border: 1.5px solid var(--b-bord); background: var(--b-fond); color: var(--b-texte); font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer; transition: background var(--duree), border-color var(--duree), transform var(--duree), box-shadow var(--duree); box-shadow: var(--ombre-1);
}
.btn:hover { border-color: var(--encre-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-principal { --b-fond: var(--accent); --b-texte: var(--accent-sur); --b-bord: var(--accent); background-image: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,0)); }
.btn-principal:hover { --b-fond: var(--accent-survol); --b-bord: var(--accent-survol); }
.btn-sombre { --b-fond: var(--nuit-2); --b-texte: #fff; --b-bord: var(--nuit-2); }
.btn-sombre:hover { --b-fond: var(--nuit-3); --b-bord: var(--nuit-3); }
.btn-danger { --b-fond: var(--danger-fond); --b-texte: var(--danger); --b-bord: var(--danger-bord); }
.btn-danger:hover { --b-bord: var(--danger); }
.btn-discret { --b-fond: transparent; --b-bord: transparent; box-shadow: none; }
.btn-discret:hover { --b-fond: rgba(14, 23, 34, .06); --b-bord: transparent; }
.btn-petit { min-height: 38px; padding: .35em .9em; font-size: .95rem; }
.btn-large { min-height: 54px; padding: .7em 1.6em; font-size: 1.1rem; }
.btn-bloc { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

/* Formulaires */
.champ { display: grid; gap: .35rem; margin-bottom: 1rem; }
.champ label, .etiquette { font-weight: 600; font-size: .95rem; color: var(--encre); }
.champ .aide { font-size: .875rem; color: var(--encre-3); }
.champ .erreur-champ { font-size: .9rem; color: var(--danger); font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="tel"], input[type="number"], select, textarea {
  width: 100%; min-height: 48px; padding: .6em .85em; font: inherit; font-size: 1rem; color: var(--encre); background: var(--carte);
  border: 1.5px solid var(--trait-fort); border-radius: var(--rayon-petit); box-shadow: inset 0 1px 2px rgba(14, 23, 34, .05);
  transition: border-color var(--duree), box-shadow var(--duree);
}
textarea { min-height: 7.5em; resize: vertical; line-height: 1.45; }
select { appearance: none; padding-right: 2.4em; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23586374' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7em center; background-size: 1.1em; }
input:hover, select:hover, textarea:hover { border-color: var(--encre-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: #1b4fd8; box-shadow: 0 0 0 3px rgba(27, 79, 216, .25); }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
input[type="checkbox"] { width: 1.5rem; height: 1.5rem; accent-color: var(--accent); flex: none; margin: 0; }
.case { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; border: 1.5px solid var(--trait-fort); border-radius: var(--rayon-petit); background: var(--carte); cursor: pointer; }
.case:has(input:checked) { border-color: var(--accent); background: var(--accent-doux); }
.case:has(input:focus-visible) { outline: 3px solid #1b4fd8; outline-offset: 2px; }
.case span { font-weight: 500; }
.ligne-champs { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

/* Alertes */
.alerte { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--rayon-petit); border: 1.5px solid var(--neutre-bord); background: var(--neutre-fond); color: var(--encre); margin-bottom: 1rem; font-weight: 500; }
.alerte .ico { margin-top: .15em; }
.alerte-ok { background: var(--ok-fond); border-color: var(--ok-bord); color: #0d4a23; }
.alerte-erreur { background: var(--danger-fond); border-color: var(--danger-bord); color: #7d1a13; }
.alerte-info { background: var(--info-fond); border-color: var(--info-bord); color: #2b2680; }
.alerte-attention { background: var(--alerte-fond); border-color: var(--alerte-bord); color: #5e3802; }

/* Pastilles de statut : icône + texte, jamais la couleur seule */
.pastille { display: inline-flex; align-items: center; gap: .4em; padding: .2em .7em .2em .55em; border-radius: 999px; font-size: .85rem; font-weight: 600; line-height: 1.3; border: 1px solid var(--neutre-bord); background: var(--neutre-fond); color: var(--neutre); white-space: nowrap; }
.pastille::before { content: ""; width: .55em; height: .55em; border-radius: 50%; background: currentColor; }
.ton-ok { background: var(--ok-fond); color: var(--ok); border-color: var(--ok-bord); }
.ton-ok-clair { background: var(--ok-clair-fond); color: var(--ok-clair); border-color: var(--ok-clair-bord); }
.ton-info { background: var(--info-fond); color: var(--info); border-color: var(--info-bord); }
.ton-attente { background: var(--attente-fond); color: var(--attente); border-color: var(--attente-bord); }
.ton-alerte { background: var(--alerte-fond); color: var(--alerte); border-color: var(--alerte-bord); }
.ton-danger { background: var(--danger-fond); color: var(--danger); border-color: var(--danger-bord); }
.ton-neutre { background: var(--neutre-fond); color: var(--neutre); border-color: var(--neutre-bord); }
/* Forme du repère selon le ton (en plus de la couleur et du libellé) */
.ton-alerte::before { border-radius: 2px; transform: rotate(45deg); }
.ton-danger::before { border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); width: .7em; height: .65em; }
.ton-attente::before { background: none; border: 2px solid currentColor; }

.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); box-shadow: var(--ombre-1); }
.carte-pad { padding: 1.25rem; }

/* Bandeau mode démo */
.bandeau-demo { background: repeating-linear-gradient(-45deg, #ffd93d 0 14px, #1a1a1a 14px 28px); padding: 0; }
.bandeau-demo p { margin: 0; padding: 5px 12px; text-align: center; font-size: .85rem; font-weight: 700; color: #111; background: linear-gradient(180deg, #ffd93d, #ffcf1a); width: fit-content; margin-inline: auto; border-radius: 0 0 8px 8px; }

/* Tableaux */
.tableau { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tableau th { text-align: left; font-size: .85rem; font-weight: 600; color: var(--encre-3); padding: .6rem .9rem; border-bottom: 1px solid var(--trait-fort); white-space: nowrap; }
.tableau td { padding: .8rem .9rem; border-bottom: 1px solid var(--trait); vertical-align: middle; }
.tableau tr:last-child td { border-bottom: 0; }
.tableau .droite { text-align: right; }
.tableau tbody tr:hover { background: #f8fafc; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .btn, .pastille, .alerte, .carte { border: 1px solid CanvasText; }
}
