/* ============================================================
   CaptaLead — estilos
   ============================================================ */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --brand: #0d7a63;
  --brand-2: #0a5f4d;
  --brand-soft: #e3f3ee;
  --brand-ink: #ffffff;
  --side: #0b1220;
  --side-ink: #cbd5e1;
  --side-active: #16233a;
  --hot: #c2410c;
  --hot-soft: #fff1e7;
  --warm: #b45309;
  --warm-soft: #fef6e4;
  --ok: #047857;
  --ok-soft: #e7f6ef;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --info: #1d4ed8;
  --info-soft: #e8efff;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .18);
  --r: 12px;
  --r-sm: 8px;
  --fuente: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1018; --panel: #121a26; --panel-2: #0f1620; --ink: #e5ebf3; --ink-2: #c3cdda; --muted: #8b98aa;
    --line: #223044; --line-2: #2f3f56; --brand: #2fb391; --brand-2: #4cc7a6; --brand-soft: #123a31; --brand-ink: #04140f;
    --side: #070b12; --side-ink: #aab6c6; --side-active: #142033;
    --hot: #fb923c; --hot-soft: #3a2113; --warm: #fbbf24; --warm-soft: #33270f; --ok: #34d399; --ok-soft: #10302a;
    --bad: #f87171; --bad-soft: #3a1717; --info: #93b4ff; --info-soft: #17233f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 10px 40px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1018; --panel: #121a26; --panel-2: #0f1620; --ink: #e5ebf3; --ink-2: #c3cdda; --muted: #8b98aa;
  --line: #223044; --line-2: #2f3f56; --brand: #2fb391; --brand-2: #4cc7a6; --brand-soft: #123a31; --brand-ink: #04140f;
  --side: #070b12; --side-ink: #aab6c6; --side-active: #142033;
  --hot: #fb923c; --hot-soft: #3a2113; --warm: #fbbf24; --warm-soft: #33270f; --ok: #34d399; --ok-soft: #10302a;
  --bad: #f87171; --bad-soft: #3a1717; --info: #93b4ff; --info-soft: #17233f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 10px 40px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--fuente); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.bold { font-weight: 600; }
.nowrap { white-space: nowrap; }
.break { word-break: break-word; overflow-wrap: anywhere; }
.right { margin-left: auto; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.stack-sm > * + * { margin-top: 6px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } }

.dos-col { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .dos-col { grid-template-columns: minmax(0, 1fr); } }
.mt { margin-top: 16px; }
.mt-sm { margin-top: 8px; }

/* ── Estructura ── */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; }
.marca { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.marca svg { width: 30px; height: 30px; flex: none; }
.marca small { display: block; font-weight: 500; font-size: 11px; color: var(--side-ink); opacity: .8; letter-spacing: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--side-ink); font-weight: 500; }
.nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.nav a.activo { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #2fb391; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .sep { height: 1px; background: rgba(255, 255, 255, .07); margin: 10px 6px; }
.lateral-pie { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, .07); font-size: 12px; }
.lateral-pie .quien { color: #fff; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lateral-pie button { background: none; border: 0; color: var(--side-ink); padding: 0; cursor: pointer; text-decoration: underline; font-size: 12px; }
.lateral-pie button:hover { color: #fff; }
.principal { min-width: 0; display: flex; flex-direction: column; }
.barra { display: flex; align-items: center; gap: 12px; padding: 16px 28px; background: var(--bg); position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--line); }
.barra h1 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.barra .acciones { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn-menu { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--ink); }
.contenido { padding: 24px 28px 64px; max-width: 1400px; width: 100%; }
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.abierta { transform: none; box-shadow: var(--shadow-lg); }
  .btn-menu { display: inline-flex; }
  .barra { padding: 12px 16px; }
  .barra h1 { font-size: 17px; }
  .contenido { padding: 16px 16px 64px; }
}

/* ── Tarjetas ── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-cab { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-cab h2, .card-cab h3 { font-size: 15px; font-weight: 650; }
.card-cuerpo { padding: 16px 18px; }
.seccion-titulo { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.vacio { padding: 36px 18px; text-align: center; color: var(--muted); }
.vacio .icono { font-size: 30px; margin-bottom: 8px; }

/* ── KPIs ── */
.kpi { padding: 16px 18px; }
.kpi .etq { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .valor { font-size: 28px; font-weight: 750; letter-spacing: -.02em; margin-top: 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.medidor { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 8px; }
.medidor > div { height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.embudo { display: flex; gap: 2px; height: 10px; border-radius: 99px; overflow: hidden; background: var(--line); }
.embudo > div { height: 100%; }
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.leyenda i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ── Botones ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--panel); color: var(--ink); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; text-decoration: none; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-pri { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-pri:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-wapp { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn-wapp:hover { background: #178a45; border-color: #178a45; }
.btn-peligro { color: var(--bad); }
.btn-peligro:hover { border-color: var(--bad); }
.btn-txt { border-color: transparent; background: transparent; padding: 6px 8px; color: var(--muted); }
.btn-txt:hover { color: var(--ink); border-color: transparent; background: var(--panel-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 18px; font-size: 14px; }
.btn-bloque { width: 100%; }

/* ── Formularios ── */
.campo { display: block; }
.campo > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.campo > small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.input, select.input, textarea.input { width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--panel); color: var(--ink); outline: none; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.input { resize: vertical; min-height: 70px; line-height: 1.45; }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 13px; }
.check input { margin-top: 3px; accent-color: var(--brand); }
.form-seccion { padding: 18px; border-bottom: 1px solid var(--line); }
.form-seccion:last-child { border-bottom: 0; }
.form-seccion h3 { font-size: 15px; font-weight: 650; }
.form-seccion > p.muted { margin: 2px 0 14px; font-size: 12.5px; }

/* ── Chips y badges ── */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2); white-space: nowrap; }
.chip-hot { background: var(--hot-soft); color: var(--hot); border-color: transparent; }
.chip-warm { background: var(--warm-soft); color: var(--warm); border-color: transparent; }
.chip-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.chip-brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.filtros { display: flex; flex-wrap: wrap; gap: 6px; }
.filtro { padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--panel); font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.filtro:hover { border-color: var(--brand); }
.filtro.on { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.filtro .n { opacity: .6; margin-left: 3px; font-weight: 500; }

/* ── Puntuación ── */
.nota { --c: var(--muted); width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--line) 0); }
.nota::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--panel); }
.nota b { position: relative; font-size: 14px; font-weight: 750; color: var(--ink); }
.nota-alta { --c: var(--ok); }
.nota-media { --c: #d4a017; }
.nota-baja { --c: var(--hot); }
.nota-gris { --c: var(--line-2); }
.nota-lg { width: 64px; height: 64px; }
.nota-lg::before { inset: 5px; }
.nota-lg b { font-size: 19px; }

/* ── Lista de leads ── */
.lista-leads { display: flex; flex-direction: column; }
.fila-lead { display: grid; grid-template-columns: 46px minmax(0, 2.2fr) minmax(0, 1.6fr) minmax(0, 1.2fr) 120px; gap: 14px; align-items: center;
  padding: 12px 18px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.fila-lead:last-child { border-bottom: 0; }
.fila-lead:hover { background: var(--panel-2); }
.fila-lead .empresa { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-lead .meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-lead .chips { display: flex; flex-wrap: wrap; gap: 4px; }
.fila-lead .contacto { font-size: 12px; color: var(--ink-2); min-width: 0; }
.fila-lead .contacto div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-lead.descartada { opacity: .62; }
@media (max-width: 1000px) {
  .fila-lead { grid-template-columns: 46px minmax(0, 1fr) auto; }
  .fila-lead > :last-child { grid-column: 3; grid-row: 1; }
  .fila-lead .col-chips, .fila-lead .contacto { grid-column: 2 / -1; }
}

/* ── Estados ── */
.estado { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.e-Nuevo { background: var(--brand-soft); color: var(--brand); }
.e-Contactado { background: var(--info-soft); color: var(--info); }
.e-Respondió, .e-Reunión { background: var(--warm-soft); color: var(--warm); }
.e-Ganado { background: var(--ok); color: #fff; }
.e-Perdido, .e-Descartado, .e-Descartado-IA { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

/* ── Progreso de búsqueda ── */
.log { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow-y: auto; font-size: 12.5px; }
.log li { display: flex; gap: 8px; padding: 4px 0; align-items: flex-start; }
.log li .ic { width: 16px; flex: none; text-align: center; }
.log .t-buscar { font-weight: 650; color: var(--ink); }
.log .t-info { color: var(--muted); }
.log .t-ok { color: var(--ok); font-weight: 600; }
.log .t-no { color: var(--muted); }
.log .t-error { color: var(--bad); }
.log .t-aviso { color: var(--warm); }
.log .t-fin { font-weight: 700; color: var(--ink); }
.log a { color: inherit; text-decoration: underline; }
.contadores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.contadores > div { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; text-align: center; }
.contadores b { display: block; font-size: 20px; }
.contadores span { font-size: 11px; color: var(--muted); }
.girando { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: girar .7s linear infinite; vertical-align: -2px; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ── Campañas ── */
.campana-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; cursor: pointer; transition: border-color .15s, transform .15s; }
.campana-card:hover { border-color: var(--brand); }
.campana-card h3 { font-size: 16px; }
.campana-card .oferta { color: var(--ink-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.stats { display: flex; gap: 18px; font-size: 12px; color: var(--muted); }
.stats b { display: block; font-size: 18px; color: var(--ink); }
.plantilla { text-align: left; padding: 16px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); cursor: pointer; }
.plantilla:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.plantilla h4 { font-size: 14px; margin-bottom: 4px; }

/* ── Panel lateral del lead ── */
.velo { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 50; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--bg); z-index: 51; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: entrar .18s ease-out; }
@keyframes entrar { from { transform: translateX(30px); opacity: 0; } }
.drawer-cab { padding: 18px 22px 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.drawer-cab h2 { font-size: 20px; letter-spacing: -.01em; }
.drawer-cuerpo { flex: 1; overflow-y: auto; padding: 18px 22px 40px; }
.pestanas { display: flex; gap: 2px; margin-top: 14px; overflow-x: auto; }
.pestanas button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 12px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.pestanas button.on { color: var(--ink); border-bottom-color: var(--brand); }
.acciones-lead { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.dato { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.dato:last-child { border-bottom: 0; }
.dato > span:first-child { color: var(--muted); }
.lista { margin: 4px 0 0; padding-left: 18px; }
.lista li { margin: 3px 0; }
.red { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); }
.red .logo { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px; flex: none; }
.red .met { font-size: 12px; color: var(--muted); }
.burbuja { background: #dcf8c6; color: #111b21; border-radius: 10px 10px 2px 10px; padding: 9px 11px; white-space: pre-wrap; font-size: 13.5px; max-width: 92%; margin-left: auto; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.fondo-wapp { background: #efe7de; border-radius: var(--r-sm); padding: 12px; }
.correo-prev { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); padding: 14px; white-space: pre-wrap; font-size: 13.5px; }
.linea-tiempo { list-style: none; margin: 0; padding: 0; }
.linea-tiempo li { padding: 6px 0 6px 14px; border-left: 2px solid var(--line); font-size: 12.5px; }

/* ── Tablas ── */
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.tabla td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabla tr:last-child td { border-bottom: 0; }
.scroll-x { overflow-x: auto; }

/* ── Modales y avisos ── */
.modal-fondo { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: 90vh; overflow-y: auto; }
.modal-ancho { width: min(860px, 100%); }
.modal-cab { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-cab h3 { font-size: 16px; }
.modal-cuerpo { padding: 18px 20px; }
.modal-pie { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.cerrar { margin-left: auto; background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(520px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--panel); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; display: flex; gap: 12px; align-items: center; width: 100%; }
.toast.error { background: var(--bad); color: #fff; }
.toast button { background: none; border: 1px solid currentColor; color: inherit; border-radius: 6px; padding: 3px 8px; cursor: pointer; font-weight: 600; font-size: 12px; margin-left: auto; white-space: nowrap; }
.aviso { padding: 10px 12px; border-radius: var(--r-sm); font-size: 12.5px; background: var(--warm-soft); color: var(--warm); }
.aviso-info { background: var(--info-soft); color: var(--info); }
.aviso-bad { background: var(--bad-soft); color: var(--bad); }
.cargando { padding: 48px; text-align: center; color: var(--muted); }

/* ── Acceso ── */
.acceso { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 10% -10%, var(--brand-soft), transparent), var(--bg); }
.acceso-caja { width: min(420px, 100%); }
.acceso .marca { color: var(--ink); justify-content: center; padding-bottom: 22px; font-size: 22px; }
.acceso .marca small { color: var(--muted); }
