/* house-finder UI on top of Pico.css.
   Theme tokens: --bg (page), --surface (cards), --surface-2 (nested / table head), --border, --text, --muted.
   Dark mode follows the OS; both palettes keep >= 4.5:1 contrast for body text. */
:root {
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --info: #2563eb;
  --bg: #eef1f5; --surface: #ffffff; --surface-2: #f5f7fa; --border: #d5dbe3;
  --text: #1b2330; --muted: #5b6676; --heading: #0f1722; --accent: #1d4ed8;
  --chip-bg: var(--surface-2);
  --pico-font-size: 96%;
  --pico-background-color: var(--bg);
  --pico-color: var(--text);
  --pico-muted-color: var(--muted);
  --pico-muted-border-color: var(--border);
  --pico-card-background-color: var(--surface);
  --pico-card-sectioning-background-color: var(--surface-2);
  --pico-table-border-color: var(--border);
  --pico-h1-color: var(--heading); --pico-h2-color: var(--heading); --pico-h3-color: var(--heading);
  --pico-h4-color: var(--heading); --pico-h5-color: var(--heading); --pico-h6-color: var(--heading);
  --pico-primary: var(--accent); --pico-primary-hover: #1e40af;
  --pico-form-element-background-color: var(--surface);
  --pico-form-element-border-color: #b9c2ce;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ok: #22c55e; --warn: #f59e0b; --bad: #f87171; --info: #60a5fa;
    --bg: #0f141c; --surface: #1b2330; --surface-2: #243042; --border: #3a4759;
    --text: #e6ebf2; --muted: #a9b4c4; --heading: #ffffff; --accent: #7cb4ff;
    --pico-primary-hover: #a8ccff;
    --pico-form-element-background-color: #141b26;
    --pico-form-element-border-color: #4a586c;
    --pico-table-border-color: var(--border);
  }
}
html, body { background: var(--bg); color: var(--text); min-height: 100%; }
body > header.app { padding: .5rem 1.25rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1000;
  background: var(--surface); box-shadow: 0 2px 10px rgba(0,0,0,.18); }
header.app nav ul { gap: .35rem; flex-wrap: wrap; }
header.app nav a { padding: .3rem .6rem; border-radius: 8px; color: var(--text); }
header.app nav a:hover { background: var(--surface-2); }
header.app .brand { font-weight: 800; text-decoration: none; color: var(--heading); }
main.container-fluid { padding: 1.5rem clamp(1rem, 3vw, 2.5rem); max-width: 1440px; margin: 0 auto; }
body.map-page main { max-width: none; }
h2 { margin: .4rem 0 1.1rem; }
h3 { margin: 1.4rem 0 .8rem; font-size: 1.15rem; }
a { text-underline-offset: 3px; }
.lock { font-size: .9rem; }

/* every page block = a card with breathing room */
main > section, main > article, .grid-2 > section, .grid-3 > section, .grid-2 > details.section, details.section, main article {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 1.1rem 1.3rem; margin: 0 0 1.4rem; box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.grid-2 > section > h3:first-child, main > section > h3:first-child { margin-top: 0; }
table { margin-bottom: .5rem; }
th { color: var(--heading); background: var(--surface-2); font-weight: 700; }
td, th { border-bottom-color: var(--border) !important; }
tbody tr:hover td { background: var(--surface-2); }
figure { margin: 0 0 1.4rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: .4rem .8rem; }
.muted, small.muted { color: var(--muted) !important; }

/* badges */
.badge { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .78rem; font-weight: 600; color: #fff; background: #4b5563; white-space: nowrap; vertical-align: middle; }
.badge.ok, .badge.conf-ok { background: #15803d; }
.badge.warn, .badge.conf-check { background: #b45309; }
.badge.bad, .badge.alert { background: #b91c1c; }
.badge.info, .badge.conf-stable { background: #1d4ed8; }
.badge.ai { background: #6d28d9; }
.badge.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.src { text-decoration: none; margin-left: .15rem; }
.src-ref { font-size: .75rem; color: var(--muted); margin-left: .1rem; }

/* glossary tooltips */
abbr.gl { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
#gl-pop { position: fixed; z-index: 5000; max-width: 360px; padding: .7rem .8rem; border-radius: 10px; font-size: .85rem; line-height: 1.35;
  background: var(--pico-card-background-color); color: var(--pico-color); box-shadow: 0 8px 30px rgba(0,0,0,.25); border: 1px solid var(--pico-muted-border-color); display: none; }
#gl-pop .t { font-weight: 700; } #gl-pop .f { color: var(--muted); } #gl-pop .imp { margin-top: .35rem; padding-left: .5rem; border-left: 3px solid var(--info); }
#gl-pop a { font-size: .8rem; }

/* info boxes */
.box { border-radius: 10px; padding: .8rem 1rem; margin: .8rem 0; border: 1px solid var(--border); border-left: 5px solid var(--info); background: var(--surface-2); color: var(--text); }
.box.ok { border-color: var(--ok); } .box.warn { border-color: var(--warn); } .box.bad { border-color: var(--bad); }
.box > :last-child { margin-bottom: 0; }

/* kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(205px, 1fr); gap: 1rem; overflow-x: auto; padding-bottom: .8rem; scrollbar-color: var(--border) transparent; }
html { scrollbar-color: var(--border) var(--bg); }
.board .col { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: .7rem; min-height: 220px; }
.board .col h4 { margin: .2rem .3rem .6rem; font-size: .95rem; }
.card-p { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: .6rem; margin-bottom: .8rem; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.card-p img { width: 100%; height: 120px; object-fit: cover; border-radius: 6px; }
.card-p .meta { font-size: .8rem; color: var(--muted); }
.card-p a { text-decoration: none; }
.score { font-weight: 700; }
.score.hi { color: var(--ok); } .score.mid { color: var(--warn); } .score.lo { color: var(--bad); }

/* property page */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
[x-cloak] { display: none !important; }
.gallery { display: flex; gap: .4rem; overflow-x: auto; }
.gallery img { height: 150px; border-radius: 6px; flex: none; }

/* photo carousel (property page) */
.carousel { margin: .8rem 0 1.4rem; outline: none; }
.car-stage { position: relative; height: min(62vh, 520px); background: #0b0f15; border-radius: 12px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; user-select: none; }
.car-stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; cursor: zoom-in; }
.car-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 3rem; height: 3rem; padding: 0; margin: 0;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 2rem; line-height: 1; cursor: pointer; }
.car-nav:hover { background: rgba(0,0,0,.8); }
.car-nav.prev { left: .7rem; } .car-nav.next { right: .7rem; }
.car-count { position: absolute; left: .7rem; bottom: .7rem; background: rgba(0,0,0,.65); color: #fff;
  padding: .15rem .6rem; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.car-tools { position: absolute; right: .7rem; top: .7rem; display: flex; gap: .4rem; }
.car-tools a, .car-tools button { display: inline-flex; align-items: center; justify-content: center; width: 2.3rem; height: 2.3rem;
  padding: 0; margin: 0; border: 0; border-radius: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 1.1rem;
  text-decoration: none; cursor: pointer; }
.car-tools a:hover, .car-tools button:hover { background: rgba(0,0,0,.85); }
.car-thumbs { display: flex; gap: .4rem; overflow-x: auto; padding: .5rem .1rem .3rem; scrollbar-width: thin; }
.car-thumbs img { flex: none; width: 96px; height: 68px; object-fit: cover; border-radius: 6px; cursor: pointer;
  opacity: .6; border: 2px solid transparent; transition: opacity .15s, border-color .15s; }
.car-thumbs img:hover { opacity: .9; }
.car-thumbs img.on { opacity: 1; border-color: var(--accent); }
.carousel.fs { position: fixed; inset: 0; z-index: 2000; margin: 0; background: rgba(5,8,12,.96);
  display: flex; flex-direction: column; padding: .8rem; }
.carousel.fs .car-stage { flex: 1; height: auto; background: transparent; border-radius: 0; }
.carousel.fs .car-stage img { cursor: zoom-out; }
.carousel.fs .car-thumbs { justify-content: safe center; }
@media (max-width: 600px) {
  .car-stage { height: 46vh; }
  .car-nav { width: 2.4rem; height: 2.4rem; font-size: 1.6rem; }
  .car-thumbs img { width: 72px; height: 52px; }
}
table.facts td, table.facts th { padding: .25rem .4rem; font-size: .9rem; }
.kpi { display: flex; gap: 1rem; flex-wrap: wrap; margin: .5rem 0 1.6rem; }
.kpi > div { flex: 1 1 200px; background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--info); border-radius: 12px; padding: .8rem 1rem; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.kpi > div:last-child { border-top-color: var(--ok); }
.kpi .v { font-size: 1.45rem; font-weight: 800; color: var(--heading); margin: .15rem 0; } .kpi .l { font-size: .82rem; color: var(--muted); }
.pos { color: var(--ok); } .neg { color: var(--bad); }
details.section > summary { padding: .1rem 0; }
details.section > summary { font-weight: 700; }
.links a { display: inline-block; margin: .15rem .3rem .15rem 0; }

/* map */
body.map-page main { padding: 0; }
#map-wrap { position: relative; height: calc(100vh - 60px); }
#map { position: absolute; inset: 0; }
#map-side { position: absolute; top: .8rem; left: .8rem; z-index: 800; width: 340px; max-height: calc(100% - 1.6rem); overflow: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: .8rem 1rem; box-shadow: 0 8px 28px rgba(0,0,0,.35); font-size: .88rem; }
@media (max-width: 700px) { #map-side { width: calc(100% - 1.2rem); max-height: 40%; top: auto; bottom: .6rem; } }
#map-side h3 { font-size: 1rem; margin: .2rem 0 .4rem; }
#map-side label { font-size: .85rem; margin: .1rem 0; }
.legend-dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; vertical-align: middle; margin-right: .3rem; }
.emoji-marker { font-size: 18px; text-shadow: 0 0 3px #fff; }
.leaflet-popup-content img { max-width: 220px; border-radius: 6px; }

/* checklist */
.check-item { border-bottom: 1px solid var(--pico-muted-border-color); padding: .6rem 0; }
.states { display: flex; gap: .3rem; flex-wrap: wrap; }
.states label { border: 1px solid var(--pico-muted-border-color); border-radius: 999px; padding: .1rem .6rem; cursor: pointer; }
.states input { display: none; }
.states input:checked + span { font-weight: 700; }
.media-compare { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: .4rem 0; }
.media-compare figure { margin: 0; }
.media-compare img, .media-compare svg { width: 100%; max-height: 180px; object-fit: cover; border-radius: 6px; background: #fff; }
.media-compare figcaption { font-size: .72rem; color: var(--muted); }
.sev-alert { color: var(--bad); font-weight: 700; } .sev-warn { color: var(--warn); font-weight: 600; }
.toast-wrap { position: fixed; right: 1rem; bottom: 1rem; z-index: 6000; display: flex; flex-direction: column; gap: .4rem; }
.toast { padding: .7rem 1rem; border-radius: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: 0 6px 20px rgba(0,0,0,.25); border-left: 5px solid var(--info); max-width: 420px; }
.toast.success { border-color: var(--ok); } .toast.warning { border-color: var(--warn); } .toast.error { border-color: var(--bad); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.recovery-code { font-family: monospace; font-size: 1.4rem; letter-spacing: .1rem; padding: 1rem; border: 3px dashed var(--warn); border-radius: 10px; text-align: center; }

/* map: no browser focus box on clicked shapes; legend */
.leaflet-interactive:focus, .leaflet-container path:focus { outline: none; }
.leaflet-popup-content { font-size: .9rem; line-height: 1.45; }
.legend h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .9rem 0 .35rem; }
.legend-row { display: flex; align-items: center; gap: .55rem; margin: .25rem 0; font-size: .86rem; }
.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .1rem .8rem; }
.legend-sw { display: inline-block; width: 26px; height: 14px; border-radius: 3px; flex: none; vertical-align: middle; margin-right: .35rem; }
.legend svg { flex: none; }
.legend .hint { font-size: .78rem; color: var(--muted); margin: .2rem 0 0; }
.work-marker span { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%;
  background: #1d4ed8; color: #fff; font: 800 14px system-ui, sans-serif; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.45); }
.leaflet-pane > svg { pointer-events: none; } .leaflet-pane > svg path.leaflet-interactive { pointer-events: visiblePainted; pointer-events: auto; }

/* Leaflet sets role="button" on markers and Pico styles [role=button] as a blue button: neutralise it. */
.leaflet-container .leaflet-marker-icon[role="button"] { background: none; border: 0; padding: 0; margin: 0; box-shadow: none;
  width: auto; min-width: 0; outline: none; }
.leaflet-container .leaflet-marker-icon.store-marker { display: flex; align-items: center; justify-content: center;
  width: 26px !important; height: 26px !important; border-radius: 50%; background: #fff; border: 2.5px solid #2563eb;
  font-size: 14px; line-height: 1; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.store-hyper_leclerc { border-color: #2563eb !important; }
.store-super_local { border-color: #16a34a !important; }
.store-diy_big { border-color: #ea580c !important; }
.store-diy_small { border-color: #a16207 !important; }
.store-furniture_big { border-color: #7c3aed !important; }
.sector-tip { font-size: .85rem; line-height: 1.45; min-width: 190px; }
.leaflet-tooltip { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.leaflet-tooltip-top:before { border-top-color: var(--surface); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }
.store-pill { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2px solid; font-size: 12px; flex: none; }

/* Leaflet controls themed (Pico restyles their role=button links, inputs and labels) */
.leaflet-container .leaflet-control { margin: 12px; }
.leaflet-container a.leaflet-control-layers-toggle[role="button"], .leaflet-container .leaflet-control-layers-toggle {
  background-color: var(--surface); border: 0; padding: 0; margin: 0; box-shadow: none;
  width: 44px; height: 44px; border-radius: 10px; }
.leaflet-control-layers { background: var(--surface); color: var(--text); border: 1px solid var(--border) !important;
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.35) !important; }
.leaflet-control-layers-expanded { padding: .6rem .9rem .6rem .7rem; }
.leaflet-control-layers label { color: var(--text); font-size: .9rem; margin: .25rem 0; display: flex; align-items: center; gap: .1rem; }
.leaflet-control-layers label span { color: var(--text); }
.leaflet-control-layers input[type="checkbox"], .leaflet-control-layers input[type="radio"] { margin: 0 .5rem 0 0; width: 1.05rem; height: 1.05rem; }
.leaflet-control-layers-separator { border-top-color: var(--border); margin: .5rem 0; }
.leaflet-bar { border: 1px solid var(--border) !important; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.3) !important; }
.leaflet-container .leaflet-bar a, .leaflet-container .leaflet-bar a[role="button"] { background-color: var(--surface); color: var(--text);
  border: 0; border-bottom: 1px solid var(--border); padding: 0; margin: 0; width: 36px; height: 36px; line-height: 36px;
  font-size: 20px; border-radius: 0; box-shadow: none; }
.leaflet-container .leaflet-bar a:hover { background-color: var(--surface-2); color: var(--heading); }
.leaflet-control-scale-line { background: var(--surface); color: var(--text); border-color: var(--text); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 85%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--accent); }
.leaflet-control-layers label > span, .leaflet-control-layers label > div { display: flex; align-items: center; }
.leaflet-control-layers input[type="checkbox"], .leaflet-control-layers input[type="radio"] { flex: none; vertical-align: middle; top: 0; }

/* Map page = exactly the viewport under the header: no page scroll, the panel never slides under the header */
body.map-page { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
body.map-page > header.app { flex: none; position: relative; }
body.map-page > main { flex: 1 1 auto; min-height: 0; padding: 0; }
body.map-page #map-wrap { height: 100%; }

/* kanban v2: collapsible / wide columns, stars, drag */
.board { grid-auto-columns: auto; grid-template-columns: none; display: flex; align-items: stretch; }
.board .col { flex: 1 1 210px; min-width: 210px; display: flex; flex-direction: column; transition: flex-basis .15s; }
.board .col.wide { flex: 2.2 1 440px; min-width: 420px; }
.board .col.wide .col-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; align-content: start; }
.board .col.wide .col-cards .card-p { margin-bottom: 0; }
.board .col.collapsed { flex: 0 0 52px; min-width: 52px; padding: .5rem .2rem; cursor: pointer; }
.board .col.collapsed .col-head { flex-direction: column; align-items: center; gap: .5rem; }
.board .col.collapsed h4 { writing-mode: vertical-rl; transform: rotate(180deg); margin: .4rem 0; white-space: nowrap; }
.col-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .3rem; }
.col-head h4 { margin: .2rem .2rem .7rem; font-size: .95rem; }
.col-tools { display: flex; gap: .2rem; }
.col-tools button { padding: .05rem .4rem; margin: 0; font-size: .85rem; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; width: auto; }
.col-cards { flex: 1; min-height: 120px; }
.card-p .card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
.card-p .card-title { font-weight: 700; margin: .35rem 0 .2rem; line-height: 1.25; }
.card-p .drag { cursor: grab; color: var(--muted); font-size: 1.1rem; padding: 0 .2rem; user-select: none; }
.card-ghost { opacity: .35; outline: 2px dashed var(--accent); }
.stars { display: inline-flex; gap: 1px; }
.stars .star { background: none; border: 0; padding: 0 .05rem; margin: 0; width: auto; font-size: 1.45rem; line-height: 1;
  color: var(--border); cursor: pointer; box-shadow: none; }
.stars .star.on { color: #f59e0b; text-shadow: 0 0 6px rgba(245,158,11,.45); }
.stars .star:hover, .stars:hover .star.on { color: #fbbf24; }
.board .empty { padding: .6rem; border: 1px dashed var(--border); border-radius: 10px; text-align: center; }

/* location picker (edit page) */
#loc-map { height: 420px; border-radius: 10px; border: 1px solid var(--border); margin-top: .4rem; }
.loc-picker .suggest { position: absolute; z-index: 1500; left: 0; right: 0; top: 100%; margin: -.6rem 0 0; padding: .2rem 0;
  list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.loc-picker .suggest li { list-style: none; padding: .4rem .7rem; cursor: pointer; font-size: .92rem; color: var(--text); }
.loc-picker .suggest li:hover { background: var(--surface-2); }
@media (max-width: 600px) { #loc-map { height: 320px; } }
