:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --brand: #1a9850;
  --brand-d: #14773f;
  --line: #e2e8f0;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #f1f5f9;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--bg); color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 28px; }
.brand h1 { margin: 0; font-size: 18px; }
.brand p { margin: 0; font-size: 12px; color: #cbd5e1; }
.badge {
  background: var(--brand); color: #fff; padding: 4px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
}

/* Layout */
.layout {
  display: grid; grid-template-columns: 380px 1fr;
  height: calc(100vh - 57px);
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .map-wrap { height: 60vh; }
}

/* Painel */
.panel { background: var(--panel); overflow-y: auto; padding: 18px; border-right: 1px solid var(--line); }
.step { margin-bottom: 26px; }
.step h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; margin: 0 0 14px; }
.step .num {
  display: inline-grid; place-items: center; width: 24px; height: 24px;
  background: var(--brand); color: #fff; border-radius: 50%; font-size: 13px;
}
.hidden { display: none; }
.muted { color: var(--muted); font-size: 13px; }

/* Ramos (filtro) */
.ramos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ramo-cat { grid-column: 1 / -1; font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); margin-top: 6px; }
.ramo {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px;
  cursor: pointer; background: #fff; text-align: left; font-size: 13px;
  transition: .15s; font-weight: 600; color: var(--ink);
}
.ramo:hover { border-color: var(--brand); }
.ramo.sel { border-color: var(--brand); background: #ecfdf3; box-shadow: var(--shadow); }
.ramo small { display: block; font-weight: 400; color: var(--muted); margin-top: 2px; }

/* Questionário */
.q { margin-bottom: 16px; }
.q label.q-title { font-weight: 600; font-size: 13px; display: block; margin-bottom: 6px; }
.q .ajuda { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.opcoes { display: grid; gap: 6px; }
.opcao {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 13px;
}
.opcao:hover { border-color: var(--brand); }
.opcao input { accent-color: var(--brand); }
.q input[type=range] { width: 100%; accent-color: var(--brand); }
.q .range-val { font-weight: 600; color: var(--brand-d); }

/* Botões */
.btn {
  width: 100%; padding: 11px; border-radius: var(--radius); border: none;
  font-size: 14px; font-weight: 700; cursor: pointer; margin-top: 6px;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.primary:disabled { background: #cbd5e1; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }

/* Banner de saúde do setor */
.setor-banner {
  border: 1px solid var(--line); border-left: 5px solid var(--brand);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; background: #f8fafc;
}
.setor-banner .sb-top { font-size: 13px; }
.setor-banner .sb-top small { color: var(--muted); font-weight: 400; }
.setor-banner .sb-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Ranking */
.rank-nota { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.rank-item {
  border: 1px solid var(--line); border-left: 5px solid var(--brand);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #fff;
}
.rank-item h3 { margin: 0 0 4px; font-size: 14px; display: flex; justify-content: space-between; }
.rank-item .score { font-weight: 800; }
.rank-item ul { margin: 6px 0 0; padding-left: 16px; }
.rank-item li { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.bars { display: flex; gap: 4px; margin-top: 8px; }
.bar { flex: 1; text-align: center; }
.bar .track { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--brand); }
.bar small { font-size: 9px; color: var(--muted); }

/* Mapa */
.map-wrap { position: relative; }
#map { width: 100%; height: 100%; }
.legend {
  position: absolute; bottom: 18px; right: 18px; z-index: 1000;
  background: #fff; padding: 10px 12px; border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 12px; max-width: 230px;
}
.legend strong { font-size: 12px; }
.scale { display: flex; height: 10px; border-radius: 4px; overflow: hidden; margin: 6px 0 2px; }
.scale span { flex: 1; }
.scale-labels { display: flex; justify-content: space-between; }
.legend .muted { margin: 6px 0 0; }
.legend .toggle { display: flex; align-items: center; gap: 6px; margin-top: 8px; cursor: pointer; }
.legend .toggle input { accent-color: var(--brand); }
.region-label { font-weight: 700; }

/* Salas comerciais */
.imovel-pin { font-size: 18px; line-height: 22px; text-align: center; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.imovel-chip { font-size: 12px; color: #6b21a8; background: #faf5ff; border: 1px solid #e9d5ff;
  border-radius: 8px; padding: 5px 8px; margin-top: 8px; }
.imovel-chip .muted { color: var(--muted); }

.imovel-chip.clicavel { cursor: pointer; }
.imovel-chip.clicavel:hover { background: #f3e8ff; border-color: #d8b4fe; }

/* Modal de imóveis */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 2000;
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal.hidden { display: none; }
.modal-box { background: #fff; border-radius: 12px; max-width: 560px; width: 100%;
  max-height: 80vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-x { border: none; background: transparent; font-size: 18px; cursor: pointer; color: var(--muted); }
#imoveis-modal-lista { overflow-y: auto; padding: 8px 16px 16px; }
.imovel-item { border-bottom: 1px solid var(--line); padding: 10px 0; }
.imovel-item:last-child { border-bottom: none; }
.imovel-item h4 { margin: 0 0 2px; font-size: 14px; }
.imovel-item .meta { font-size: 12px; color: var(--muted); }
.imovel-item .preco { font-size: 13px; color: #6b21a8; font-weight: 600; }
.imovel-item a { font-size: 13px; color: var(--brand-d); font-weight: 600; }

/* Filtro Bairro */
#bairro-select { width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 8px; font: inherit; margin-bottom: 8px; }
.ramo-rank { border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 8px;
  padding: 8px 10px; margin-top: 8px; font-size: 13px; }
.ramo-rank b { color: var(--brand-d); }
.ramo-rank .pos { display: inline-block; min-width: 18px; font-weight: 700; color: var(--muted); }

/* Pergunta ao analista (IA) */
#step-ia textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px; font: inherit; resize: vertical; }
#pergunta-resposta { margin-top: 10px; }
.ia-resposta { font-size: 13px; line-height: 1.5; background: #f8fafc;
  border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 8px; padding: 10px 12px; }
.ia-resposta p { margin: 0 0 8px; }
.ia-resposta ul { margin: 4px 0 8px; padding-left: 18px; }
.ia-aviso { font-size: 12px; color: #92400e; background: #fffbeb;
  border: 1px solid #fde68a; border-radius: 8px; padding: 8px 10px; }
.ia-aviso code { background: #fef3c7; padding: 1px 4px; border-radius: 3px; }
