/* Feuille de style Cadatrack.
   Reprise telle quelle de la maquette validée le 12 septembre : c'est elle la
   référence, et non une improvisation. Seuls deux blocs ont été ajoutés en fin
   de fichier — la page de connexion et la liste « à envoyer » — qui n'existaient
   pas dans la maquette. */

:root {
  color-scheme: light;
  --navy: #0B2A4A;
  --teal: #128C8C;
  --teal-clair: #E3F1F1;
  --white: #FFFFFF;
  --light: #F4F6F8;
  --slate: #4A5A68;
  --coral: #E4572E;
  --coral-clair: #FBE8E1;
  --green: #2E9E5B;
  --green-clair: #E4F3EA;
  --border: #E2E6EA;
  --font: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  --ombre: 0 1px 3px rgba(11, 42, 74, .07);
}
* { box-sizing: border-box; }
body {
  background: var(--light); color: var(--navy); font-family: var(--font);
  font-size: 14px; line-height: 1.55; font-variant-numeric: tabular-nums;
  margin: 0; padding: 0;
}
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
p { margin: 0; }

/* ------------------------------------------------------------- ossature */
.barre {
  background: var(--white); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.barre-interieur {
  max-width: 1920px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.logo { height: 34px; width: auto; display: block; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
.onglet {
  font: inherit; font-weight: 600; color: var(--slate); background: none;
  border: 0; border-radius: 4px; padding: 7px 13px; cursor: pointer;
  text-decoration: none; display: inline-block;
}
.onglet:hover { background: var(--light); color: var(--navy); }
.onglet[aria-selected="true"] { background: var(--navy); color: var(--white); }
.onglet:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.compte-utilisateur {
  margin-left: auto; display: flex; align-items: center; gap: 14px;
  font-size: .85rem; color: var(--slate);
}
.compte-utilisateur a { color: var(--slate); font-weight: 600; }
.compte-utilisateur a:hover { color: var(--navy); }
main { max-width: 1920px; margin: 0 auto; padding: 20px 24px 56px; display: grid; gap: 20px; }
.panneau[hidden] { display: none !important; }
.panneau { display: grid; gap: 20px; }

/* --------------------------------------------------------- chiffres clés */
.cles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.cle {
  background: var(--white); border: 1px solid var(--border); border-radius: 6px;
  padding: 14px 16px; display: grid; gap: 2px; box-shadow: var(--ombre);
}
.cle .valeur { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.cle .libelle { font-size: .82rem; color: var(--slate); }

/* ------------------------------------------------------------- filtres */
.filtres {
  background: var(--white); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.filtre {
  font-size: .85rem; font-weight: 600; color: var(--navy); background: var(--white);
  border: 1px solid var(--border); border-radius: 4px; padding: 6px 11px;
}
.filtre.actif { border-color: var(--teal); color: var(--teal); background: var(--teal-clair); }
.filtres .compte { margin-left: auto; font-size: .85rem; color: var(--slate); }
.champ {
  font: inherit; font-size: .85rem; font-weight: 600; color: var(--navy);
  background: var(--white); border: 1px solid var(--teal); border-radius: 4px;
  padding: 6px 9px; cursor: pointer;
}
.champ:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.champ[type="number"], .champ[type="text"] { cursor: text; width: 116px; }
.champ-case {
  display: inline-flex; align-items: center; gap: 7px; font-size: .85rem;
  font-weight: 600; color: var(--navy); cursor: pointer;
}
.champ-case input { width: 15px; height: 15px; accent-color: var(--teal); }

/* -------------------------------------------------------------- tableau */
/* Le tableau porte sept colonnes dont deux — Signal et Contact — décident de
   l'action : elles doivent rester visibles sans défilement horizontal. On leur
   reprend donc de la largeur sur la fiche, qui supporte mieux d'être étroite. */
.colonnes { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(430px, 1fr); gap: 16px; align-items: start; }
.carte {
  background: var(--white); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: var(--ombre); overflow: hidden;
}
.carte-titre {
  padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--white);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.carte-titre h2 { font-size: 1rem; font-weight: 700; }
.carte-titre .note { font-size: .8rem; color: var(--slate); }
.defilement { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 9px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
  font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--slate); background: var(--light); white-space: nowrap;
}
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--light); }
tbody tr[aria-selected="true"] { background: var(--teal-clair); }
tbody tr[aria-selected="true"] td:first-child { box-shadow: inset 3px 0 0 var(--teal); }
td.num { text-align: right; white-space: nowrap; font-weight: 600; }
.adresse { font-weight: 600; }
.adresse span { display: block; font-weight: 400; font-size: .82rem; color: var(--slate); }
td.adresse { white-space: nowrap; }
/* Le propriétaire peut passer à la ligne : c'est la colonne la plus longue, et
   la forcer sur une seule ligne rejetait Signal et Contact hors de l'écran. */
td.proprio { white-space: normal; min-width: 130px; line-height: 1.35; }
.jauge { width: 46px; }

/* jauge de score : magnitude, une seule teinte */
.score { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.score b { font-size: 1rem; font-weight: 800; width: 2.1ch; text-align: right; }
.jauge { width: 62px; height: 5px; border-radius: 4px; background: var(--light); overflow: hidden; }
.jauge i { display: block; height: 100%; border-radius: 4px; background: var(--teal); }

.etiquette {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 4px;
  border: 1.5px solid currentColor; background: var(--white); position: relative;
}
.etiquette::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.etiquette.proprietaire { color: var(--teal); }
.etiquette.groupe { color: var(--navy); }
.etiquette.sans-lien { color: var(--slate); }
.etiquette.vide { color: var(--slate); border-style: dashed; }
.etiquette.vide::before { background: transparent; border: 1.5px solid currentColor; }

.signal {
  display: inline-flex; align-items: center; white-space: nowrap; font-size: .76rem;
  font-weight: 700; padding: 3px 8px; border-radius: 4px;
  background: var(--coral); color: var(--white);
}
.contact-ok { color: var(--green); font-weight: 700; font-size: .8rem; }
.contact-non { color: var(--slate); font-size: .8rem; }

.aide { cursor: help; outline: none; }
.aide::after {
  content: attr(data-aide); position: absolute; left: -1.5px; top: calc(100% + 7px); z-index: 20;
  width: max-content; max-width: min(280px, 70vw); white-space: normal;
  background: var(--navy); color: var(--white); font-size: .78rem; font-weight: 400;
  line-height: 1.45; padding: 8px 10px; border-radius: 4px;
  opacity: 0; transform: translateY(-3px); pointer-events: none; transition: opacity .15s;
}
.aide:hover::after, .aide:focus-visible::after { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- fiche */
/* La fiche accompagne le défilement au lieu de rester en haut de page : on
   parcourt le tableau, on clique une ligne, et la fiche est déjà sous les yeux.
   Faire sauter la page vers le haut à chaque clic serait désorientant quand on
   descend une liste de cent bâtiments.
   Elle garde son propre défilement : un dossier complet — propriétaire,
   dirigeants, contacts, score détaillé, estimation — dépasse souvent la hauteur
   de l'écran, et sans cela sa fin deviendrait inaccessible. */
.fiche {
  display: grid; gap: 0;
  position: sticky; top: 76px;
  max-height: calc(100vh - 96px); overflow-y: auto;
}
.fiche-entete { padding: 14px 16px; border-bottom: 1px solid var(--border); display: grid; gap: 6px; }
.fiche-entete h2 { font-size: 1.12rem; font-weight: 800; }
.fiche-entete .meta { font-size: .85rem; color: var(--slate); }
.vues { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 16px; }
.vue {
  aspect-ratio: 16 / 9; border: 1px solid var(--border); border-radius: 4px;
  background: var(--light); display: grid; place-content: center; text-align: center;
  gap: 2px; padding: 8px; overflow: hidden; text-decoration: none; color: inherit;
}
.vue b { font-size: .84rem; }
.vue span { font-size: .74rem; color: var(--slate); }
.vue img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bloc { padding: 14px 16px; border-top: 1px solid var(--border); display: grid; gap: 10px; }
.bloc h3 {
  font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--slate);
}
.paires { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 16px; }
.paire { display: grid; gap: 1px; min-width: 0; }
.paire .k { font-size: .76rem; color: var(--slate); }
.paire .v { font-weight: 600; overflow-wrap: anywhere; }
.paire .v.alerte { color: var(--coral); }
.chaine { display: grid; gap: 6px; }
.chaine li { list-style: none; display: flex; gap: 9px; align-items: baseline; }
.chaine .niveau {
  font-size: .7rem; font-weight: 700; color: var(--teal); background: var(--teal-clair);
  border-radius: 4px; padding: 1px 6px; white-space: nowrap;
}
ul { margin: 0; padding: 0; }
.criteres { display: grid; gap: 5px; }
.critere { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; }
.critere .points { font-weight: 800; white-space: nowrap; }
.critere .plus { color: var(--coral); }
.critere .moins { color: var(--slate); }
.total-score {
  display: flex; justify-content: space-between; align-items: baseline;
  border-top: 1px solid var(--border); padding-top: 8px; font-weight: 800;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bouton {
  font: inherit; font-size: .86rem; font-weight: 600; padding: 8px 13px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--white); color: var(--navy); cursor: pointer;
  text-decoration: none; display: inline-block;
}
.bouton:hover { background: var(--light); }
.bouton.principal { background: var(--teal); border-color: var(--teal); color: var(--white); }
.bouton.principal:hover { background: #0f7878; }
.bouton.postal { background: var(--navy); border-color: var(--navy); color: var(--white); }
.bouton:disabled { background: var(--border); border-color: var(--border); color: var(--slate); cursor: default; }
.legende { font-size: .78rem; color: var(--slate); }

.pastille {
  display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700;
  padding: 3px 9px; border-radius: 4px;
}
.pastille.ok { color: var(--green); background: var(--green-clair); }
.pastille.attention { color: var(--coral); background: var(--coral-clair); }

/* ------------------------------------------- version mobile : des fiches */
.cartes { display: none; }
.cartes li {
  list-style: none; padding: 13px 16px; border-bottom: 1px solid var(--border);
  display: grid; gap: 8px; cursor: pointer;
}
.cartes li[aria-selected="true"] { background: var(--teal-clair); box-shadow: inset 3px 0 0 var(--teal); }
.carte-haut { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.carte-haut .adresse { font-size: 1rem; }
.carte-bas { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.carte-proprio { font-size: .84rem; color: var(--slate); }

/* ---------------------------------------------------- fenêtre flottante */
.voile {
  position: fixed; inset: 0; z-index: 50; background: rgba(11, 42, 74, .55);
  display: grid; place-items: center; padding: 20px;
}
.voile[hidden] { display: none; }
.modale {
  background: var(--white); border-radius: 6px; max-width: 560px; width: 100%;
  box-shadow: 0 18px 48px rgba(11, 42, 74, .3); overflow: hidden;
  max-height: 90vh; display: grid; grid-template-rows: auto 1fr auto;
}
.modale.large { max-width: 780px; }
.modale-entete { padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.modale-entete h2 { font-size: 1.1rem; font-weight: 800; }
.modale-entete p { font-size: .85rem; color: var(--slate); margin-top: 3px; }
.modale-corps { padding: 6px 18px 14px; overflow-y: auto; }
.modale-item { padding: 12px 0; border-bottom: 1px solid var(--border); display: grid; gap: 4px; }
.modale-item:last-child { border-bottom: 0; }
.modale-item .titre { font-weight: 700; }
.modale-item .detail { font-size: .85rem; color: var(--slate); }
.modale-pied {
  padding: 12px 18px; border-top: 1px solid var(--border); background: var(--light);
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
}

/* ================================================== ajouts hors maquette */

/* ------------------------------------------------------------ connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.connexion form {
  background: var(--white); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: var(--ombre); padding: 28px; width: min(380px, 100%); display: grid; gap: 14px;
}
.connexion h1 { font-size: 1.2rem; font-weight: 800; }
.connexion .sous { color: var(--slate); font-size: .85rem; }
.connexion label { display: grid; gap: 5px; font-size: .76rem; font-weight: 700; color: var(--slate); }
.connexion input {
  font: inherit; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 4px; color: var(--navy); background: var(--white);
}
.connexion input:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.erreur {
  background: var(--coral-clair); border: 1px solid var(--coral);
  border-radius: 4px; padding: 9px 11px; font-size: .85rem; color: var(--navy);
}

/* ----------------------------------------------------------- à envoyer */
.dossier { display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.dossier > img { width: 100%; height: 100%; min-height: 240px; object-fit: cover; display: block; background: var(--light); }
.dossier-corps { display: grid; gap: 0; min-width: 0; }
.redaction {
  width: 100%; min-height: 250px; font: inherit; line-height: 1.6; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 4px; color: var(--navy);
  background: var(--white); resize: vertical;
}
.redaction:focus-visible { outline: 2px solid var(--teal); outline-offset: -1px; }
.destinataire { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 9px; align-items: baseline; }
.destinataire .k { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--slate); }
.destinataire .v {
  background: var(--light); border: 1px solid var(--border); border-radius: 4px;
  padding: 3px 8px; font-weight: 600; overflow-wrap: anywhere;
}
.avis {
  background: var(--coral-clair); border-left: 3px solid var(--coral);
  border-radius: 4px; padding: 8px 11px; font-size: .82rem; line-height: 1.5;
}
.resultat { font-size: .85rem; font-weight: 700; }
.resultat.ok { color: var(--green); }
.resultat.ko { color: var(--coral); }
.vide-liste { padding: 34px 16px; text-align: center; color: var(--slate); }

@media (max-width: 1000px) {
  .colonnes { grid-template-columns: 1fr; }
  .cles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* En une seule colonne, la fiche passe sous le tableau : l'y coller n'aurait
     plus de sens et l'empêcherait de se lire en entier. */
  .fiche { position: static; max-height: none; overflow-y: visible; }
}
@media (max-width: 900px) {
  .dossier { grid-template-columns: 1fr; }
  .dossier > img { min-height: 190px; }
}
@media (max-width: 720px) {
  body { font-size: 15px; }
  main { padding: 14px 12px 44px; gap: 14px; }
  .barre-interieur { padding: 10px 12px; gap: 12px; }
  .defilement.tableau-batiments { display: none; }
  .cartes { display: block; }
  .cle .valeur { font-size: 1.45rem; }
  .filtres { gap: 6px; }
  .fiche-entete h2 { font-size: 1.05rem; }
  .compte-utilisateur { margin-left: 0; order: 3; width: 100%; }
}
@media (max-width: 560px) {
  .paires, .vues { grid-template-columns: 1fr; }
  .cles { grid-template-columns: 1fr 1fr; }
  .destinataire { grid-template-columns: 1fr; gap: 2px; }
}
@media (prefers-reduced-motion: reduce) { .aide::after { transition: none; } }
