/* ------------------------------------------------------------ Identité ExaImmo
   « Les toits de France » : bleu ardoise (toits d'ardoise, couleur principale), rouge tuile (toits de
   tuile, accent : marque, maisons, mises en avant), fond pierre calcaire. Titres en Bricolage
   Grotesque, texte en Inter, polices auto-hébergées (vendor/fonts, licence OFL). */

@font-face {
  font-family: "Inter";
  src: url("../vendor/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../vendor/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --ardoise: #1e3a5f;
  --ardoise-fonce: #142a46;
  --ardoise-clair: #e9eff6;
  --tuile: #d9572b;
  --tuile-fonce: #b2431d;
  --tuile-clair: #fbeae2;
  --pierre: #f6f4ef;

  --bg: var(--pierre);
  --surface: #ffffff;
  --text: #15233a;
  --muted: #5e6a79;
  --border: #e4e0d7;
  --primary: var(--ardoise);
  --primary-strong: var(--ardoise-fonce);
  --primary-soft: var(--ardoise-clair);
  --accent: var(--tuile);
  --accent-strong: var(--tuile-fonce);
  --accent-soft: var(--tuile-clair);
  --warn: #b42318;
  --ok: #217346;
  /* Reste du monde sur la carte (hors France) */
  --masque: #d9d6cf;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(21 35 58 / 6%), 0 2px 6px rgb(21 35 58 / 6%);
  --shadow-lg: 0 10px 30px rgb(21 35 58 / 12%);
  --font-titre: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --font-texte: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --topbar-h: 60px;

  /* Échelle officielle des étiquettes DPE / GES */
  --dpe-A: #009c6d; --dpe-B: #52b153; --dpe-C: #a5cc74; --dpe-D: #f4e70f;
  --dpe-E: #f0b50f; --dpe-F: #eb8235; --dpe-G: #d7221f;
  --ges-A: #a4dbf8; --ges-B: #8cb4d3; --ges-C: #7792b1; --ges-D: #5f708d;
  --ges-E: #4a5269; --ges-F: #343147; --ges-G: #211027;

  font-family: var(--font-texte);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-family: var(--font-titre); font-weight: 700; letter-spacing: -.01em; }
h1 { letter-spacing: -.02em; }
::selection { background: var(--accent-soft); }
code { font-size: .85em; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.error { color: var(--warn); }
.warn { color: var(--warn); font-weight: 600; }

/* ------------------------------------------------------------ Barre supérieure */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1000;
}
/* Logo : pictogramme (repère de carte coiffé d'un toit de tuile) et nom en Bricolage Grotesque */
.brand { display: inline-flex; align-items: center; font-family: var(--font-titre); font-weight: 800; font-size: 1.35rem; color: var(--primary); text-decoration: none; letter-spacing: -.035em; white-space: nowrap; }
.brand::before { content: ""; width: 30px; height: 30px; margin-right: 8px; flex: none; background: url("../img/picto.svg") center / contain no-repeat; }
.brand span { color: var(--accent); }
.topbar-title { font-weight: 600; color: var(--muted); }
.account { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.quota { font-size: .8rem; color: var(--primary); background: var(--primary-soft); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.quota.empty { color: var(--warn); background: #fde8e7; }

.search { position: relative; flex: 1; max-width: 640px; }
.search input {
  width: 100%;
  padding: 10px 14px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.search input:focus { outline: 2px solid var(--primary); background: var(--surface); }
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.search-results li { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; }
.search-results li:hover, .search-results li.active { background: var(--primary-soft); }

/* ------------------------------------------------------------ Mise en page */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  height: calc(100vh - var(--topbar-h));
}
.map-wrap { position: relative; }
#map { position: absolute; inset: 0; }
.map-controls {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: .85rem;
}
.map-controls select { margin-left: 6px; }
.legend { display: inline-flex; align-items: center; gap: 4px; }
/* Mêmes remplissages et contours que les couches de la carte (map.js) */
.swatch { display: inline-block; width: 14px; height: 12px; border-radius: 2px; margin-left: 8px; border: 2px solid; }
.swatch.batiment { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 55%, transparent); }
.swatch.parcelle { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

.panel { overflow-y: auto; padding: 20px; }
.empty { max-width: 620px; margin: 6vh auto; text-align: center; }
.empty h1 { font-size: 1.75rem; margin: 6px 0 12px; text-wrap: balance; }
.empty > p { line-height: 1.55; }
.empty a { color: var(--primary); }
/* Atouts de l'accueil (contenu indexé par les moteurs de recherche) */
.atouts { list-style: none; padding: 0; margin: 22px 0 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; text-align: left; }
.atouts li { padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; font-size: .85rem; color: var(--muted); line-height: 1.45; }
.atouts strong { display: block; margin-bottom: 2px; font-family: var(--font-titre); font-size: .98rem; color: var(--primary); }
.atouts li:nth-child(odd) strong::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 2px; background: var(--accent); vertical-align: 1px; }
.atouts li:nth-child(even) strong::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 2px; background: var(--primary); vertical-align: 1px; }

#fiche { display: flex; flex-direction: column; gap: 16px; }
#fiche[hidden] { display: none; }
/* Copropriété et logement social côte à côte, empilés quand le panneau est étroit */
.cartes-paire { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; align-items: start; }
.fiche-header h1 { font-size: 1.35rem; }
.fiche-header p { margin: 4px 0 0; }

/* ------------------------------------------------------------ Cartes */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > header { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 16px 0; }
.card > header h2 { font-size: 1.05rem; }
.card-body { padding: 12px 16px 16px; }
.card-body h3 { font-size: .9rem; margin: 14px 0 8px; display: flex; align-items: center; gap: 8px; }
.card-body h3:first-child { margin-top: 0; }
.loading { color: var(--muted); font-size: .9rem; }
.count { background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 0 8px; font-size: .75rem; }

.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table.compact td { padding: 5px 8px; }
.table .num { text-align: right; white-space: nowrap; }
.table tr[data-mutation], .table tr[data-vente-proche] { cursor: pointer; }
.table tr[data-mutation]:hover, .table tr[data-mutation]:focus,
.table tr[data-vente-proche]:hover, .table tr[data-vente-proche]:focus { background: var(--primary-soft); outline: none; }

.type-pill { font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: #eef0f3; color: #475467; }
.type-pill.appartement { background: var(--primary-soft); color: var(--primary); }
.type-pill.maison { background: var(--accent-soft); color: var(--accent-strong); }

.tag { font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); white-space: nowrap; font-weight: 500; }
.tag.light { background: #eef0f3; color: #475467; }
.tag.warn { background: #fde8e7; color: var(--warn); }

/* ------------------------------------------------------------ DPE */

.etiquette {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 1px rgb(0 0 0 / 25%);
}
.etiquette.none { background: #d0d5dd; }
.etiquette.e-A, .fill.e-A { background: var(--dpe-A); }
.etiquette.e-B, .fill.e-B { background: var(--dpe-B); }
.etiquette.e-C, .fill.e-C { background: var(--dpe-C); }
.etiquette.e-D, .fill.e-D { background: var(--dpe-D); color: #333; text-shadow: none; }
.etiquette.e-E, .fill.e-E { background: var(--dpe-E); }
.etiquette.e-F, .fill.e-F { background: var(--dpe-F); }
.etiquette.e-G, .fill.e-G { background: var(--dpe-G); }
.etiquette.ges.e-A { background: var(--ges-A); }
.etiquette.ges.e-B { background: var(--ges-B); }
.etiquette.ges.e-C { background: var(--ges-C); }
.etiquette.ges.e-D { background: var(--ges-D); color: #fff; }
.etiquette.ges.e-E { background: var(--ges-E); }
.etiquette.ges.e-F { background: var(--ges-F); }
.etiquette.ges.e-G { background: var(--ges-G); }

.dpe-list { display: flex; flex-direction: column; gap: 8px; }
.dpe-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 10px;
  text-align: left;
  font: inherit;
  font-size: .875rem;
  color: inherit;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.dpe-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.dpe-badges { display: flex; gap: 4px; }
.dpe-badges.big .etiquette { width: 44px; height: 44px; font-size: 1.4rem; }
.dpe-tags { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

.dpe-bars { display: flex; flex-direction: column; gap: 4px; }
.dpe-bar { display: grid; grid-template-columns: 28px 1fr 52px; gap: 8px; align-items: center; }
.dpe-bar .etiquette { width: 22px; height: 22px; font-size: .75rem; }
.bar { background: var(--bg); border-radius: 4px; height: 12px; overflow: hidden; }
.bar .fill { height: 100%; }

.timeline { list-style: none; padding-left: 14px; border-left: 2px solid var(--border); margin: 0; }
.timeline li { padding: 4px 0 4px 10px; display: flex; gap: 8px; align-items: center; font-size: .875rem; }
.timeline li.current { font-weight: 600; }
.timeline .etiquette { width: 22px; height: 22px; font-size: .75rem; }

/* ------------------------------------------------------------ Copropriétés, marché, risques */

.copro + .copro { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.copro h3 { font-size: .95rem; }
.copro p { margin: 2px 0 8px; }

dl.grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0; font-size: .875rem; }
dl.grid dt { color: var(--muted); }
dl.grid dd { margin: 0; }
/* Paires libellé / valeur sur deux colonnes quand la largeur le permet */
dl.grid.paires { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 32px; }
dl.grid.paires > div { display: grid; grid-template-columns: 150px 1fr; gap: 16px; }

.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 8px; }
.chart-head h3 { margin: 0; }
.chart-legende { display: grid; grid-template-columns: repeat(2, max-content); gap: 4px 18px; font-size: .8rem; color: var(--muted); }
.chart-legende span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legende .trait { width: 26px; border-top: 3px solid; }
.chart-legende .trait.tirets { border-top-style: dashed; }
.chart-wrap { position: relative; height: 240px; margin-bottom: 8px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.kpi strong { font-size: 1.1rem; }

.chips { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { font-size: .8rem; padding: 3px 10px; border-radius: 999px; background: #fdf1e8; color: #8a3d12; }

/* ------------------------------------------------------------ Dialogue */

dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: 85vh;
  border: none;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 50px rgb(16 24 40 / 25%);
}
dialog::backdrop { background: rgb(16 24 40 / 45%); }
dialog h2 { margin-bottom: 4px; }
dialog h3 { margin: 16px 0 8px; font-size: .95rem; }
dialog .close { position: absolute; top: 12px; right: 14px; border: none; background: none; font-size: 1.6rem; cursor: pointer; color: var(--muted); }

/* ------------------------------------------------------------ Boutons, formulaires, compte */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn.accent { color: #fff; background: var(--accent); border-color: var(--accent); }
.btn.accent:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.disabled { opacity: .65; cursor: default; pointer-events: none; }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { color: var(--warn); }
.btn.danger:hover { border-color: var(--warn); }
.link { background: none; border: none; padding: 0; font: inherit; font-size: .85rem; color: var(--primary); cursor: pointer; text-decoration: underline; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.row.actions { justify-content: flex-start; margin-top: 16px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.stack input, .stack select, .filters select {
  padding: 9px 11px;
  font: inherit;
  font-size: .95rem;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.stack input:focus, .stack select:focus, .filters select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.code-input { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.error.info { color: var(--ok); }
.notice { background: #fff6e5; color: #7a4b00; border-radius: 8px; padding: 10px 12px; font-size: .9rem; }
.checks { padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; margin: 12px 0 18px; }
.checks li { display: flex; gap: 8px; }
.checks li::before { content: "✓"; color: var(--accent); font-weight: 800; flex: none; }
.small-dialog { width: min(440px, calc(100vw - 32px)); }
.small-dialog h2 { margin-bottom: 8px; }
.card.blocked .card-body { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.menu-panel p { margin: 0 0 8px; }
.menu-item { display: block; padding: 8px 10px; border-radius: 6px; font: inherit; font-size: .9rem; text-align: left; color: var(--text); background: none; border: none; cursor: pointer; text-decoration: none; }
.menu-item:hover { background: var(--primary-soft); }

/* ------------------------------------------------------------ Administration */

.admin-main { max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px; display: flex; flex-direction: column; gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tiles .kpi { background: var(--surface); box-shadow: var(--shadow); }
.tiles .kpi strong { font-size: 1.5rem; }
.card > header .btn { align-self: center; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input { flex: 1; min-width: 200px; padding: 9px 11px; font: inherit; border: 1px solid var(--border); border-radius: 8px; }
.table.users tr[data-user] { cursor: pointer; }
.table.users tr[data-user]:hover, .table.users tr[data-user]:focus { background: var(--primary-soft); outline: none; }
.tag.premium { background: #fdf3d7; color: #8a5a00; }
.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.pager .muted { margin-right: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.user-form { margin: 16px 0 0; }
.user-form .btn { align-self: flex-start; }

/* ------------------------------------------------------------ Mobile */

@media (max-width: 900px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .quota { display: none; }
  .menu summary { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
  /* minmax(0, …) : les tableaux larges défilent dans leur carte au lieu d'élargir la page */
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: 45vh auto; height: auto; }
  .card-body { overflow-x: auto; }
  .panel { overflow: visible; padding: 16px; }
  .cols { grid-template-columns: 1fr; }
  .dpe-item { grid-template-columns: auto 1fr; }
  .dpe-tags { grid-column: 1 / -1; flex-direction: row; align-items: center; }
  .grid-2 { grid-template-columns: 1fr; }
  .table.users th:nth-child(n+6), .table.users td:nth-child(n+6) { display: none; }
}

details.more summary { cursor: pointer; color: var(--primary); font-size: .875rem; padding: 8px 0; }

/* Accordéon « À proximité » des sections de la fiche, fermé par défaut */
details.accordeon { border: 1px solid var(--border); border-radius: 8px; margin-top: 14px; }
details.accordeon > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: .9rem; font-weight: 600; }
details.accordeon > summary::-webkit-details-marker { display: none; }
details.accordeon > summary::before { content: '›'; color: var(--muted); font-size: 1.1rem; line-height: 1; transition: transform .15s; }
details.accordeon[open] > summary::before { transform: rotate(90deg); }
details.accordeon > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px; }
.accordeon-body { padding: 0 12px 12px; overflow-x: auto; }

/* ------------------------------------------------------------ Recherche avancée */

#recherche { display: flex; flex-direction: column; gap: 16px; }
#recherche[hidden] { display: none; }
.topbar #btn-recherche { white-space: nowrap; }

.r-form fieldset { border: 0; padding: 0; margin: 0 0 14px; }
.r-form legend { font-weight: 700; font-size: .9rem; margin-bottom: 8px; color: var(--primary); }
.r-form input, .r-form select {
  padding: 7px 9px;
  font: inherit;
  font-size: .9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.r-form input:focus, .r-form select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.r-zone .row { justify-content: flex-start; }
.r-zone #r-zone { flex: 1; min-width: 180px; }
.r-field { display: grid; grid-template-columns: 150px 1fr auto 1fr; align-items: center; gap: 8px; margin-bottom: 6px; font-size: .9rem; }
.r-field input[type="number"] { width: 100%; min-width: 0; }
.r-field select { grid-column: 2 / span 3; }
.r-label { font-weight: 600; color: var(--muted); }
.r-classes { grid-column: 2 / span 3; display: flex; gap: 4px; flex-wrap: wrap; }
.r-classes label { display: inline-flex; align-items: center; cursor: pointer; }
.r-classes input { position: absolute; opacity: 0; pointer-events: none; }
.r-classes .etiquette { opacity: .3; transition: opacity .1s; }
.r-classes input:checked + .etiquette { opacity: 1; outline: 2px solid var(--text); outline-offset: 1px; }
.r-classes input:focus-visible + .etiquette { outline: 2px solid var(--primary); }
.r-check { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--muted); }

.r-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.r-head p { margin: 0; flex: 1; }
.r-head select { padding: 5px 8px; font: inherit; font-size: .85rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.r-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.r-item { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.r-item.selected { outline: 2px solid #5b21b6; }
.r-item p { margin: 0; }
.r-item-head { display: flex; align-items: center; gap: 10px; width: 100%; }
.r-item-head h3 { flex: 1; font-size: 1rem; }
.r-rank { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 50%; background: #5b21b6; color: #fff; font-weight: 700; font-size: .8rem; }
.r-score { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; color: #5b21b6; white-space: nowrap; }
.r-score .bar { width: 60px; height: 8px; }
.r-score .fill { display: block; background: #5b21b6; }
.r-crit { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.r-crit li { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; padding: 2px 9px; border-radius: 999px; }
.r-crit li .etiquette { width: 18px; height: 18px; font-size: .7rem; border-radius: 4px; }
.r-crit li.ok { background: #e7f6ec; color: #067647; }
.r-crit li.proche { background: #fff6e5; color: #7a4b00; }
.r-crit li.ko { background: var(--bg); color: var(--muted); }

@media (max-width: 900px) {
  .r-field { grid-template-columns: 110px 1fr auto 1fr; }
  .topbar #btn-recherche, .topbar .account .btn { padding: 6px 10px; font-size: .8rem; }
  /* Le champ d'adresse rétrécit plutôt que de pousser le compte hors de l'écran */
  .search { min-width: 0; }
}
@media (max-width: 600px) {
  /* Champ d'adresse sur sa propre ligne, sous le logo et les boutons */
  .topbar { height: auto; flex-wrap: wrap; row-gap: 8px; padding: 8px 12px; }
  .search { order: 1; flex-basis: 100%; max-width: none; }
}
#r-resultats[aria-busy="true"] { opacity: .5; pointer-events: none; transition: opacity .15s; }

/* ------------------------------------------------------------ Pages légales */

.legal-nav { display: flex; gap: 4px; margin-left: auto; }
.legal-nav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); font-size: .9rem; text-decoration: none; white-space: nowrap; }
.legal-nav a:hover { background: var(--primary-soft); color: var(--primary); }
.legal-nav a[aria-current="page"] { color: var(--primary); font-weight: 600; background: var(--primary-soft); }
.legal { max-width: 820px; margin: 0 auto; padding: 32px 20px 64px; line-height: 1.6; }
.legal h1 { font-size: 1.7rem; margin-bottom: 4px; }
.legal h2 { font-size: 1.15rem; margin: 32px 0 10px; color: var(--primary); }
.legal a { color: var(--primary); }
.legal ul { padding-left: 22px; }
.legal li + li { margin-top: 4px; }
.legal-dl { display: grid; grid-template-columns: 220px 1fr; gap: 6px 16px; margin: 0; }
.legal-dl dt { color: var(--muted); }
.legal-dl dd { margin: 0; }
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.legal-table { font-size: .875rem; line-height: 1.45; }
.legal-table td { min-width: 120px; }
.todo { color: var(--warn); font-weight: 600; }

.site-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 32px; font-size: .8rem; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--primary); text-decoration: underline; }
.consent { margin: 4px 0 0; }
.consent a { color: inherit; }

@media (max-width: 640px) {
  .legal-page .topbar { height: auto; flex-wrap: wrap; gap: 6px; padding: 10px 16px; }
  .legal-nav { margin-left: 0; width: 100%; overflow-x: auto; }
  .legal { padding: 20px 16px 48px; }
  .legal-dl { grid-template-columns: 1fr; gap: 0; }
  .legal-dl dd { margin-bottom: 8px; }
}

/* ------------------------------------------------------------ Alertes */

.btn svg { flex: none; }
.fiche-top { display: flex; align-items: flex-start; gap: 12px; }
.fiche-top #fiche-header { flex: 1; min-width: 0; }
.fiche-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.fiche-actions .fermer { padding: 4px 12px; font-size: 1.3rem; line-height: 1.2; }
.alertes-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 10px; }
.alerte { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; }
.alerte.inactive { background: var(--bg); }
.alerte p { margin: 0; }
.alerte-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.alerte .row.actions { margin-top: 6px; gap: 6px; }
.alerte .btn { padding: 6px 10px; font-size: .85rem; }
.alerte details.more summary { padding: 4px 0; }
.historique { margin: 4px 0 0; padding-left: 18px; font-size: .85rem; display: flex; flex-direction: column; gap: 4px; }

@media (max-width: 900px) {
  .fiche-top { flex-direction: column-reverse; }
  .fiche-actions { align-self: stretch; justify-content: space-between; }
}

/* ------------------------------------------------------------ Bâtiment, énergie, urbanisme, quartier */

.card-body h4 { font-size: .85rem; margin: 10px 0 6px; display: flex; align-items: center; gap: 6px; }
.chips.neutral li { background: #eef0f3; color: #344054; }
.bloc + .bloc { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.bloc p { margin: 0 0 4px; }
dl.grid dd .etiquette { width: 22px; height: 22px; font-size: .75rem; vertical-align: middle; }
dl.grid dd .etiquette + .small { margin: 0 6px 0 2px; }
.statut { font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.statut.ok { background: #e7f6ec; color: #067647; }
.statut.proche { background: #fff6e5; color: #7a4b00; }
.statut.ko { background: #fde8e7; color: var(--warn); }
.arrets { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 6px; }
.arrets li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .875rem; }
.arret-nom { min-width: 180px; }
.lignes { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.ligne { --ligne: #667085; display: inline-grid; place-items: center; min-width: 24px; height: 20px; padding: 0 5px; border-radius: 4px; font-size: .72rem; font-weight: 700; color: #fff; background: var(--ligne); text-shadow: 0 1px 1px rgb(0 0 0 / 30%); }

/* ------------------------------------------------------------ Pages « Mon compte » et « Formules » */

.page { min-height: 100vh; display: flex; flex-direction: column; }
.page .topbar { flex: none; }
.page-main { width: 100%; max-width: 960px; margin: 0 auto; padding: 32px 20px 64px; display: flex; flex-direction: column; gap: 18px; }
.page-main > h1 { font-size: 2rem; }
.eyebrow { margin: 0; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-strong); }

.compte-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.compte-nav a { padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--primary); font-size: .85rem; font-weight: 600; text-decoration: none; }
.compte-nav a:hover { border-color: var(--primary); }
.page-main .card { scroll-margin-top: 16px; }
.page-main .card > header { padding: 18px 20px 0; }
.page-main .card-body { padding: 14px 20px 20px; }

.profil-form { max-width: 640px; }
.profil-form input[readonly] { background: var(--bg); color: var(--muted); }
.profil-form fieldset { border: none; padding: 0; margin: 0; }
.profil-form legend { font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; padding: 0; }
.choix { display: flex; gap: 10px; flex-wrap: wrap; }
.stack .choix label { flex-direction: row; align-items: center; gap: 8px; padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-weight: 500; cursor: pointer; }
.stack .choix label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.stack .choix input { accent-color: var(--primary); margin: 0; }
.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grille-2[hidden] { display: none; }
.grille-cp { display: grid; grid-template-columns: 140px 1fr; gap: 12px; }

.abonnement { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 18px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--border); }
.abonnement.payant { background: linear-gradient(135deg, var(--primary-soft), var(--surface)); border-color: #cfdbe8; }
.abonnement p { margin: 2px 0; }
.abonnement-nom { font-family: var(--font-titre); font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.abonnement .row.actions { margin-top: 0; }
.abonnement + .notice { margin-top: 12px; }

.offres-intro { max-width: 680px; }
.offres-intro h1 { font-size: 2.2rem; margin-bottom: 8px; }
.offres-intro p { margin: 0; font-size: 1.05rem; line-height: 1.5; }
.offres { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; align-items: stretch; margin-top: 8px; }
.offre { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 26px 24px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.offre h2 { font-size: 1.5rem; }
.offre > p { margin: 0; }
.offre.vedette { border: 2px solid var(--primary); box-shadow: var(--shadow-lg); }
.offre-badge { position: absolute; top: -12px; left: 24px; padding: 3px 10px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.offre .offre-prix { margin: 12px 0 0; display: flex; align-items: baseline; gap: 6px; color: var(--muted); }
.offre-prix strong { font-family: var(--font-titre); font-size: 2.6rem; font-weight: 800; color: var(--text); letter-spacing: -.03em; }
.offre .checks { flex: 1; }
.offre-action .btn { width: 100%; padding: 11px 14px; }
.offres-note { max-width: 680px; }
.offres-note a, .notice a { color: inherit; }

.paywall-offres { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 16px; }
.paywall-offre { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.paywall-offre .muted { grid-column: 1 / -1; }
.prix-court { font-weight: 700; color: var(--primary); }

@media (max-width: 640px) {
  .page-main { padding: 20px 16px 48px; }
  .page-main > h1, .offres-intro h1 { font-size: 1.6rem; }
  .grille-2, .grille-cp { grid-template-columns: 1fr; }
  .page .legal-nav { display: none; }
}
