/* ════════════════════════════════════════════════════════════════════════
   Contrôle de note de calcul électrique — feuille de style
   Reprend le design system d'AuditBTP (thème sombre, palette 1GeleC) pour
   que les deux outils se ressemblent, mais reste autonome : ce fichier ne
   dépend d'aucune autre feuille de style.
   ════════════════════════════════════════════════════════════════════════ */

:root {
  --bg-base:       #090d19;
  --bg-surface:    #111827;
  --bg-surface2:   #1a2236;
  --bg-surface3:   #1f2d45;
  --bg-hover:      #243047;

  --accent:        #2c5c8f;
  --accent-light:  #4f8fd1;
  --accent-dim:    rgba(44, 92, 143, 0.15);
  --lime:          #a8cc3a;
  --blue:          #2ea8b8;

  --ok:            #10b981;
  --ok-bg:         rgba(16, 185, 129, 0.12);
  --defaut:        #ef4444;
  --defaut-bg:     rgba(239, 68, 68, 0.12);
  --attention:     #f59e0b;
  --attention-bg:  rgba(245, 158, 11, 0.12);
  --inconnu:       #94a3b8;
  --inconnu-bg:    rgba(148, 163, 184, 0.10);
  --economie:      #a8cc3a;
  --economie-bg:   rgba(168, 204, 58, 0.10);

  --text:          #f1f5f9;
  --text-dim:      #94a3b8;
  --text-muted:    #64748b;
  --border:        rgba(255, 255, 255, 0.08);
  --border-bright: rgba(255, 255, 255, 0.16);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --transition: 0.16s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-base);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── En-tête ───────────────────────────────────────────────────────────── */
.entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.5rem;
  background: linear-gradient(180deg, var(--bg-surface2), var(--bg-surface));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.entete h1 { font-size: 1.15rem; font-weight: 650; letter-spacing: -0.01em; }
.entete-sous-titre { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.1rem; }
.entete-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Boutons ───────────────────────────────────────────────────────────── */
.bouton {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 550;
  color: var(--text);
  background: var(--bg-surface3);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.bouton:hover { background: var(--bg-hover); border-color: var(--accent-light); }
.bouton:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }
.bouton-principal { background: var(--accent); border-color: var(--accent-light); }
.bouton-principal:hover { background: var(--accent-light); }
.bouton-discret { background: transparent; border-color: var(--border); color: var(--text-dim); font-size: 0.8rem; }
.bouton-ligne {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font: inherit; font-size: 1rem; line-height: 1; padding: 0.2rem 0.35rem;
  border-radius: var(--radius-sm);
}
.bouton-ligne:hover { background: var(--defaut-bg); color: var(--defaut); }

/* ── Mise en page ──────────────────────────────────────────────────────── */
.contenu { max-width: 1600px; margin: 0 auto; padding: 1.25rem 1.5rem 4rem; }

.panneau {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.1rem;
  overflow: hidden;
}
.panneau-titre {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.8rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-surface2);
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
}
.panneau-titre:hover { background: var(--bg-surface3); }
.chevron { color: var(--accent-light); transition: transform var(--transition); display: inline-block; }
.panneau-titre[aria-expanded="false"] .chevron { transform: rotate(-90deg); }
.panneau-note { margin-left: auto; font-size: 0.78rem; font-weight: 450; color: var(--text-muted); }
.panneau-corps { padding: 1rem; }
.panneau-corps[hidden] { display: none; }

.sous-titre { font-size: 0.9rem; font-weight: 600; margin: 1.2rem 0 0.35rem; }
.aide { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.6rem; max-width: 75ch; }

/* ── Champs de formulaire ──────────────────────────────────────────────── */
.grille-champs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.9rem;
}
.champ { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; }
.champ > span { font-weight: 550; color: var(--text-dim); }
.champ small { font-size: 0.72rem; color: var(--text-muted); line-height: 1.35; }
.champ-case { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.champ-case small { flex-basis: 100%; }

input[type="text"], input[type="number"], select, textarea {
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg-base);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.5rem;
  width: 100%;
  transition: border-color var(--transition);
}
input:focus, select:focus { outline: none; border-color: var(--accent-light); }
input[type="checkbox"] { width: auto; accent-color: var(--accent-light); }
select { cursor: pointer; }

.bascule { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; color: var(--text-dim); cursor: pointer; }
.barre-outils { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; }

/* ── Diagnostic d'extraction ───────────────────────────────────────────── */
.diagnostic {
  display: flex;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
  border-left: 3px solid;
}
.diagnostic-info { background: var(--inconnu-bg); border-color: var(--blue); }
.diagnostic-avertissement { background: var(--attention-bg); border-color: var(--attention); }
.diagnostic-erreur { background: var(--defaut-bg); border-color: var(--defaut); }

.mapping { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.6rem; }
.mapping-colonne {
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem;
}
.mapping-titre { font-size: 0.8rem; font-weight: 600; margin-bottom: 0.1rem; word-break: break-word; }
.mapping-exemple { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 0.35rem; font-family: ui-monospace, monospace; }

.depliant { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 0.7rem; }
.depliant summary { cursor: pointer; font-size: 0.85rem; font-weight: 550; color: var(--text-dim); }
.lignes-brutes { max-height: 320px; overflow-y: auto; margin-top: 0.5rem; }
.ligne-brute {
  display: flex; align-items: baseline; gap: 0.6rem;
  padding: 0.25rem 0.4rem; font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, monospace;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
}
.ligne-brute:hover { background: var(--bg-surface2); }
.ligne-brute-page { color: var(--text-muted); flex-shrink: 0; }
.ligne-brute-texte { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-brute-entete { background: var(--accent-dim); color: var(--text); }

/* ── Tableau des circuits ──────────────────────────────────────────────── */
.table-defilante { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table-circuits { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 0.78rem; }
.table-circuits th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-surface3);
  padding: 0.45rem 0.5rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  border-bottom: 1px solid var(--border-bright);
}
.table-circuits td { padding: 0.15rem 0.2rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-circuits tbody tr:hover { background: var(--bg-surface2); }
.table-circuits input, .table-circuits select { padding: 0.25rem 0.35rem; font-size: 0.78rem; min-width: 60px; }
.table-circuits .col-large input { min-width: 150px; }
.table-circuits .col-moyenne input, .table-circuits .col-moyenne select { min-width: 95px; }
.cellule-verdict { text-align: center; }

.pastille {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
}
.pastille-ok { background: var(--ok); }
.pastille-defaut { background: var(--defaut); }
.pastille-attention { background: var(--attention); }
.pastille-inconnu { background: var(--inconnu); }

.vide { color: var(--text-muted); font-size: 0.85rem; text-align: center; padding: 2rem 1rem; }

/* ── Synthèse ──────────────────────────────────────────────────────────── */
.synthese { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.7rem; margin-bottom: 1rem; }
.carte-synthese {
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
}
.carte-synthese-valeur { font-size: 1.6rem; font-weight: 650; line-height: 1.1; }
.carte-synthese-libelle { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }
.carte-defaut { border-left-color: var(--defaut); } .carte-defaut .carte-synthese-valeur { color: var(--defaut); }
.carte-attention { border-left-color: var(--attention); } .carte-attention .carte-synthese-valeur { color: var(--attention); }
.carte-ok { border-left-color: var(--ok); } .carte-ok .carte-synthese-valeur { color: var(--ok); }
.carte-inconnu { border-left-color: var(--inconnu); } .carte-inconnu .carte-synthese-valeur { color: var(--inconnu); }
.carte-economie { border-left-color: var(--economie); } .carte-economie .carte-synthese-valeur { color: var(--economie); }

/* ── Résultat par circuit ──────────────────────────────────────────────── */
.circuit-resultat {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.6rem;
  overflow: hidden;
  background: var(--bg-surface2);
}
.circuit-entete {
  display: flex; align-items: center; gap: 0.6rem;
  width: 100%; padding: 0.6rem 0.8rem;
  font: inherit; text-align: left; color: var(--text);
  background: none; border: none; cursor: pointer;
  border-left: 3px solid transparent;
}
.circuit-entete:hover { background: var(--bg-surface3); }
.circuit-defaut .circuit-entete { border-left-color: var(--defaut); }
.circuit-attention .circuit-entete { border-left-color: var(--attention); }
.circuit-ok .circuit-entete { border-left-color: var(--ok); }
.circuit-inconnu .circuit-entete { border-left-color: var(--inconnu); }
.circuit-repere { font-weight: 650; font-size: 0.88rem; }
.circuit-designation { color: var(--text-dim); font-size: 0.82rem; }
.circuit-compteurs { margin-left: auto; display: flex; gap: 0.4rem; align-items: center; }
.jeton {
  font-size: 0.7rem; font-weight: 600; padding: 0.12rem 0.4rem;
  border-radius: 999px; white-space: nowrap;
}
.jeton-defaut { background: var(--defaut-bg); color: var(--defaut); }
.jeton-attention { background: var(--attention-bg); color: var(--attention); }
.jeton-economie { background: var(--economie-bg); color: var(--economie); }
.jeton-ok { background: var(--ok-bg); color: var(--ok); }
/* Ni vert ni orange : une vérification que le texte ne demande pas n'est pas
   une réussite, et n'est pas non plus une réserve. */
.jeton-info { background: var(--inconnu-bg); color: var(--inconnu); }

/* ── Comparaison entre deux indices ────────────────────────────────────
   Le bandeau de gauche porte le sens de l'évolution, pas le verdict : c'est
   la dégradation qu'il faut voir en premier, et elle peut très bien laisser
   un circuit « à vérifier » qui l'était déjà. */
.comparaison-entete { cursor: default; }
.comparaison-entete:hover { background: none; }
.comparaison-regression .circuit-entete { border-left-color: var(--defaut); }
.comparaison-amelioration .circuit-entete { border-left-color: var(--ok); }
.comparaison-apparu .circuit-entete { border-left-color: var(--blue); }
.comparaison-stable .circuit-entete { border-left-color: var(--attention); }
.comparaison-renseigne .circuit-entete { border-left-color: var(--ok); }
.comparaison-appauvri .circuit-entete { border-left-color: var(--inconnu); }
/* Ni vert ni rouge : l'outil ne sait pas si le circuit a été corrigé ou s'il
   a disparu, et la couleur ne doit pas trancher à sa place. */
.comparaison-incertain .circuit-entete { border-left-color: var(--attention); }
.comparaison-doute {
  margin: 0.5rem 0 0; padding: 0.5rem 0.7rem;
  font-size: 0.82rem; line-height: 1.45; color: var(--text-muted);
  border-left: 3px solid var(--attention);
  background: rgba(255, 255, 255, 0.03);
}
.comparaison-sous-titre {
  font-size: 0.78rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-muted);
  margin: 0.8rem 0 0.4rem;
}
.changement {
  display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap;
  font-size: 0.82rem; padding: 0.25rem 0; border-bottom: 1px solid var(--border);
}
.changement:last-child { border-bottom: none; }
.changement-champ { color: var(--text-dim); min-width: 16ch; }
.changement-avant { color: var(--text-muted); text-decoration: line-through; }
.changement-fleche { color: var(--text-muted); }
.changement-apres { color: var(--text); font-weight: 600; }
.changement-regression .changement-apres { color: var(--defaut); }
.changement-amelioration .changement-apres { color: var(--ok); }
.changement-apparu .changement-apres { color: var(--blue); }
.changement-disparu .changement-apres { color: var(--text-muted); }
.changement-renseigne .changement-apres { color: var(--ok); }
.changement-appauvri .changement-apres { color: var(--inconnu); }

.circuit-corps { padding: 0.2rem 0.8rem 0.8rem; border-top: 1px solid var(--border); }
.circuit-corps[hidden] { display: none; }

.controle {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.controle:last-child { border-bottom: none; }
.controle-point { width: 9px; height: 9px; border-radius: 50%; margin-top: 0.4rem; }
.controle-ok .controle-point { background: var(--ok); }
.controle-defaut .controle-point { background: var(--defaut); }
.controle-attention .controle-point { background: var(--attention); }
.controle-inconnu .controle-point { background: var(--inconnu); }
/* `info` : contrôle général écarté par une règle propre au type de circuit
   (désenfumage et protection contre les surcharges). Ni vert ni rouge — ce
   n'est ni un constat de conformité ni un défaut, mais l'explication d'une
   absence, et c'est justement ce qu'un lecteur ne doit pas confondre. */
.controle-info .controle-point { background: var(--blue); }
.controle-info .controle-message { color: var(--blue); }
.controle-libelle { font-weight: 600; font-size: 0.78rem; color: var(--text-dim); }
.controle-message { margin-top: 0.1rem; }
.controle-defaut .controle-message { color: #fca5a5; }
.controle-detail { margin-top: 0.25rem; font-size: 0.76rem; color: var(--text-muted); line-height: 1.45; }

/* Provenance du constat. Toujours au même endroit et sous la même forme, que
   la source vienne du moteur ou d'une règle liée au type de circuit : c'est ce
   qui permet de lire un rapport en vérifiant chaque ligne. */
.controle-source {
  margin-top: 0.3rem; font-size: 0.73rem; line-height: 1.4;
  color: var(--text-muted);
}
.source-intitule { font-weight: 600; }
.source-lien { color: var(--blue); text-decoration: underline; }
/* Une convention interne ne doit pas emprunter l'allure d'une exigence : elle
   est mise en retrait, en italique, et son intitulé le dit en toutes lettres. */
.controle-source-convention,
.controle-source-pratique { font-style: italic; opacity: 0.85; }

.economie {
  display: grid; grid-template-columns: 12px 1fr; gap: 0.6rem;
  padding: 0.55rem 0.6rem; margin-top: 0.5rem;
  background: var(--economie-bg);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
.economie-point { width: 9px; height: 9px; border-radius: 50%; background: var(--economie); margin-top: 0.4rem; }

/* Prescriptions : exigences réglementaires qu'une note de calcul ne permet pas
   de vérifier. Présentation délibérément neutre, sans pastille de verdict :
   ce sont des points à contrôler ailleurs, pas des constats. */
.prescriptions {
  margin-top: 0.6rem; padding: 0.55rem 0.7rem;
  background: var(--inconnu-bg);
  border-left: 3px solid var(--inconnu);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}
.prescriptions-titre {
  font-weight: 600; font-size: 0.76rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.35rem;
}
.prescriptions-liste { margin: 0; padding-left: 1.1rem; line-height: 1.5; }
.prescriptions-liste li { margin-bottom: 0.3rem; }
.prescription-source { color: var(--text-muted); font-size: 0.75rem; }
.economie-gain { font-weight: 600; color: var(--economie); }

/* Remarque de conception : même forme qu'une économie, mais ni le vert ni la
   promesse de gain. Réservée aux pistes NON chiffrables — typiquement le
   calibre très supérieur au courant d'emploi, qui ne fait rien économiser. */
.remarque {
  display: grid; grid-template-columns: 12px 1fr; gap: 0.6rem;
  padding: 0.55rem 0.6rem; margin-top: 0.5rem;
  background: var(--inconnu-bg);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
.remarque-point { width: 9px; height: 9px; border-radius: 50%; background: var(--inconnu); margin-top: 0.4rem; }
.remarque-gain { font-weight: 600; color: var(--text-muted); }

.valeurs-cles {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem;
  padding: 0.5rem 0; font-size: 0.76rem; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.valeurs-cles b { color: var(--text-dim); font-weight: 600; }

.pied { margin-top: 2rem; font-size: 0.76rem; color: var(--text-muted); line-height: 1.55; max-width: 90ch; }

/* ── Impression du rapport ─────────────────────────────────────────────── */
@media print {
  :root {
    --bg-base: #fff; --bg-surface: #fff; --bg-surface2: #fff; --bg-surface3: #f1f5f9;
    --text: #0f172a; --text-dim: #334155; --text-muted: #64748b;
    --border: #cbd5e1; --border-bright: #94a3b8;
  }
  body { background: #fff; color: #0f172a; font-size: 10pt; }
  .entete-actions, .barre-outils, #panneau-extraction, #panneau-circuits,
  .depliant, .bouton, .bouton-ligne { display: none !important; }
  .entete { position: static; border-bottom: 2px solid #0f172a; }
  .panneau { border: none; margin-bottom: 0.6rem; page-break-inside: avoid; }
  .panneau-titre { background: none; border-bottom: 1px solid #0f172a; padding-left: 0; }
  .chevron, .panneau-note { display: none; }
  .panneau-corps { padding: 0.4rem 0; display: block !important; }
  .circuit-resultat { page-break-inside: avoid; border: 1px solid #cbd5e1; }
  .circuit-corps { display: block !important; }
  .circuit-entete { border-left-width: 4px; }
  .controle-defaut .controle-message { color: #b91c1c; }
  .grille-champs { grid-template-columns: repeat(3, 1fr); }
  .champ small { display: none; }
  a { text-decoration: none; color: inherit; }
}
