/* Villa Hunter - phone-first styles. Light and dark follow the phone, or the Theme button. */
:root {
  --bg: #f6f5f2; --card: #fff; --text: #1d1d1b; --muted: #6b6b66; --line: #e2e0da; --soft: #efede8;
  --accent: #1f6f5c; --accent-text: #fff; --warn: #b4531a; --yes: #1f7a3d; --maybe: #a57a00; --no: #a33a2c;
  --wa: #128c4a; --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131312; --card: #1d1d1b; --text: #ecebe6; --muted: #a09f98; --line: #33322e; --soft: #262522;
    --accent: #5cc0a4; --accent-text: #0d1f1a; --warn: #e48a4f; --yes: #5cc07a; --maybe: #e0b84a; --no: #e07a6c; --wa: #3fbf75;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131312; --card: #1d1d1b; --text: #ecebe6; --muted: #a09f98; --line: #33322e; --soft: #262522;
  --accent: #5cc0a4; --accent-text: #0d1f1a; --warn: #e48a4f; --yes: #5cc07a; --maybe: #e0b84a; --no: #e07a6c; --wa: #3fbf75;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
main { max-width: 760px; margin: 0 auto; padding: 8px 16px 64px; }
main.wide { max-width: 1200px; }
h1 { font-size: 1.35rem; margin: 10px 0 4px; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
h3 { font-size: 1rem; margin: 14px 0 6px; }

/* header and tabs */
.sticky { position: sticky; top: 0; z-index: 1000; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line); }
.topnav { display: flex; gap: 16px; align-items: center; font-size: .92rem; }
.theme-toggle::before { content: "\25D0"; margin-right: 4px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.tabs { display: flex; background: var(--card); border-bottom: 1px solid var(--line); }
.tabs a { flex: 1; text-align: center; padding: 10px 4px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.pills a { padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); text-decoration: none; font-size: .9rem; }

/* building blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 12px 0; }
.narrow { max-width: 380px; margin: 40px auto; }
.stack { display: grid; gap: 12px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; justify-content: flex-start; }
label { display: grid; gap: 4px; font-size: .95rem; }
.inline-label { display: inline-flex; align-items: center; gap: 8px; }
input, select, button, textarea { font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); min-height: 44px; }
textarea { width: 100%; resize: vertical; }
button { background: var(--accent); color: var(--accent-text); border: 0; cursor: pointer; font-weight: 600; }
button[disabled] { opacity: .6; cursor: default; }
button.link { background: none; color: var(--accent); padding: 0; min-height: 0; font-weight: 500; }
button.link.danger, .danger { color: var(--no); }
.button { display: inline-block; padding: 10px 14px; border-radius: 8px; background: var(--accent); color: var(--accent-text); text-decoration: none; }
form.inline { display: inline; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.error { color: var(--warn); }
.ok { color: var(--yes); }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.plain li:last-child { border-bottom: 0; }
.tag { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag.warn { border-color: var(--warn); color: var(--warn); }
.tag.brief { border-color: var(--accent); color: var(--accent); }
.badge { display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: .75rem; font-weight: 700; text-align: center; }
.alert { border-color: var(--no); border-width: 2px; }
.soft-note { border-color: var(--warn); }
.pre { white-space: pre-wrap; }
.scroll { overflow-x: auto; }
pre.log { white-space: pre-wrap; font-size: .78rem; max-height: 320px; overflow: auto; background: var(--soft); padding: 8px; border-radius: 8px; }

/* brief bar and sliders */
.briefbar { display: grid; gap: 10px; }
.range2-label { display: flex; justify-content: space-between; gap: 8px; font-size: .92rem; }
.range2-label output { font-weight: 600; }
.range2-track { position: relative; height: 44px; --lo: 0%; --hi: 100%; }
.range2-track::before { content: ""; position: absolute; left: 0; right: 0; top: 20px; height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--line) var(--lo), var(--accent) var(--lo), var(--accent) var(--hi), var(--line) var(--hi)); }
.range2-track input[type=range] { position: absolute; inset: 0; width: 100%; margin: 0; padding: 0; border: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; min-height: 44px; }
.range2-track input[type=range]::-webkit-slider-thumb { pointer-events: auto; -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: var(--card); border: 3px solid var(--accent); cursor: pointer; }
.range2-track input[type=range]::-moz-range-thumb { pointer-events: auto; width: 24px; height: 24px; border-radius: 50%; background: var(--card); border: 3px solid var(--accent); cursor: pointer; }
.range2-track input[type=range]::-webkit-slider-runnable-track { background: none; }
.range2-track input[type=range]::-moz-range-track { background: none; }
.slider-row { display: grid; grid-template-columns: 1fr 4.5em; gap: 2px 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.slider-row label { grid-column: 1 / -1; font-size: .92rem; }
.slider-row input[type=range] { width: 100%; padding: 0; border: 0; accent-color: var(--accent); }
.slider-row output { text-align: right; font-weight: 600; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 12px; margin: 8px 0; }
.check { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.check input { min-height: 0; width: 20px; height: 20px; accent-color: var(--accent); }
details.region { border-top: 1px solid var(--line); padding: 6px 0; }
details > summary { cursor: pointer; font-weight: 600; min-height: 32px; display: list-item; }

/* filters */
.filters summary { list-style-position: inside; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.filter-grid .span2 { grid-column: 1 / -1; }
.filter-grid select, .filter-grid input { width: 100%; }
.sortbar { display: flex; justify-content: flex-end; margin: -4px 0 0; }
@media (min-width: 640px) { .filter-grid { grid-template-columns: repeat(4, 1fr); } }

/* listing cards */
#results.loading { opacity: .5; transition: opacity .2s; }
.listing { display: grid; grid-template-columns: 1fr; gap: 0; padding: 0; overflow: hidden; }
.listing .thumb { display: block; position: relative; aspect-ratio: 16 / 10; background: var(--soft); }
.listing .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.listing .thumb.empty { aspect-ratio: auto; min-height: 52px; }
.nophoto { text-decoration: none; padding: 14px 0; display: flex; height: 100%; align-items: center; justify-content: center; color: var(--muted); font-size: .9rem; }
.listing .score { position: absolute; right: 10px; top: 10px; }
.badges { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; }
.badges .badge.new { background: #2a6fdb; color: #fff; }
.badges .badge.drop { background: var(--yes); color: #fff; }
.listing .body { padding: 10px 12px 12px; display: grid; gap: 3px; }
@media (min-width: 640px) { .listing { grid-template-columns: 240px 1fr; } .listing .thumb { aspect-ratio: auto; min-height: 180px; } .listing .thumb.empty { min-height: 100%; } }
.title { font-weight: 650; text-decoration: none; color: var(--text); font-size: 1.02rem; }
.meta { color: var(--muted); font-size: .9rem; }
.score { min-width: 2.6em; text-align: center; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-text); }
.price { font-weight: 650; }
.price .per { font-weight: 400; color: var(--muted); font-size: .88em; }
.listed { font-size: .82rem; color: var(--muted); }
.approx { font-style: italic; color: var(--muted); border-bottom: 1px dotted var(--muted); }
.flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.others .who { margin-right: 8px; font-weight: 600; }
.who.v-yes { color: var(--yes); } .who.v-maybe { color: var(--maybe); } .who.v-no { color: var(--no); }
.verdicts { display: flex; gap: 6px; margin-top: 8px; }
.verdicts button { flex: 1; padding: 10px; background: var(--card); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.verdicts .v-yes.on { background: var(--yes); color: #fff; border-color: var(--yes); }
.verdicts .v-maybe.on { background: var(--maybe); color: #fff; border-color: var(--maybe); }
.verdicts .v-no.on { background: var(--no); color: #fff; border-color: var(--no); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }

/* detail */
.gallery { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 8px -16px; padding: 0 16px; }
.gallery img { height: 220px; border-radius: 10px; scroll-snap-align: start; display: block; }
.facts { width: 100%; border-collapse: collapse; }
.facts th, .facts td { text-align: left; vertical-align: top; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.facts th { width: 38%; font-weight: 500; color: var(--muted); }
.wa { display: grid; gap: 10px; }
button.whatsapp { background: var(--wa); color: #fff; }
.minimap { height: 220px; border-radius: 10px; overflow: hidden; }

/* map */
.mapwrap { margin: 0 -16px; }
#bigmap { height: calc(100vh - 230px); min-height: 360px; }
@media (min-width: 640px) { .mapwrap { margin: 0; } #bigmap { border-radius: var(--radius); } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; margin-right: 2px; }
.dot.v-yes { background: #1f7a3d; } .dot.v-maybe { background: #c29100; } .dot.v-no { background: #a33a2c; } .dot.v-none { background: #3b6fb6; }
.dot.ring { border: 2px solid #3b6fb6; background: transparent; } .dot.beach { background: #5ec8f2; border: 1px solid #0b7fab; width: 9px; height: 9px; }
.leaflet-container { font: inherit; }
.leaflet-popup-content a { font-weight: 600; }

/* admin tables */
.runs { border-collapse: collapse; width: 100%; font-size: .9rem; }
.runs th, .runs td { padding: 6px; border-bottom: 1px solid var(--line); text-align: left; }
.runs tr.bad td { background: color-mix(in srgb, var(--no) 12%, transparent); }

/* duplicates review */
.dup-why { margin: 0 0 8px; }
.dup-pair { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 10px; }
@media (min-width: 640px) { .dup-pair { grid-template-columns: 1fr 1fr; } }
.dup-side { display: grid; gap: 3px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.dup-thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.dup-thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
button.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.price-gap { margin: 8px 0 0; }
.dup.undone { opacity: .6; }

