/* =====================================================
   BRAVYXO — Composants communs V2  (css/style.css, lot 1)
   "Le terrain parle. L'entreprise avance."
   Les valeurs viennent de css/tokens.css (chargé AVANT ce fichier).
   Règle : on garde TOUS les noms de classes existants (générés par le JS),
   on les restyle et on ajoute des modificateurs. Moins d'effets, plus de matière.
   Les sélecteurs d'éléments nus passent par :where() (spécificité 0) pour que
   les feuilles de page (ouvrier.css, chef.css, shell.css) gardent la main.
   ===================================================== */

/* ---------- BASE ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--texte);
  font: var(--fw-regular) var(--fs-15)/var(--lh-corps) var(--police);
  min-height: 100vh; min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--d-moyen) var(--ease-sortie), color var(--d-moyen) var(--ease-sortie);
}
/* SUPPRIMÉ : body::before (halo animé), radial-gradients du body, background-attachment:fixed */
:where(h1, h2, h3, h4) { font-family: var(--police-titre); letter-spacing: var(--ls-titre); line-height: var(--lh-titre); font-weight: var(--fw-bold); }
.chiffre, .kpi .val, .kpi-val, .valeur, .temps, .chrono, .num {
  font-variant-numeric: tabular-nums; letter-spacing: var(--ls-chiffre);
}
.chiffre, .kpi-val, .chrono { font-family: var(--police-chiffre); }
.ref-parc { font-family: var(--police-mono); font-weight: var(--fw-semibold); letter-spacing: .02em; }
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--bord-focus); outline-offset: 2px; }
:root[data-theme="soleil"] :focus-visible { outline-color: var(--texte); }
::selection { background: rgba(255,106,0,.32); }
:where(button) { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:where(a) { color: var(--accent-texte); text-decoration-thickness: 1px; text-underline-offset: 2px; }
:where(img) { max-width: 100%; }
:where(hr) { border: 0; border-top: 1px solid var(--bord); margin: var(--sp-4) 0; }

/* Utilitaires CONSERVÉS (utilisés par tout le JS) */
.masque { display: none !important; }
.muted { color: var(--texte-2); }
.centre { text-align: center; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- ICÔNES (sprite local assets/icones.svg) ---------- */
.ic {
  width: 24px; height: 24px; flex: none; display: inline-block; vertical-align: middle;
  stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.ic-sm { width: 18px; height: 18px; }
.ic-lg { width: 28px; height: 28px; }
.ic-xl { width: 40px; height: 40px; }

/* ---------- LOGO (sans halo orange : plus grand et plus seul) ---------- */
.logo { display: inline-flex; align-items: center; gap: var(--sp-3); }
.logo img.symbole { height: 34px; width: auto; filter: none; }
.logo .mot { font: var(--fw-heavy) 1.25rem/1 var(--police-titre); letter-spacing: .08em; color: var(--texte); }
.logo .mot .xo { color: var(--accent-texte); }
.logo img.complet { height: 64px; width: auto; filter: none; }
.logo-petit img.symbole { height: 28px; }
.logo-petit .mot { font-size: 1rem; }

.slogan { color: var(--texte-3); font-size: var(--fs-13); font-weight: var(--fw-medium); letter-spacing: var(--ls-label); }
.slogan b { color: var(--accent-texte); font-weight: var(--fw-bold); }

/* ---------- BOUTONS ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  width: 100%; min-height: var(--h-md); padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md); border: 1px solid transparent;
  font: var(--fw-semibold) var(--fs-15)/1.2 var(--police); text-align: center; text-decoration: none;
  color: var(--texte); background: var(--surface-2);
  transition: background-color var(--d-rapide) var(--ease-sortie), border-color var(--d-rapide) var(--ease-sortie),
              color var(--d-rapide) var(--ease-sortie), transform var(--d-instant) var(--ease-sortie), opacity var(--d-rapide);
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.btn:active { transform: scale(.97); transition-duration: var(--d-instant); }
.btn:not(:active) { transition-timing-function: var(--ease-ressort); }
.btn[disabled], .btn:disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; box-shadow: none; }
.btn[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--texte); border-right-color: transparent; animation: tourne .7s linear infinite;
}
.btn .ic { width: 20px; height: 20px; }

/* Principal : 1 seul par écran. Aplat orange, texte anthracite (signalétique chantier). */
.btn-orange { background: var(--accent); color: var(--sur-accent); font-weight: var(--fw-bold); box-shadow: var(--e-accent); }
.btn-orange::after { content: none; }                      /* fin du reflet balayant */
.btn-orange[aria-busy="true"]::after { content: ""; border-color: var(--sur-accent); border-right-color: transparent; }
@media (hover: hover) { .btn-orange:hover { background: var(--accent-survol); } }
.btn-orange:active { background: var(--accent-presse); }

/* Secondaire */
.btn-sombre { background: var(--surface-2); border-color: var(--bord-fort); color: var(--texte); }
@media (hover: hover) { .btn-sombre:hover { background: var(--surface-3); } }

/* Fantôme : Retour, Annuler, liens d'action */
.btn-fantome { background: transparent; color: var(--texte-2); width: auto; }
@media (hover: hover) { .btn-fantome:hover { background: var(--surface-3); color: var(--texte); } }

/* Danger / Succès / Inverse */
.btn-danger { background: var(--rouge-500); color: #fff; font-weight: var(--fw-bold); }
@media (hover: hover) { .btn-danger:hover { filter: brightness(1.06); } }
.btn-succes { background: var(--vert-bg); border-color: var(--vert-bord); color: var(--vert-500); }
.btn-inverse { background: var(--surface-inverse); color: var(--bg); font-weight: var(--fw-bold); }

/* Tailles */
.btn-sm { min-height: var(--h-sm); padding: var(--sp-1) var(--sp-3); font-size: var(--fs-13); border-radius: var(--r-sm); width: auto; }
.btn-xl { min-height: var(--h-xl); font-size: var(--fs-17); border-radius: var(--r-lg); }
.btn-icone { width: var(--h-md); min-width: var(--h-md); min-height: var(--h-md); padding: 0; flex: none; }
.btn-auto { width: auto; }
.btn + .btn { margin-top: var(--sp-3); }                   /* CONSERVÉ pour les piles verticales */

/* Terrain (ouvrier) : tout bouton ≥ 52 px, gants compris */
:is(.appli, body.avec-nav) .btn { min-height: var(--h-lg); font-size: var(--fs-17); }
:is(.appli, body.avec-nav) .btn-sm { min-height: var(--h-tactile); font-size: var(--fs-15); }
:is(.appli, body.avec-nav) .btn-icone { width: var(--h-tactile); min-width: var(--h-tactile); min-height: var(--h-tactile); }

/* Badge utilisé comme bouton (« ✕ Annuler », « ← Retour ») : devient tactile sans toucher au HTML */
button.badge, a.badge {
  min-height: var(--h-md); height: auto; padding: 0 var(--sp-4); font-size: var(--fs-15);
  cursor: pointer; transition: background-color var(--d-rapide), transform var(--d-instant);
}
button.badge::before, a.badge::before { content: none; }
button.badge:active, a.badge:active { transform: scale(.97); }
:is(.appli, body.avec-nav) button.badge { min-height: var(--h-tactile); }

/* ---------- CARTES (fin du verre dépoli et du filet lumineux) ---------- */
.carte {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--bord);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--e-1);
  -webkit-backdrop-filter: none; backdrop-filter: none;
  transition: border-color var(--d-rapide) var(--ease-sortie), background-color var(--d-rapide) var(--ease-sortie);
}
.carte::before { content: none; }
.carte.interactive { cursor: pointer; }
@media (hover: hover) {
  .carte.interactive:hover { transform: none; border-color: var(--bord-fort); background: var(--surface-2); }
  @supports (background: color-mix(in srgb, red, blue)) {
    .carte.interactive:hover { background: color-mix(in srgb, var(--surface-1) 70%, var(--surface-3)); }
  }
}
.carte.interactive:active { transform: scale(.995); }
.carte-titre, .titre-carte {
  display: flex; align-items: center; gap: var(--sp-2);
  font: var(--fw-semibold) var(--fs-17)/var(--lh-titre) var(--police-titre);
  letter-spacing: -.01em; color: var(--texte); margin-bottom: var(--sp-3);
}
:is(.carte-titre, .titre-carte) .ic { color: var(--texte-2); }
:is(.carte-titre, .titre-carte) .action { margin-left: auto; }
.carte-etat { border-left: 3px solid var(--etat, var(--bord-fort)); }
.carte-etat.ok { --etat: var(--vert-500); }
.carte-etat.attention { --etat: var(--jaune-500); }
.carte-etat.bloquant { --etat: var(--rouge-500); }
.carte-etat.info { --etat: var(--bleu-500); }
.carte-hero { padding: var(--sp-6); border-radius: var(--r-xl); box-shadow: var(--e-2); }
.carte-plate { box-shadow: none; background: var(--surface-2); }

/* Panneau (sections du bureau : « carte panneau ») */
.panneau { padding: var(--sp-5); }
.panneau > h3:first-child, .panneau > .carte-titre:first-child { margin-bottom: var(--sp-1); }
.panneau .sous { color: var(--texte-2); font-size: var(--fs-13); }

/* ---------- KPI ---------- */
.kpi { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-1); }
.kpi-label { display: flex; align-items: center; gap: var(--sp-2); color: var(--texte-2); font-size: var(--fs-13); font-weight: var(--fw-medium); }
.kpi-val, .kpi .val {
  font: var(--fw-bold) var(--fs-30)/var(--lh-serre) var(--police-chiffre);
  font-variant-numeric: tabular-nums; letter-spacing: var(--ls-chiffre);
  color: var(--texte); background: none; -webkit-text-fill-color: currentColor;   /* fin du texte dégradé */
}
.kpi-delta { font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--texte-3); }
.kpi-delta.hausse { color: var(--vert-500); }
.kpi-delta.baisse { color: var(--rouge-500); }
.kpi.alerte .kpi-val, .kpi.alerte .val { color: var(--rouge-500); -webkit-text-fill-color: var(--rouge-500); }
.kpi.alerte { box-shadow: inset 3px 0 0 var(--rouge-500), var(--e-1); }
.kpi-hero .kpi-val { font-size: var(--fs-40); }
/* Mise à jour d'un chiffre : fond orange léger, une seule fois */
.pulse-maj { animation: pulse-maj 600ms var(--ease-sortie) 1; border-radius: var(--r-xs); }
@keyframes pulse-maj { from { background-color: var(--accent-bg); } to { background-color: transparent; } }

/* Chiffres qui comptent (CONSERVÉ) : petite montée, une fois */
.compte-anim { display: inline-block; animation: pousse-chiffre var(--d-moyen) var(--ease-sortie); }
@keyframes pousse-chiffre { from { transform: translateY(4px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ---------- LIGNES (anatomie unique, nouvelle classe générique) ---------- */
.ligne {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 56px;
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--bord);
}
.ligne:last-child { border-bottom: 0; }
.ligne[data-href], .ligne.interactive { cursor: pointer; }
@media (hover: hover) { .ligne[data-href]:hover, .ligne.interactive:hover { background: var(--surface-2); } }
.ligne .vignette { width: 40px; height: 40px; border-radius: var(--r-sm); background: var(--surface-2); display: grid; place-items: center; flex: none; overflow: hidden; color: var(--texte-2); }
.ligne .corps { flex: 1; min-width: 0; }
.ligne .corps .titre { font-weight: var(--fw-semibold); font-size: var(--fs-15); overflow-wrap: anywhere; }
.ligne .corps .meta { color: var(--texte-2); font-size: var(--fs-13); }
:is(.appli, body.avec-nav) .ligne { min-height: 64px; }
.intercalaire { position: sticky; top: 0; z-index: var(--z-eleve); padding: var(--sp-2) var(--sp-4); background: var(--bg); color: var(--texte-2); font-size: var(--fs-13); font-weight: var(--fw-semibold); }

/* ---------- TABLEAUX ---------- */
table.tb { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-13); }
table.tb th {
  text-align: left; vertical-align: middle;
  color: var(--texte-2); font-weight: var(--fw-semibold); font-size: var(--fs-12);
  text-transform: none; letter-spacing: 0;
  padding: var(--sp-2) var(--sp-3); height: 40px;
  border-bottom: 1px solid var(--bord-fort);
}
table.tb thead th { position: sticky; top: 0; z-index: var(--z-eleve); background: var(--surface-1); }
table.tb td { padding: var(--sp-2) var(--sp-3); height: 44px; border-bottom: 1px solid var(--bord); vertical-align: middle; }
table.tb.compact td { height: 36px; padding-top: var(--sp-1); padding-bottom: var(--sp-1); }
table.tb tbody tr { transition: background-color var(--d-rapide); }
@media (hover: hover) { table.tb tbody tr:hover { background: var(--surface-2); } }
table.tb :is(td, th).num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--police-chiffre); }
table.tb tr.total td {
  font-weight: var(--fw-bold); color: var(--texte);
  border-top: 2px solid var(--bord-fort); border-bottom: 0;
  background: var(--surface-1);
}
table.tb tbody tr:last-child td { border-bottom: 0; }
.tb-conteneur { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--bord); border-radius: var(--r-md); }
@media (max-width: 640px) {      /* tableau → cartes ; nécessite data-label sur les td */
  table.tb.empilable thead { display: none; }
  table.tb.empilable tr { display: grid; padding: var(--sp-3) 0; border-bottom: 1px solid var(--bord); }
  table.tb.empilable td { height: auto; border: 0; display: flex; justify-content: space-between; gap: var(--sp-3); }
  table.tb.empilable td::before { content: attr(data-label); color: var(--texte-2); }
}

/* ---------- BADGES (point coloré : l'info ne repose pas sur la couleur seule) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 24px; padding: 2px 10px;
  border-radius: var(--r-pill); border: 1px solid var(--bord);
  background: var(--surface-2); color: var(--texte-2);
  font: var(--fw-semibold) var(--fs-12)/1.2 var(--police);
  letter-spacing: 0; text-transform: none; white-space: nowrap; vertical-align: middle;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.sans-point::before { content: none; }
.badge-vert   { background: var(--vert-bg);  color: var(--vert-500);  border-color: var(--vert-bord); }
.badge-orange { background: var(--accent-bg); color: var(--accent-texte); border-color: var(--accent-bord); }   /* Nouveau / à traiter */
.badge-rouge  { background: var(--rouge-bg); color: var(--rouge-500); border-color: var(--rouge-bord); }
.badge-gris   { background: var(--surface-2); color: var(--texte-2); border-color: var(--bord); }
.badge-bleu   { background: var(--bleu-bg);  color: var(--bleu-500);  border-color: var(--bleu-bord); }
.badge-jaune  { background: var(--jaune-bg); color: var(--jaune-500); border-color: var(--jaune-bord); }    /* attention / en attente */
.badge-gris.clos { text-decoration: line-through; opacity: .8; }

/* ---------- CHAMPS ---------- */
label.champ { display: block; margin-bottom: var(--sp-4); }
label.champ > span:first-child {
  display: block; margin-bottom: var(--sp-2);
  color: var(--texte-2); font-size: var(--fs-13); font-weight: var(--fw-semibold);
  text-transform: none; letter-spacing: 0;
}
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]), select, textarea) {
  width: 100%; min-height: var(--h-md); padding: var(--sp-2) var(--sp-4);
  background: var(--surface-2); border: 1px solid var(--bord-fort); border-radius: var(--r-md);
  color: var(--texte); font: var(--fw-regular) 16px/1.4 var(--police);   /* ≥ 16 px : pas de zoom iOS */
  transition: border-color var(--d-rapide), box-shadow var(--d-rapide), background-color var(--d-rapide);
  -webkit-appearance: none; appearance: none;
}
:where(input, textarea)::placeholder { color: var(--texte-3); opacity: 1; }
:where(textarea) { padding: var(--sp-3) var(--sp-4); min-height: 96px; resize: vertical; }
:where(input, select, textarea):focus, :where(input, select, textarea):focus-visible { outline: none; border-color: var(--bord-focus); box-shadow: var(--anneau-focus); }
:where(input, select, textarea):disabled { opacity: .55; cursor: not-allowed; }
:where(input, select, textarea)[aria-invalid="true"] { border-color: var(--rouge-500); }
:where(select) {
  padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0a8b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
:where(input[type="checkbox"], input[type="radio"], input[type="range"]) { accent-color: var(--accent); }
:where(input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"]) { min-width: 0; }
:is(.appli, body.avec-nav) :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select) { min-height: var(--h-lg); font-size: var(--fs-17); }
.champ .aide { margin-top: var(--sp-1); font-size: var(--fs-13); color: var(--texte-3); }
.champ .erreur-champ, .erreur-champ { margin-top: var(--sp-1); font-size: var(--fs-13); color: var(--rouge-500); }
.erreur-champ:empty { display: none; }

/* ---------- FEUILLES DU BAS / MODALES (js/ui.js, <dialog>) ---------- */
dialog.feuille, .feuille-repli {
  position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; max-height: 92vh; max-height: 92dvh;
  padding: var(--sp-2) var(--gouttiere-mobile) calc(var(--sp-5) + var(--safe-bas));
  background: var(--surface-1); color: var(--texte);
  border: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--e-3);
  overflow: auto; overscroll-behavior: contain; z-index: var(--z-feuille);
  animation: feuille-monte var(--d-lent) var(--ease-sortie);
}
dialog.feuille:not([open]) { display: none; }
dialog.feuille::backdrop { background: var(--voile); animation: fondu var(--d-moyen) var(--ease-sortie); }
.feuille-voile-repli { position: fixed; inset: 0; background: var(--voile); z-index: calc(var(--z-feuille) - 1); animation: fondu var(--d-moyen) var(--ease-sortie); }
.feuille .poignee { width: 40px; height: 5px; border-radius: 3px; background: var(--bord-fort); margin: 0 auto var(--sp-4); }
.feuille h2 { font-size: var(--fs-20); margin-bottom: var(--sp-2); color: var(--texte); }
.feuille .feuille-texte { color: var(--texte-2); font-size: var(--fs-15); line-height: var(--lh-corps); white-space: pre-line; overflow-wrap: anywhere; }
.feuille h2 + .feuille-texte { margin-top: 0; }
.feuille .poignee + .feuille-texte { color: var(--texte); font-size: var(--fs-17); }
.feuille .feuille-champ { margin-top: var(--sp-4); }
.feuille .actions { display: grid; gap: var(--sp-3); margin-top: var(--sp-5); }   /* action principale EN BAS (pouce) */
.feuille .actions .btn { margin: 0; min-height: var(--h-lg); font-size: var(--fs-17); }
.feuille .actions .btn-fantome { width: 100%; }
.feuille-choix { display: grid; margin-top: var(--sp-3); border: 1px solid var(--bord); border-radius: var(--r-md); overflow: hidden; }
.feuille-choix .choix-ligne {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 64px;
  padding: var(--sp-3) var(--sp-4); text-align: left; background: var(--surface-1); color: var(--texte);
  border-bottom: 1px solid var(--bord); transition: background-color var(--d-rapide);
}
.feuille-choix .choix-ligne:last-child { border-bottom: 0; }
.feuille-choix .choix-ligne:active { background: var(--surface-3); }
@media (hover: hover) { .feuille-choix .choix-ligne:hover { background: var(--surface-2); } }
.feuille-choix .choix-ligne:focus-visible { outline-offset: -3px; }
.feuille-choix .choix-ligne.danger { color: var(--rouge-500); }
.feuille-choix .choix-ligne > .ic:first-child { color: var(--texte-2); }
.feuille-choix .choix-corps { flex: 1; min-width: 0; display: grid; gap: 2px; }
.feuille-choix .choix-libelle { font-weight: var(--fw-semibold); font-size: var(--fs-17); overflow-wrap: anywhere; }
.feuille-choix .choix-sous { color: var(--texte-2); font-size: var(--fs-13); }
.feuille-choix .choix-chevron { color: var(--texte-3); }
@media (min-width: 640px) {
  dialog.feuille, .feuille-repli {
    inset: 0; margin: auto; width: min(520px, 92vw); height: fit-content; max-height: 86vh;
    border-radius: var(--r-xl); padding: var(--sp-6);
    animation: modale-entre var(--d-moyen) var(--ease-sortie);
  }
  .feuille .poignee { display: none; }
  .feuille .actions { grid-auto-flow: column; justify-content: end; }
  .feuille .actions .btn, .feuille .actions .btn-fantome { width: auto; min-width: 120px; min-height: var(--h-md); font-size: var(--fs-15); }
  .feuille .poignee + .feuille-texte { font-size: var(--fs-15); }
}
@keyframes feuille-monte { from { transform: translateY(100%); } to { transform: none; } }
@keyframes modale-entre { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fondu { from { opacity: 0; } }

/* ---------- TOASTS ---------- */
.toast-zone {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: var(--z-toast);
  bottom: calc(var(--sp-4) + var(--safe-bas));
  display: grid; gap: var(--sp-2); width: min(440px, calc(100vw - 32px)); pointer-events: none;
}
body.avec-nav .toast-zone { bottom: calc(var(--tabbar) + var(--sp-5) + var(--safe-bas)); }
@media (min-width: 940px) {
  .toast-zone, body.avec-nav .toast-zone { bottom: var(--sp-6); left: auto; right: var(--sp-6); transform: none; }
}
.toast-zone:empty { display: none; }
.toast {
  position: fixed; bottom: calc(var(--sp-6) + var(--safe-bas)); left: 50%; transform: translateX(-50%); z-index: var(--z-toast);
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: 52px; max-width: min(440px, calc(100vw - 32px)); padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  border-radius: var(--r-md); border: 0;
  background: var(--surface-inverse); color: var(--bg);
  font-weight: var(--fw-semibold); font-size: var(--fs-15); line-height: 1.35;
  box-shadow: var(--e-3);
  animation: toast-entre var(--d-moyen) var(--ease-sortie);
}
.toast-zone .toast { position: static; transform: none; max-width: none; pointer-events: auto; }
.toast .toast-texte { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-line; padding: var(--sp-1) 0; }
.toast .ic { flex: none; width: 22px; height: 22px; }
.toast.succes .ic { color: var(--vert-500); }
.toast.info .ic { color: var(--bleu-500); }
.toast.attention .ic { color: var(--jaune-500); }
.toast.erreur { background: var(--rouge-500); color: #fff; }
.toast.erreur .ic { color: #fff; }
.toast .action {
  flex: none; min-height: var(--h-md); padding: 0 var(--sp-3); border-radius: var(--r-sm);
  color: var(--orange-500); font-weight: var(--fw-bold); font-size: var(--fs-15);
}
:root[data-theme="soleil"] .toast .action { color: var(--orange-300); }
.toast.erreur .action { color: #fff; text-decoration: underline; }
.toast .toast-fermer {
  flex: none; width: var(--h-md); height: var(--h-md); display: grid; place-items: center;
  border-radius: var(--r-sm); color: inherit; opacity: .6;
}
.toast .toast-fermer:hover { opacity: 1; }
.toast.sort { opacity: 0; transform: translateY(8px); transition: opacity 150ms var(--ease-entree), transform 150ms var(--ease-entree); }
@keyframes toast-entre { from { opacity: 0; transform: translateY(12px); } }

/* ---------- ÉTATS VIDES, ERREURS, SQUELETTES ---------- */
.etat-vide, .vide-etat {
  display: grid; justify-items: center; gap: var(--sp-2);
  padding: var(--sp-8) var(--sp-5); text-align: center;
  color: var(--texte-2); font-style: normal; font-size: var(--fs-15);
}
:is(.etat-vide, .vide-etat, .etat-erreur) .icone {
  width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2);
  display: grid; place-items: center; font-size: 1.5rem; line-height: 1; opacity: 1; margin: 0 auto var(--sp-1);
  color: var(--texte-2); font-style: normal;
}
.etat-vide .pastille-ic { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--texte-2); }
.etat-vide.ok .pastille-ic { background: var(--vert-bg); color: var(--vert-500); }
.etat-vide h3 { color: var(--texte); font-size: var(--fs-17); }
.etat-vide p { max-width: 32ch; font-size: var(--fs-15); }
.etat-vide .btn { width: auto; margin-top: var(--sp-3); }
.etat-erreur {
  display: grid; justify-items: center; gap: var(--sp-2);
  padding: var(--sp-8) var(--sp-5); text-align: center;
  color: var(--rouge-500); font-weight: var(--fw-semibold);
}
.etat-erreur .icone, .etat-erreur .pastille-ic { background: var(--rouge-bg); color: var(--rouge-500); }
.squelette { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); min-height: 14px; }
.squelette::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent);
  animation: shimmer 1.3s ease-in-out infinite;
}
:root[data-theme="soleil"] .squelette::after { background: linear-gradient(90deg, transparent, rgba(0,0,0,.05), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }

/* Spinner : chargement en cours (CONSERVÉ) */
.spinner {
  width: 22px; height: 22px; border-radius: 50%; display: inline-block; vertical-align: middle;
  border: 2.5px solid var(--bord-fort); border-top-color: var(--accent);
  animation: tourne .8s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }

/* Point « en direct » (CONSERVÉ) : statique, plus de pulsation infinie */
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle;
  background: var(--vert-500); box-shadow: 0 0 0 3px var(--vert-bg);
}

/* Secousse : retour d'erreur de saisie (sas.html) */
@keyframes secousse { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- ÉCRANS (CONSERVÉ) : apparition courte ---------- */
.ecran { animation: apparait var(--d-moyen) var(--ease-sortie); }
@keyframes apparait { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- SPLASH (CONSERVÉ dans le DOM, jamais bloquant) ---------- */
.splash {
  position: fixed; inset: 0; z-index: var(--z-splash);
  background: var(--bg);
  display: grid; place-items: center;
  transition: opacity 200ms var(--ease-sortie), visibility 200ms;
  animation: splash-fin 200ms 2s forwards;          /* masqué d'office à 2 s, même si le JS plante */
}
.splash.parti { opacity: 0; visibility: hidden; pointer-events: none; }
.splash img { height: 64px; width: auto; animation: none; filter: none; }
.splash .txt { margin-top: var(--sp-4); color: var(--texte-3); font-size: var(--fs-13); letter-spacing: var(--ls-label); text-transform: none; }
.splash .contenu-splash { text-align: center; }
@keyframes splash-fin { to { opacity: 0; visibility: hidden; pointer-events: none; } }

/* ---------- BARRE D'ONGLETS MOBILE (seul flou conservé côté terrain) ---------- */
.nav-bas {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: var(--z-nav);
  display: flex; align-items: stretch;
  min-height: calc(var(--tabbar) + var(--safe-bas));
  padding: var(--sp-1) var(--sp-1) calc(var(--sp-1) + var(--safe-bas));
  background: rgba(15,17,20,.86);
  -webkit-backdrop-filter: blur(20px) saturate(140%); backdrop-filter: blur(20px) saturate(140%);
  border-top: 1px solid var(--bord);
}
:root[data-theme="soleil"] .nav-bas { background: rgba(255,255,255,.94); border-top: 2px solid var(--bord-fort); }
.nav-bas button {
  flex: 1; position: relative; min-height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; color: var(--texte-3);
  font-size: var(--fs-12); font-weight: var(--fw-semibold); letter-spacing: 0;
  border-radius: var(--r-md);
  transition: color var(--d-rapide) var(--ease-sortie), transform var(--d-instant) var(--ease-sortie);
}
.nav-bas button:active { transform: scale(.94); }
.nav-bas button.actif { color: var(--texte); }
.nav-bas button.actif::before { content: none; }
.nav-bas svg, .nav-bas .ic { width: 26px; height: 26px; padding: 3px 15px; box-sizing: content-box; border-radius: var(--r-pill); transition: background-color var(--d-rapide); }
.nav-bas button.actif svg, .nav-bas button.actif .ic { background: var(--accent-bg); color: var(--accent-texte); }

.avec-nav { padding-bottom: calc(var(--tabbar) + var(--sp-7) + var(--safe-bas)); }

/* ---------- BARRES DE DÉFILEMENT DISCRÈTES ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- MODE SOLEIL : bordures 2 px, aucune ombre floue ---------- */
:root[data-theme="soleil"] .carte { border: 2px solid var(--bord); box-shadow: none; }
:root[data-theme="soleil"] .btn-sombre { border-width: 2px; }
:root[data-theme="soleil"] .btn-orange { color: #140a02; }
:root[data-theme="soleil"] :where(input, select, textarea) { border-width: 2px; background-color: #fff; }
:root[data-theme="soleil"] .badge { border-width: 1.5px; }
:root[data-theme="soleil"] ::selection { background: var(--orange-100); }
:root[data-theme="soleil"] :where(select) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230a0b0d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* ---------- IMPRESSION : rien d'interactif ---------- */
@media print {
  .toast-zone, .toast, dialog.feuille, .feuille-repli, .feuille-voile-repli, .nav-bas, .splash { display: none !important; }
  body { background: #fff; color: #000; }
}
