:root {
  --red: #e30613;
  --red-dark: #c10510;
  --red-soft: #ffe8ea;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e3e3e3;
  --bg: #f5f5f5;
  --surface: #fff;
  --ok: #0d7a3f;
  --ok-soft: #e5f6ec;
  --warn: #9c5700;
  --warn-soft: #fff2cc;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.04);
  font-family: Manrope, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(1000px 360px at 8% -12%, #ffe5e7 0%, transparent 55%), var(--bg); color: var(--ink); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.app { max-width: 1240px; margin: 0 auto; padding: 16px 16px 40px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--red); color: #fff; font-weight: 800;
  display: grid; place-items: center; font-size: 20px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 18px; }
.brand-text span { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.lead { margin: 0; color: var(--muted); font-weight: 500; }

.search-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.search-label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
#q {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; background: #fff; outline: none;
}
#q:focus { border-color: #f2a0a5; box-shadow: 0 0 0 3px var(--red-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 12px; font-weight: 600; font-size: 13px;
}
.chip.on { background: var(--red); border-color: var(--red); color: #fff; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px;
}
.stat b { display: block; font-size: 22px; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; }

.layout { display: grid; grid-template-columns: 340px 1fr; gap: 12px; align-items: start; }
.list-col {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; box-shadow: var(--shadow);
}
.list-head { padding: 10px 12px; font-weight: 700; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.list { max-height: calc(100vh - 280px); overflow: auto; }
.item {
  width: 100%; text-align: left; border: 0; border-bottom: 1px solid #f0f0f0;
  background: #fff; padding: 10px 12px; display: block;
}
.item:hover, .item.on { background: var(--red-soft); }
.item .addr { font-weight: 700; }
.item .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item .mark { color: var(--ok); font-weight: 700; }

.detail {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  min-height: 360px; padding: 16px; box-shadow: var(--shadow);
}
.empty { color: var(--muted); padding: 40px 12px; text-align: center; }

.house-title { margin: 0 0 4px; font-size: 22px; }
.house-sub { margin: 0 0 14px; color: var(--muted); font-weight: 500; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.kpi { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.kpi.hot { background: var(--warn-soft); border-color: #f0d48a; }
.kpi.ok { background: var(--ok-soft); border-color: #bfe5cb; }
.kpi b { display: block; font-size: 28px; line-height: 1; }
.kpi span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

.porches { display: grid; grid-template-columns: 1fr; gap: 10px; }
.porch {
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fff;
}
.porch.has { background: #fffaf0; border-color: #e6c25a; }
.porch.empty-porch { opacity: .72; }
.porch-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.porch .num { font-weight: 800; font-size: 20px; }
.porch .range { font-size: 13px; color: var(--muted); margin-top: 2px; }
.badge {
  flex-shrink: 0; background: var(--warn); color: #fff; border-radius: 999px;
  padding: 5px 10px; font-weight: 800; font-size: 13px; white-space: nowrap;
}
.badge small { font-size: 10px; font-weight: 700; opacity: .9; }
.badge.quiet { background: #ececec; color: var(--muted); }
.apt-row { display: grid; grid-template-columns: 132px 1fr; gap: 8px; align-items: start; margin-top: 8px; }
.apt-label { font-size: 12px; font-weight: 800; padding-top: 4px; }
.apt-label.mun { color: var(--ok); }
.apt-label.undef { color: #1d4ed8; }
.apt-list { display: flex; flex-wrap: wrap; gap: 6px; }
.apt {
  min-width: 36px; text-align: center; border-radius: 8px;
  padding: 5px 8px; font-weight: 800; font-size: 15px; line-height: 1;
}
.apt.mun { background: var(--ok-soft); color: #085c2e; }
.apt.undef { background: #e8efff; color: #1d4ed8; }
.legend { margin: 14px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.link { display: inline-block; margin-top: 12px; color: var(--red); font-weight: 700; text-decoration: none; }

@media (max-width: 860px) {
  .topbar, .layout { display: block; }
  .lead { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .kpis { grid-template-columns: 1fr; }
  .list { max-height: 280px; margin-bottom: 12px; }
  .apt-row { grid-template-columns: 1fr; }
}
