/* ============================================================================
   Démo « Le rapprochement qui tombe juste » — styles propres à cette démo.
   ========================================================================== */

.rap {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: var(--sp-2);
  align-items: start;
}
.rap__gauche, .rap__droite { display: grid; gap: var(--sp-2); align-content: start; }

/* Chaque colonne défile CHEZ ELLE. Sans cela, ouvrir le panneau de résolution
   allongeait la page et il fallait descendre tout en bas pour voir les factures
   cochées — au moment précis où l'on veut garder l'écart sous les yeux. */
.rap__defile { overflow: auto; }
.rap__defile--brut { max-height: 270px; }
.rap__defile--pivot { max-height: 290px; }

@media (min-width: 1001px) {
  .rap__droite {
    position: sticky;
    top: calc(var(--entete-h) + var(--sp-1));
    max-height: calc(100dvh - var(--entete-h) - 170px);
    overflow-y: auto;
    padding-right: 4px;
  }
}

/* --------------------------------------------------------- Export brut --- */
.tableau--brut td { font-size: var(--t-sm); }
.tableau--brut .compte { font-family: var(--mono); color: var(--ardoise); }

/* Les quatre lignes d'une même pièce : liées par un liseré à gauche, pour
   qu'on voie d'un coup d'œil qu'elles n'en font qu'une. */
.ligne-brute.est-vedette td:first-child { box-shadow: inset 3px 0 0 var(--bleu); }
.ligne-brute.est-vedette { background: var(--bleu-ciel); }
.ligne-brute.est-repliee { animation: kit-part .5s var(--sortie) both; }

/* ------------------------------------------------------------- Pivot ----- */
/* Colonnes serrées : sans `nowrap`, « 2 592,00 € » se coupe entre le montant et
   l'euro, et le tableau devient illisible juste au moment où l'on demande de
   comparer des chiffres. */
.tableau--pivot th, .tableau--pivot td { font-size: var(--t-sm); padding: 9px 8px; white-space: nowrap; }
.tableau--pivot .colonne-compte { font-family: var(--mono); }
.tableau--pivot .ref { font-size: var(--t-xs); }
.marque-deja { white-space: nowrap; }
.ligne-pivot.est-neuve { animation: kit-entre .45s var(--sortie) both; }

/* Facture déjà présente dans le fichier : elle s'efface, sans disparaître. */
.ligne-pivot.est-deja { opacity: .42; }
.ligne-pivot.est-deja .ref { text-decoration: line-through; }

.etat-ligne { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.marque-deja, .marque-sort {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
}
.marque-deja { color: var(--acier); }
.marque-sort { color: var(--bleu-fonce); }

/* Ligne désignée par le solveur, reportée depuis le panneau de droite : on voit
   dans le fichier ce qui va en sortir, avant d'avoir validé quoi que ce soit. */
.ligne-pivot.est-designee td { background: var(--bleu-ciel); }
.ligne-pivot.est-designee .ref { color: var(--bleu-fonce); font-weight: 600; }

/* Une fois l'écart annulé, la ligne est barrée : elle quitte le fichier. */
.ligne-pivot.est-retiree td { background: var(--valide-fond); }
.ligne-pivot.est-retiree .ref,
.ligne-pivot.est-retiree .chiffre { text-decoration: line-through; opacity: .7; }
.ligne-pivot.est-retiree .marque-sort { color: var(--valide); }

/* ------------------------------------------------------------ Comptes ---- */
.comptes { display: grid; gap: 6px; }

.compte-ligne {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--ligne);
  border-radius: var(--r-md);
  background: var(--blanc);
  text-align: left;
  transition: border-color var(--vite) linear, box-shadow var(--moyen) var(--sortie),
              transform var(--vite) linear;
}
.compte-ligne[data-cliquable="1"] { cursor: pointer; }
.compte-ligne[data-cliquable="1"]:hover { border-color: var(--bleu); box-shadow: var(--ombre-s); transform: translateY(-1px); }
.compte-ligne.est-ouvert { border-color: var(--bleu); box-shadow: var(--ombre-focus); }

.compte-ligne__nom { font-weight: 600; }
.compte-ligne__code { font-family: var(--mono); font-size: var(--t-xs); color: var(--acier); }
.compte-ligne__ecart { font-family: var(--mono); font-weight: 600; text-align: right; white-space: nowrap; }
.compte-ligne__ecart.est-nul { color: var(--valide); }
.compte-ligne__ecart.est-rouge { color: var(--alerte); }

/* ------------------------------------------------------------ Panneau ---- */
.panneau__jauge {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2);
  padding: 13px 14px;
  border-radius: var(--r-md);
  background: var(--alerte-fond);
  margin-bottom: var(--sp-2);
  transition: background var(--moyen) linear;
}
.panneau__jauge.est-resolu { background: var(--valide-fond); }
.panneau__jauge-libelle { font-size: var(--t-sm); font-weight: 600; color: var(--alerte); }
.panneau__jauge.est-resolu .panneau__jauge-libelle { color: var(--valide); }
.panneau__jauge-valeur {
  font-family: var(--mono); font-size: var(--t-2xl); font-weight: 500;
  color: var(--alerte); font-variant-numeric: tabular-nums;
}
.panneau__jauge.est-resolu .panneau__jauge-valeur { color: var(--valide); }

.propositions { display: grid; gap: 4px; }

.proposition {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px; align-items: center;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  font-size: var(--t-md);
  cursor: pointer;
  transition: background var(--vite) linear;
}
.proposition:hover { background: var(--voile); }
.proposition input { width: 15px; height: 15px; accent-color: var(--bleu); cursor: pointer; }
.proposition__ref { font-family: var(--mono); font-size: var(--t-sm); }
.proposition__ttc { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }

/* La facture retenue par la machine, avant tout geste du visiteur. */
.proposition.est-retenue { background: var(--bleu-ciel); }
.proposition.est-retenue .proposition__ref { color: var(--bleu-fonce); font-weight: 600; }

.panneau__diagnostic { display: grid; gap: 10px; }
.panneau__detail { font-size: var(--t-sm); color: var(--ardoise); }
.panneau__detail strong { color: var(--encre); }

/* ---------------------------------------------------------- Responsive --- */
@media (max-width: 1000px) {
  .rap { grid-template-columns: minmax(0, 1fr); }
  .rap__defile--brut { max-height: 220px; }
  .rap__droite { position: static; }
}

@media (max-width: 620px) {
  .tableau--brut thead, .tableau--pivot thead { display: none; }
  .tableau--brut td, .tableau--pivot td { padding: 7px 8px; }
  .rap__defile { max-height: 320px; }
}
