/* LIGNES — composants partagés (Opérations, Bilan, Grille logements, Dashboard).
   N'utilise que les rôles de variables.css. */

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font-family: var(--police-texte); font-weight: var(--graisse-texte);
  font-size: var(--taille-m); line-height: var(--interligne);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-weight: var(--graisse-titre); line-height: var(--interligne-serre); margin: 0 0 var(--e-4); }
h1 { font-size: var(--taille-xl); }
h2 { font-size: var(--taille-l); }
h3 { font-size: var(--taille-m); }
p { margin: 0 0 var(--e-4); max-width: 72ch; }

/* Mesures : tout chiffre en IBM Plex Mono 600 (charte p. 08, 17) */
.mesure, td.num, .indicateur__valeur {
  font-family: var(--police-mesure); font-weight: var(--graisse-mesure);
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.unite { font-family: var(--police-texte); font-weight: var(--graisse-texte); color: var(--texte-secondaire); font-size: var(--taille-xs); margin-left: 2px; }
.methode { font-family: var(--police-methode); font-style: italic; font-weight: 400; color: var(--texte-secondaire); font-size: var(--taille-s); }
.secondaire { color: var(--texte-secondaire); }

/* Focus clavier visible partout (WCAG 2.4.7) */
:focus { outline: none; }
:focus-visible { box-shadow: var(--anneau-focus); border-radius: var(--rayon); }
.inverse :focus-visible { box-shadow: 0 0 0 2px var(--granit), 0 0 0 4px var(--focus); }

.evitement { position: absolute; left: -9999px; }
.evitement:focus { left: var(--e-4); top: var(--e-2); background: var(--fond); color: var(--lien); padding: var(--e-2) var(--e-3); z-index: 10; }

/* ---- Barre de navigation (fond Granit, libellés Kaolin, onglet courant liseré bleu minéral) ---- */
.barre { background: var(--fond-inverse); color: var(--texte-inverse); height: var(--hauteur-barre);
  display: flex; align-items: center; gap: var(--e-8); padding: 0 var(--gouttiere); }
.barre__logo { height: 48px; display: block; }        /* capitales du mot ≈ 24 px : minimum écran du logotype (charte p. 07) */
.barre nav { display: flex; gap: var(--e-1); height: 100%; }
.barre a { color: var(--texte-inverse); text-decoration: none; display: flex; align-items: center;
  padding: 0 var(--e-3); height: 100%; border-bottom: 3px solid transparent; font-weight: var(--graisse-titre); font-size: var(--taille-s); }
.barre a:hover { border-bottom-color: var(--trait-champ); }
.barre a[aria-current="page"] { border-bottom-color: var(--bleu-mineral); }
.barre__operation { margin-left: auto; font-size: var(--taille-s); }

/* ---- Bandeau d'état brouillon / version ---- */
.bandeau { display: flex; align-items: center; gap: var(--e-4); padding: var(--e-2) var(--gouttiere);
  border-bottom: var(--trait) solid var(--trait-discret); font-size: var(--taille-s); }
.bandeau__etat { font-weight: var(--graisse-titre); }
.bandeau--version { background: var(--surface-survol); }
.bandeau .actions { margin-left: auto; display: flex; gap: var(--e-2); }

/* ---- Boutons ---- */
.btn { font: inherit; font-weight: var(--graisse-titre); font-size: var(--taille-s); min-height: var(--hauteur-champ);
  padding: 0 var(--e-4); border-radius: var(--rayon); cursor: pointer; border: var(--trait) solid transparent; }
.btn--principal { background: var(--action); color: var(--action-texte); }
.btn--principal:hover { background: var(--granit); }
.btn--secondaire { background: transparent; color: var(--lien); border-color: var(--bleu-interface); }
.btn--secondaire:hover { background: var(--surface-survol); }
.btn:disabled { background: transparent; color: var(--texte-secondaire); border: var(--trait) dashed var(--trait-champ); cursor: not-allowed; }
a, .lien { color: var(--lien); text-decoration: underline; text-underline-offset: 2px; }

/* ---- Champs ---- */
.champ { display: grid; gap: var(--e-1); max-width: 320px; }
.champ label { font-size: var(--taille-s); font-weight: var(--graisse-titre); }
.champ__ligne { display: flex; align-items: center; gap: var(--e-2); }
.saisie {
  font-family: var(--police-mesure); font-weight: var(--graisse-mesure); font-size: var(--taille-s);
  color: var(--texte); background: var(--fond); min-height: var(--hauteur-champ); width: 100%;
  border: var(--trait) solid var(--trait-champ); border-bottom-width: var(--trait-fort);
  border-radius: var(--rayon); padding: 0 var(--e-3); text-align: right;
}
.saisie--texte { font-family: var(--police-texte); font-weight: var(--graisse-texte); text-align: left; }
.saisie:hover { border-color: var(--granit); }
.saisie[aria-invalid="true"] { border: var(--trait-fort) solid var(--trait-accent); border-left-width: 6px; }
.saisie[readonly] { border-style: dashed; color: var(--texte-secondaire); }
.etat { font-size: var(--taille-xs); color: var(--texte-secondaire); white-space: nowrap; }
.etat--erreur, .message-erreur { color: var(--texte); font-weight: var(--graisse-titre); }
.message-erreur { font-size: var(--taille-s); }
.message-erreur::before { content: "Erreur — "; }

/* ---- Étiquettes d'état métier (DEC-023) : couleur + mot explicite ----
   grave = rouge plein · vigilance = orange plein · norme = vert plein · notable (au-dessus des attentes) = vert */
.etiquette { display: inline-flex; align-items: center; gap: var(--e-1); font-size: var(--taille-xs);
  font-weight: var(--graisse-titre); letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px var(--e-2); border-radius: var(--rayon); white-space: nowrap; border: var(--trait) solid transparent; }
.etiquette--grave { background: var(--rouge); color: var(--kaolin); }
.etiquette--vigilance { background: var(--orange-clair); color: var(--granit); }
.etiquette--norme { background: var(--vert); color: var(--kaolin); }
.etiquette--notable { background: var(--vert); color: var(--kaolin); }
.etiquette--reserve { background: var(--bleu-interface); color: var(--kaolin); }                 /* statut de vente (DEC-027) */
.etiquette--libre { color: var(--texte); border: var(--trait) solid var(--trait-champ); }
.etiquette--indisponible { color: var(--texte-secondaire); border: var(--trait) dashed var(--trait-champ); text-transform: none; letter-spacing: 0; }

/* ---- Tonalité des chiffres (DEC-023) ---- */
.ton-negatif, .negatif { color: var(--negatif) !important; }
.ton-positif { color: var(--positif) !important; }
.ton-vigilance { color: var(--vigilance) !important; }

/* ---- Tableaux ---- */
.tableau { border-collapse: collapse; width: 100%; font-size: var(--taille-s); }
.tableau caption { text-align: left; font-weight: var(--graisse-titre); padding-bottom: var(--e-2); }
.tableau th { text-align: left; font-weight: var(--graisse-titre); font-size: var(--taille-xs); text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--texte-secondaire); padding: var(--e-2) var(--e-2); border-bottom: var(--trait-fort) solid var(--trait-accent); }
.tableau th.num { text-align: right; }
.tableau th, .tableau tbody th { white-space: nowrap; }
.tableau tbody th { font-weight: var(--graisse-titre); font-size: var(--taille-s); text-transform: none; letter-spacing: 0; color: var(--texte);
  border-bottom: var(--trait) solid var(--trait-discret); padding: 0 var(--e-2); }
.tableau td { height: var(--hauteur-ligne-tableau); padding: 0 var(--e-2); border-bottom: var(--trait) solid var(--trait-discret); }
.tableau td.num { text-align: right; }
.tableau tbody tr:hover { background: var(--surface-survol); }
.tableau tr[aria-selected="true"] { background: var(--surface-selection); box-shadow: inset 4px 0 0 var(--selection-trait); }
.tableau td.cellule-saisie { padding: 2px var(--e-1); }
.tableau td.cellule-saisie .saisie { min-height: 30px; border-bottom-width: var(--trait); }
.tableau tfoot td { font-weight: var(--graisse-titre); border-top: var(--trait-fort) solid var(--trait-accent); border-bottom: none; }
.tableau .recalcul { color: var(--texte-secondaire); }
.tableau .recalcul::after { content: " recalcul…"; font-family: var(--police-texte); font-weight: var(--graisse-texte); font-size: var(--taille-xs); }

/* ---- Indicateurs ---- */
.indicateurs { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--e-4); }
.indicateur { border-top: var(--trait-fort) solid var(--trait-accent); padding-top: var(--e-3); }
.indicateur__libelle { font-size: var(--taille-s); font-weight: var(--graisse-titre); }
.indicateur__valeur { font-size: var(--taille-xxl); line-height: 1.1; display: block; margin: var(--e-1) 0; }
.indicateur__repere { font-size: var(--taille-xs); color: var(--texte-secondaire); }
.indicateur__repere .mesure { color: var(--texte); }
.score--notable { color: var(--score-notable); }
.inverse .score--notable { color: var(--texte-inverse); }   /* Grand Fond interdit sur Granit */

/* ---- Décision (DEC-023) : bloc anthracite, liseré et titre de la couleur de la décision ---- */
.decision { padding: var(--e-4) var(--e-6); border-radius: var(--rayon); background: var(--granit); color: var(--kaolin); border-left: 10px solid var(--trait-champ); }
.decision h2 { margin-bottom: var(--e-2); font-size: var(--taille-xl); }
.decision ul { margin: 0; padding-left: var(--e-4); }
.decision a { color: var(--kaolin); }
.decision--grave { border-left-color: var(--rouge-clair); }
.decision--grave h2 { color: var(--rouge-clair); }
.decision--vigilance { border-left-color: var(--orange-clair); }
.decision--vigilance h2 { color: var(--orange-clair); }
.decision--ok { border-left-color: var(--vert-clair); }
.decision--ok h2 { color: var(--vert-clair); }

/* ---- Blocs alternés Kaolin / anthracite (DEC-023) ----
   .bloc--inverse redéfinit les rôles : tout composant placé dedans s'adapte (texte, traits, liens, couleurs d'état). */
.bloc { padding: var(--e-6) var(--e-6) var(--e-4); margin: 0 calc(-1 * var(--e-6)); border-radius: var(--rayon); }
.bloc > h2:first-child, .bloc > .titre-groupe:first-child { margin-top: 0; }
.bloc--inverse, .decision {
  --fond: var(--granit); --texte: var(--kaolin); --texte-secondaire: #B8B3A9;  /* 7,59:1 sur Granit */
  --trait-champ: #8C8881; --trait-discret: #4A4743; --trait-accent: #8C8881; --surface-survol: #34312D; --surface-selection: #2E3A42;
  --lien: #8FC1E3;                                                             /* 8,23:1 sur Granit */
  --negatif: var(--rouge-clair); --positif: var(--vert-clair); --vigilance: var(--orange-clair); --score-notable: var(--vert-clair);
  background: var(--granit); color: var(--kaolin);
}
.bloc--inverse .btn--secondaire { color: var(--lien); border-color: var(--lien); }
.bloc--inverse :focus-visible { box-shadow: 0 0 0 2px var(--granit), 0 0 0 4px var(--lien); }

/* ---- Messages ---- */
.message { border-radius: var(--rayon); border-left: 6px solid var(--trait-accent); padding: var(--e-3) var(--e-4); background: var(--surface-survol); font-size: var(--taille-s); }
.message--info { border-left-color: var(--bleu-mineral); }
.message p { margin: 0 0 var(--e-2); }
.message p:last-child { margin: 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
