:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --sale: #c2410c;
  --rent: #1d4ed8;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f6f7f9;
  --card: #fff;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(15, 23, 42, .12);
  --top: 64px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

/* ---------- barre du haut ---------- */
.topbar {
  height: var(--top); display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: var(--card); border-bottom: 1px solid var(--line); position: relative; z-index: 5;
}
.logo { display: flex; align-items: center; gap: 8px; color: var(--brand); text-decoration: none; font-size: 20px; white-space: nowrap; }
.logo span { color: var(--ink); } .logo b { color: var(--brand); }
.tx-switch { display: flex; background: var(--bg); border-radius: 999px; padding: 3px; }
.tx-switch button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tx-switch button.active { background: var(--card); color: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.place-search { flex: 1; min-width: 160px; max-width: 520px; }
.place-search input, .place-search gmp-place-autocomplete { width: 100%; }
.place-search input { border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; background: var(--bg); }
gmp-place-autocomplete { color-scheme: light; }
.top-actions { display: flex; gap: 8px; margin-left: auto; }

.btn { border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.btn.primary { background: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-dark); }
.btn.primary:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: var(--card); border-color: var(--line); } .btn.ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn.wa { background: #16a34a; color: #fff; } .btn.danger { background: #fff; color: #b91c1c; border-color: #fecaca; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.link { border: 0; background: none; color: var(--brand); cursor: pointer; padding: 0; font-weight: 600; }

/* ---------- mise en page ---------- */
.layout { display: grid; grid-template-columns: 420px 1fr; height: calc(100% - var(--top)); }
.sidebar { overflow-y: auto; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.map-wrap { position: relative; }
.map { position: absolute; inset: 0; background: #e8ecef; z-index: 0; }
.map-empty { display: grid; place-items: center; height: 100%; padding: 24px; text-align: center; color: var(--muted); }
.map-empty code { background: #fff; padding: 2px 6px; border-radius: 6px; }

/* ---------- filtres ---------- */
.filters { padding: 14px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.row.four { grid-template-columns: repeat(4, 1fr); }
label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: #374151; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; font-weight: 400; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.more summary { cursor: pointer; font-weight: 600; color: var(--brand); font-size: 14px; }
.more[open] { display: grid; gap: 10px; }
.feature-filter, .features { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-check { position: relative; }
.chip-check input { position: absolute; opacity: 0; }
.chip-check span { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; font-weight: 500; cursor: pointer; background: #fff; }
.chip-check input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip-check input:focus-visible + span { outline: 2px solid var(--brand); }
.tools { grid-template-columns: 1fr auto; }

.results-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; gap: 10px; }
.results-head select { width: auto; }
.results { list-style: none; margin: 0; padding: 0 12px 80px; display: grid; gap: 10px; }
.card { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; background: #fff; transition: box-shadow .15s, border-color .15s; }
.card:hover, .card.hl { border-color: var(--brand); box-shadow: var(--shadow); }
.card .ph { width: 130px; height: 98px; border-radius: 8px; object-fit: cover; background: linear-gradient(135deg, #e2e8f0, #cbd5e1); display: grid; place-items: center; font-size: 30px; }
.card .price { font-weight: 800; font-size: 17px; }
.card .t { font-size: 14px; margin: 2px 0 4px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 2px 7px; border-radius: 6px; color: #fff; }
.tag.vente { background: var(--sale); } .tag.location { background: var(--rent); }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }

/* ---------- carte : marqueurs & outils ---------- */
.pin {
  background: var(--sale); color: #fff; font-weight: 700; font-size: 12.5px; padding: 4px 8px; border-radius: 999px;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); white-space: nowrap; position: relative; transition: transform .12s;
}
.pin::after { content: ""; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); border: 6px solid transparent; border-top-color: #fff; border-bottom: 0; }
.pin.location { background: var(--rent); }
.pin.hl { transform: scale(1.18); background: #111827; z-index: 9; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #2563eb; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(37,99,235,.25); }
.poi-pin { background: #fff; border: 2px solid var(--brand); border-radius: 50%; width: 28px; height: 28px; display: grid; place-items: center; font-size: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.3); }

.map-tools { position: absolute; top: 60px; left: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.map-btn { border: 0; background: #fff; border-radius: 8px; padding: 8px 10px; box-shadow: 0 1px 4px rgba(0,0,0,.25); cursor: pointer; font-size: 13px; font-weight: 600; text-align: left; }
.map-btn[aria-pressed=true] { background: var(--brand); color: #fff; }
.legend { position: absolute; bottom: 24px; left: 10px; background: #fff; border-radius: 8px; padding: 6px 10px; font-size: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.25); display: flex; gap: 6px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; } .dot.vente { background: var(--sale); } .dot.location { background: var(--rent); margin-left: 6px; }
.toggle-view { display: none; }
.legend { z-index: 2; }

/* ---------- OpenStreetMap (Leaflet) ---------- */
.map-osm .map-tools { top: 10px; }
.leaflet-container { font: inherit; }
.lf-pin { background: none; border: 0; }
.lf-anchor { transform: translate(-50%, calc(-100% - 7px)); width: max-content; }
.marker-cluster { background: rgba(15, 118, 110, .25) !important; }
.marker-cluster div { background: var(--brand) !important; color: #fff; font-weight: 700; }
.osm-search { position: relative; width: 100%; }
.place-search.inline .osm-search input { border-radius: 8px; background: #fff; }
.osm-sugg { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 1100; list-style: none; margin: 0; padding: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 320px; overflow: auto; }
.osm-sugg li { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: grid; font-size: 14px; }
.osm-sugg li:hover { background: var(--bg); }
.osm-sugg li.none { cursor: default; color: var(--muted); }
.osm-sugg small { color: var(--muted); }
.nearby li { cursor: pointer; }

/* ---------- modales ---------- */
.modal { border: 0; border-radius: 16px; padding: 24px; width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px); box-shadow: var(--shadow); }
.modal.wide { width: min(980px, calc(100% - 24px)); }
.modal::backdrop { background: rgba(15, 23, 42, .55); }
.modal h2 { margin: 0 0 12px; }
.close { position: absolute; top: 10px; right: 12px; border: 0; background: var(--bg); width: 36px; height: 36px; border-radius: 50%; font-size: 22px; cursor: pointer; z-index: 3; }

.detail { display: grid; grid-template-columns: 1.25fr 1fr; gap: 22px; }
.gallery .main { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; background: linear-gradient(135deg, #e2e8f0, #cbd5e1); display: grid; place-items: center; font-size: 60px; }
.gallery .thumbs { display: flex; gap: 6px; margin-top: 6px; overflow-x: auto; }
.gallery .thumbs img { width: 76px; height: 58px; object-fit: cover; border-radius: 6px; cursor: pointer; opacity: .65; flex: none; }
.gallery .thumbs img.on { opacity: 1; outline: 2px solid var(--brand); }
.d-price { font-size: 26px; font-weight: 800; margin: 6px 0 2px; }
.d-title { margin: 0 0 6px; font-size: 18px; }
.d-addr { color: var(--muted); margin: 0 0 12px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.fact { background: var(--bg); border-radius: 10px; padding: 8px; text-align: center; font-size: 12px; color: var(--muted); }
.fact b { display: block; color: var(--ink); font-size: 16px; }
.feat-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.feat-list li { background: #ecfdf5; color: #065f46; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; }
.desc { white-space: pre-line; line-height: 1.55; }
.contact { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; }
.contact .who { font-weight: 700; }
.contact .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.contact .btns .btn { flex: 1; }
.place-tabs { display: flex; gap: 6px; margin: 16px 0 8px; flex-wrap: wrap; }
.place-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; font-weight: 600; }
.place-tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.mini-map { height: 320px; border-radius: 12px; overflow: hidden; background: #e8ecef; }
.nearby { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; font-size: 13.5px; max-height: 180px; overflow: auto; }
.nearby li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 8px; border-radius: 6px; background: var(--bg); }
.nearby small { color: var(--muted); white-space: nowrap; }
.sub-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.status-banner { background: #fef3c7; color: #92400e; padding: 8px 12px; border-radius: 8px; font-weight: 600; margin-bottom: 10px; }

/* ---------- formulaire publication ---------- */
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 0 0 14px; display: grid; gap: 10px; }
legend { font-weight: 800; padding: 0 6px; color: var(--brand); }
.seg { display: flex; gap: 8px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 10px; border: 2px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 15px; }
.seg input:checked + span { border-color: var(--brand); background: #f0fdfa; color: var(--brand); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); }
.picker-map { height: 300px; border-radius: 10px; overflow: hidden; background: #e8ecef; }
.place-search.inline { max-width: none; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.dropzone { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 22px; text-align: center; cursor: pointer; font-weight: 500; color: var(--muted); display: block; }
.dropzone.over { border-color: var(--brand); background: #f0fdfa; }
.dropzone input { display: none; }
.previews { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.previews li { position: relative; }
.previews img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; }
.previews button { position: absolute; top: 4px; right: 4px; border: 0; background: rgba(0,0,0,.65); color: #fff; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; line-height: 1; }
.previews li:first-child::after { content: "Principale"; position: absolute; left: 4px; bottom: 4px; background: var(--brand); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 4px; }
.error { background: #fef2f2; color: #b91c1c; padding: 10px 12px; border-radius: 8px; margin: 0 0 10px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: -24px; background: #fff; padding: 12px 0; }
.success { text-align: center; display: grid; gap: 12px; }
.manage-link { display: flex; gap: 6px; } .manage-link input { font-size: 12.5px; }
body:not(.rent) .rent-only { display: none; }

.mine-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.mine-list li { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 8px; }
.mine-list .acts { display: flex; gap: 6px; flex-wrap: wrap; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; box-shadow: var(--shadow); }

/* ---------- mobile ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 360px 1fr; }
  .top-actions #btn-mine { display: none; }
}
@media (max-width: 860px) {
  :root { --top: 112px; }
  .topbar { flex-wrap: wrap; height: var(--top); padding: 8px 12px; gap: 8px; align-content: center; }
  .logo span { display: none; }
  .tx-switch button { padding: 6px 9px; font-size: 13.5px; }
  .hide-sm { display: none; }
  .place-search { order: 5; flex-basis: 100%; max-width: none; }
  .top-actions #btn-mine { display: inline-flex; }
  .top-actions .btn { padding: 8px 10px; font-size: 13px; }
  .layout { grid-template-columns: 1fr; position: relative; }
  .sidebar { position: absolute; inset: 0; z-index: 3; display: none; }
  body.show-list .sidebar { display: flex; }
  .toggle-view { display: block; position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 4; border: 0; background: #111827; color: #fff; padding: 11px 22px; border-radius: 999px; font-weight: 700; box-shadow: var(--shadow); }
  .detail { grid-template-columns: 1fr; }
  .modal { padding: 16px; }
  .row.four { grid-template-columns: 1fr 1fr; }
  .card { grid-template-columns: 110px 1fr; } .card .ph { width: 110px; height: 86px; }
  .legend { bottom: 76px; }
}
@media (max-width: 420px) {
  .top-actions #btn-mine { display: none; }
}
