:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e6e9ef;
  --text: #1b2430;
  --muted: #6b7686;
  --primary: #0f766e;
  --primary-600: #0d655e;
  --primary-50: #ecfdf9;
  --accent: #f59e0b;
  --good: #15803d;
  --good-bg: #dcfce7;
  --mid: #0f766e;
  --mid-bg: #d6f3ee;
  --low: #64748b;
  --low-bg: #eef1f5;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 28px; height: 62px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #2dd4bf);
  display: grid; place-items: center; color: #fff; font-weight: 800;
}
.nav { display: flex; gap: 6px; margin-left: auto; }
.nav a {
  color: var(--muted); padding: 8px 14px; border-radius: 9px; font-weight: 500; font-size: .95rem;
}
.nav a:hover { background: var(--primary-50); color: var(--primary); text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }

/* ---------- Layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 28px 24px 56px; }
.page-header { margin-bottom: 22px; }
.page-header h1 { margin: 0 0 4px; font-size: 1.6rem; }
.page-header p { margin: 0; color: var(--muted); }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.9rem; font-weight: 700; margin-top: 6px; }

/* ---------- Card / surface ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { margin: 0; font-size: 1.05rem; }
.panel-body { padding: 20px; }

/* ---------- Filters ---------- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .8rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; }
.field input, .field select {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; font-size: .95rem; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.field input:disabled, .field select:disabled { background: #f3f5f8; color: var(--muted); cursor: not-allowed; }

/* UF/Cidade/Bairro: busca + checklist (opt-in) */
.checklists { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.checklists-3 { grid-template-columns: 0.7fr 1fr 1fr; margin-top: 0; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.cl-clear { margin-top: 8px; align-self: flex-start; color: var(--muted); }
.cl-clear:hover { color: var(--primary); border-color: var(--primary); }
.cl-clear:disabled { opacity: .45; cursor: not-allowed; }
.count { font-size: .72rem; color: var(--primary); font-weight: 700; margin-left: 8px;
  background: var(--primary-50); padding: 1px 8px; border-radius: 999px; }
.cl-search {
  width: 100%; padding: 9px 11px 9px 34px !important; border: 1px solid var(--border);
  border-radius: 9px; font-size: .92rem;
  background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="%236b7686" stroke-width="2" stroke-linecap="round" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4.3-4.3"/></svg>') no-repeat 11px center;
}
.checklist {
  max-height: 190px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px;
  padding: 6px; background: #fff; margin-top: 8px; display: flex; flex-direction: column; gap: 2px;
}
.checklist label { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 8px;
  font-size: .9rem; font-weight: 400; color: var(--text); cursor: pointer; }
.checklist label:hover { background: var(--primary-50); }
.checklist input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex: none; }
.checklist .hint { padding: 12px 10px; }
.checklist::-webkit-scrollbar { width: 11px; }
.checklist::-webkit-scrollbar-thumb { background: #d7dde5; border-radius: 8px; border: 3px solid #fff; }
.checklist::-webkit-scrollbar-thumb:hover { background: #c4ccd6; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-weight: 600; font-size: .95rem; cursor: pointer; transition: .15s;
}
.btn:hover { text-decoration: none; border-color: #cfd6e0; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-ghost { background: transparent; }

/* ---------- Property grid ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 22px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; transition: .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 26px rgba(16,24,40,.10); }
.card-top { padding: 16px 18px 0; display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.card-city { font-weight: 700; font-size: 1.02rem; }
.card-uf { color: var(--muted); font-size: .85rem; }
.card-body { padding: 8px 18px 16px; flex: 1; }
.card-addr { color: var(--muted); font-size: .9rem; min-height: 2.6em; }
.card-prices { display: flex; align-items: baseline; gap: 10px; margin-top: 12px; }
.price { font-size: 1.35rem; font-weight: 800; color: var(--text); }
.price-old { color: var(--muted); text-decoration: line-through; font-size: .9rem; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.tag { font-size: .78rem; color: var(--muted); }

/* ---------- Discount badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px; font-weight: 700; font-size: .82rem; white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.mid  { background: var(--mid-bg);  color: var(--mid); }
.badge.low  { background: var(--low-bg);  color: var(--low); }
.score-chip { font-size: .82rem; color: var(--muted); }
.score-chip b { color: var(--primary); }

/* ---------- Table ---------- */
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: .92rem; }
table.data th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafbfc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 26px; }
.pagination .pages { display: flex; gap: 6px; }
.pagination .muted { color: var(--muted); font-size: .9rem; }

/* ---------- Detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 10px 16px; }
.kv dt { color: var(--muted); font-size: .9rem; }
.kv dd { margin: 0; font-weight: 500; }
.detail-price { font-size: 2.2rem; font-weight: 800; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .big { font-size: 1.1rem; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.alert { padding: 12px 16px; border-radius: 10px; background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; margin-bottom: 18px; }
.notice { padding: 12px 16px; border-radius: 10px; background: var(--primary-50); color: var(--primary-600); border: 1px solid #cdeee7; }
.hint { color: var(--muted); font-size: .88rem; }
.row-gap { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

@media (max-width: 920px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
  .checklists, .checklists-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .nav a { padding: 8px 10px; }
}
