/* ===================================================================
   Casas en Valparaíso — misma base que el visor principal (celular
   primero, filtros que suben desde abajo, Fraunces + Inter servidas
   desde el propio sitio) con una paleta de cuatro colores del puerto:
     hueso  #F2EEE6  fondo (nunca blanco puro)
     tinta  #1B2431  texto
     azul bahía  #1F5A7A  lo que se puede tocar
     calamina oxidada  #A3521A  solo el Match
   Los estados (casi / parcial / fuera / contactada) son tonos apagados
   que codifican datos, no decoran.
   =================================================================== */
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(fuentes/inter.woff2) format('woff2');
}
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 400 650; font-display: swap;
  src: url(fuentes/fraunces.woff2) format('woff2');
}

:root {
  --bg:        #f2eee6;   /* hueso */
  --surface:   #fbf9f4;
  --surface-2: #f5f1e9;
  --ink:       #1b2431;   /* tinta */
  --muted:     #5a6170;   /* 6:1 sobre --surface */
  --line:      #dcd6ca;
  --accent:    #1f5a7a;   /* azul bahía: botones, links, activos */
  --accent-d:  #143e55;
  --accent-bg: rgba(31,90,122,.10);
  --match:     #a3521a;   /* calamina oxidada: solo el Match */
  --match-bg:  rgba(163,82,26,.11);
  --good:      #3b6e58;   /* casi match */
  --mid:       #8a6420;
  --bad:       #747069;
  --done:      #5f5b86;
  --shadow:    0 1px 2px rgba(27,36,49,.06), 0 8px 24px rgba(27,36,49,.06);
  --shadow-h:  0 6px 16px rgba(27,36,49,.10), 0 16px 40px rgba(27,36,49,.10);
  --r:         14px;
  --r-sm:      9px;
  --tabs-h:    56px;
  --t:         .16s ease;
  --focus:     0 0 0 3px var(--surface), 0 0 0 5px var(--accent);
  --serif:     'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px; line-height: 1.45;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body.bloqueado { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

.skip { position: absolute; left: 12px; top: -60px; z-index: 3000; background: var(--accent); color: #fff;
  padding: 10px 14px; border-radius: 9px; text-decoration: none; font-weight: 600; }
.skip:focus { top: 12px; }

/* ----------------------------- Topbar ----------------------------- */
.topbar {
  display: grid; grid-template-columns: 1fr; gap: 12px;
  padding: 18px 16px 16px;
  background: var(--accent-d); color: #f2eee6;
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
/* logotipo: un ascensor subiendo el cerro */
.logo {
  width: 44px; height: 44px; border-radius: 12px; flex: none; position: relative; overflow: hidden;
  background: rgba(242,238,230,.08); border: 1px solid rgba(242,238,230,.16);
}
.logo::before {   /* el riel */
  content: ""; position: absolute; left: -6px; right: -6px; top: 21px; height: 2px;
  background: rgba(242,238,230,.55); transform: rotate(-38deg);
}
.logo::after {    /* el carro */
  content: ""; position: absolute; left: 17px; top: 12px; width: 13px; height: 12px;
  background: #d9864a; border-radius: 3px 3px 2px 2px; transform: rotate(-38deg) skewX(10deg);
}
.topbar h1 {
  font-family: var(--serif); font-weight: 500; font-variation-settings: "opsz" 72;
  font-size: 25px; line-height: 1; margin: 0; letter-spacing: -.01em;
}
.sub { margin: 6px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .09em;
  color: rgba(242,238,230,.72); }
.busqueda { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.busqueda span { font-size: 13px; font-weight: 600; padding: 6px 11px; border-radius: 999px;
  background: rgba(242,238,230,.1); border: 1px solid rgba(242,238,230,.16); }
.busqueda small { font-weight: 400; color: rgba(242,238,230,.72); font-size: 12.5px; }
@media (max-width: 639px) {
  .topbar h1 { font-size: 23px; }
  .sub { font-size: 11px; }
  .busqueda span { font-size: 12.5px; padding: 5px 10px; }
}

.stats { display: none; gap: 8px; }
.stat { padding: 4px 14px; min-width: 78px; border-left: 1px solid rgba(242,238,230,.18); }
.stat b { font-family: var(--serif); font-weight: 500; font-size: 24px; display: block; line-height: 1.1;
  font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: rgba(242,238,230,.7); text-transform: uppercase; letter-spacing: .08em; }
.stat.hl b { color: #eba36f; }

/* ------------------------- Pestañas (vistas) ---------------------- */
.tabs-row { position: sticky; top: 0; z-index: 1000; height: var(--tabs-h);
  display: flex; align-items: center; padding: 0 8px;
  background: rgba(242,238,230,.94); backdrop-filter: saturate(120%) blur(10px);
  -webkit-backdrop-filter: saturate(120%) blur(10px);
  border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; height: 100%; align-items: center; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 13px;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 600; white-space: nowrap; transition: background var(--t), color var(--t); }
.tab:hover { color: var(--ink); background: rgba(27,36,49,.05); }
.tab[aria-selected="true"] { background: var(--accent); color: #fff; }
.tab .i { width: 16px; height: 16px; }

/* ------------------------- Banner update -------------------------- */
.update-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px;
  padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--muted); }
.update-bar b { color: var(--ink); }
.ub-tag { font-weight: 600; padding: 4px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.ub-tag.nuevo { background: var(--accent-bg); color: var(--accent); }
.ub-tag.baja { background: rgba(59,110,88,.13); color: var(--good); }
.ub-tag.viendo-pasado { background: rgba(138,100,32,.14); color: var(--mid); }
.ub-tag.vieja { background: var(--match-bg); color: var(--match); }
.ub-select { font-size: 14px; font-weight: 600; color: var(--ink); min-height: 44px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }

/* ----------------------------- Layout ----------------------------- */
.layout { display: block; }
.content { padding: 16px 16px 120px; min-width: 0; }

/* ----------------------------- Filtros ---------------------------- */
.filters {
  position: fixed; left: 0; right: 0; bottom: 0; top: 6vh; z-index: 2100;
  display: flex; flex-direction: column;
  background: var(--surface-2); border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 40px rgba(0,0,0,.25);
  transform: translateY(105%); visibility: hidden;
  transition: transform .26s cubic-bezier(.2,.8,.2,1), visibility 0s linear .26s;
}
.filters.abierto { transform: none; visibility: visible; transition: transform .26s cubic-bezier(.2,.8,.2,1); }
.velo { position: fixed; inset: 0; z-index: 2050; background: rgba(18,24,32,.45); }
.filters-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 18px;
  border-bottom: 1px solid var(--line); }
.filters-head h2 { font-family: var(--serif); font-weight: 500; font-size: 20px; margin: 0; flex: 1; }
.filters-body { overflow-y: auto; overscroll-behavior: contain; padding: 16px 18px 24px;
  display: flex; flex-direction: column; gap: 20px; flex: 1; }
.filters-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
  background: var(--surface-2); }
.filters-foot .btn { width: 100%; min-height: 48px; font-size: 15px; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent;
  display: grid; place-items: center; color: var(--ink); }
.icon-btn:hover { background: rgba(27,36,49,.06); }
.link { background: none; border: 0; color: var(--accent); font-size: 14px; font-weight: 600;
  min-height: 44px; padding: 0 10px; border-radius: 8px; }
.link:hover { text-decoration: underline; }

/* Botones Match y Casi */
.match-btns { display: flex; flex-direction: column; gap: 8px; }
.match-btn { display: flex; align-items: center; gap: 12px; width: 100%;
  border: 1.5px solid var(--match); background: var(--surface);
  color: var(--ink); border-radius: 12px; padding: 12px 14px; text-align: left;
  box-shadow: var(--shadow); transition: background var(--t), color var(--t), box-shadow var(--t); }
.match-btn:hover { box-shadow: var(--shadow-h); background: #fff; }
.match-btn[aria-pressed="true"] { background: var(--match); color: #fff; border-color: var(--match); }
.match-mark { flex: none; width: 20px; height: 20px; background: var(--match);
  clip-path: polygon(50% 0, 100% 42%, 100% 100%, 0 100%, 0 42%); }
.match-btn[aria-pressed="true"] .match-mark { background: #fff; }
.match-txt { display: flex; flex-direction: column; line-height: 1.3; flex: 1; min-width: 0; }
.match-txt b { font-size: 15px; }
.match-txt small { font-size: 12px; color: var(--muted); }
.match-btn[aria-pressed="true"] .match-txt small { color: rgba(255,255,255,.88); }
.match-count { font-family: var(--serif); font-size: 21px; font-weight: 500;
  background: var(--match); color: #fff; min-width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; flex: none; padding: 0 7px; font-variant-numeric: tabular-nums; }
.match-btn[aria-pressed="true"] .match-count { background: rgba(255,255,255,.22); }
.match-btn.casi { border-color: var(--good); box-shadow: none; }
.match-btn.casi .match-mark { background: transparent; border: 2.5px solid var(--good); clip-path: none;
  width: 18px; height: 18px; border-radius: 5px; }
.match-btn.casi .match-count { background: var(--good); }
.match-btn.casi[aria-pressed="true"] { background: var(--good); border-color: var(--good); }
.match-btn.casi[aria-pressed="true"] .match-mark { border-color: #fff; }
.match-btn.casi[aria-pressed="true"] .match-count { background: rgba(255,255,255,.22); }

.field { display: flex; flex-direction: column; gap: 8px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: 14px; font-weight: 600; color: var(--ink); padding: 0; }
.field .hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.field input[type=search], .field select {
  font-size: 16px; min-height: 44px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); width: 100%;
}
.field input[type=search]:focus-visible, .field select:focus-visible { border-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 44px; margin: 0; }
.val { color: var(--accent); font-variant-numeric: tabular-nums; }
.grupo-filtros { display: flex; flex-direction: column; gap: 20px; }
.grupo-titulo { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin: 6px 0 -8px; padding-top: 14px; border-top: 1px solid var(--line); }

.seg { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; }
.seg.seg-3 { grid-template-columns: repeat(3,1fr); }
.seg button {
  font-size: 13.5px; font-weight: 600; min-height: 44px; padding: 6px 4px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--muted); transition: background var(--t), color var(--t);
}
.seg button:hover { color: var(--ink); border-color: #c8c1b3; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 13.5px; font-weight: 500; min-height: 44px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); transition: background var(--t), color var(--t); }
.chip:hover { color: var(--ink); border-color: #c8c1b3; }
.chip[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip small { font-size: 11.5px; opacity: .8; margin-left: 3px; }

.switches { display: flex; flex-direction: column; gap: 2px; }
.switch { display: flex; align-items: center; gap: 12px; font-size: 14px; min-height: 44px; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
.switch em { font-style: normal; color: var(--muted); font-size: 12.5px; }
.temporal-filters { background: var(--accent-bg); border: 1px solid rgba(31,90,122,.2);
  border-radius: 11px; padding: 10px 12px 6px; }
.temporal-filters > legend { float: left; width: 100%; color: var(--accent); margin-bottom: 2px; }

/* --------------------- Barra inferior (celular) ------------------- */
.dock { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 1500;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px;
  background: rgba(20,62,85,.96); border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.28);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.dock button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  border: 0; border-radius: 11px; background: transparent; color: #fff; font-size: 15px; font-weight: 600; }
.dock button:hover { background: rgba(255,255,255,.08); }
.dock #dock-match[aria-pressed="true"] { background: var(--match); }
.dock-n { min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px; background: #f2eee6; color: var(--ink);
  font-size: 12.5px; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.dock-n:empty { display: none; }
.dock :focus-visible { box-shadow: 0 0 0 3px #fff; }

/* --------------------------- Result bar --------------------------- */
.result-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 6px 14px; margin-bottom: 14px; }
#count { font-size: 14.5px; font-weight: 600; }
#count b { font-family: var(--serif); font-weight: 500; font-size: 20px; }
#count .n-match { color: var(--match); }
.legend { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.casi { background: var(--good); } .dot.mid { background: var(--mid); }
.dot.bad { background: var(--bad); } .dot.done { background: var(--done); }
.dot.match { background: var(--match); box-shadow: 0 0 0 2px var(--match-bg); }

/* ----------------------------- Grid ------------------------------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.mas { grid-column: 1 / -1; display: flex; justify-content: center; padding: 8px 0 20px; }
.mas .btn { flex: none; min-width: 220px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; box-shadow: var(--shadow); transition: box-shadow var(--t), transform var(--t);
  display: flex; flex-direction: column; position: relative; }
.card.es-match { border-color: rgba(163,82,26,.45); box-shadow: 0 0 0 1px rgba(163,82,26,.25), var(--shadow); }
.card.contactada { opacity: .75; }
.card.contactada .thumb::after {
  content: "Contactada"; position: absolute; inset: 0; display: grid; place-items: center; z-index: 1;
  background: rgba(27,36,49,.55); color: #fff; font-weight: 600; font-size: 14px; letter-spacing: .02em; }

.thumb { position: relative; aspect-ratio: 16/10; background: var(--surface-2); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph { width: 100%; height: 100%; display: grid; place-items: center; }
.ph::after { content: ""; width: 30px; height: 30px; background: var(--line);
  clip-path: polygon(50% 0, 100% 42%, 100% 100%, 0 100%, 0 42%); }
.badges { position: absolute; top: 10px; left: 10px; z-index: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.badge-rel, .nuevo-badge { font-size: 11.5px; font-weight: 700; color: #fff; padding: 4px 10px; border-radius: 999px;
  box-shadow: var(--shadow); letter-spacing: .03em; }
.badge-rel.casi { background: var(--good); } .badge-rel.mid { background: var(--mid); }
.badge-rel.bad { background: var(--bad); }
.badge-rel.match { background: var(--match); }
.nuevo-badge { background: var(--surface); color: var(--accent); }
.src-chip { position: absolute; bottom: 10px; left: 10px; z-index: 2;
  font-size: 11px; font-weight: 600; background: rgba(251,249,244,.94); color: var(--ink);
  padding: 4px 9px; border-radius: 999px; box-shadow: var(--shadow); }
.fav-btn { position: absolute; top: 6px; right: 6px; z-index: 3; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: transparent; padding: 0;
  display: grid; place-items: center; }
.fav-btn span { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(251,249,244,.94); color: var(--muted); box-shadow: var(--shadow); transition: background var(--t), color var(--t); }
.fav-btn:hover span { color: var(--ink); }
.fav-btn[aria-pressed="true"] span { background: var(--accent); color: #fff; }
.fav-btn[aria-pressed="true"] .i { fill: currentColor; }

/* galería de fotos en la tarjeta */
.foto-nav { position: absolute; top: 50%; z-index: 2; transform: translateY(-50%);
  width: 44px; height: 44px; border: 0; background: transparent; padding: 0; display: grid; place-items: center; }
.foto-nav span { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(251,249,244,.9); color: var(--ink); box-shadow: var(--shadow); font-size: 18px; line-height: 1; }
.foto-nav.prev { left: 2px; } .foto-nav.next { right: 2px; }
.foto-n { position: absolute; bottom: 10px; right: 10px; z-index: 2; font-size: 11px; font-weight: 600;
  color: #fff; background: rgba(27,36,49,.62); padding: 3px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }

.body { padding: 14px 15px 15px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.price-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.price { font-family: var(--serif); font-size: 25px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums;
  letter-spacing: -.01em; }
.price small { font-size: 12.5px; color: var(--muted); font-family: 'Inter', sans-serif; font-weight: 500; letter-spacing: 0; }
.price-col { display: flex; flex-direction: column; gap: 4px; }
.price-ref { font-size: 12px; color: var(--muted); font-weight: 500; }
.precio-cambio { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.precio-cambio.baja { background: rgba(59,110,88,.13); color: var(--good); }
.precio-cambio.sube { background: var(--match-bg); color: var(--match); }
.falta { font-size: 12.5px; color: var(--good); font-weight: 600; margin: 0; }

.title { font-size: 15px; font-weight: 600; line-height: 1.35; margin: 2px 0 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.addr { font-size: 13px; color: var(--muted); line-height: 1.4; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.specs { display: flex; flex-wrap: wrap; gap: 6px; }
.spec { font-size: 12.5px; font-weight: 500; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); padding: 4px 9px; border-radius: 7px; white-space: nowrap; }
.tag-cerro { background: var(--accent-bg); border-color: rgba(31,90,122,.22); color: var(--accent); font-weight: 600; }
.tag-cerro.nucleo { background: var(--match-bg); border-color: rgba(163,82,26,.3); color: #8a4415; }
.tag-ok { background: rgba(59,110,88,.12); border-color: rgba(59,110,88,.3); color: var(--good); }
.tag-warn { background: rgba(138,100,32,.12); border-color: rgba(138,100,32,.3); color: #6f5119; }
.tag-mute { color: var(--muted); }

/* bloque de accesibilidad */
.acceso { font-size: 12.5px; color: var(--muted); line-height: 1.5; padding: 8px 10px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--line); }
.acceso b { color: var(--ink); }
.acc-nivel { display: inline-block; font-weight: 700; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  padding: 1px 7px; border-radius: 6px; margin-right: 4px; }
.acc-nivel.buena { background: rgba(59,110,88,.15); color: var(--good); }
.acc-nivel.media { background: rgba(138,100,32,.14); color: #6f5119; }
.acc-nivel.difícil, .acc-nivel.sin { background: rgba(116,112,105,.15); color: #57534d; }

.desc { font-size: 13px; color: #3c4350; line-height: 1.5; }
.desc summary { cursor: pointer; list-style: none; min-height: 44px; display: flex; align-items: center;
  color: var(--accent); font-weight: 600; font-size: 13px; }
.desc summary::-webkit-details-marker { display: none; }
.desc summary::before { content: "+"; display: inline-grid; place-items: center; width: 20px; height: 20px;
  border-radius: 6px; border: 1px solid rgba(31,90,122,.3); margin-right: 8px; font-weight: 700; }
.desc[open] summary::before { content: "−"; }
.desc p { margin: 0 0 6px; white-space: pre-line; }
.evid { font-size: 12.5px; color: var(--muted); margin: 0; font-style: italic; }

.otras { font-size: 12.5px; color: var(--muted); }
.otras a { color: var(--accent); font-weight: 600; text-decoration: none; padding: 6px 2px; display: inline-block; }
.otras a:hover { text-decoration: underline; }

.grupo-badge { font-size: 12.5px; font-weight: 700; padding: 5px 9px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 5px; width: fit-content; flex-wrap: wrap; }
.grupo-badge small { font-weight: 500; opacity: .85; }
.grupo-badge.oferta { background: rgba(59,110,88,.13); color: var(--good); }
.grupo-badge.caro { background: var(--match-bg); color: var(--match); }

.actions { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 6px; }
.btn { flex: 1; text-align: center; font-size: 14px; font-weight: 600; min-height: 44px;
  padding: 9px 12px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); text-decoration: none; transition: background var(--t), border-color var(--t);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-d); color: #fff; }
.btn.sq { flex: none; width: 44px; padding: 0; }
.btn.contact[aria-pressed="true"] { background: var(--done); border-color: var(--done); color: #fff; }

/* ----------------------------- Mapa ------------------------------- */
#map { height: calc(100vh - var(--tabs-h) - 150px); height: calc(100svh - var(--tabs-h) - 150px); min-height: 380px; border-radius: var(--r);
  border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
#map .leaflet-tile-pane { filter: saturate(.45) sepia(.1) contrast(.96); }
.leaflet-popup-content { margin: 0; width: 250px !important; }
.leaflet-container a.leaflet-popup-close-button { width: 32px; height: 32px; font-size: 22px; }
.pop { font-family: 'Inter', sans-serif; }
.pop img { width: 100%; height: 130px; object-fit: cover; display: block; }
.pop-b { padding: 11px 12px; }
.pop-price { font-family: var(--serif); font-size: 20px; font-weight: 500; }
.pop-price small { font-family: 'Inter', sans-serif; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.pop-t { font-size: 12.5px; margin: 4px 0 6px; line-height: 1.3; color: var(--ink); }
.pop-a { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.pop-aprox { font-size: 11.5px; color: var(--mid); margin-bottom: 8px; }
a.pop-link { display: block; text-align: center; background: var(--accent); color: #fff;
  text-decoration: none; font-size: 13px; font-weight: 600; padding: 10px; border-radius: 8px; margin-top: 8px; }
.marker-pin { width: 24px; height: 24px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  border: 2px solid #fff; box-shadow: var(--shadow-h); }
.marker-pin.casi { background: var(--good); } .marker-pin.mid { background: var(--mid); }
.marker-pin.bad { background: var(--bad); } .marker-pin.done { background: var(--done); }
.marker-pin.match { background: var(--match); width: 32px; height: 32px; border-width: 3px;
  box-shadow: 0 0 0 3px rgba(163,82,26,.28), var(--shadow-h); }
/* ascensores y nombres de cerros */
.asc-ico { width: 16px; height: 16px; border-radius: 4px; border: 2px solid #fff; background: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,.3); display: grid; place-items: center; color: #fff; font-size: 9px; font-weight: 800; }
.asc-ico.cerrado { background: #b8b2a7; }
.cerro-lbl { font-family: var(--serif); font-size: 13px; font-weight: 600; color: var(--accent-d); white-space: nowrap;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 6px #fff; pointer-events: none; transform: translate(-50%, -50%); width: max-content; }
.cerro-lbl.nucleo { color: #7a3c12; font-size: 14px; }
.map-ley { background: rgba(251,249,244,.95); padding: 8px 10px; border-radius: 9px; box-shadow: var(--shadow);
  font: 12px/1.6 'Inter', sans-serif; color: var(--ink); }
.map-ley i { display: inline-block; vertical-align: middle; margin-right: 6px; }
.map-ley .l-asc { width: 11px; height: 11px; border-radius: 3px; background: var(--accent); }
.map-ley .l-asc.c { background: #b8b2a7; }
.map-ley .l-ale { width: 18px; border-top: 3px dashed var(--accent); }

/* ---------------------------- Métricas ---------------------------- */
.metrics-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.metric-card.wide { grid-column: 1 / -1; }
.metric-card h3 { font-family: var(--serif); font-weight: 500; font-size: 19px; margin: 0 0 14px; line-height: 1.25; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 140px) 1fr 44px; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-label { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--surface-2); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.bar-val { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.funnel { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.fn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 12px; text-align: center; }
.fn b { font-family: var(--serif); font-weight: 500; font-size: 28px; display: block; line-height: 1; font-variant-numeric: tabular-nums; }
.fn span { font-size: 12px; color: var(--muted); margin-top: 6px; display: block; line-height: 1.3; }
.fn.hl { background: var(--match); border-color: var(--match); }
.fn.hl b, .fn.hl span { color: #fff; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; align-self: start; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 14px; box-shadow: var(--shadow); }
.kpi b { font-family: var(--serif); font-weight: 500; font-size: 27px; display: block; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--muted); margin-top: 6px; display: block; line-height: 1.3; }
.kpi.hl b { color: var(--match); }

.tp-scroll { overflow-x: auto; }
.tp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tp-table th { text-align: right; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 0 0 8px 8px; font-weight: 600; }
.tp-table th:first-child { text-align: left; padding-left: 0; }
.tp-table td { text-align: right; padding: 7px 0 7px 8px; border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.tp-table td.tp-g { text-align: left; font-weight: 500; padding-left: 0; white-space: normal; }
.tp-table td.tp-sub { color: var(--muted); font-weight: 500; }
.tp-n { color: var(--muted); font-size: 12px; font-weight: 400; }
.tp-note { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.tp-intro { font-size: 14px; color: var(--muted); margin: 0; max-width: 72ch; }

.of-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 52px;
  padding: 9px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.of-row:last-child { border-bottom: 0; }
.of-row:hover .of-title { color: var(--accent); text-decoration: underline; }
.of-info { min-width: 0; }
.of-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.of-specs { font-size: 12px; color: var(--muted); margin-top: 2px; }
.of-price { text-align: right; flex: none; }
.of-price b { font-size: 14px; font-variant-numeric: tabular-nums; display: block; }
.of-delta { font-size: 12px; font-weight: 700; }
.of-delta.oferta { color: var(--good); } .of-delta.caro { color: var(--match); }

/* ------------------------------ Cerros ---------------------------- */
.zona-h { grid-column: 1 / -1; font-family: var(--serif); font-weight: 500; font-size: 21px; margin: 10px 0 -4px; }
.zona-h small { font-family: 'Inter', sans-serif; font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.cerro-card { display: flex; flex-direction: column; gap: 8px; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 15px;
  box-shadow: var(--shadow); transition: box-shadow var(--t), border-color var(--t); }
.cerro-card:hover { box-shadow: var(--shadow-h); border-color: var(--accent); }
.cerro-card.nucleo { border-left: 4px solid var(--match); }
.cerro-card.turistico { border-left: 4px solid var(--accent); }
.cc-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.cc-nombre { font-family: var(--serif); font-size: 18px; font-weight: 500; }
.cc-n { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.cc-precio { font-size: 13px; color: var(--muted); }
.cc-precio b { font-family: var(--serif); font-size: 19px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.cc-datos { display: flex; flex-wrap: wrap; gap: 6px; }
.cc-cta { font-size: 13px; font-weight: 600; color: var(--accent); }
.asc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 18px; margin: 0; padding: 0; list-style: none; }
.asc-list li { font-size: 13px; display: flex; gap: 8px; align-items: baseline; }
.asc-list .st { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 5px; flex: none; }
.asc-list .st.si { background: rgba(59,110,88,.14); color: var(--good); }
.asc-list .st.no { background: rgba(116,112,105,.15); color: #57534d; }
.asc-list small { color: var(--muted); }

/* ------------------------ Análisis temporal ----------------------- */
.ts-block { margin-bottom: 22px; }
.ts-title { font-size: 13.5px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.ts-scroll { overflow-x: auto; }
.ts-chart { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding-top: 18px; min-width: 100%; }
.ts-col { flex: 1 0 34px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 34px; }
.ts-val { font-size: 10.5px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.ts-bar { width: 64%; max-width: 40px; background: var(--accent); border-radius: 5px 5px 0 0; }
.ts-col:first-child .ts-bar { background: var(--match); }
.ts-x { font-size: 10px; color: var(--muted); white-space: nowrap; }
.ts-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px;
  padding: 8px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.ts-row:last-child { border-bottom: 0; }
.ts-t { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-row:hover .ts-t { color: var(--accent); text-decoration: underline; }
.ts-d { font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.ts-d.baja { color: var(--good); } .ts-d.sube { color: var(--match); } .ts-d.nuevo { color: var(--accent); }
.ts-empty { color: var(--muted); font-size: 13px; }
.cmp-controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.cmp-controls label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.cmp-controls select { font-size: 14px; font-weight: 600; color: var(--ink); min-height: 44px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.cmp-arrow { font-size: 18px; color: var(--accent); padding-bottom: 10px; }
.cmp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 18px; }
.cmp-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.cmp-lists h4 { font-size: 13.5px; margin: 0 0 6px; }

/* ----------------------------- Método ----------------------------- */
.met-tag { display: inline-block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--accent); margin-bottom: 6px; }
.met, .met-intro { font-size: 14.5px; line-height: 1.6; color: #333a46; margin: 0 0 10px; max-width: 72ch; }
.met-intro { font-size: 16px; }
ul.met, ol.met { padding-left: 20px; }
ul.met li, ol.met li { margin-bottom: 6px; }
.met-formula { font-size: 14px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--match);
  border-radius: 8px; padding: 10px 12px; margin: 8px 0 10px; }
.met a { color: var(--accent); }

/* ----------------------------- Vacío ------------------------------ */
.empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h3 { font-family: var(--serif); font-weight: 500; font-size: 22px; color: var(--ink); margin: 0 0 8px; }
.empty .btn { flex: none; margin-top: 12px; }

/* --------------------------- Responsive --------------------------- */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
  .metrics-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .topbar { padding: 20px 24px 18px; }
  .update-bar { padding: 10px 24px; }
  .content { padding: 20px 24px 120px; }
  .tabs-row { padding: 0 16px; }
}
@media (min-width: 1000px) {
  /* cuatro pastillas no caben al medio: van en su propia fila bajo la marca */
  .topbar { grid-template-columns: 1fr auto; align-items: center; gap: 14px 28px; }
  .busqueda { grid-column: 1 / -1; order: 3; }
  .busqueda span { white-space: nowrap; }
  .stats { display: flex; justify-self: end; }
  .layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); align-items: start; }
  .content { padding: 22px 28px 60px; }
  .filters { position: sticky; top: var(--tabs-h); left: auto; right: auto; bottom: auto; z-index: 1;
    height: calc(100vh - var(--tabs-h)); border-radius: 0; box-shadow: none; transform: none; visibility: visible;
    transition: none; border-right: 1px solid var(--line); }
  .filters-head { padding: 14px 12px 6px 20px; border-bottom: 0; }
  .filters-body { padding: 8px 20px 28px; }
  .filters-foot, .filters-head .cerrar, .dock, .velo { display: none !important; }
  .card:hover { box-shadow: var(--shadow-h); transform: translateY(-3px); }
  #map { height: calc(100vh - var(--tabs-h) - 130px); }
}

@media (min-width: 1500px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .busqueda { grid-column: auto; order: 0; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .card:hover { transform: none; }
}
