:root {
  --paper: #f3ebe0;
  --paper-2: #e9dfd0;
  --ink: #1b1610;
  --ink-soft: #5b5248;
  --line: rgba(27, 22, 16, 0.12);
  --terracotta: #c24b1b;
  --terracotta-deep: #8f3310;
  --olive: #2f3d2c;
  --sand: #d8c4a4;
  --white: #fffaf4;
  --shadow: 0 18px 50px rgba(27, 22, 16, 0.12);
  --radius: 22px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Sora", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
}

body {
  background-image:
    radial-gradient(1200px 500px at 10% -10%, rgba(194, 75, 27, 0.08), transparent 50%),
    radial-gradient(800px 400px at 100% 0%, rgba(47, 61, 44, 0.08), transparent 45%);
}

body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 1;
  opacity: .18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

button, input, select { font: inherit; color: inherit; }
a { color: inherit; }

.app {
  position: relative;
  z-index: 2;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(243, 235, 224, 0.86);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--olive);
  color: var(--white);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand p {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.count-pill {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.82rem;
}

.count-pill strong { font-family: var(--font-display); font-size: 1.05rem; }

.fav-bar {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.82rem;
}

.fav-bar strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin-left: 4px;
}

.fav-bar.active {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: white;
}

.fav-bar:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.pdf-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(27, 22, 16, 0.55);
  place-items: center;
}

.pdf-overlay.open { display: grid; }

.pdf-box {
  background: var(--white);
  border-radius: 22px;
  padding: 22px 26px;
  min-width: 260px;
  box-shadow: var(--shadow);
}

.pdf-box p {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.pdf-box span { color: var(--ink-soft); font-size: 0.9rem; }

.fav-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 250, 244, 0.92);
  color: #b9aea3;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(27, 22, 16, 0.12);
}

.fav-toggle.is-on {
  color: var(--terracotta);
  background: #fff;
}

.fav-chip.active {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: white;
}

.view-switch {
  display: flex;
  background: var(--olive);
  padding: 4px;
  border-radius: 999px;
}

.view-switch button {
  border: 0;
  background: transparent;
  color: #d9d3c6;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.view-switch button.active {
  background: var(--white);
  color: var(--ink);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.filter {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.filter label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.filter input, .filter select {
  border: 0;
  background: transparent;
  outline: none;
}

.filter.grow { flex: 1; min-width: 220px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chip {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.chip.active {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: white;
}

.explore {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(340px, 42%) 1fr;
  min-height: 0;
}

.explore.map-only .list-pane { display: none; }
.explore.map-only { grid-template-columns: 1fr; }
.explore.list-only .map-pane { display: none; }
.explore.list-only { grid-template-columns: 1fr; }

.list-pane {
  overflow: auto;
  padding: 18px 18px 40px;
  max-height: calc(100vh - 168px);
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 16px;
}

.list-head h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  letter-spacing: -0.04em;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  background: var(--white);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 1px 0 var(--line);
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
}

.card:hover, .card.is-active {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.card-photo {
  position: relative;
  aspect-ratio: 4/3;
  background: var(--paper-2);
  overflow: hidden;
}

.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: #f3c56b;
  color: var(--ink);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.card-body { padding: 14px 14px 16px; }

.card-body .meta {
  color: var(--ink-soft);
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.card-body h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.price {
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.specs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.map-pane {
  position: relative;
  min-height: 520px;
}

#map {
  position: absolute;
  inset: 0;
}

.cluster-wrap { background: none !important; border: 0 !important; }
.cluster {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--olive);
  color: var(--white);
  display: grid;
  place-items: center;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(27,22,16,.22);
}

.price-pin { background: none !important; border: 0 !important; }
.price-tag {
  background: white;
  border: 1px solid rgba(27,22,16,.12);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(27,22,16,.16);
  white-space: nowrap;
}

.price-tag.active {
  background: var(--terracotta);
  color: white;
  border-color: var(--terracotta);
  z-index: 400;
}

.price-tag.tag-delta { border-color: #2f3d2c; }
.price-tag.tag-delta.active {
  background: var(--olive);
  border-color: var(--olive);
}

.badge-agency {
  position: absolute;
  bottom: 10px;
  left: 12px;
  background: rgba(27, 22, 16, 0.82);
  color: white;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.badge-agency.agency-delta { background: var(--olive); }
.badge-agency.agency-objetiva { background: var(--terracotta); }

.leaflet-tooltip {
  border: 0;
  border-radius: 16px;
  padding: 0;
  box-shadow: var(--shadow);
  overflow: hidden;
  background: var(--white);
}

.leaflet-tooltip-top:before { display: none; }

.popup-card img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  display: block;
}

.popup-card .txt { padding: 10px 12px 12px; }
.popup-card strong { display: block; font-family: var(--font-display); font-size: 1.05rem; }
.popup-card span { color: var(--ink-soft); font-size: 0.78rem; }

.detail {
  display: none;
}

.detail.open { display: block; }
.explore.hidden { display: none; }

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 22px 72px;
}

.gallery figure {
  margin: 0;
  border-radius: 18px;
  overflow: hidden;
  background: var(--paper-2);
  aspect-ratio: 4 / 3;
}

.gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.album-count {
  grid-column: 1 / -1;
  color: var(--ink-soft);
  font-size: 0.82rem;
  padding: 4px 2px 0;
}

.detail-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 28px;
  padding: 12px 22px 28px;
}

.kicker {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--terracotta-deep);
  margin-bottom: 8px;
}

.detail h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.4rem);
  letter-spacing: -0.045em;
  line-height: 0.95;
  margin-bottom: 12px;
}

.detail .lead {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink-soft);
  max-width: 68ch;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin: 22px 0;
}

.stat {
  background: var(--white);
  border-radius: 18px;
  padding: 14px;
  border: 1px solid var(--line);
}

.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.4rem;
}

.stat span { font-size: 0.75rem; color: var(--ink-soft); }

.amenity-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.amenity-list span {
  background: var(--paper-2);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.82rem;
}

.side-card {
  background: var(--white);
  border-radius: 28px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.side-card .big-price {
  font-family: var(--font-display);
  font-size: 2.2rem;
  letter-spacing: -0.04em;
}

.side-card .old {
  text-decoration: line-through;
  color: var(--ink-soft);
  margin-left: 8px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 13px 16px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.btn-primary { background: var(--terracotta); color: white; }
.btn-ghost { background: var(--paper-2); }

#detail-map {
  height: 280px;
  border-radius: 20px;
  margin-top: 14px;
  overflow: hidden;
}

.empty {
  padding: 40px 10px;
  color: var(--ink-soft);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 8, 0.88);
  display: none;
  place-items: center;
  z-index: 80;
  padding: 24px;
}

.lightbox.open { display: grid; }

.lightbox figure { margin: 0; text-align: center; }

.lightbox img {
  max-width: min(1100px, 84vw);
  max-height: 80vh;
  border-radius: 16px;
}

.lightbox figcaption {
  color: #f3ebe0;
  margin-top: 10px;
  font-size: 0.9rem;
}

.lb-close, .lb-nav {
  position: absolute;
  border: 0;
  background: rgba(255,250,244,.12);
  color: white;
  cursor: pointer;
  border-radius: 999px;
}

.lb-close {
  top: 18px;
  right: 22px;
  width: 42px;
  height: 42px;
  font-size: 1.6rem;
}

.lb-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  font-size: 2rem;
}

.lb-prev { left: 18px; }
.lb-next { right: 18px; }

.note {
  padding: 10px 22px 18px;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

@media (max-width: 980px) {
  .explore { grid-template-columns: 1fr; }
  .map-pane { min-height: 55vh; }
  .list-pane { max-height: none; }
  .gallery { grid-template-columns: 1fr 1fr; }
  .detail-wrap { grid-template-columns: 1fr; }
  .side-card { position: static; }
  .topbar { flex-wrap: wrap; }
}
