/* Démo « Outil de prospection » — complète ../_shared/demo.css */

:root {
  --c-copro: #4f7a3a;
  --c-ent: #1f5f7a;
  --c-permis: #c8643b;
  --c-depot: #10291d;
  --panel-h: calc(100vh - 210px);
}

body { background: var(--sand-50); }
.skip { position: absolute; left: -9999px; top: 0; z-index: 100; background: var(--forest-900); color: var(--sand-100); padding: 12px 16px; border-radius: 0 0 10px 0; }
.skip:focus { left: 0; }
.demo-banner a { color: inherit; font-weight: 600; }

/* En-tête */
.topbar { background: var(--forest-900); color: var(--sand-100); }
.topbar-in { max-width: 1600px; margin: 0 auto; padding: 14px var(--gutter); display: flex; align-items: center; gap: 20px; }
.topbar .back { color: var(--sand-100); text-decoration: none; font-weight: 600; font-size: .95rem; opacity: .9; min-height: 44px; display: inline-flex; align-items: center; white-space: nowrap; }
.topbar .back:hover { opacity: 1; text-decoration: underline; }
.topbar .titles { flex: 1; min-width: 0; }
.topbar .eyebrow { color: var(--moss-300); margin: 0 0 6px; }
.topbar h1 { font-size: clamp(1.35rem, 2.4vw, 2rem); margin: 0; color: #fff; }
.topbar .cta { white-space: nowrap; }

.app { max-width: 1600px; margin: 0 auto; padding: 0 var(--gutter) 0; }
.intro { padding: 18px 0 6px; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 24px; }
.intro .lead { font-size: 1.02rem; margin: 0; max-width: 62rem; }
.stats { margin: 0; font-weight: 600; color: var(--forest-800); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 4px 0 14px; }
.toolbar .stats { flex: 1 1 320px; }
.toolbar .btn { min-height: 44px; padding: .6em 1.1em; font-size: .95rem; }
.open-filters { display: none; }
.toolbar #export { margin-left: auto; }
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--clay-500); color: #fff; font-size: .78rem; }
.count { opacity: .85; font-weight: 500; }
.badge[hidden] { display: none; }

/* Grille principale */
.layout { position: relative; display: grid; grid-template-columns: 290px minmax(0, 1fr) 410px; grid-template-areas: "filters map list"; gap: 16px; align-items: start; }
.filters { grid-area: filters; }
.map-wrap { grid-area: map; position: sticky; top: 12px; }
.list-wrap { grid-area: list; }
.detail { grid-area: list; }
@media (min-width: 761px) { .has-detail .list-wrap { display: none; } }

.map { height: var(--panel-h); min-height: 560px; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); background: #e8ede0; z-index: 0; }
.legend { position: absolute; left: 12px; bottom: 12px; z-index: 500; display: flex; flex-wrap: wrap; gap: 4px 12px; background: rgba(255, 255, 255, .94); border-radius: 10px; padding: 7px 11px; font-size: .8rem; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); max-width: calc(100% - 24px); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-msg { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 600; margin: 0; background: var(--forest-900); color: var(--sand-100); padding: 10px 16px; border-radius: 99px; font-size: .9rem; box-shadow: var(--shadow); width: max-content; max-width: calc(100% - 24px); }
.map-msg .linklike { color: var(--sun-400); }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }
.dot-copro { background: var(--c-copro); }
.dot-ent { background: var(--c-ent); }
.dot-permis { background: var(--c-permis); }
.dot-depot { background: var(--c-depot); border-radius: 3px; }

/* Filtres */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); max-height: var(--panel-h); min-height: 560px; display: flex; flex-direction: column; position: sticky; top: 12px; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 6px; }
.drawer-head h2 { font-size: 1.1rem; margin: 0; }
.icon-btn { display: none; width: 44px; height: 44px; border: 0; background: none; font-size: 1.8rem; line-height: 1; cursor: pointer; color: var(--muted); border-radius: 10px; }
.filter-form { padding: 4px 18px 16px; overflow-y: auto; display: grid; gap: 14px; font-size: .93rem; }
.filter-form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 4px; }
.filter-form legend { font-weight: 700; padding: 0; margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 9px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--forest-700); margin: 0; }
.check .n { margin-left: auto; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.field { display: grid; gap: 5px; font-weight: 600; }
.field select, .field input, .sort select { font: inherit; font-weight: 400; min-height: 44px; padding: 8px 12px; border: 1px solid rgba(18, 33, 26, .25); border-radius: var(--radius-sm); background: var(--sand-50); color: var(--text); width: 100%; }
.range { display: grid; gap: 2px; }
.range label { display: flex; justify-content: space-between; font-weight: 600; }
.range output { font-variant-numeric: tabular-nums; color: var(--forest-700); }
input[type="range"] { width: 100%; min-height: 36px; accent-color: var(--clay-500); margin: 0; }
.hint { font-size: .84rem; color: var(--muted); margin: -6px 0 0; font-weight: 400; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--forest-700); text-decoration: underline; cursor: pointer; min-height: 32px; text-align: left; }
.weights .range label { font-weight: 500; }
.small-btn { min-height: 44px; font-size: .88rem; padding: .5em 1em; justify-self: start; margin-top: 4px; }
.rules { background: var(--sand-100); border-radius: var(--radius-sm); padding: 10px 12px; font-size: .86rem; }
.rules summary { cursor: pointer; font-weight: 700; min-height: 32px; display: flex; align-items: center; }
.rules ul { padding-left: 1.1em; margin: 8px 0; }
.rules li { margin-bottom: 6px; }
.rules p { margin: 0; }
.drawer-foot { display: flex; padding: 10px 18px 14px; border-top: 1px solid var(--line); }
.drawer-foot .btn { min-height: 44px; font-size: .9rem; padding: .5em 1em; }
.drawer-foot .btn-ghost { color: var(--forest-900); }
#apply-filters { display: none; }

/* Liste */
.list-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 0 14px; min-height: 560px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px 8px; border-bottom: 1px solid var(--line); }
.list-head h2 { font-size: 1.1rem; margin: 0; }
.sort { display: flex; align-items: center; gap: 8px; font-size: .88rem; white-space: nowrap; }
.sort select { width: auto; min-height: 44px; padding: 6px 10px; }
.list { list-style: none; margin: 0; padding: 0; outline: none; }
@media (min-width: 761px) {
  .list-wrap { max-height: var(--panel-h); min-height: 560px; display: flex; flex-direction: column; position: sticky; top: 12px; }
  .list-scroll { overflow-y: auto; flex: 1; overscroll-behavior: contain; }
}
.list li { border-bottom: 1px solid var(--line); }
.item { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; width: 100%; text-align: left; padding: 12px 16px; background: none; border: 0; font: inherit; color: inherit; cursor: pointer; min-height: 64px; }
.item:hover, .item.active { background: var(--sand-100); }
.score { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; font: 700 1.2rem/1 var(--font-body); color: #fff; font-variant-numeric: tabular-nums; }
.score small { display: block; font-size: .62rem; font-weight: 600; opacity: .85; margin-top: 2px; letter-spacing: .04em; }
.s-hi { background: var(--forest-700); }
.s-mid { background: var(--moss-500); }
.s-lo { background: #8a958c; }
.item-main { min-width: 0; }
.item-name { display: block; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 4px; font-size: .84rem; color: var(--muted); }
.item-fact { display: block; font-size: .85rem; margin-top: 3px; color: var(--forest-800); }
.tag.t-copro { background: #dfe9d2; color: #2f4d22; }
.tag.t-ent { background: #d6e6ee; color: #174a5f; }
.tag.t-permis { background: #f6dccf; color: #8a3a1a; }
.more { display: flex; margin: 14px auto 0; color: var(--forest-800); min-height: 44px; }
.empty { padding: 24px 16px; color: var(--muted); }

/* Fiche détail */
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-height: 560px; max-height: var(--panel-h); overflow-y: auto; position: sticky; top: 12px; z-index: 5; outline: none; }
.detail[hidden] { display: none; }
.detail-head { position: sticky; top: 0; background: var(--surface); padding: 8px 16px; border-bottom: 1px solid var(--line); z-index: 1; }
.back-list { min-height: 44px; font-weight: 600; }
.detail-body { padding: 14px 18px 22px; }
.detail-body h2 { font-size: 1.35rem; margin: 6px 0 4px; overflow-wrap: anywhere; }
.d-addr { color: var(--muted); margin: 0 0 12px; font-size: .92rem; }
.d-score { display: flex; align-items: center; gap: 14px; margin: 10px 0 6px; }
.d-score .score { width: 64px; height: 64px; font-size: 1.5rem; }
.d-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .9rem; margin: 12px 0; }
.d-facts dt { color: var(--muted); }
.d-facts dd { margin: 0; overflow-wrap: anywhere; }
.d-section { margin-top: 18px; }
.d-section h3 { font-size: 1rem; margin-bottom: 8px; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 118px 1fr 44px; gap: 8px; align-items: center; font-size: .86rem; }
.bar { height: 10px; background: var(--sand-100); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--moss-500); border-radius: 99px; }
.bar-row b { text-align: right; font-variant-numeric: tabular-nums; }
.why { padding-left: 1.1em; margin: 0; font-size: .9rem; }
.why li { margin-bottom: 5px; }
.pitch { background: #fff8e6; border: 1px dashed #d9b45a; border-radius: var(--radius-sm); padding: 12px 14px; font-size: .92rem; }
.pitch .tag { margin-bottom: 8px; }
.pitch p { margin: 0 0 .6em; white-space: pre-line; }
.pitch-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.pitch-actions .btn { min-height: 44px; font-size: .9rem; padding: .5em 1em; }
.d-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.d-links a { font-size: .88rem; min-height: 44px; display: inline-flex; align-items: center; }
.d-source { font-size: .8rem; color: var(--muted); margin-top: 14px; }

/* Sources */
.sources { margin: 36px calc(var(--gutter) * -1) 0; background: var(--sand-100); padding: 48px var(--gutter) 64px; }
.sources-in { max-width: 1200px; margin: 0 auto; }
.sources h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); }
.small-lead { font-size: 1rem; }
.table-scroll { overflow-x: auto; margin: 18px 0 24px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); }
.src-table { border-collapse: collapse; width: 100%; font-size: .88rem; min-width: 760px; }
.src-table th, .src-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.src-table th { background: var(--forest-900); color: var(--sand-100); font-weight: 600; }
.src-table td:first-child { font-weight: 600; }
.src-table .fictif { color: #8a3a1a; font-weight: 700; }
.src-grid { margin-bottom: 24px; }
.src-grid ul { padding-left: 1.1em; margin: 0 0 1em; font-size: .93rem; }
.src-grid li { margin-bottom: 6px; }
.market { margin-bottom: 20px; }
.market-bars { display: grid; gap: 6px; margin-top: 12px; }
.mb { display: grid; grid-template-columns: 190px 1fr 92px; gap: 10px; align-items: center; font-size: .86rem; }
.mb .bar i { background: var(--clay-500); }
.mb b { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.method { margin-top: 8px; }
.end-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.end-cta .btn-ghost { color: var(--forest-900); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--forest-900); color: var(--sand-100); padding: 12px 18px; border-radius: 12px; z-index: 2000; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }

/* Marqueur dépôt */
.depot-icon { width: 22px !important; height: 22px !important; margin: -11px 0 0 -11px !important; background: var(--c-depot); border: 3px solid #fff; border-radius: 6px; box-shadow: 0 2px 8px rgba(0, 0, 0, .4); }
.leaflet-container { font: inherit; }
/* demo.css borne img/svg/canvas à 100 % : Leaflet a besoin de leur taille réelle */
.leaflet-container img, .leaflet-container canvas, .leaflet-container svg { max-width: none !important; max-height: none !important; }
.leaflet-container canvas, .leaflet-container svg { display: block; }
.leaflet-container a.leaflet-popup-close-button { width: 32px; height: 32px; font-size: 22px; }
.leaflet-touch .leaflet-bar a, .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
.leaflet-tooltip.tt { font-size: .82rem; padding: 4px 8px; }

/* ---- Tablette : filtres en tiroir ---- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(0, 1fr) 380px; grid-template-areas: "map list"; }
  .open-filters { display: inline-flex; margin-right: auto; }
  .filters { position: fixed; inset: 0 auto 0 0; width: min(380px, 92vw); max-height: none; min-height: 0; z-index: 1500; border-radius: 0 var(--radius) var(--radius) 0; transform: translateX(-105%); transition: transform .22s ease; visibility: hidden; }
  .filters.open { transform: none; visibility: visible; }
  .icon-btn { display: inline-grid; place-items: center; }
  .filter-form { flex: 1; }
  #apply-filters { display: inline-flex; }
  .drawer-foot { display: flex; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface); }
  .drawer-foot .btn { flex: 1; min-height: 48px; padding: .6em .8em; font-size: .95rem; }
  .drawer-foot .btn-ghost { color: var(--forest-900); }
  .scrim { position: fixed; inset: 0; background: rgba(11, 31, 22, .55); z-index: 1400; }
}

/* ---- Mobile : carte puis liste ---- */
@media (max-width: 760px) {
  .topbar-in { flex-wrap: wrap; gap: 6px 12px; padding-top: 8px; padding-bottom: 14px; }
  .topbar .back { order: 0; }
  .topbar .titles { order: 1; flex-basis: 100%; }
  .topbar .cta { order: 2; width: 100%; white-space: normal; text-align: center; }
  .intro { padding-top: 14px; }
  .intro .lead { font-size: .95rem; }
  .toolbar { position: sticky; top: 0; z-index: 900; background: var(--sand-50); margin: 0 calc(var(--gutter) * -1); padding: 8px var(--gutter); box-shadow: 0 6px 12px -10px rgba(0, 0, 0, .35); }
  .toolbar { gap: 6px 8px; }
  .toolbar .stats { order: -1; flex-basis: 100%; font-size: .84rem; line-height: 1.35; }
  .toolbar .btn { flex: 1; padding: .55em .6em; font-size: .9rem; }
  .toolbar .count, .toolbar .wide { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "map" "list"; gap: 12px; }
  .map-wrap { position: relative; top: 0; }
  .map { height: 52vh; min-height: 300px; max-height: 460px; }
  .legend { font-size: .74rem; padding: 5px 8px; gap: 2px 9px; left: 8px; bottom: 8px; }
  .list-wrap { min-height: 0; scroll-margin-top: 130px; }
  #detail-body h2 { scroll-margin-top: 80px; }
  .item { padding: 12px; gap: 10px; }
  .detail { position: fixed; inset: 0; z-index: 1600; border-radius: 0; max-height: none; min-height: 0; border: 0; }
  .bar-row { grid-template-columns: 104px 1fr 40px; }
  .mb { grid-template-columns: 112px 1fr 70px; font-size: .8rem; }
  .sources { padding-top: 36px; }
}

@media (prefers-reduced-motion: reduce) { .filters { transition: none; } }

/* Imprimer / PDF : seule la liste des cibles filtrées (avec la mention « données fictives »). */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff !important; }
  .skip, .topbar, .intro .lead, .open-filters, #export, .filters, .map-wrap, .detail, .sources, .toast, #more, .list-head button { display: none !important; }
  .layout { display: block !important; }
  .list-wrap, .list-scroll { overflow: visible !important; max-height: none !important; height: auto !important; position: static !important; }
  .list li { break-inside: avoid; }
  .item { border: 0; border-bottom: 1px solid #ccc; box-shadow: none; }
  .demo-banner { background: none !important; border: 1px solid #999; }
}
