/* ============================================================
   ObtenYA — sistema de diseño (docs/design-system.md)
   Paleta: navy (marca) + verde (acción) + neutros fríos.
   Tipografía: Inter 400/600. Mobile-first.
   ============================================================ */

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

:root {
  /* Marca */
  --navy: #14304e;
  --navy-deep: #0d2138;
  --green: #047857;
  --green-hover: #065f46;
  --green-soft: #e7f4ee;
  --mint: #34d399;

  /* Neutros */
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #16283a;
  --muted: #5b6b7b;

  /* Semánticos */
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #b42318;
  --danger-soft: #fbebe9;
  --neutral-soft: #eef2f6;

  /* Forma */
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow-pop: 0 12px 32px rgba(13, 33, 56, 0.16);
  --ring: 0 0 0 3px rgba(4, 120, 87, 0.15);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

main { flex: 1; }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.2; color: var(--navy); }

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

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.container { max-width: 1080px; margin: 0 auto; padding-inline: 20px; }

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sm { width: 15px; height: 15px; flex-shrink: 0; }

/* Foco visible siempre */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex; align-items: center; gap: 20px;
  height: 60px;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 600; font-size: 1.06rem; color: var(--navy);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; flex-shrink: 0; }

.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: cover;
  object-position: center;
  display: block;
  flex-shrink: 0;
  border-radius: 8px;
}

.topbar-nav { display: flex; gap: 4px; }
.nav-link {
  border: none; background: none; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 0.9rem; color: var(--muted);
  padding: 8px 12px; border-radius: var(--r-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
}
.nav-link:hover { color: var(--text); background: var(--neutral-soft); }
.nav-link.active { color: var(--green); background: var(--green-soft); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip { color: var(--muted); font-size: 0.85rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 640px) {
  .topbar-inner { gap: 10px; }
  .topbar .btn { padding-inline: 12px; }
  .nav-link { padding-inline: 9px; }
  .user-chip { display: none; }
}

/* ===== Botones ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 18px;
  border: 1px solid transparent; border-radius: var(--r-md);
  font: inherit; font-weight: 600; font-size: 0.9rem;
  cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--green); color: var(--green); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--neutral-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9a1e14; text-decoration: none; }
.btn-lg { min-height: 48px; padding: 12px 24px; font-size: 0.95rem; }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: none; border-radius: var(--r-sm);
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--neutral-soft); color: var(--text); }

.link-btn {
  background: none; border: none; padding: 4px 2px;
  font: inherit; font-size: 0.85rem; font-weight: 600;
  color: var(--green); cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.link-btn-danger { color: var(--danger); }

/* ===== Formularios ===== */
label { display: block; font-size: 0.85rem; font-weight: 600; margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font: inherit; font-size: 0.95rem;
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green); box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: #94a3b8; }
textarea { resize: vertical; min-height: 110px; }

.field-error {
  display: flex; align-items: flex-start; gap: 6px;
  color: var(--danger); font-size: 0.85rem; margin-top: 10px;
}
.info-box {
  background: var(--green-soft); color: var(--green-hover);
  padding: 10px 14px; border-radius: var(--r-md);
  font-size: 0.88rem; margin-bottom: 14px; text-align: left;
}
/* Toggle "Filtrar datos con IA": switch estilo iOS bajo el buscador. */
.filtro-ia {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 12px; cursor: pointer; user-select: none;
  font-size: 0.9rem; color: var(--text);
}
.filtro-ia input { position: absolute; opacity: 0; width: 0; height: 0; }
.filtro-ia-switch {
  flex: 0 0 auto; position: relative; width: 40px; height: 22px;
  background: var(--border-strong); border-radius: 999px; transition: background .18s;
}
.filtro-ia-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; background: #fff; border-radius: 50%;
  transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.filtro-ia input:checked + .filtro-ia-switch { background: var(--green); }
.filtro-ia input:checked + .filtro-ia-switch::after { transform: translateX(18px); }
.filtro-ia input:focus-visible + .filtro-ia-switch { box-shadow: var(--ring); }
.filtro-ia-text small { color: var(--muted); font-size: 0.8rem; }
@media (max-width: 620px) {
  .filtro-ia-text small { display: none; }
}

/* Avisos sobre los resultados (filtro de IA activo, no hay más leads). */
#leads-avisos { display: flex; flex-direction: column; gap: 8px; }
#leads-avisos:not(:empty) { margin-bottom: 14px; }
.leads-aviso {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; border-radius: var(--r-md);
  font-size: 0.86rem; line-height: 1.4;
}
.leads-aviso svg { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; }
.leads-aviso-ia {
  background: var(--green-soft); color: var(--green-hover);
  border: 1px solid rgba(4, 120, 87, 0.18);
}
.leads-aviso-tope {
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid rgba(180, 83, 9, 0.2);
}
.leads-aviso strong { font-weight: 600; }

/* Aviso de tope del plan: tono de advertencia, no de error — el cliente no
   hizo nada mal, solo pidió más de lo que su plan cubre. */
.limite-aviso {
  display: flex; align-items: center; gap: 12px;
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid rgba(180, 83, 9, 0.22);
  border-radius: var(--r-md);
  padding: 10px 12px; margin-top: 10px;
  font-size: 0.88rem;
}
.limite-aviso p { flex: 1 1 auto; }
.limite-aviso strong { font-weight: 600; }
.limite-aviso .btn { flex: 0 0 auto; padding: 7px 14px; font-size: 0.85rem; }
.limite-aviso-x { flex: 0 0 auto; color: var(--warn); font-size: 1.1rem; line-height: 1; }
@media (max-width: 620px) {
  .limite-aviso { flex-wrap: wrap; }
  .limite-aviso p { flex-basis: 100%; }
}
.success-box {
  background: var(--green-soft); color: var(--green-hover);
  padding: 12px 14px; border-radius: var(--r-md);
  font-size: 0.9rem; margin-top: 14px;
}

/* ===== Barra de búsqueda (una sola línea) ===== */
/* Base compartida por el hero (landing) y el buscador de la app. El input
   crece con base 280px; nunca definir aquí flex-basis 0 ni max-width sobre el
   formulario: con los dos selectores fijos el input colapsaría a 0px. */
.searchbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  padding: 6px 6px 6px 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.searchbar:focus-within { border-color: var(--green); box-shadow: var(--ring); }
.searchbar > .icon { color: var(--muted); }
.searchbar input {
  flex: 1 1 280px; min-width: 0; border: none; background: transparent;
  padding: 10px 0; font-size: 1rem;
}
.searchbar input:focus { outline: none; box-shadow: none; }
.searchbar .btn { flex: 0 0 auto; }

/* Hero de la landing: [input] [botón]. Se apila solo en pantallas angostas. */
@media (max-width: 560px) {
  .hero .searchbar { flex-wrap: wrap; padding: 6px; }
  .hero .searchbar > .icon { display: none; }
  .hero .searchbar input { padding: 10px 10px; flex-basis: 100%; }
  .hero .searchbar .btn { width: 100%; }
}

/* Buscador de la app:
   [icono] [tipo de negocio] [país] [ciudad] [cantidad] [botón] */
.searchbar-filters { width: 100%; flex-wrap: wrap; }
.searchbar-filters input {
  flex: 1 1 260px;
  min-width: 200px;
  width: auto;
}
.searchbar-filters .searchbar-select {
  flex: 1 1 150px; width: auto; min-width: 130px;
  padding: 8px 10px; font-size: 0.88rem;
  border-color: var(--border);
}
/* La cantidad es un número corto: no necesita el ancho de país/ciudad. */
.searchbar-filters #amount-select { flex: 0 1 120px; min-width: 100px; }
.searchbar-filters .btn { flex: 0 0 auto; }

/* Franja 701–980px: se mantiene en línea pero compacta (sin icono,
   selectores encogibles) para que la fila quepa sin desbordar. */
@media (min-width: 701px) and (max-width: 980px) {
  .searchbar-filters > .icon { display: none; }
  .searchbar-filters input { min-width: 0; }
  .searchbar-filters .searchbar-select { flex: 1 1 120px; min-width: 110px; }
}

/* Bajo 700px la fila ya no cabe: se apila
   [tipo] / [país] / [ciudad] / [cantidad] / [buscar leads], cada uno al 100%. */
@media (max-width: 700px) {
  .searchbar-filters { flex-wrap: wrap; padding: 6px; }
  .searchbar-filters > .icon { display: none; }
  .searchbar-filters input { flex-basis: 100%; min-width: 0; padding: 10px 10px; }
  .searchbar-filters .searchbar-select { flex-basis: 100%; width: 100%; min-width: 0; }
  .searchbar-filters #amount-select { flex-basis: 100%; }
  .searchbar-filters .btn { width: 100%; }
}

/* ===== Landing ===== */
.hero { padding: clamp(48px, 9vh, 96px) 20px 28px; text-align: center; }
.eyebrow {
  display: inline-block;
  color: var(--green); font-size: 0.8rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 14px;
}
.hero h1 {
  font-size: clamp(2rem, 5.5vw, 3rem);
  letter-spacing: -0.025em; max-width: 680px; margin: 0 auto 16px;
}
.hero-sub { color: var(--muted); font-size: 1.05rem; max-width: 560px; margin: 0 auto 28px; }
.hero .searchbar { max-width: 620px; margin: 0 auto; text-align: left; }
.hero .field-error { max-width: 620px; margin-inline: auto; justify-content: center; }
.hero-hint { color: var(--muted); font-size: 0.85rem; margin-top: 14px; }

.hero-demo { max-width: 660px; margin: 36px auto 0; padding-inline: 20px; }
.demo-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden; text-align: left;
}
.demo-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  font-size: 0.82rem; color: var(--muted);
}
.demo-row {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 13px 18px; border-bottom: 1px solid var(--border);
}
.demo-row:last-child { border-bottom: none; }
.demo-name { font-weight: 600; font-size: 0.92rem; }
.demo-meta { color: var(--muted); font-size: 0.8rem; }

.landing-section { padding: 56px 20px; }
.landing-section > h2, .section-head h2 {
  font-size: clamp(1.4rem, 3vw, 1.7rem); letter-spacing: -0.02em;
  text-align: center; margin-bottom: 8px;
}
.section-sub { text-align: center; color: var(--muted); max-width: 520px; margin: 0 auto 36px; }

.steps-grid { display: grid; gap: 20px; grid-template-columns: 1fr; max-width: 960px; margin: 36px auto 0; list-style: none; counter-reset: paso; }
.step { padding: 4px 8px; }
.step-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--green-soft); color: var(--green);
  font-weight: 600; margin-bottom: 12px;
}
.step h3 { font-size: 1rem; margin-bottom: 6px; }
.step p { color: var(--muted); font-size: 0.92rem; }

.features-grid { display: grid; gap: 16px; grid-template-columns: 1fr; max-width: 960px; margin: 36px auto 0; }
.feature {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 22px;
}
.feature .icon { width: 22px; height: 22px; color: var(--green); margin-bottom: 12px; }
.feature h3 { font-size: 1rem; margin-bottom: 6px; }
.feature p { color: var(--muted); font-size: 0.92rem; }

@media (min-width: 720px) {
  .steps-grid, .features-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Planes / precios ===== */
.plans-grid { display: grid; gap: 16px; grid-template-columns: 1fr; max-width: 960px; margin: 36px auto 0; }
@media (min-width: 720px) { .plans-grid { grid-template-columns: repeat(3, 1fr); } }

.plan-card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 26px 22px;
  display: flex; flex-direction: column; gap: 0;
}
.plan-card.featured { border-color: var(--green); }
.plan-tag {
  position: absolute; top: -11px; left: 22px;
  background: var(--green); color: #fff;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
  padding: 3px 10px; border-radius: 999px;
}
.plan-name { font-size: 0.95rem; font-weight: 600; }
.plan-desc { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.plan-price { margin: 16px 0 4px; font-size: 2rem; font-weight: 600; color: var(--navy); letter-spacing: -0.02em; }
.plan-price span { font-size: 0.9rem; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.plan-features { list-style: none; margin: 14px 0 22px; display: grid; gap: 9px; }
.plan-features li { display: flex; gap: 9px; align-items: flex-start; font-size: 0.9rem; color: var(--text); }
.plan-features .icon-sm { color: var(--green); margin-top: 3px; }
.plan-card .btn { margin-top: auto; }
.plan-current {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: auto; min-height: 42px;
  border: 1px dashed var(--border-strong); border-radius: var(--r-md);
  color: var(--muted); font-size: 0.88rem; font-weight: 600;
}

.plans-note { text-align: center; color: var(--muted); font-size: 0.85rem; max-width: 560px; margin: 26px auto 0; }
.pay-method { max-width: 340px; margin: 26px auto 0; text-align: left; }

/* Banda CTA final de la landing */
.cta-band {
  background: var(--navy-deep); color: #fff;
  border-radius: 18px; padding: 48px 24px; text-align: center;
  max-width: 960px; margin: 0 auto;
}
.cta-band h2 { color: #fff; font-size: clamp(1.4rem, 3vw, 1.7rem); letter-spacing: -0.02em; margin-bottom: 8px; }
.cta-band p { color: #b8c4d0; margin-bottom: 24px; }

/* ===== Auth ===== */
.auth-wrap { display: flex; justify-content: center; padding: clamp(32px, 8vh, 80px) 20px 60px; }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 28px;
}
.auth-card h1 { font-size: 1.35rem; letter-spacing: -0.02em; margin-bottom: 4px; }
.auth-card h2 { font-size: 1.15rem; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 18px; }
.auth-back { margin-bottom: 14px; display: inline-flex; align-items: center; gap: 4px; }

.tabs {
  display: flex; gap: 4px; margin-bottom: 18px;
  background: var(--neutral-soft); border-radius: var(--r-md); padding: 4px;
}
.tab {
  flex: 1; min-height: 38px; padding: 7px; border: none; background: transparent;
  border-radius: var(--r-sm); cursor: pointer;
  font: inherit; font-weight: 600; font-size: 0.88rem; color: var(--muted);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(13, 33, 56, 0.1); }

.dev-box {
  margin-top: 16px; padding: 12px; text-align: left;
  background: var(--warn-soft); border: 1px dashed var(--warn);
  border-radius: var(--r-md); font-size: 0.85rem;
}
.dev-box code {
  display: block; margin: 8px 0; padding: 8px;
  background: var(--surface); border-radius: 6px;
  word-break: break-all; font-size: 0.75rem; max-height: 90px; overflow-y: auto;
}

/* ===== App: buscador + uso ===== */
/* Capas de la vista app. El bloque del buscador (tipo de negocio, país,
   ciudad, cantidad) vive en una capa propia por encima de los paneles de
   contenido (historial, resultados, plantillas), y toda su cadena conserva
   overflow visible: nada debe recortar ni tapar los desplegables abiertos.
   Orden resultante: topbar (50) > buscador (20) > paneles de contenido (1). */
.app-head,
.searchbar,
.searchbar-filters { overflow: visible; }
.app-head {
  padding: 28px 20px 0;
  position: relative;
  z-index: 20;
}
.searchbar,
.searchbar-filters { position: relative; z-index: 30; }
.app-layout,
.quick-app-wrap { position: relative; z-index: 1; }
.usage-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  margin-top: 14px; font-size: 0.85rem; color: var(--muted);
}
.chip {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.03em;
}
.chip-navy { background: var(--navy); color: #fff; }
.usage-bar {
  width: 120px; height: 6px; border-radius: 999px;
  background: var(--neutral-soft); overflow: hidden;
}
.usage-bar i {
  display: block; height: 100%; width: 0;
  background: var(--green); border-radius: 999px;
  transition: width 0.3s ease;
}

/* ===== App: layout historial + resultados ===== */
.app-layout {
  display: grid; grid-template-columns: 1fr; gap: 16px;
  align-items: start; padding: 20px 20px 56px;
}
@media (min-width: 900px) { .app-layout { grid-template-columns: 280px minmax(0, 1fr); } }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px;
}
.panel-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 12px; }

/* Historial */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.panel-head .panel-title { margin-bottom: 0; }

.search-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.search-list li { display: flex; align-items: center; gap: 2px; }
.search-item {
  flex: 1; min-width: 0;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px; text-align: left;
  background: none; border: 1px solid transparent; border-radius: var(--r-md);
  font: inherit; cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.search-item:hover { background: var(--bg); }
.search-item.selected { border-color: var(--green); background: var(--green-soft); }
.search-item strong { font-weight: 600; font-size: 0.9rem; display: block; }
.search-item .meta { color: var(--muted); font-size: 0.78rem; }

/* Papelera por búsqueda: discreta, se resalta al pasar el cursor o enfocar */
.search-del { flex-shrink: 0; opacity: 0.45; }
.search-del:hover, .search-del:focus-visible {
  opacity: 1; background: var(--danger-soft); color: var(--danger);
}

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pendiente { color: var(--muted); }
.status-procesando { color: var(--warn); }
.status-procesando::before { animation: pulso 1.2s ease-in-out infinite; }
.status-completa { color: var(--green); }
.status-error { color: var(--danger); }
@keyframes pulso { 50% { opacity: 0.3; } }

/* Panel de resultados */
.leads-header {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 10px; margin-bottom: 8px;
}
.leads-tools { display: flex; align-items: center; gap: 8px; }
.leads-tools select { width: auto; padding: 7px 10px; font-size: 0.85rem; }

/* Menú exportar */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-pop);
}
.menu button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px; border: none; background: none;
  border-radius: var(--r-sm); font: inherit; font-size: 0.88rem;
  color: var(--text); cursor: pointer; text-align: left;
}
.menu button:hover { background: var(--neutral-soft); }
.menu button .icon { color: var(--muted); }
.menu-hint { padding: 4px 12px 8px; color: var(--muted); font-size: 0.75rem; }

/* Lista de leads */
.leads-list { list-style: none; }
.lead-item { border-top: 1px solid var(--border); }
.lead-summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: center; gap: 4px 18px;
  width: 100%; padding: 14px 6px; text-align: left;
  background: none; border: none; font: inherit; cursor: pointer;
  border-radius: var(--r-sm);
  transition: background-color 0.15s ease;
}
.lead-summary:hover { background: var(--bg); }
.lead-main { min-width: 0; }
.lead-name { display: block; font-weight: 600; font-size: 0.95rem; }
.lead-addr { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 1px; }
.lead-channels { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 7px; color: var(--muted); font-size: 0.78rem; }
.lead-channels span { display: inline-flex; align-items: center; gap: 5px; }
.lead-channels .icon-sm { width: 13px; height: 13px; }

.lead-meta { display: flex; align-items: center; gap: 18px; justify-self: end; }
.lead-rating { color: var(--muted); font-size: 0.82rem; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.lead-rating .icon-sm { color: var(--warn); }

.lead-score { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 72px; }
.score-num { font-weight: 600; font-size: 0.95rem; }
.scorebar { width: 72px; height: 5px; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
.scorebar i { display: block; height: 100%; border-radius: 999px; }
.score-alto .score-num { color: var(--green); }
.score-alto .scorebar i { background: var(--green); }
.score-medio .score-num { color: var(--warn); }
.score-medio .scorebar i { background: var(--warn); }
.score-bajo .score-num { color: var(--danger); }
.score-bajo .scorebar i { background: var(--danger); }
.score-na .score-num { color: var(--muted); font-weight: 400; }

.lead-chevron { color: var(--border-strong); }

.flag-revisar {
  display: inline-block; margin-left: 8px; padding: 1px 8px;
  background: var(--warn-soft); color: var(--warn);
  border-radius: 999px; font-size: 0.72rem; font-weight: 600;
  vertical-align: 2px; cursor: help;
}

@media (max-width: 640px) {
  .lead-summary { grid-template-columns: 1fr; }
  .lead-meta { justify-self: stretch; justify-content: space-between; margin-top: 10px; }
  .lead-chevron { display: none; }
}

/* ===== Estados (vacío / carga / error) ===== */
.state { text-align: center; padding: 48px 20px; }
.state .state-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--neutral-soft); color: var(--muted); margin-bottom: 14px;
}
.state .state-icon .icon { width: 22px; height: 22px; }
.state.error .state-icon { background: var(--danger-soft); color: var(--danger); }
.state.loading .state-icon { background: var(--green-soft); color: var(--green); }
.state h3 { font-size: 1rem; margin-bottom: 6px; }
.state p { color: var(--muted); font-size: 0.9rem; max-width: 380px; margin: 0 auto; }

.spinner {
  display: inline-block; width: 22px; height: 22px;
  border: 2.5px solid var(--green-soft); border-top-color: var(--green);
  border-radius: 50%; animation: girar 0.8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.skeleton-list { list-style: none; }
.skeleton-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px; gap: 16px; padding: 16px 6px; border-top: 1px solid var(--border); }
.sk {
  height: 12px; border-radius: 6px;
  background: var(--neutral-soft);
  animation: pulso 1.4s ease-in-out infinite;
}
.sk + .sk { margin-top: 8px; }
.sk.w40 { width: 40%; } .sk.w60 { width: 60%; } .sk.w80 { width: 80%; }

/* ===== Drawer de detalle de lead ===== */
.drawer-overlay, .modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(13, 33, 56, 0.45);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 95;
  width: min(430px, 100vw);
  background: var(--surface); box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}
.drawer[hidden] { display: none; }
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 20px 20px 14px; border-bottom: 1px solid var(--border);
}
.drawer-head h3 { font-size: 1.1rem; letter-spacing: -0.01em; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 28px; }

.drawer-scorebox {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border-radius: var(--r-md); margin-bottom: 20px;
}
.drawer-scorebox.score-alto { background: var(--green-soft); }
.drawer-scorebox.score-medio { background: var(--warn-soft); }
.drawer-scorebox.score-bajo { background: var(--danger-soft); }
.drawer-scorebox.score-na { background: var(--neutral-soft); }
.drawer-scorebox .big { font-size: 1.7rem; font-weight: 600; line-height: 1; }
.drawer-scorebox .label { font-weight: 600; font-size: 0.9rem; }
.drawer-scorebox .sub { color: var(--muted); font-size: 0.8rem; }

.drawer-section { margin-bottom: 22px; }
.drawer-section > h4 {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin-bottom: 10px;
}
.datalist { display: grid; gap: 9px; }
.datalist div { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; }
.datalist .icon-sm { color: var(--muted); margin-top: 3px; }
.datalist a { word-break: break-all; }

.msg-box {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px; font-size: 0.9rem;
  white-space: pre-wrap;
}
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Mini mapa del lead (solo cuando el backend trae lat/lng) */
.drawer-map {
  display: block; width: 100%; height: 190px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--neutral-soft);
}

/* ===== Modales (API / pago) ===== */
.modal-overlay { display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal {
  width: 100%; max-width: 480px;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); padding: 26px;
}
.modal h3 { font-size: 1.15rem; margin-bottom: 6px; }
.modal .modal-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 16px; }
.modal pre {
  background: var(--navy-deep); color: #d7e3ee;
  padding: 14px; border-radius: var(--r-md);
  font-size: 0.78rem; overflow-x: auto; line-height: 1.6;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ===== Toasts ===== */
.toast-root {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; max-width: calc(100vw - 32px);
}
.toast {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--r-md);
  background: var(--navy-deep); color: #fff;
  font-size: 0.9rem; font-weight: 600;
  box-shadow: var(--shadow-pop);
  animation: toast-in 0.2s ease;
}
.toast.error { background: var(--danger); }
.toast .icon-sm { flex-shrink: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Estado de pago */
.pay-state { text-align: center; }
.pay-state .pay-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 54px; height: 54px; border-radius: 50%; margin-bottom: 16px;
}
.pay-state .pay-icon .icon { width: 26px; height: 26px; }
.pay-state.loading .pay-icon { background: var(--green-soft); }
.pay-state.success .pay-icon { background: var(--green-soft); color: var(--green); }
.pay-state.error .pay-icon { background: var(--danger-soft); color: var(--danger); }
.pay-state.info .pay-icon { background: var(--green-soft); color: var(--green); }
.pay-state p { color: var(--muted); font-size: 0.92rem; margin-top: 4px; }
.pay-state .btn { margin-top: 20px; }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 26px 20px; font-size: 0.85rem; color: var(--muted);
}
.footer-inner {
  max-width: 1080px; margin: 0 auto;
  display: flex; flex-wrap: wrap; justify-content: space-between;
  align-items: center; gap: 12px;
}
.footer-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.footer-brand .brand-mark { width: 18px; height: 18px; }
.footer-links { display: flex; gap: 8px 18px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* ===== Páginas de contenido (legales / contacto) ===== */
.content-page { max-width: 720px; margin: 0 auto; padding: 40px 20px 64px; }
.content-page .back-link { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 26px; font-size: 0.88rem; }
.content-page h1 { font-size: clamp(1.5rem, 4vw, 1.9rem); letter-spacing: -0.02em; margin-bottom: 6px; }
.content-page .updated { color: var(--muted); font-size: 0.85rem; margin-bottom: 30px; }
.content-page h2 { margin: 30px 0 8px; font-size: 1.05rem; }
.content-page p, .content-page li { margin: 9px 0; line-height: 1.65; }
.content-page ul, .content-page ol { padding-left: 22px; }

.content-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 24px;
}

/* ===== Tabla explicativa del score de IA ===== */
.score-table-wrap {
  max-width: 960px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow-x: auto;
}
.score-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.score-table th {
  text-align: left; padding: 12px 16px;
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.score-table td {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  vertical-align: top; color: var(--text);
}
.score-table tr:last-child td { border-bottom: none; }
.score-range { font-weight: 600; white-space: nowrap; color: var(--navy); }
.score-pill {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.score-pill.alta { background: var(--green-soft); color: var(--green); }
.score-pill.buena { background: var(--neutral-soft); color: var(--navy); }
.score-pill.media { background: var(--warn-soft); color: var(--warn); }
.score-pill.baja { background: var(--danger-soft); color: var(--danger); }
.score-note {
  max-width: 720px; margin: 18px auto 0; text-align: center;
  color: var(--muted); font-size: 0.9rem;
}

/* En móvil la tabla se apila como tarjetas */
@media (max-width: 640px) {
  .score-table-wrap { background: none; border: none; border-radius: 0; overflow: visible; }
  .score-table thead { display: none; }
  .score-table, .score-table tbody, .score-table tr, .score-table td { display: block; width: 100%; }
  .score-table tr {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: 6px 0; margin-bottom: 10px;
  }
  .score-table td { display: flex; gap: 10px; border: none; padding: 7px 14px; }
  .score-table td::before {
    content: attr(data-label);
    flex-shrink: 0; min-width: 88px;
    font-size: 0.78rem; font-weight: 600; color: var(--muted);
    padding-top: 1px;
  }
}

/* ===== Plantillas de búsqueda ===== */
.quick-sub { color: var(--muted); font-size: 0.85rem; margin: -4px 0 14px; }
.quick-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  max-width: 960px; margin: 0 auto;
}
.quick-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.quick-text { font-weight: 600; font-size: 0.95rem; color: var(--text); }
.quick-actions { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.quick-actions .btn { flex: 1; }

/* El panel de ideas en la app va pegado al layout de resultados */
.quick-app-wrap { padding: 0 20px 56px; margin-top: -40px; }
