:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --ink: #111111;
  --muted: #6b6760;
  --line: #e6e2da;
  --accent: #111111;
  --accent-ink: #fff;
  --gold: #c8a467;
  --gold-dark: #9c7c43;
  --radius: 4px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 12px 36px rgb(0 0 0 / 0.09);
  --bar-h: 76px;
}

h1, h2, h3 { font-weight: 500; }
.eyebrow { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold-dark); margin-bottom: 16px; }
.section { padding: clamp(72px, 10vw, 128px) 0; }
.section-head { margin-bottom: 40px; }
.section-head h2, .calc-section h2, .sell h2 { font-size: clamp(2.2rem, 4.6vw, 3.6rem); line-height: 1.05; }
.btn-sm { min-height: 42px; padding: 0 20px; font-size: 0.9rem; }

/* Header */
.header { position: fixed; inset: 0 0 auto; z-index: 1000; color: #fff; transition: background 0.3s, color 0.3s, box-shadow 0.3s; }
.header.is-solid { background: rgb(17 17 17 / 0.94); backdrop-filter: blur(12px); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; height: var(--bar-h); }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; letter-spacing: 0.32em; font-size: 0.95rem; }
.logo svg { width: 30px; flex: none; fill: var(--gold); }
.nav { display: flex; gap: 32px; font-size: 0.9rem; }
.nav a { text-decoration: none; opacity: 0.75; transition: opacity 0.2s; }
.nav a:hover { opacity: 1; }
.header .btn { background: var(--gold); color: var(--ink); }

/* Hero */
.hero { position: relative; min-height: 100svh; display: grid; align-content: end; padding: 140px 0 0; color: #fff; overflow: hidden; isolation: isolate; }
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.hero::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgb(10 10 10 / 0.75), rgb(10 10 10 / 0.25) 60%, transparent), linear-gradient(180deg, transparent 50%, rgb(10 10 10 / 0.7)); }
.hero .eyebrow { color: var(--gold); }
.hero h1 { font-size: clamp(2.8rem, 7.4vw, 6.2rem); line-height: 1; letter-spacing: -0.01em; }
.hero h1 em { color: var(--gold); }
.finder { margin-top: 40px; max-width: 760px; }
.op-toggle { display: inline-flex; background: rgb(255 255 255 / 0.12); backdrop-filter: blur(10px); }
.op-toggle button { padding: 12px 22px; border: 0; background: transparent; color: #fff; font-weight: 600; font-size: 0.9rem; }
.op-toggle button[aria-checked='true'] { background: #fff; color: var(--ink); }
.finder-fields { display: grid; grid-template-columns: 1.3fr 1fr auto; background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.finder-fields label { display: grid; gap: 2px; padding: 14px 20px; border-right: 1px solid var(--line); }
.finder-fields span { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.finder-fields select { border: 0; background: transparent; padding: 0; height: 28px; font-weight: 600; outline: none; }
.finder-fields .btn { border-radius: 0; min-height: 100%; padding: 0 32px; background: var(--gold); color: var(--ink); }
.hero-stats { display: flex; gap: clamp(20px, 6vw, 80px); margin-top: 56px; padding: 22px 0 30px; list-style: none; border-top: 1px solid rgb(255 255 255 / 0.2); font-size: 0.9rem; color: rgb(255 255 255 / 0.75); }
.hero-stats strong { display: block; font-family: var(--font-display); font-size: 1.6rem; font-weight: 500; color: #fff; }

/* Buscador */
.search-section { scroll-margin-top: var(--bar-h); }
.filters-bar { position: sticky; top: var(--bar-h); z-index: 900; background: var(--surface); border-bottom: 1px solid var(--line); }
.filters-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 76px; flex-wrap: wrap; padding-block: 12px; }
.results-title { font-size: 1.5rem; }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); }
.seg button { padding: 0 16px; height: 42px; border: 0; background: transparent; font-weight: 600; font-size: 0.88rem; }
.seg button[aria-checked='true'] { background: var(--ink); color: #fff; }
select.input.input-sm { height: 44px; width: auto; min-height: 0; font-size: 0.9rem; padding: 0 12px; }
.price-filter { display: grid; gap: 2px; min-width: 190px; font-size: 0.78rem; color: var(--muted); }
.price-filter strong { color: var(--ink); }
.price-filter input { accent-color: var(--ink); }
.map-toggle { display: none; height: 48px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 600; box-shadow: var(--shadow); }
/* Mapa base de OpenStreetMap en grises para mantener la estética sobria. */
.leaflet-tile-pane { filter: grayscale(1) contrast(0.92) brightness(1.04); }
.results-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.results { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-content: start; padding: 24px max(var(--gutter), (100vw - var(--max)) / 2); padding-right: 24px; }
.map-panel { position: sticky; top: calc(var(--bar-h) * 2); height: calc(100vh - var(--bar-h) * 2); }
#map { width: 100%; height: 100%; background: var(--surface-2); }
.map-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 32px; text-align: center; color: var(--muted); background: var(--surface-2); }
.no-results { grid-column: 1 / -1; padding: 48px 0; text-align: center; color: var(--muted); }

.card { display: grid; background: var(--surface); border: 1px solid var(--line); transition: box-shadow 0.25s, border-color 0.25s, transform 0.25s var(--ease); animation: rise 0.45s var(--ease) both; cursor: pointer; text-align: left; padding: 0; color: inherit; }
.card:hover, .card.is-hover { box-shadow: var(--shadow); border-color: transparent; transform: translateY(-3px); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.card-media { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: var(--surface-2); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease); }
.card:hover .card-media img { transform: scale(1.05); }
.flag { position: absolute; top: 12px; left: 12px; padding: 5px 10px; background: var(--ink); color: #fff; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.flag.new { background: var(--gold); color: var(--ink); left: auto; right: 12px; }
.card-body { display: grid; gap: 6px; padding: 18px; }
.card-price { font-family: var(--font-display); font-size: 1.5rem; }
.card-price small { font-family: var(--font-body); font-size: 0.8rem; color: var(--muted); }
.card h3 { font-family: var(--font-body); font-weight: 500; font-size: 0.98rem; }
.card-loc { font-size: 0.85rem; color: var(--muted); }
.specs { display: flex; gap: 14px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.82rem; color: var(--muted); }
.specs b { color: var(--ink); font-weight: 600; }

/* Marcadores del mapa */
.pin { display: inline-block; padding: 6px 10px; background: #fff; color: var(--ink); font: 600 12px var(--font-body); white-space: nowrap; box-shadow: 0 2px 10px rgb(0 0 0 / 0.22); border-radius: 999px; transform: translate(-50%, -50%); transition: background 0.2s, color 0.2s, transform 0.2s; }
.pin.is-active { background: var(--ink); color: #fff; transform: translate(-50%, -50%) scale(1.15); z-index: 1000; position: relative; }
.leaflet-div-icon { background: none; border: 0; }
.leaflet-container { font-family: var(--font-body); }
.leaflet-popup-content-wrapper { border-radius: 0; padding: 0; overflow: hidden; }
.leaflet-popup-content { margin: 0; width: 240px !important; }
.popup img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.popup div { padding: 12px 14px; display: grid; gap: 4px; }
.popup strong { font-family: var(--font-display); font-size: 1.15rem; font-weight: 500; }
.popup button { justify-self: start; margin-top: 4px; padding: 0; border: 0; background: none; font-weight: 600; text-decoration: underline; }

/* Ficha */
.sheet { width: min(1100px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; background: var(--surface); color: var(--ink); box-shadow: 0 40px 100px rgb(0 0 0 / 0.4); }
.sheet::backdrop { background: rgb(10 10 10 / 0.6); backdrop-filter: blur(3px); }
.sheet[open] { animation: rise 0.3s var(--ease); }
.sheet-close { position: absolute; top: 12px; right: 12px; z-index: 2; width: 42px; height: 42px; border: 0; border-radius: 50%; background: #fff; font-size: 1.5rem; box-shadow: var(--shadow); }
.sheet-grid { display: grid; grid-template-columns: 1.25fr 1fr; }
.gallery { display: grid; gap: 6px; padding: 6px; align-content: start; background: var(--surface-2); }
.gallery-main { aspect-ratio: 3 / 2; overflow: hidden; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.thumbs button { padding: 0; border: 2px solid transparent; aspect-ratio: 3 / 2; overflow: hidden; background: none; }
.thumbs button[aria-pressed='true'] { border-color: var(--ink); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.sheet-info { display: grid; gap: 16px; align-content: start; padding: 32px; }
.sheet-info h2 { font-size: 2rem; line-height: 1.1; }
.sheet-price { font-family: var(--font-display); font-size: 2rem; }
.sheet-specs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); margin: 0; }
.sheet-specs div { background: var(--surface); padding: 12px; text-align: center; }
.sheet-specs dt { font-size: 0.72rem; color: var(--muted); }
.sheet-specs dd { margin: 0; font-weight: 600; }
.features { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.features li { padding: 6px 12px; background: var(--surface-2); font-size: 0.85rem; }
.agent-mini { display: flex; align-items: center; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.agent-mini img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.agent-mini small { display: block; color: var(--muted); }
.visit-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.visit-form .btn { grid-column: 1 / -1; }
.visit-form .field-error { grid-column: 1 / -1; min-height: 0; }
.link-btn { padding: 0; border: 0; background: none; text-decoration: underline; font-weight: 600; justify-self: start; color: var(--gold-dark); }

/* Calculadora */
.calc-section { background: var(--ink); color: #fff; }
.calc-section .eyebrow { color: var(--gold); }
.calc-grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: clamp(32px, 6vw, 88px); align-items: center; }
.calc-sub { margin-top: 18px; color: rgb(255 255 255 / 0.65); font-size: 1.05rem; max-width: 440px; }
.calc { display: grid; gap: 26px; padding: clamp(24px, 4vw, 44px); background: #1b1b1b; border: 1px solid #2c2c2c; }
.slider-field { display: grid; gap: 12px; }
.slider-field span { display: flex; justify-content: space-between; font-size: 0.9rem; color: rgb(255 255 255 / 0.7); }
.slider-field output { color: #fff; font-weight: 600; }
.slider-field input { accent-color: var(--gold); width: 100%; }
.calc-result { display: grid; gap: 16px; padding-top: 24px; border-top: 1px solid #2c2c2c; }
.calc-result small { display: block; color: rgb(255 255 255 / 0.6); font-size: 0.82rem; }
.calc-result strong { font-family: var(--font-display); font-weight: 500; font-size: clamp(2.4rem, 5vw, 3.4rem); color: var(--gold); line-height: 1.1; }
.calc-bar { height: 8px; background: #555; }
.calc-bar span { display: block; height: 100%; background: var(--gold); transition: width 0.3s var(--ease); }
.calc-result dl { display: flex; gap: 32px; margin: 0; }
.calc-result dt { font-size: 0.82rem; color: rgb(255 255 255 / 0.6); display: flex; align-items: center; gap: 8px; }
.calc-result dd { margin: 4px 0 0; font-weight: 600; }
.sw { width: 10px; height: 10px; display: inline-block; }
.sw.cap { background: var(--gold); }
.sw.int { background: #555; }
.calc-note { font-size: 0.78rem; color: rgb(255 255 255 / 0.5); }

/* Asesores */
.agents { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.agent { display: grid; gap: 16px; }
.agent img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: center 20%; filter: grayscale(0.25); }
.agent h3 { font-size: 1.5rem; }
.agent p { color: var(--muted); font-size: 0.92rem; }
.agent .btn { justify-self: start; min-height: 42px; }

/* Vender */
.sell { background: var(--surface-2); }
.sell-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 32px 80px; align-items: start; }
.sell-grid > .btn { grid-column: 2; justify-self: start; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 4px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 56px 1fr; gap: 4px 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.steps li::before { content: '0' counter(s); grid-row: span 2; font-family: var(--font-display); font-size: 2rem; color: var(--gold-dark); line-height: 1; }
.steps span { color: var(--muted); }

.footer { padding: 32px 0 100px; background: var(--ink); color: rgb(255 255 255 / 0.6); font-size: 0.85rem; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo.small { color: #fff; }

@media (max-width: 1100px) {
  .results { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .nav { display: none; }
  .results-layout { grid-template-columns: 1fr; }
  .results { grid-template-columns: 1fr 1fr; padding: 20px var(--gutter); }
  .map-panel { position: fixed; inset: calc(var(--bar-h) + 1px) 0 0; z-index: 950; height: auto; display: none; }
  .search-section.show-map .map-panel { display: block; }
  .map-toggle { display: inline-block; position: fixed; left: 50%; bottom: 24px; translate: -50% 0; z-index: 970; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  .search-section.in-view .map-toggle { opacity: 1; pointer-events: auto; }
  .filters-bar { top: var(--bar-h); }
  .price-filter { min-width: 150px; }
  .sheet-grid, .calc-grid, .sell-grid { grid-template-columns: 1fr; }
  .sell-grid > .btn { grid-column: auto; }
  .agents { grid-template-columns: 1fr 1fr; }
  .finder-fields { grid-template-columns: 1fr 1fr; }
  .finder-fields .btn { grid-column: 1 / -1; min-height: 52px; }
}
@media (max-width: 600px) {
  .results, .agents { grid-template-columns: 1fr; }
  .filters-inner { gap: 8px; }
  .results-title { font-size: 1.15rem; }
  .filters { overflow-x: auto; flex-wrap: nowrap; width: 100%; padding-bottom: 4px; }
  .hero-stats { flex-wrap: wrap; gap: 12px 28px; }
  .sheet-specs { grid-template-columns: 1fr 1fr; }
  .visit-form { grid-template-columns: 1fr; }
}
