/* Charte graphique Capio v1.0 — voir Capio/DESIGN-Capio.md
   Aucune couleur hors jetons. L'orange ne sert jamais au texte. */
:root {
  --bleu-capio: #123A66;
  --bleu-nuit: #0A1E38;
  --orange: #F07D00;
  --orange-fonce: #D95F00;
  --creme: #F5F1DE;
  --blanc: #FFFFFF;
  --gris-ardoise: #5C6B7A;
  --gris-fond: #EEF1F4;
  --bleu-clair: #DCE7F2;
  --succes: #2E8B57;
  --erreur: #C0392B;
  --alerte: #E9A400;
  --info: #2E7FB8;
  --texte: #1A1A1A;
  --r-bouton: 8px;
  --r-carte: 12px;
}

* { box-sizing: border-box; }

/* Toute l'application masque et démasque par l'attribut hidden. Or la
   règle `button { display: inline-flex }` plus bas le battait en duel de
   spécificité : les boutons masqués restaient visibles et cliquables.
   Cette ligne rend la promesse de `hidden` inconditionnelle. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Semplicita Pro", "Jost", "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--texte);
  background: var(--blanc);
}

h1 { font-size: 2rem; color: var(--bleu-capio); margin: 0 0 .5rem; }
h2 { font-size: 1.5rem; color: var(--bleu-capio); margin: 2rem 0 .75rem;
     border-bottom: 1px solid var(--orange); padding-bottom: .25rem; }
h3 { font-size: 1.25rem; color: var(--bleu-nuit); margin: 1.5rem 0 .5rem; }
a { color: var(--info); }

.bandeau {
  background: var(--bleu-capio);
  color: var(--blanc);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.bandeau img { height: 36px; width: 36px; border-radius: 50%; }
.bandeau .titre { font-weight: 700; font-size: 1.15rem; }
.bandeau .sous { color: var(--bleu-clair); font-size: .9rem; margin-left: auto; }

.page { max-width: 780px; margin: 0 auto; padding: 24px 16px 64px; }
.centre { text-align: center; }

.carte {
  background: var(--blanc);
  border: 1px solid var(--gris-fond);
  border-radius: var(--r-carte);
  box-shadow: 0 1px 3px rgba(10, 30, 56, .08);
  padding: 24px;
  margin: 16px 0;
}
.carte .coin { height: 4px; background: var(--orange); border-radius: 4px 4px 0 0;
               margin: -24px -24px 20px; }

/* Encadrés pédagogiques normalisés (charte §6) */
.encadre { border-left: 4px solid; padding: 12px 16px; border-radius: 0 var(--r-bouton) var(--r-bouton) 0; margin: 16px 0; }
.encadre .t { font-weight: 700; color: var(--bleu-capio); }
.encadre.definition { background: var(--creme); border-color: var(--bleu-capio); }
.encadre.exemple    { background: var(--bleu-clair); border-color: var(--bleu-capio); }
.encadre.piege      { background: var(--blanc); border-color: var(--alerte); }
.encadre.methode    { background: var(--blanc); border-color: var(--succes); }

label { display: block; font-weight: 600; color: var(--bleu-capio); margin-bottom: 6px; }
.aide { color: var(--gris-ardoise); font-size: .92rem; margin: 0 0 8px; }
.exemple { color: var(--gris-ardoise); font-size: .92rem; font-style: italic; margin: 6px 0 0; white-space: pre-line; }

input[type=text], input[type=number], textarea, select {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1.5px solid var(--bleu-clair);
  border-radius: var(--r-bouton);
  background: var(--blanc);
  color: var(--texte);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--info); outline-offset: 1px; border-color: var(--info); }
textarea { min-height: 96px; resize: vertical; }

button, .bouton {
  font: inherit; font-weight: 700;
  padding: 11px 20px;
  border: none;
  border-radius: var(--r-bouton);
  background: var(--orange);
  color: var(--bleu-nuit);       /* pas de blanc sur orange : contraste */
  cursor: pointer;
  min-height: 48px;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
button:hover, .bouton:hover { background: var(--orange-fonce); }
button.secondaire, .bouton.secondaire {
  background: transparent; color: var(--bleu-capio);
  border: 1.5px solid var(--bleu-capio);
}
button.secondaire:hover, .bouton.secondaire:hover { background: var(--gris-fond); }
button:disabled { opacity: .45; cursor: not-allowed; }

.barre { height: 8px; background: var(--gris-fond); border-radius: 4px; overflow: hidden; margin: 8px 0 4px; }
.barre > span { display: block; height: 100%; background: var(--orange); transition: width .25s; }
.progression { color: var(--gris-ardoise); font-size: .9rem; }

.etat { display: inline-block; padding: 2px 10px; border-radius: 999px;
        background: var(--bleu-clair); color: var(--bleu-capio); font-size: .82rem; font-weight: 600; }
.etat.alerte { background: #FBF0D3; color: #7A5600; }

table { width: 100%; border-collapse: collapse; margin: 12px 0; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--gris-fond); font-size: .95rem; }
th { background: var(--bleu-clair); color: var(--bleu-capio); }

.sauvegarde { color: var(--succes); font-size: .88rem; min-height: 1.2em; }
.sauvegarde.erreur { color: var(--erreur); }

/* Les messages d'erreur portent des listes et des sauts de ligne :
   posés par textContent, ils se collaient les uns aux autres. */
#texteErreur { white-space: pre-line; line-height: 1.6; }

/* Bulles du glossaire — le porteur n'est pas comptable.
   Survol à la souris, focus au clavier, appui au doigt. */
.bulle {
  border-bottom: 1px dotted var(--info);
  color: var(--info);
  cursor: help;
  position: relative;
  outline-offset: 2px;
}
.bulle::after {
  content: attr(data-def);
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 20;
  width: max-content;
  max-width: min(320px, 78vw);
  background: var(--bleu-nuit);
  color: #F5F5F0;
  font-size: .88rem;
  font-style: normal;
  line-height: 1.4;
  padding: 10px 12px;
  border-radius: var(--r-bouton);
  box-shadow: 0 4px 14px rgba(10, 30, 56, .28);
  opacity: 0;
  visibility: hidden;
  transition: opacity .12s;
}
.bulle::before {
  content: '';
  position: absolute;
  left: 10px; top: calc(100% + 2px);
  border: 6px solid transparent;
  border-bottom-color: var(--bleu-nuit);
  opacity: 0; visibility: hidden;
  transition: opacity .12s;
}
.bulle:hover::after, .bulle:focus::after, .bulle.ouverte::after,
.bulle:hover::before, .bulle:focus::before, .bulle.ouverte::before {
  opacity: 1; visibility: visible;
}
/* Près du bord droit, la bulle déborderait : on l'ancre à droite. */
.bulle.a-droite::after { left: auto; right: 0; }
.bulle.a-droite::before { left: auto; right: 10px; }

.entete-doc { border-bottom: 2px solid var(--orange); padding-bottom: 10px; margin-bottom: 18px; }
.entete-doc .code { color: var(--bleu-capio); }
.entete-doc .meta { color: var(--gris-ardoise); font-size: .9rem; }
.pied-doc { margin-top: 28px; padding-top: 10px; border-top: 1px solid var(--gris-fond);
            color: var(--gris-ardoise); font-size: .88rem; }

.rangee { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.rangee > * { flex: 1 1 180px; }

/* Fil d'étapes — le porteur revient plusieurs fois sur son dossier :
   il doit voir d'un coup d'œil où il en est. */
.etapes {
  display: flex; flex-wrap: wrap; gap: 8px;
  list-style: none; counter-reset: etape;
  margin: 0 0 4px; padding: 0;
}
.etapes li {
  counter-increment: etape;
  flex: 1 1 140px;
  font-size: .88rem; font-weight: 600;
  color: var(--gris-ardoise);
  padding: 8px 10px 8px 34px;
  position: relative;
  border-top: 3px solid var(--gris-fond);
}
.etapes li::before {
  content: counter(etape);
  position: absolute; left: 8px; top: 8px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--gris-fond); color: var(--gris-ardoise);
  font-size: .75rem; line-height: 20px; text-align: center;
}
.etapes li.faite { color: var(--bleu-capio); border-top-color: var(--bleu-capio); }
.etapes li.faite::before { content: '✓'; background: var(--bleu-capio); color: var(--blanc); }
.etapes li.active { color: var(--bleu-capio); border-top-color: var(--orange); }
.etapes li.active::before { background: var(--orange); color: var(--bleu-nuit); }

/* Écran 3 — une précision demandée au porteur */
.precision {
  border-left: 4px solid var(--orange);
  background: var(--gris-fond);
  border-radius: 0 var(--r-bouton) var(--r-bouton) 0;
  padding: 14px 16px;
  margin: 0 0 16px;
}
.precision .q { font-weight: 700; color: var(--bleu-capio); margin: 0 0 4px; }
.precision textarea { min-height: 72px; background: var(--blanc); }

/* Écran 4 — un paragraphe de la reformulation, corrigeable */
.paragraphe { margin: 0 0 18px; }
.paragraphe textarea { overflow: hidden; line-height: 1.55; }
textarea[readonly] { background: var(--gris-fond); color: var(--gris-ardoise); resize: none; }

/* Écran 5 — la note de marché.
   Les étiquettes sont le cœur du document : on doit distinguer d'un
   coup d'œil ce qui est établi de ce qui ne l'est pas. */
.banniere-demo {
  background: var(--alerte); color: var(--bleu-nuit);
  font-weight: 700; text-align: center;
  padding: 10px 16px; border-radius: var(--r-bouton); margin: 0 0 16px;
}
.avertissement {
  color: var(--gris-ardoise); font-size: .86rem; font-style: italic;
  line-height: 1.45; margin: 12px 0;
}
.legende { font-size: .86rem; color: var(--gris-ardoise); line-height: 2.1; margin-top: 14px; }

.etiq {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; vertical-align: 2px; margin-right: 6px;
}
.etiq.source     { background: #DCEEE3; color: #1E5C3A; }
.etiq.declare    { background: var(--bleu-clair); color: var(--bleu-capio); }
.etiq.estime     { background: #E6E1F2; color: #43356E; }
.etiq.a_verifier { background: #FBF0D3; color: #7A5600; }

.donnee { padding: 14px 0; border-top: 1px solid var(--gris-fond); }
.donnee:first-of-type { border-top: none; padding-top: 0; }
.donnee p { margin: 0 0 6px; }
.donnee .t { font-weight: 600; color: var(--bleu-capio); }
.donnee .methode { font-size: .88rem; color: var(--gris-ardoise); font-style: italic; }
.donnee .src { font-size: .84rem; color: var(--gris-ardoise); }
.donnee .src a { word-break: break-word; }

#listeVerifier li { margin-bottom: 12px; }
#listeSources li { margin-bottom: 10px; font-size: .9rem; word-break: break-word; }

/* Écrans 6 et 7 — la partie.
   Le tableau de bord met la trésorerie au même rang que le reste :
   c'est elle qui arrête une entreprise, et c'est elle qu'on regarde
   en dernier. */
.tableau-bord {
  display: grid; gap: 10px; margin-top: 18px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.tuile {
  background: var(--gris-fond); border-radius: var(--r-bouton);
  padding: 12px 14px; border-left: 4px solid var(--bleu-clair);
}
.tuile .l { display: block; font-size: .82rem; color: var(--gris-ardoise); }
.tuile .v { display: block; font-size: 1.35rem; font-weight: 700; color: var(--bleu-capio); }
.tuile.ok { border-left-color: var(--succes); }
.tuile.vigilance { border-left-color: var(--alerte); background: #FBF0D3; }
.tuile.critique { border-left-color: var(--erreur); background: #FBE3E0; }
.tuile.critique .v { color: var(--erreur); }

.t-bloc { font-weight: 700; color: var(--bleu-capio); margin: 0 0 8px; }
.ligne {
  display: flex; justify-content: space-between; gap: 12px;
  margin: 0 0 4px; font-size: .95rem;
  border-bottom: 1px dotted var(--gris-fond); padding-bottom: 3px;
}
.ligne-forte {
  font-weight: 700; font-size: 1.1rem; margin: 16px 0 8px;
  padding: 10px 14px; border-radius: var(--r-bouton); background: var(--gris-fond);
}
.ligne-forte.bon { background: #DCEEE3; color: #1E5C3A; }
.ligne-forte.mauvais { background: #FBE3E0; color: var(--erreur); }

/* Console — onglets et statistiques */
.onglets { display: flex; gap: 4px; flex-wrap: wrap; margin: 20px 0 0; border-bottom: 2px solid var(--gris-fond); }
.onglet {
  background: transparent; color: var(--gris-ardoise); border: none;
  border-bottom: 3px solid transparent; border-radius: 0;
  min-height: 42px; padding: 8px 18px; font-weight: 600;
}
.onglet:hover { background: var(--gris-fond); }
.onglet.actif { color: var(--bleu-capio); border-bottom-color: var(--orange); }

.etape-stat { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; font-size: .92rem; }
.etape-stat .l { flex: 0 0 190px; color: var(--bleu-capio); }
.etape-stat .jauge { flex: 1 1 auto; height: 14px; background: var(--gris-fond); border-radius: 7px; overflow: hidden; }
.etape-stat .jauge > span { display: block; height: 100%; background: var(--bleu-clair); }
.etape-stat .n { flex: 0 0 40px; text-align: right; font-weight: 700; color: var(--bleu-capio); }

/* Le tableau des offres, relu par le porteur avant que la partie soit
   construite. Une case grisée n'est pas un chiffre de lui : c'est une
   valeur que le programme a dû déduire, et il doit pouvoir la repérer
   d'un coup d'œil sans lire la légende. */
table.offres th:not(:first-child), table.offres td:not(:first-child) { text-align: right; }
table.offres td.deduit {
  background: var(--gris-fond);
  color: var(--gris-ardoise);
  font-style: italic;
}
table.offres td.deduit::after { content: ' ·'; }

td.actions { white-space: nowrap; }
td.actions button {
  min-height: 32px; padding: 4px 10px; font-size: .82rem; font-weight: 600;
  background: transparent; color: var(--bleu-capio);
  border: 1px solid var(--bleu-clair); margin-right: 4px;
}
td.actions button:hover { background: var(--gris-fond); }
td.actions button.danger { color: var(--erreur); border-color: #E8C0BA; }
td.actions button.danger:hover { background: #FBE3E0; }

code { background: var(--gris-fond); padding: 2px 6px; border-radius: 4px; font-size: .9rem; }

@media (max-width: 640px) {
  .etape-stat .l { flex: 0 0 120px; font-size: .84rem; }
}

td.bon { color: #1E5C3A; font-weight: 600; }
td.mauvais { color: var(--erreur); font-weight: 600; }
#tableauMois { font-size: .9rem; min-width: 620px; }
#tableauMois td, #tableauMois th { padding: 7px 9px; }

@media (max-width: 640px) {
  .bandeau .sous { display: none; }
  .page { padding: 16px 12px 48px; }
  .etapes li { flex: 1 1 100%; border-top: none; border-left: 3px solid var(--gris-fond); padding: 4px 10px 4px 34px; }
  .etapes li::before { top: 4px; }
  .etapes li.faite { border-left-color: var(--bleu-capio); }
  .etapes li.active { border-left-color: var(--orange); }
}
