/* ===========================================================================
   ImmoScan — design system
   Vanilla CSS, custom properties, light/dark themes, desktop + mobile.
   No framework, no build step.
   ======================================================================== */

/* ------------------------------- Tokens --------------------------------- */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #edf1f4;
  --surface-3: #e2e8ee;
  --ink: #16212b;
  --muted: #607181;
  --line: #e2e8ee;
  --brand: #0e7a6a;
  --brand-strong: #0a5f53;
  --brand-ink: #ffffff;
  --brand-soft: #dff1ee;
  --good: #177245;
  --good-bg: #dcf4e6;
  --bad: #b3362b;
  --bad-bg: #fbe4e1;
  --warn: #9a6208;
  --warn-bg: #fcf0d7;
  --violet: #6941c6;
  --violet-bg: #ece6fa;
  --amber: #d97706;
  --shadow-1: 0 1px 2px rgb(16 24 32 / .06), 0 1px 6px rgb(16 24 32 / .05);
  --shadow-2: 0 6px 16px rgb(16 24 32 / .10), 0 2px 6px rgb(16 24 32 / .06);
  --shadow-3: 0 18px 44px rgb(16 24 32 / .18);
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --topbar-h: 60px;
  --tabbar-h: 62px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

html[data-theme="dark"] {
  --bg: #0e1418;
  --surface: #161e24;
  --surface-2: #1e2830;
  --surface-3: #27333d;
  --ink: #e7edf2;
  --muted: #8fa0ae;
  --line: #2a3540;
  --brand: #2fbfae;
  --brand-strong: #53d3c2;
  --brand-ink: #062621;
  --brand-soft: #14383c;
  --good: #4ade80;
  --good-bg: #12362a;
  --bad: #f28b82;
  --bad-bg: #40201d;
  --warn: #fbbf24;
  --warn-bg: #3a2d12;
  --violet: #b39dfc;
  --violet-bg: #2c2447;
  --amber: #fbbf24;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .35), 0 1px 6px rgb(0 0 0 / .25);
  --shadow-2: 0 6px 16px rgb(0 0 0 / .4), 0 2px 6px rgb(0 0 0 / .3);
  --shadow-3: 0 18px 44px rgb(0 0 0 / .5);
  color-scheme: dark;
}

/* ------------------------------- Base ----------------------------------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
/* Les cibles d'ancres ne doivent pas atterrir sous le header sticky. */
[id] { scroll-margin-top: calc(var(--topbar-h) + 12px); }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 10px; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.container { max-width: 1240px; margin: 0 auto; padding: 20px 20px 40px; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brand-soft); }

/* Icons */
.ic { width: 18px; height: 18px; flex-shrink: 0; }
.ic.sm { width: 15px; height: 15px; }
.ic.lg { width: 22px; height: 22px; }

/* ------------------------------ Top bar --------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 1150; /* > .toolbar (1100) : panneau de notifs/menus au-dessus des filtres */
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 750; font-size: 17px; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  display: grid; place-items: center; color: var(--brand-ink);
  box-shadow: var(--shadow-1);
}
.brand .logo .ic { width: 19px; height: 19px; }
.nav-links { display: flex; gap: 2px; }
.nav-links a {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: var(--r-pill);
  color: var(--muted); font-weight: 550; font-size: 14px;
}
.nav-links a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.nav-links a.active { color: var(--brand); background: var(--brand-soft); }
.topbar .spacer { flex: 1; }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: var(--r-pill);
  border: 1px solid transparent; background: transparent; color: var(--muted);
  cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.lang-switch { display: inline-flex; background: var(--surface-2); border-radius: var(--r-pill); padding: 3px; }
.lang-switch a {
  padding: 5px 11px; border-radius: var(--r-pill); font-size: 12px; font-weight: 650; color: var(--muted);
}
.lang-switch a:hover { text-decoration: none; color: var(--ink); }
.lang-switch a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* --------------------------- Mobile tab bar ------------------------------ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 600;
  display: none;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 10.5px; font-weight: 600;
}
.tabbar a:hover { text-decoration: none; }
.tabbar a.active { color: var(--brand); }
.tabbar a .ic { width: 21px; height: 21px; }

/* ------------------------------ Buttons --------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: var(--brand-ink); border: none;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 650;
  cursor: pointer; font-family: inherit; transition: background .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-strong); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.outline { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.outline:hover { border-color: var(--surface-3); background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); text-decoration: none; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; }

/* ------------------------- Filter toolbar ------------------------------- */
.toolbar {
  position: sticky; top: var(--topbar-h); z-index: 1100; /* au-dessus des contrôles Leaflet (1000) : popovers visibles sur la carte */
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.toolbar-inner { max-width: 1240px; margin: 0 auto; padding: 10px 20px; display: flex; flex-direction: column; gap: 8px; }
.toolbar-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-form { display: contents; } /* the form wraps the row without affecting layout */

/* Segmented control — radios (server-rendered GET form) */
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--r-pill); padding: 3px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: inline-block; padding: 7px 16px; border-radius: var(--r-pill);
  font-size: 13.5px; font-weight: 650; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }
/* Segmented control as links (server-side state change) */
.seg a { text-decoration: none; }
.seg a span { display: inline-block; padding: 7px 16px; border-radius: var(--r-pill); font-size: 13.5px; font-weight: 650; color: var(--muted); white-space: nowrap; }
.seg a:hover span { color: var(--ink); }
.seg a.on span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* Popover trigger chips */
.pop { position: relative; }
.pop-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  padding: 8px 13px; border-radius: var(--r-pill); font-size: 13.5px; font-weight: 550;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.pop-btn:hover { border-color: var(--surface-3); background: var(--surface-2); }
.pop-btn .ic { width: 14px; height: 14px; color: var(--muted); }
.pop-btn.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.pop-btn.on .ic { color: var(--brand); }
.pop-panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 700;
  min-width: 260px; max-width: min(92vw, 340px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); padding: 16px;
  opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
  transition: opacity .16s, transform .16s;
}
.pop.open .pop-panel { opacity: 1; transform: none; pointer-events: auto; }
.pop-panel.align-end { left: auto; right: 0; }
.pop-panel h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pop-panel .row { display: flex; gap: 10px; align-items: center; }
.pop-panel .row + .row { margin-top: 10px; }
.pop-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* Option list inside popovers — radios/checkboxes as rows */
.opt-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; max-height: min(260px, 45dvh); overflow: auto; margin: -4px; padding: 4px; }
.opt {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  cursor: pointer; font-size: 14px; user-select: none;
}
.opt:hover { background: var(--surface-2); }
.opt input { accent-color: var(--brand); width: 16px; height: 16px; }

/* Stepper (beds / baths) — radios */
.stepper { display: flex; gap: 6px; flex-wrap: wrap; }
.stepper label { position: relative; }
.stepper input { position: absolute; opacity: 0; pointer-events: none; }
.stepper span {
  display: inline-block; min-width: 38px; text-align: center; padding: 7px 10px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.stepper span:hover { border-color: var(--surface-3); }
.stepper input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.stepper input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Text inputs */
.input, .select {
  width: 100%; padding: 9px 12px; font-size: 14px; font-family: inherit;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
}
.input:focus, .select:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.field-label { display: block; font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 5px; }

/* Active filter chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-soft); color: var(--brand);
  padding: 5px 8px 5px 12px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 600;
}
.chip:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.chip .ic { width: 13px; height: 13px; }
.chips .clear-all { color: var(--muted); font-size: 12.5px; font-weight: 600; text-decoration: underline; }
.chips .zone-map-link { color: var(--brand); font-size: 12.5px; font-weight: 600; text-decoration: underline; }

/* Results meta row */
.results-meta { display: flex; align-items: center; gap: 14px; }
.results-meta .count { font-weight: 700; font-size: 15px; }
.results-meta .count b { color: var(--brand); }
.results-meta .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ------------------------------- Cards ---------------------------------- */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 18px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; display: flex; flex-direction: column; position: relative;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
/* Les effets de survol restent réservés aux vrais pointeurs : sur tactile,
   iOS « colle » l'état :hover après un tap. */
@media (hover: hover) and (pointer: fine) {
  .card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--surface-3); }
  .card:hover .photo .ph-art, .card:hover .photo .ph-img { transform: scale(1.05); }
  .fav-btn:hover { transform: scale(1.1); color: var(--amber); }
  .row-card:hover { border-color: var(--brand); box-shadow: var(--shadow-1); }
  .pill-marker:hover {
    background: var(--brand, #0e7a6a); border-color: var(--brand, #0e7a6a); color: #fff;
    transform: translate(-50%, -50%) scale(1.15); z-index: 1000 !important;
  }
  table.tbl tbody tr:hover { background: var(--surface-2); }
}
.stretched::after { content: ""; position: absolute; inset: 0; z-index: 2; }

.photo {
  position: relative; aspect-ratio: 16 / 10; overflow: hidden;
  background: linear-gradient(135deg,
    hsl(var(--ph, 200) 46% 87%), hsl(calc(var(--ph, 200) + 34) 42% 74%));
}
html[data-theme="dark"] .photo {
  background: linear-gradient(135deg,
    hsl(var(--ph, 200) 32% 24%), hsl(calc(var(--ph, 200) + 34) 30% 16%));
}
.photo .ph-art {
  position: absolute; inset: 0; display: grid; place-items: center;
  transition: transform .35s ease;
  color: hsl(var(--ph, 200) 30% 42% / .55);
}
html[data-theme="dark"] .photo .ph-art { color: hsl(var(--ph, 200) 40% 60% / .4); }
.photo .ph-art .ic { width: 58px; height: 58px; }
.ph-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transition: transform .35s ease;
}

/* pointer-events: none — les badges sont décoratifs et ne doivent pas
   intercepter le tap destiné au lien pleine-carte (.stretched). */
.photo .overlay-tl { position: absolute; top: 10px; left: 10px; z-index: 4; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; pointer-events: none; }
.photo .overlay-bl { position: absolute; bottom: 10px; left: 10px; z-index: 4; display: flex; gap: 6px; pointer-events: none; }

.fav-form { margin: 0; }
.card .fav-form, .row-card .fav-form { position: absolute; top: 10px; right: 10px; z-index: 5; }
.fav-btn {
  width: 36px; height: 36px; border-radius: var(--r-pill); border: none; cursor: pointer;
  background: rgb(255 255 255 / .92); color: #64748b;
  display: grid; place-items: center; box-shadow: var(--shadow-1);
  transition: transform .15s, color .15s, background .15s;
}
.fav-btn.on { color: var(--amber); }
.fav-btn.on svg { fill: currentColor; }
.fav-btn .ic { width: 17px; height: 17px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .01em;
  padding: 4px 9px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--muted);
}
.badge.new { background: var(--good-bg); color: var(--good); }
.badge.drop { background: var(--bad-bg); color: var(--bad); }
.badge.rent { background: var(--violet-bg); color: var(--violet); }
.badge.solid { background: rgb(22 28 36 / .78); color: #fff; backdrop-filter: blur(4px); }
.badge .ic { width: 12px; height: 12px; }

.card .body { padding: 13px 15px 14px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.price-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.price { font-size: 19px; font-weight: 780; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.price .per { font-size: 13px; font-weight: 550; color: var(--muted); }
.ppsf { font-size: 12px; color: var(--muted); white-space: nowrap; }
.facts { display: flex; align-items: center; gap: 13px; color: var(--ink); font-size: 13.5px; font-weight: 550; flex-wrap: wrap; row-gap: 3px; }
.facts span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.facts .ic { color: var(--muted); }
.addr { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.addr a { color: var(--ink); }
.addr a:hover { color: var(--brand); text-decoration: none; }
.loc { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.loc .ic { width: 14px; height: 14px; }
.dom-chip { font-size: 11.5px; color: var(--muted); }

/* Compact row cards (map list side) */
.row-card {
  display: flex; gap: 14px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  cursor: pointer; transition: box-shadow .15s, border-color .15s, background .15s;
  position: relative;
}
.row-card.hl { border-color: var(--brand); box-shadow: var(--shadow-1); }
.row-card .photo { width: 168px; flex-shrink: 0; aspect-ratio: 4 / 3; border-radius: var(--r-sm); }
.row-card .photo .ph-art .ic { width: 34px; height: 34px; }
.row-card .fav-btn { width: 30px; height: 30px; }
.row-card .fav-btn .ic { width: 15px; height: 15px; }
.row-card .body { padding: 2px 0; min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 5px; }

/* Pager */
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 26px 0 8px; }
.pager a, .pager span { padding: 8px 15px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 13.5px; }
.pager a:hover { border-color: var(--surface-3); background: var(--surface-2); text-decoration: none; }
.pager span.current { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.pager .disabled { color: var(--muted); opacity: .55; }

/* ------------------------------ Panels ---------------------------------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px 20px;
  box-shadow: var(--shadow-1);
}
.panel + .panel { margin-top: 16px; }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px 16px; box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 4px;
}
.kpi .lbl { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .val { font-size: 24px; font-weight: 780; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.kpi .spark { margin-top: 6px; align-self: flex-end; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: var(--r-pill); }
.delta.up { background: var(--good-bg); color: var(--good); }
.delta.down { background: var(--bad-bg); color: var(--bad); }
.delta .ic { width: 11px; height: 11px; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: var(--r-pill); }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }

/* ------------------------------ Tables ---------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.tbl th, table.tbl td { padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* La 1re colonne (libellés : noms de quartiers…) peut passer à la ligne —
   en nowrap, les noms longs poussaient le tableau hors de la page sur PC. */
table.tbl th:first-child, table.tbl td:first-child { text-align: left; white-space: normal; min-width: 130px; }
table.tbl thead th {
  position: sticky; top: 0; background: var(--surface-2); z-index: 1;
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700;
}
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl td .bar-cell { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
table.tbl td.best { color: var(--good); font-weight: 750; }
table.tbl .mini-bar { height: 6px; border-radius: 3px; background: var(--brand); opacity: .55; display: inline-block; }
table.tbl.kv td:first-child { color: var(--muted); }
table.tbl.kv td { white-space: normal; }

/* --------------------------- Estimate bar -------------------------------- */
.est-bar { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); margin: 30px 6px 8px; }
.est-bar .range { position: absolute; top: 0; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--good), #eab308 55%, var(--bad)); opacity: .35; }
.est-bar .marker {
  position: absolute; top: 50%; width: 3px; height: 20px; border-radius: 2px;
  transform: translate(-50%, -50%); background: var(--muted);
}
.est-bar .marker.ask {
  width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--surface);
  background: var(--brand); box-shadow: var(--shadow-2);
}
.est-bar .marker .tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); font-size: 11px; font-weight: 650;
  padding: 3px 8px; border-radius: 6px; white-space: nowrap;
}
.est-scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin: 0 6px; }

/* --------------------------- Mortgage calc ------------------------------- */
.slider-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.slider-row .top { display: flex; justify-content: space-between; font-size: 13px; }
.slider-row .top b { font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--brand); height: 26px; cursor: pointer; }
.stack-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin-top: 6px; }
.stack-bar > span { display: block; height: 100%; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* --------------------------- Sheet / modal ------------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 2000; background: rgb(10 15 20 / .5);
  opacity: 0; pointer-events: none; transition: opacity .2s;
  backdrop-filter: blur(2px);
}
.sheet {
  position: fixed; z-index: 2010;
  background: var(--surface); box-shadow: var(--shadow-3);
  transition: transform .25s ease, opacity .25s ease;
  display: flex; flex-direction: column;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.sheet-body { padding: 14px 20px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.sheet-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }

@media (max-width: 860px) {
  .sheet {
    left: 0; right: 0; bottom: 0; top: auto;
    max-height: 82vh; max-height: 82dvh;
    border-radius: 18px 18px 0 0;
    transform: translateY(102%);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    /* Fermée : invisible aussi pour le clavier et les lecteurs d'écran. */
    visibility: hidden;
    transition: transform .25s ease, opacity .25s ease, visibility .25s;
  }
  .sheet::before {
    content: ""; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 2px; background: var(--surface-3);
  }
}
@media (min-width: 861px) {
  .sheet {
    left: 50%; top: 50%; width: min(480px, 92vw); max-height: 84vh;
    border-radius: var(--r-lg);
    transform: translate(-50%, -46%) scale(.97); opacity: 0; pointer-events: none;
    visibility: hidden;
    transition: transform .25s ease, opacity .25s ease, visibility .25s;
  }
}
.sheet-open .sheet-backdrop { opacity: 1; pointer-events: auto; }
/* La page ne défile pas derrière une sheet ouverte. */
body.sheet-open { overflow: hidden; }
@media (max-width: 860px) { .sheet.open { transform: translateY(0); visibility: visible; } }
@media (min-width: 861px) { .sheet.open { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; visibility: visible; } }

/* Bouton « Appliquer » flottant (mobile) : sur mobile, les changements de
   filtres ne rechargent pas la page tant qu'on ne l'a pas tapé. */
.apply-fab { display: none; }
@media (max-width: 860px) {
  .apply-fab.show {
    display: inline-flex; position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px);
    z-index: 1500; box-shadow: var(--shadow-3);
  }
  /* Page carte : au-dessus du basculeur Carte/Liste */
  body[data-page="map"] .apply-fab.show {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 62px);
  }
}

/* Pilules de regroupement (Leaflet.markercluster) */
.cluster-pill {
  background: var(--brand, #0e7a6a); color: #fff;
  border: 2px solid #fff; border-radius: 999px;
  padding: 5px 10px; font-size: 12px; font-weight: 800; font-family: var(--font);
  box-shadow: var(--shadow-2); transform: translate(-50%, -50%);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* ------------------------------- Map page -------------------------------- */
/* --toolbar-h est mesurée en JS (ResizeObserver) : la barre de filtres
   grandit quand la rangée de chips actifs apparaît. */
.map-layout { display: flex; gap: 0; height: calc(100vh - var(--topbar-h) - var(--toolbar-h, 57px)); height: calc(100dvh - var(--topbar-h) - var(--toolbar-h, 57px)); }
.map-side { flex: 1.25; position: relative; min-width: 0; }
.list-side {
  flex: 1; min-width: 380px; max-width: 520px; overflow-y: auto;
  border-left: 1px solid var(--line); background: var(--bg);
  padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
#map { position: absolute; inset: 0; background: var(--surface-2); }
.map-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; text-align: center; padding: 20px; }

/* Price pill markers (Leaflet divIcon) */
.pill-marker {
  background: #fff; color: #16212b;
  border: 1.5px solid #94a3b8; border-radius: 999px;
  padding: 3px 9px; font-size: 12px; font-weight: 750; font-family: var(--font);
  white-space: nowrap; box-shadow: var(--shadow-1); cursor: pointer;
  transform: translate(-50%, -50%);
  transition: transform .12s, background .12s, color .12s;
  font-variant-numeric: tabular-nums;
}
.pill-marker.c0 { border-color: #16a34a; color: #15803d; }
.pill-marker.c1 { border-color: #ca8a04; color: #a16207; }
.pill-marker.c2 { border-color: #ea580c; color: #c2410c; }
.pill-marker.c3 { border-color: #dc2626; color: #b91c1c; }
.pill-marker.rent { border-style: dashed; }
.pill-marker.hl {
  background: var(--brand, #0e7a6a); border-color: var(--brand, #0e7a6a); color: #fff;
  transform: translate(-50%, -50%) scale(1.15); z-index: 1000 !important;
}
.leaflet-popup-content-wrapper { border-radius: var(--r-md) !important; background: var(--surface) !important; color: var(--ink) !important; }
.leaflet-popup-tip { background: var(--surface) !important; }
.map-pop { min-width: 210px; font-family: var(--font); }
.map-pop .photo { border-radius: 8px; margin: -14px -14px 10px; aspect-ratio: 16/9; }
.map-pop .price { font-size: 16px; }

/* Floating map panels (search / legend) */
.map-float {
  position: absolute; z-index: 500;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
}
.map-float.search { left: 60px; top: 10px; right: 60px; padding: 8px; display: flex; gap: 8px; }
.map-float.search .input { border-radius: 8px; }
.map-float.legend { left: 10px; bottom: 18px; padding: 10px 13px; font-size: 12px; display: flex; flex-direction: column; gap: 5px;
  /* Les mises en garde des couches (inondation, GTC, criminalité) passent à
     la ligne au lieu d'étirer la légende sur la moitié de la carte. */
  max-width: 300px; }
.map-float .li { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.map-float .dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid; flex-shrink: 0; }
.map-float details { font-size: 12px; color: var(--muted); }
.map-float details summary { cursor: pointer; font-weight: 600; }
.map-float details label { display: flex; align-items: center; gap: 6px; padding: 3px 0; cursor: pointer; }
/* Bouton transit mobile : n'existe que sous 860px (voir bloc responsive). */
.map-float.transit-fab { display: none; border: 1px solid var(--line); }
.transit-opts label { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.transit-opts input { accent-color: var(--brand); width: 18px; height: 18px; }
/* Pastille de couleur des couches surfaciques (zones inondables) : les
   couches linéaires se repèrent à la couleur de leur libellé, une surface
   translucide non. */
.swatch {
  width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0;
  opacity: .55; border: 1px solid rgba(0, 0, 0, .25);
}

/* Dessin de zone (Leaflet-Geoman) : colonne d'outils flottante. Desktop :
   en haut à droite, dans la marge laissée par la barre de recherche. */
.map-float.zone-tools {
  top: 10px; right: 10px;
  display: flex; flex-direction: column; gap: 4px; padding: 4px;
}
.zone-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: none; border-radius: var(--r-sm); background: transparent; color: var(--ink);
  font-family: inherit; cursor: pointer; transition: background .15s, color .15s;
}
.zone-btn:hover { text-decoration: none; }
/* Survol réservé aux vrais pointeurs (même règle que les cartes). */
@media (hover: hover) and (pointer: fine) {
  .zone-btn:hover { background: var(--surface-2); }
}
.zone-btn.on { background: var(--brand); color: var(--brand-ink); }
.zone-btn .ic { width: 18px; height: 18px; }
/* Astuce affichée pendant le tracé, sous la colonne d'outils. */
.zone-hint {
  position: absolute; top: calc(100% + 8px); right: 0; width: 210px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow-2); color: var(--ink); font-size: 12px; line-height: 1.4;
  /* Simple étiquette : le clic ou le toucher qui tombe dessus doit placer
     le point sur la carte en dessous, pas se perdre dans la bulle. */
  pointer-events: none;
}
/* Pendant le tracé, pilules et grappes ne captent pas le clic : le sommet
   part sur la carte. Hors tracé, leur comportement ne change pas. Les
   sommets de Geoman (.marker-icon) restent cliquables : cliquer le premier
   est ce qui ferme le polygone. */
#map.zone-drawing .leaflet-marker-icon:not(.marker-icon),
#map.zone-drawing .pill-marker,
#map.zone-drawing .cluster-pill { pointer-events: none; }

/* Mobile map/list switch */
.map-switch {
  position: fixed; z-index: 700; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px);
  display: none;
  box-shadow: var(--shadow-3); border-radius: var(--r-pill);
}

/* ------------------------------ Deals ------------------------------------ */
.deal-row {
  display: flex; gap: 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 13px 16px 13px 13px; box-shadow: var(--shadow-1);
  transition: box-shadow .15s; position: relative;
}
.deal-row:hover { box-shadow: var(--shadow-2); }
.deal-row .photo { width: 132px; flex-shrink: 0; aspect-ratio: 4/3; border-radius: var(--r-md); }
.deal-row .photo .ph-art .ic { width: 30px; height: 30px; }
.deal-row .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.deal-row .z-chip { margin-left: auto; text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

/* --------------------------- Empty state --------------------------------- */
.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty .ic { width: 52px; height: 52px; opacity: .5; }
.empty .t { font-size: 16px; font-weight: 700; color: var(--ink); }

/* ----------------------------- Detail page ------------------------------- */
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); gap: 26px; align-items: start; }
.split-60-40 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 26px; align-items: start; }
/* Les enfants de ces grilles doivent pouvoir rétrécir sous leur min-content
   (tableaux nowrap, rails défilants) — sinon la page déborde sur mobile. */
.detail-layout > *, .split-60-40 > * { min-width: 0; }
.detail-side { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 16px; }
.crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.crumb:hover { color: var(--brand); text-decoration: none; }

.gallery-main {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-lg); overflow: hidden;
  background: linear-gradient(135deg,
    hsl(var(--ph, 200) 46% 87%), hsl(calc(var(--ph, 200) + 34) 42% 74%));
}
html[data-theme="dark"] .gallery-main {
  background: linear-gradient(135deg, hsl(var(--ph, 200) 32% 24%), hsl(calc(var(--ph, 200) + 34) 30% 16%));
}
.gallery-main .ph-art { position: absolute; inset: 0; display: grid; place-items: center; color: hsl(var(--ph, 200) 30% 42% / .5); }
.gallery-main .ph-art .ic { width: 96px; height: 96px; }

.fact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: 10px; }
.fact {
  background: var(--surface-2); border-radius: var(--r-md); padding: 11px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.fact .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 650; display: flex; align-items: center; gap: 5px; }
.fact .v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }

.comp-rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.comp-rail > * { scroll-snap-align: start; }
/* z-index: 0 isole le contexte d'empilement : les contrôles Leaflet
   (z-index 1000) ne doivent pas passer au-dessus de la tabbar/du CTA. */
.detail-map-wrap { position: relative; z-index: 0; height: 300px; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); }
.detail-map-wrap .map-inner { position: absolute; inset: 0; }

/* Sticky mobile CTA — posé AU-DESSUS de la tabbar, pas par-dessus. */
.mobile-cta {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  z-index: 650;
  display: none; gap: 10px; align-items: center;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.mobile-cta .price { font-size: 17px; }
.mobile-cta .fav-form { position: static; }
.mobile-cta .fav-btn { border: 1px solid var(--line); background: var(--surface); }

/* ------------------------------ Footer ----------------------------------- */
.footer { border-top: 1px solid var(--line); margin-top: 30px; padding: 22px 20px 40px; color: var(--muted); font-size: 12.5px; text-align: center; }

/* SVG charts (server-rendered) */
.chart { width: 100%; height: auto; display: block; }
.bar-scroll { overflow-x: auto; }
.bar-scroll .chart { min-width: 540px; }

/* ============================ Responsive ================================= */
@media (max-width: 1080px) {
  .detail-layout, .split-60-40 { grid-template-columns: 1fr; }
  .detail-side { position: static; }
}
@media (max-width: 860px) {
  body { font-size: 14.5px; }
  .topbar { padding: 0 14px; gap: 10px;
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px)); }
  .nav-links { display: none; }
  .tabbar { display: flex; }
  .container { padding: 14px 12px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 28px); }
  /* Page annonce : le CTA fixe (~64px) s'empile au-dessus de la tabbar. */
  body[data-page="listing"] .container {
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 96px);
  }
  h1 { font-size: 19px; }

  /* iOS zoome la page au focus des champs < 16px — jamais sur mobile. */
  .input, .select, input[type="number"], input[type="text"], input[type="search"], select {
    font-size: 16px;
  }

  /* Cibles tactiles : 44px minimum sur les contrôles principaux. */
  .chip { min-height: 40px; padding: 8px 10px 8px 14px; }
  .chips .clear-all { display: inline-flex; align-items: center; min-height: 40px; padding: 0 6px; }
  .chips .zone-map-link { display: inline-flex; align-items: center; min-height: 40px; padding: 0 6px; }
  .pop-btn { min-height: 44px; }
  .seg span, .seg a span { padding: 11px 16px; }
  .opt { min-height: 44px; }
  .pager a, .pager span { padding: 11px 15px; }
  .lang-switch a { padding: 9px 12px; }
  .row-card .fav-btn { width: 40px; height: 40px; }

  /* Toolbar: single horizontally-scrollable row of chips */
  .toolbar-inner { padding: 8px 12px; }
  .toolbar-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .toolbar-row::-webkit-scrollbar { display: none; }
  .toolbar-row > * { flex-shrink: 0; }
  /* Chips de filtres actifs : même traitement scroller que la rangée
     principale, sinon la toolbar sticky mange le tiers du viewport. */
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .chips::-webkit-scrollbar { display: none; }
  .chips > * { flex-shrink: 0; }
  /* .toolbar (backdrop-filter) est le containing block des descendants
     fixed : top:100% ancre le panneau juste sous la toolbar. */
  .pop-panel, .pop-panel.align-end {
    position: fixed; left: 12px; right: 12px; top: calc(100% + 8px); max-width: none;
  }

  .grid-cards { grid-template-columns: 1fr; gap: 14px; }
  .row-card .photo { width: 128px; }
  .price-row { flex-wrap: wrap; }

  /* Tables larges : la 1re colonne (libellé de ligne) reste visible. */
  table.tbl th:first-child, table.tbl td:first-child {
    position: sticky; left: 0; background: var(--surface); z-index: 2;
  }
  table.tbl thead th:first-child { background: var(--surface-2); z-index: 3; }

  /* Map page becomes one pane + switch */
  .map-layout {
    height: calc(100vh - var(--topbar-h) - var(--toolbar-h, 50px) - var(--tabbar-h) - env(safe-area-inset-bottom, 0px));
    height: calc(100dvh - var(--topbar-h) - var(--toolbar-h, 50px) - var(--tabbar-h) - env(safe-area-inset-bottom, 0px));
  }
  .map-side { flex: 1; }
  .list-side { display: none; max-width: none; min-width: 0; border-left: none; }
  .list-side { padding-bottom: 90px; }
  .map-layout.show-list .map-side { display: none; }
  .map-layout.show-list .list-side { display: flex; }
  .map-switch { display: block; }
  /* Recherche : à droite du contrôle de zoom ; bouton « vue d'ensemble » en icône seule */
  .map-float.search { left: 60px; right: 10px; top: 10px; padding: 6px; }
  .map-float.search #geo-reset span { display: none; }
  .map-float.search #geo-reset { padding: 7px 10px; }
  /* Legend: compact dots row, top-right, clear of the Map/List switch */
  .map-float.legend { left: auto; right: 10px; top: 64px; bottom: auto; flex-direction: row; gap: 8px; padding: 8px 10px; max-width: none; }
  .map-float.legend .li span:not(.dot) { display: none; }
  .map-float.legend .li { gap: 0; }
  .map-float.legend .li.legend-note { display: none; }
  .map-float.legend details { display: none; }
  /* Les toggles transit (cachés avec la légende) restent accessibles via
     un bouton flottant qui ouvre une bottom sheet. */
  .map-float.transit-fab {
    display: grid; place-items: center;
    left: auto; right: 10px; top: 112px; bottom: auto;
    width: 42px; height: 42px; padding: 0; cursor: pointer;
    color: var(--ink); font-family: inherit;
  }

  /* Outils de zone : colonne sous le contrôle de zoom, à gauche (la légende
     et le bouton transit occupent la droite, le basculeur le bas). */
  .map-float.zone-tools { top: 80px; left: 10px; right: auto; }
  .zone-btn { width: 40px; height: 40px; }
  /* Pas de polygone au doigt : placer chaque sommet puis viser le premier
     entre les bulles de prix est trop laborieux. Rectangle et cercle se
     tracent en deux touchers ; une zone polygonale reçue par lien reste
     affichée et filtrée. */
  .zone-btn[data-zone-tool="Polygon"] { display: none; }
  .zone-hint { left: 0; right: auto; width: 200px; }

  .mobile-cta { display: flex; }
  .mobile-cta .spacer { flex: 1; }
  .deal-row { flex-wrap: wrap; }
  .deal-row .z-chip { flex-direction: row; align-items: center; margin-left: 0; width: 100%; justify-content: flex-start; gap: 8px; }
  .footer { padding-bottom: 110px; }
}
@media (max-width: 420px) {
  /* Le champ de recherche prime : Entrée soumet déjà le formulaire. */
  .map-float.search button[type="submit"] { display: none; }
}
@media (max-width: 380px) {
  .brand span { display: none; }
}

/* ---- Contexte de quartier (fiche) : criminalité, permis, loyers SCHL ---- */
.ctx-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ctx-big { font-size: 30px; font-weight: 780; margin-right: 6px; }
.ctx-h3 { margin: 4px 0 8px; font-size: 14px; font-weight: 700; }
.ctx-h3 + * { margin-top: 0; }
.panel .ctx-h3:not(:first-of-type) { margin-top: 18px; }
/* Rang du secteur parmi les annonces de l'île : même règle que .est-bar. */
.rank-bar {
  position: relative; height: 10px; border-radius: 5px; margin: 16px 6px 8px;
  background: linear-gradient(90deg, var(--good), #eab308 55%, var(--bad)); opacity: .85;
}
.rank-bar .marker {
  position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%;
  transform: translate(-50%, -50%); border: 3px solid var(--surface);
  background: var(--ink); box-shadow: var(--shadow-2);
}
.cat-tbl td { padding-top: 6px; padding-bottom: 6px; }
.cat-bar { display: block; height: 8px; min-width: 2px; border-radius: 4px; background: var(--brand); opacity: .7; }
table.tbl.permit-tbl td {
  vertical-align: top; white-space: normal; text-align: left; min-width: 0;
}
/* Date / distance et type : colonnes étroites, la description prend le reste. */
table.tbl.permit-tbl td:nth-child(-n+2) { white-space: nowrap; width: 1%; }
.pill.permit-CO { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); }
.pill.permit-TR { background: var(--surface-2); color: var(--muted); }
.pill.permit-DE { background: var(--bad-bg); color: var(--bad); }
.permit-pin { display: block; width: 12px; height: 12px; border-radius: 2px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.crime-scale { display: inline-flex; vertical-align: middle; margin-right: 4px; }
.crime-scale i { display: block; width: 6px; height: 12px; }
.crime-scale i:first-child { border-radius: 2px 0 0 2px; }
.crime-scale i:last-child { border-radius: 0 2px 2px 0; }
.permit-sq { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 2px; }

/* ------------------------------ Comptes --------------------------------- */
/* Barre du haut : nom du compte (lien vers /compte) + déconnexion. */
.acct { display: inline-flex; align-items: center; gap: 8px; }
.acct-link {
  display: inline-flex; align-items: center; gap: 6px; max-width: 180px;
  padding: 6px 10px; border-radius: var(--r-pill);
  color: var(--ink); font-size: 13.5px; font-weight: 600;
}
.acct-link:hover { background: var(--surface-2); text-decoration: none; }
.acct-link .ic { width: 16px; height: 16px; color: var(--muted); }
.acct-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-login { color: var(--brand); }
.acct-logout { margin: 0; }
.acct-logout .btn { padding: 6px 12px; }

/* Cartes de connexion et d'inscription */
.auth-card {
  max-width: 420px; margin: 28px auto 0; padding: 26px 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 16px;
}
.auth-card h1 { margin: 0; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.auth-form .field { display: flex; flex-direction: column; gap: 5px; }
.auth-form .field .field-label { margin: 0; }
.auth-form .btn { width: 100%; }
.auth-error {
  margin: 0; padding: 10px 12px; border-radius: 10px;
  background: var(--bad-bg); color: var(--bad); font-size: 13.5px; font-weight: 600;
}
.auth-hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.auth-foot { margin: 0; font-size: 13.5px; color: var(--muted); }
.auth-foot a { font-weight: 650; }

/* Page compte */
.account { display: grid; gap: 16px; max-width: 760px; }
.account .panel h2 { margin-bottom: 12px; }
.account .panel .auth-form { max-width: 380px; }
.account .panel-danger { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.search-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.search-list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.search-list a { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.search-list form { margin: 0; }

/* Enregistrer la recherche courante (sous la barre de filtres) */
.saved-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.save-search > summary { list-style: none; cursor: pointer; }
.save-search > summary::-webkit-details-marker { display: none; }
.save-search[open] > summary { color: var(--brand); }
.save-form { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.save-form .input { flex: 1; min-width: 180px; width: auto; }
.saved-bar .chip { text-decoration: none; }

@media (max-width: 860px) {
  .acct-name { display: none; }
  .acct-link { padding: 6px; }
  .acct { gap: 4px; }
  .account { gap: 12px; }
}
@media (max-width: 420px) {
  .acct-logout .btn { font-size: 12px; padding: 6px 9px; }
  .auth-card { padding: 20px 18px; margin-top: 14px; }
}

/* ------------------------------ Agent ----------------------------------- */
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 2px;
  border-radius: var(--r-pill); background: var(--brand); color: var(--brand-ink);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.tabbar a { position: relative; }
.tab-badge { position: absolute; top: 4px; left: calc(50% + 6px); margin: 0; }
.agent-intro { max-width: 760px; margin: 4px 0 16px; }
.agent-tabs { margin-bottom: 18px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.agent-ok {
  margin: 0 0 16px; padding: 10px 14px; border-radius: var(--r-md);
  background: var(--good-bg); color: var(--good); font-weight: 600;
}
.agent-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.agent-bar form { margin: 0; }
.reco { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.reco .card { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.reco-why {
  flex: 1; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 var(--r-lg) var(--r-lg); padding: 12px 14px;
}
.reco-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.score-pill {
  --s: 50;
  padding: 3px 9px; border-radius: var(--r-pill); font-size: 12px; font-weight: 700;
  color: var(--brand-ink);
  background: color-mix(in srgb, var(--brand) calc(var(--s) * 1%), var(--muted));
}
.reco-why ul { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 2px; }
.reco-why li.neg { color: var(--bad); }
.reco-actions { display: flex; gap: 8px; margin-top: auto; }
.reco-actions form { margin: 0; }
.scout-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.scout-list li {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
}
.scout-list li.paused { opacity: .65; }
.scout-main { min-width: 0; flex: 1; }
.scout-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.scout-actions form { margin: 0; }
.scout-map-wrap { position: relative; }
.scout-map { height: 380px; border-radius: var(--r-md); border: 1px solid var(--line); z-index: 0; }
.scout-map-wrap .zone-tools { top: 10px; right: 10px; }
.agent-form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.form-grid .field { display: flex; flex-direction: column; }
.form-grid .wide { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; }
.type-checks { border: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.type-checks legend { margin-bottom: 6px; }
.weights { display: grid; gap: 8px; max-width: 520px; }
.weight { display: grid; grid-template-columns: 1fr 140px 20px; gap: 10px; align-items: center; font-size: 14px; }
.weight input { accent-color: var(--brand); }
.agent-form textarea { width: 100%; resize: vertical; font-family: inherit; }
.agent-cols { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.agent-cols .panel + .panel { margin-top: 0; }
.profile { position: sticky; top: calc(var(--topbar-h) + 16px); }
.profile dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13.5px; }
.profile dt { color: var(--muted); }
.profile dd { margin: 0; }
.agent-step { font-size: 14.5px; margin: 18px 0 8px; }
.token-form { display: flex; gap: 8px; max-width: 420px; }
.token-new { padding: 12px 14px; margin-bottom: 12px; border-radius: var(--r-md); background: var(--brand-soft); }
.copy-row { display: flex; gap: 8px; align-items: flex-start; }
.copy-row code, .copy-row pre { flex: 1; min-width: 0; overflow-wrap: anywhere; }
pre.code {
  margin: 0; padding: 12px 14px; border-radius: var(--r-md); overflow-x: auto;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; line-height: 1.5;
}
@media (max-width: 860px) {
  .agent-cols { grid-template-columns: 1fr; }
  .profile { position: static; }
}

/* Fonctions réservées aux grands écrans (ex. scouts : dessin de zone). */
@media (max-width: 860px) { .desktop-only { display: none !important; } }
@media (min-width: 861px) { .mobile-only { display: none !important; } }

.agent-review { margin-bottom: 20px; }
.review-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.review-head h2 { margin: 0; }
.review-head form { margin: 0; }
.review-summary { white-space: pre-line; line-height: 1.55; max-width: 820px; }
.review-comment { margin: 0; font-size: 13.5px; line-height: 1.5; white-space: pre-line; }

/* ---------------------------- Notifications ------------------------------ */
.notif { position: relative; }
.notif-badge { position: absolute; top: 1px; right: -2px; margin: 0; min-width: 17px; height: 17px; font-size: 10.5px; }
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 1200;
  width: min(360px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2, 0 10px 30px rgb(0 0 0 / .18)); overflow: hidden;
}
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--line); }
.notif-list { list-style: none; margin: 0; padding: 4px 0; max-height: min(420px, 60vh); overflow-y: auto; }
.notif-item {
  display: grid; gap: 3px; padding: 9px 14px 9px 24px; position: relative;
  color: var(--ink); font-size: 13.5px; line-height: 1.4;
}
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item.unread { font-weight: 600; }
.notif-item.unread::before {
  content: ""; position: absolute; left: 10px; top: 15px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--brand);
}
.notif-item time { color: var(--muted); font-size: 12px; font-weight: 500; }
.notif-empty { padding: 14px; color: var(--muted); font-size: 13.5px; }
.notif-toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 1300;
  display: flex; align-items: center; gap: 12px; max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  box-shadow: var(--shadow-2, 0 10px 30px rgb(0 0 0 / .18)); font-size: 14px;
}
@media (max-width: 860px) {
  .notif-panel { position: fixed; left: 12px; right: 12px; width: auto; top: calc(var(--topbar-h) + 6px); }
  .notif-toast { left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px); }
}

/* Barre du haut sur petit écran : la cloche prend la place du libellé
   « Déconnexion », remplacé par une icône (libellé gardé en aria-label). */
.logout-ic { display: none; }
@media (max-width: 480px) {
  .topbar { gap: 6px; }
  .logout-ic { display: block; }
  .logout-label { display: none; }
  .acct-logout .btn { padding: 6px 8px; }
  .acct { gap: 2px; }
  .acct-link { padding: 6px; }
  .notif .icon-btn, .topbar > .icon-btn { width: 34px; height: 34px; }
}

/* Bureau étroit : les 7 liens et la cloche ne tiennent pas avec leurs
   libellés ; icônes seules (libellé en infobulle et lu par les lecteurs
   d'écran, le lien gardant son texte dans le DOM). */
@media (min-width: 861px) and (max-width: 1240px) {
  .nav-links a { padding: 8px 10px; }
  .nav-links .nav-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
  }
}
