/* Hallazgo — estilos MVP */
:root {
  --brand: #0e7c5b;
  --brand-dark: #0a5c44;
  --brand-soft: #e3f2ec;
  --amber: #e8a13c;
  --wa: #25d366;
  --ink: #17211d;
  --muted: #5c6b64;
  --line: #e2e8e5;
  --bg: #f5f7f6;
  --card: #ffffff;
  --danger: #c0442c;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(23, 33, 29, 0.07), 0 6px 20px rgba(23, 33, 29, 0.06);
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Sora', 'Inter', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body); background: var(--bg); color: var(--ink); line-height: 1.5;
  overflow-x: hidden; /* nunca scroll horizontal */
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
button { font-family: inherit; cursor: pointer; }
textarea, input, select { font-family: inherit; font-size: 15px; color: var(--ink); }

/* ---------- topbar ---------- */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; padding-top: env(safe-area-inset-top, 0px); }
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 12px clamp(16px, 4vw, 20px); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-iso { flex: none; }
.brand-icon { font-size: 22px; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 20px; color: var(--ink); letter-spacing: -0.03em; }
.brand-name b { color: var(--brand); font-weight: 800; }
.brand-tag { font-size: 13px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.fx-badge { font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }

/* ---------- stepper ---------- */
.stepper { max-width: 1080px; margin: 18px auto 0; padding: 0 20px; display: flex; gap: 6px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 999px; padding: 7px 14px; font-size: 13.5px; font-weight: 500; transition: all .15s; }
.step[disabled] { opacity: .45; cursor: default; }
.step.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.step.done { border-color: var(--brand); color: var(--brand-dark); }
.step-n { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.08); font-size: 11.5px; font-weight: 700; }
.step.active .step-n { background: rgba(255,255,255,.25); }

/* ---------- layout ---------- */
.main { max-width: 1080px; margin: 0 auto; padding: 22px clamp(16px, 4vw, 20px) 150px; }
.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
h1 { font-family: var(--font-display); font-size: 34px; letter-spacing: -0.03em; line-height: 1.15; }
h2 { font-family: var(--font-display); font-size: 24px; letter-spacing: -0.02em; }
.view-sub { color: var(--muted); font-size: 14.5px; max-width: 640px; margin-top: 4px; }

/* ---------- paso 1 ---------- */
.hero { text-align: center; margin: 40px 0 24px; }
.hero-sub { color: var(--muted); margin-top: 8px; font-size: 16px; }
.search-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; max-width: 760px; margin: 0 auto; }
.search-box textarea { width: 100%; border: none; outline: none; resize: vertical; font-size: 16.5px; line-height: 1.5; min-height: 70px; }
.search-actions { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.examples { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; color: var(--muted); text-align: left; line-height: 1.4; }
.chip-example { border-radius: 10px; } /* frases largas: radio chico para que multilínea no se deforme */
.chip-example:hover { border-color: var(--brand); color: var(--brand-dark); }
.search-status { max-width: 760px; margin: 18px auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; font-size: 14.5px; }
.search-status .spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- búsquedas guardadas ---------- */
.saved-section { max-width: 760px; margin: 34px auto 0; }
.saved-title { font-family: var(--font-display); font-size: 17px; }
.saved-sub { color: var(--muted); font-size: 13px; margin: 2px 0 12px; }
.saved-list { display: flex; flex-direction: column; gap: 10px; }
.saved-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); }
.saved-info { flex: 1; min-width: 0; }
.saved-name { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.saved-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.new-badge { background: var(--amber); color: #3d2a08; border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 800; }
.badge.nueva { background: var(--amber); color: #3d2a08; }
.saved-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------- botones ---------- */
.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; padding: 9px 16px; font-size: 14px; font-weight: 600; transition: all .15s; text-decoration: none; display: inline-flex; align-items: center; gap: 7px; }
.btn:hover { border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--danger); border-color: transparent; }
.btn-lg { padding: 12px 22px; font-size: 15.5px; border-radius: 12px; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { filter: brightness(.93); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- criterios y fuentes ---------- */
.criteria-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.crit-chip { background: var(--brand-soft); color: var(--brand-dark); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; }
.source-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.src-chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 12px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line); background: var(--card); }
.src-chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.src-chip.ok .dot { background: #2ea36b; }
.src-chip.blocked .dot { background: var(--danger); }
.src-chip.error .dot, .src-chip.empty .dot { background: var(--amber); }

/* ---------- toolbar + grid ---------- */
.toolbar { display: flex; align-items: center; gap: 14px; margin: 6px 0 14px; flex-wrap: wrap; }
.result-count { font-size: 14px; color: var(--muted); margin-right: auto; }
.toggle-wrap { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--card); font-size: 13.5px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.pcard { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); position: relative; transition: border-color .15s, transform .1s; }
.pcard.selected { border-color: var(--brand); }
.pcard-img { width: 100%; height: 160px; object-fit: cover; background: #dde5e1; display: block; }
.pcard-noimg { width: 100%; height: 160px; display: flex; align-items: center; justify-content: center; background: #e8eeeb; color: var(--muted); font-size: 34px; }
.pcard-check { position: absolute; top: 10px; left: 10px; width: 26px; height: 26px; accent-color: var(--brand); cursor: pointer; }
.pcard-badges { position: absolute; top: 10px; right: 10px; display: flex; gap: 5px; flex-direction: column; align-items: flex-end; }
.badge { border-radius: 7px; padding: 2px 8px; font-size: 11px; font-weight: 700; background: rgba(23,33,29,.75); color: #fff; }
.badge.barrio { background: var(--amber); color: #3d2a08; }
.badge.dup { background: var(--brand); }
.pcard-body { padding: 12px 14px 14px; }
.pcard-price { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--brand-dark); }
.pcard-price .orig { font-size: 12px; color: var(--muted); font-weight: 500; font-family: var(--font-body); }
.pcard-feats { display: flex; gap: 10px; font-size: 12.5px; color: var(--muted); margin: 3px 0 6px; flex-wrap: wrap; }
.pcard-title { font-size: 13.5px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard-addr { font-size: 12.5px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.src-tag { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--bg); border-radius: 6px; padding: 2px 7px; }
.pcard a.view-link { font-size: 12.5px; color: var(--brand); font-weight: 600; text-decoration: none; }
.pcard a.view-link:hover { text-decoration: underline; }

/* ---------- barra selección ---------- */
.selectbar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); padding: 12px calc(clamp(16px, 4vw, 20px) + env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) calc(clamp(16px, 4vw, 20px) + env(safe-area-inset-left, 0px)); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 14px; z-index: 40; box-shadow: 0 -4px 20px rgba(23,33,29,.08); }
.selectbar > span, .selectbar .engine-note { min-width: 0; }
.selectbar .btn { flex: 0 0 auto; }
@media (max-width: 460px) { .selectbar { justify-content: stretch; } .selectbar .btn { flex: 1 1 auto; justify-content: center; } .selectbar > span:first-child { flex: 1 1 100%; } }
.selectbar span { font-size: 14px; font-weight: 600; }

/* ---------- outreach ---------- */
.progress-badge { background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: 13px; border-radius: 999px; padding: 6px 14px; }
.outreach-list, .responses-list, .visits-list { display: flex; flex-direction: column; gap: 16px; }
.ocard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.ocard.sent { border-color: var(--brand); background: linear-gradient(0deg, rgba(14,124,91,.03), rgba(14,124,91,.03)), var(--card); }
.ocard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.ocard-title { font-weight: 700; font-size: 15px; }
.ocard-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ocard-msg { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 13.5px; line-height: 1.5; min-height: 130px; resize: vertical; background: #fbfcfb; }
.ocard-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.sent-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-left: auto; cursor: pointer; }
.sent-check input { accent-color: var(--brand); width: 17px; height: 17px; }
.phone-note { font-size: 12px; color: var(--muted); }

/* ---------- respuestas / resumen ---------- */
.rcard textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 13.5px; min-height: 90px; resize: vertical; }
.summary { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 12px; display: grid; gap: 8px; }
.sum-verdict { font-weight: 800; font-size: 13px; border-radius: 8px; padding: 3px 10px; display: inline-block; width: fit-content; }
.sum-verdict.recomendada { background: var(--brand-soft); color: var(--brand-dark); }
.sum-verdict.posible { background: #fdf3e2; color: #8a5a12; }
.sum-verdict.descartar { background: #fbe9e5; color: var(--danger); }
.sum-line { font-size: 13.5px; display: flex; gap: 7px; align-items: baseline; }
.sum-line.flag { color: var(--danger); }
.sum-line.hi { color: var(--brand-dark); }
.kv-table { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.kv { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 3px 10px; font-size: 12.5px; }
.kv b { color: var(--brand-dark); }
.engine-note { font-size: 12.5px; color: var(--muted); font-weight: 500; }

/* ---------- visitas ---------- */
.vcard-form { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.vcard-form input[type="date"], .vcard-form input[type="time"] { border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: var(--card); }
.vcard-form input[type="text"] { border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; flex: 1; min-width: 180px; }
.gcal-ok { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 14px; flex-wrap: wrap; }

/* ---------- estado vacío ---------- */
.empty-sources { font-size: 12.5px; color: var(--danger); margin-top: 6px; }

/* ---------- footer ---------- */
.footer { max-width: 1080px; margin: 30px auto 110px; padding: 0 clamp(16px, 4vw, 20px); color: var(--muted); font-size: 12px; }

@media (max-width: 640px) {
  h1 { font-size: 26px; }
  .hero { margin-top: 16px; }
  .search-actions { flex-direction: column; align-items: stretch; }
  .btn-lg { justify-content: center; }
}
@media (max-width: 400px) {
  /* topbar no desborda: marca se encoge, fx-badge se oculta (el dato está en resultados) */
  .brand-name { font-size: 18px; }
  .fx-badge { display: none; }
  .topbar-right .btn { padding: 8px 12px; font-size: 13px; }
}
/* el header sticky no debe tapar el destino de los anclas */
html { scroll-padding-top: 72px; }
