/* =========================================================
   Helix · Screens (Inbox, Lead Detail, Insights, Settings)
   ========================================================= */

.helix-app .helix-loading,
.helix-app .helix-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

/* ---------- Inbox ---------- */
.helix-app .helix-inbox-scroll {
  padding-bottom: 32px;
}

.helix-app .helix-inbox-search-wrap {
  padding: 0 16px 12px;
}
.helix-app .helix-inbox-search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-1);
  border-radius: var(--r-md);
  color: var(--text-3);
  box-shadow: var(--shadow-1);
}
.helix-app .helix-inbox-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-ring);
}
.helix-app .helix-inbox-search input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-1);
}
.helix-app .helix-inbox-search input::placeholder { color: var(--text-3); }

.helix-app .helix-inbox-section { margin-bottom: 16px; }
.helix-app .helix-inbox-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 20px 10px;
}
.helix-app .helix-inbox-section-label-muted {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.helix-app .helix-inbox-section-body {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-1);
  border-bottom: 1px solid var(--border-1);
}

/* ---------- Lead detail ---------- */
.helix-app .helix-lead-detail {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--bg-page);
}
.helix-app .helix-lead-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-1);
  flex-shrink: 0;
}
.helix-app .helix-lead-detail-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.helix-app .helix-lead-detail-title-text {
  min-width: 0;
  flex: 1;
}
.helix-app .helix-lead-detail-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.helix-app .helix-lead-detail-meta {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.helix-app .helix-lead-detail-phone {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;        /* el teléfono NO se parte en vertical (fix recorte) */
  overflow: hidden;
  text-overflow: ellipsis;
}
.helix-app .helix-meta-heat { color: var(--text-3); white-space: nowrap; }
/* Barra de contexto bajo la cabecera (status badges relocalizados) */
.helix-app .helix-lead-context-bar {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-1);
}
/* Action bar sobre el input (Llamar · Pre-llamada · Más relocalizados del header) */
.helix-app .helix-lead-detail-actionbar {
  display: flex; gap: 6px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-1);
}
.helix-app .helix-actionbar-btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; border-radius: var(--r-md);
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-2); text-decoration: none;
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
}
.helix-app .helix-actionbar-btn:hover { background: var(--bg-sunken); }
.helix-app .helix-actionbar-btn:active { background: var(--bg-sunken); }
.helix-app .helix-actionbar-btn.is-done { color: var(--accent); }

.helix-app .helix-lead-detail-chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.helix-app .helix-lead-detail-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-1);
  flex-shrink: 0;
}
.helix-app .helix-lead-detail-input {
  flex: 1;
  border: 1px solid var(--border-1);
  background: var(--bg-sunken);
  border-radius: 18px;
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-1);
  resize: none;
  outline: 0;
  max-height: 120px;
}
.helix-app .helix-lead-detail-input:focus {
  background: var(--bg-elevated);
  border-color: var(--accent);
}
.helix-app .helix-lead-detail-send {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
}
.helix-app .helix-lead-detail-send:hover { background: var(--accent-hover); color: #fff; }

/* ---------- Insights ---------- */
.helix-app .helix-insights {
  padding: 20px;
  max-width: 1280px;
  margin: 0 auto;
}
.helix-app .helix-insights-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
/* ---------- Settings ---------- */
.helix-app .helix-settings {
  padding: 20px;
  max-width: 720px;
  margin: 0 auto;
}
.helix-app .helix-settings-header {
  margin-bottom: 20px;
}
.helix-app .helix-settings-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
}
.helix-app .helix-settings-section .t-eyebrow {
  margin-bottom: 10px;
}
.helix-app .helix-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-2);
}
.helix-app .helix-setting-row:last-child { border-bottom: 0; }
.helix-app .helix-setting-label {
  font-size: 14px;
  color: var(--text-1);
}
.helix-app .helix-setting-options {
  display: flex;
  gap: 6px;
}
.helix-app .helix-setting-option {
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--border-1);
  background: var(--bg-elevated);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
@media (pointer: coarse) {
  .helix-app .helix-setting-option { min-height: 44px; }
  .helix-app .helix-period-btn { min-height: 40px; }
  .helix-app .helix-heat-toggle { min-height: 44px; }
  .helix-app .helix-inbox-filter-btn { min-width: 40px; min-height: 40px; }
  .helix-app .helix-actionbar-btn { min-height: 44px; }
}
.helix-app .helix-setting-option:hover { background: var(--bg-sunken); }
.helix-app .helix-setting-option.is-active {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
}
.helix-app .helix-setting-status {
  font-size: 12px;
  font-weight: 500;
}
.helix-app .helix-setting-status--ok { color: var(--text-2); font-weight: 600; }

/* ---------- Login (Helix) — entrada branded (escena oscura, glass, logo animado) ---------- */
.helix-login{
  position:fixed;inset:0;z-index:1;
  display:grid;place-items:center;padding:24px;overflow:hidden;
  background:#08080A;color:#FAFAFA;
  font-family:'Inter',-apple-system,BlinkMacSystemFont,system-ui,sans-serif;
  letter-spacing:-.011em;-webkit-font-smoothing:antialiased;
  --hl-signal:linear-gradient(135deg,#007AFF 0%,#B84BFF 30%,#FF6B35 65%,#FF3B30 100%);
}
.helix-login,.helix-login *,.helix-login *::before,.helix-login *::after{box-sizing:border-box}
.helix-login .hl-bg{position:absolute;inset:0;z-index:0;pointer-events:none;overflow:hidden}
.helix-login .hl-blob{position:absolute;border-radius:50%;filter:blur(64px)}
.helix-login .hl-blob-b{width:46vw;height:46vw;background:radial-gradient(circle at 42% 42%,rgba(10,102,255,.58) 0%,transparent 66%);top:-16vw;left:-12vw;animation:hl-drift-a 26s ease-in-out infinite alternate}
.helix-login .hl-blob-p{width:44vw;height:44vw;background:radial-gradient(circle at 60% 40%,rgba(164,59,255,.52) 0%,transparent 66%);top:0;right:-18vw;animation:hl-drift-b 32s ease-in-out infinite alternate}
.helix-login .hl-blob-o{width:52vw;height:52vw;background:radial-gradient(circle at 50% 50%,rgba(255,94,43,.44) 0%,transparent 62%);bottom:-26vw;left:12vw;animation:hl-drift-c 38s ease-in-out infinite alternate}
@keyframes hl-drift-a{to{transform:translate(6vw,4vh)}}
@keyframes hl-drift-b{to{transform:translate(-7vw,-5vh)}}
@keyframes hl-drift-c{to{transform:translate(-8vw,5vh)}}
.helix-login .hl-sparks{position:absolute;inset:0;z-index:0;pointer-events:none}
.helix-login .hl-noise{position:absolute;inset:0;z-index:0;pointer-events:none;opacity:.04;mix-blend-mode:overlay;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.7'/%3E%3C/svg%3E")}
.helix-login .hl-vignette{position:absolute;inset:0;z-index:0;pointer-events:none;background:radial-gradient(125% 90% at 50% 40%,transparent 42%,rgba(4,4,6,.6) 100%)}
.helix-login .hl-halo{position:absolute;top:50%;left:50%;width:540px;height:540px;transform:translate(-50%,-54%);z-index:0;pointer-events:none;background:radial-gradient(circle at 50% 42%,rgba(120,92,255,.30) 0%,rgba(0,122,255,.16) 42%,rgba(255,90,60,.07) 66%,transparent 74%);filter:blur(26px);animation:hl-halo 9s ease-in-out infinite alternate}
@keyframes hl-halo{from{opacity:.82;transform:translate(-50%,-54%) scale(.97)}to{opacity:1;transform:translate(-50%,-54%) scale(1.04)}}
.helix-login .hl-card{
  position:relative;z-index:1;width:min(93vw,404px);
  background:linear-gradient(165deg,rgba(255,255,255,.14) 0%,rgba(255,255,255,.055) 42%,rgba(255,255,255,.02) 100%);
  border:1px solid rgba(255,255,255,.18);border-radius:24px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.22),inset 0 -1px 0 rgba(255,255,255,.04),0 30px 80px rgba(0,0,0,.6);
  -webkit-backdrop-filter:blur(32px) saturate(190%);backdrop-filter:blur(32px) saturate(190%);
  padding:42px 36px 32px;overflow:hidden;text-align:center;
  animation:hl-card-in .95s cubic-bezier(.16,1,.3,1) both;
}
.helix-login .hl-card::before{content:'';position:absolute;top:-60%;left:-80%;width:55%;height:230%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.09),transparent);transform:rotate(8deg);animation:hl-sheen 9s ease-in-out 1.2s infinite;pointer-events:none}
@keyframes hl-sheen{0%,58%,100%{left:-80%}28%{left:135%}}
@keyframes hl-card-in{from{opacity:0;transform:translateY(18px) scale(.985)}to{opacity:1;transform:none}}
.helix-login .hl-mark{position:relative;display:grid;place-items:center;width:66px;height:66px;border-radius:19px;margin:0 auto 22px;isolation:isolate;overflow:hidden;color:#fff;background:var(--hl-signal);box-shadow:0 10px 36px rgba(150,60,230,.46),0 3px 12px rgba(0,122,255,.34);animation:hl-mark-in 1s cubic-bezier(.16,1,.3,1) .05s both}
.helix-login .hl-mark::before{content:'';position:absolute;top:50%;left:50%;width:260%;aspect-ratio:1;transform:translate(-50%,-50%);background:conic-gradient(from 0deg,transparent 0deg,transparent 200deg,rgba(0,122,255,0) 208deg,rgba(0,122,255,.95) 228deg,rgba(184,75,255,1) 250deg,rgba(255,107,53,1) 272deg,rgba(255,59,48,.95) 288deg,transparent 304deg,transparent 360deg);animation:hl-orbit 5.5s linear infinite;z-index:0;filter:brightness(1.28);pointer-events:none}
.helix-login .hl-mark::after{content:'';position:absolute;inset:2.5px;border-radius:16.5px;background:#0e0e12;z-index:1}
.helix-login .hl-mark svg{position:relative;z-index:2;width:34px;height:34px}
@keyframes hl-orbit{to{transform:translate(-50%,-50%) rotate(360deg)}}
@keyframes hl-mark-in{from{opacity:0;transform:scale(.82)}to{opacity:1;transform:none}}
.helix-login .hl-title{font-size:30px;font-weight:600;letter-spacing:-.022em;line-height:1.04;margin:0}
.helix-login .hl-sub{color:#ABABB4;font-size:14.5px;margin:9px 0 0}
.helix-login form{margin-top:26px;display:flex;flex-direction:column;gap:11px;text-align:left}
.helix-login input{width:100%;height:50px;padding:0 15px;background:rgba(255,255,255,.05);border:1px solid rgba(255,255,255,.13);border-radius:12px;color:#FAFAFA;font-family:inherit;font-size:15px;letter-spacing:-.01em;transition:border-color .18s,background .18s,box-shadow .18s}
.helix-login input::placeholder{color:#8C8C95}
.helix-login input:focus{outline:0;border-color:#0A84FF;background:rgba(10,132,255,.08);box-shadow:0 0 0 3px rgba(10,132,255,.22)}
.helix-login .hl-btn{height:50px;margin-top:7px;border:0;border-radius:12px;cursor:pointer;font-family:inherit;font-size:15px;font-weight:600;color:#fff;letter-spacing:-.006em;background:linear-gradient(180deg,#0A84FF,#0868D8);box-shadow:0 6px 22px rgba(10,110,235,.44),inset 0 1px 0 rgba(255,255,255,.24);transition:transform .18s cubic-bezier(.16,1,.3,1),box-shadow .18s,filter .18s}
.helix-login .hl-btn:hover{filter:brightness(1.07);box-shadow:0 10px 32px rgba(10,110,235,.58),inset 0 1px 0 rgba(255,255,255,.3);transform:translateY(-1px)}
.helix-login .hl-btn:active{transform:translateY(0)}
.helix-login .helix-login-err{color:#FF6B6B;font-size:13px;min-height:16px;margin-top:12px;text-align:center}
@media (max-width:480px){.helix-login .hl-card{padding:36px 24px 28px}.helix-login .hl-title{font-size:27px}.helix-login .hl-halo{width:420px;height:420px}}
@media (prefers-reduced-motion:reduce){.helix-login .hl-blob,.helix-login .hl-card,.helix-login .hl-card::before,.helix-login .hl-mark,.helix-login .hl-mark::before,.helix-login .hl-halo{animation:none!important}}


/* ---------- Filter button dentro de la search bar ---------- */
.helix-app .helix-inbox-filter-btn {
  background: transparent;
  border: 0;
  color: var(--text-3);
  padding: 4px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.helix-app .helix-inbox-filter-btn:hover { background: var(--bg-sunken); color: var(--text-1); }

/* ---------- Composer (input bar): tamaños fijos para los iconos ---------- */
.helix-app .helix-composer-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.helix-app .helix-lead-detail-send {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
}
.helix-app .helix-lead-detail-send:active,
.helix-app .helix-composer-btn:active { opacity: 0.7; }
.helix-app .helix-lead-detail-send:disabled,
.helix-app .helix-composer-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Estado de error en chat lead detail */
.helix-app .helix-detail-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 16px;
  color: var(--danger);
  font-size: 14px;
  text-align: center;
}
.helix-app .helix-detail-error-retry {
  margin-top: 8px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* Composer textarea auto-grow */
.helix-app .helix-lead-detail-input {
  resize: none;
  overflow-y: auto;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.4;
}

/* ---------- Bottom sheets (filtros / acciones rápidas) ---------- */
.helix-app .helix-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  /* Animación de entrada: ver sección "Animaciones globales" abajo (backdrop fade + sheet spring). */
}
.helix-app .helix-sheet {
  background: var(--bg-elevated, #fff);
  color: var(--text-1, #0A0A0A);
  width: 100%;
  max-width: 540px;
  /* Nunca pasar del alto de pantalla (respeta status bar / notch) y scroll
     interno si hay muchas opciones — antes el sheet crecía sin tope y se metía
     bajo la barra de estado en móvil (incidente 2026-06-21).
     dvh = altura REAL visible en iOS Safari (vh ignora la barra de URL y deja
     el sheet más alto de lo debido). Fallback a vh para navegadores sin dvh. */
  max-height: 82vh;
  max-height: 82dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-radius: 20px 20px 0 0;
  /* Margen de seguridad arriba por si el notch/Dynamic Island está activo. */
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom));
  font-family: var(--font-sans, system-ui);
  box-shadow: var(--shadow-3);
}
.helix-app .helix-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  /* Header fijo al hacer scroll en sheets largos (móvil): la X y el título
     siempre accesibles aunque la lista de opciones desborde y haya que scrollear. */
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-elevated, #fff);
  padding-top: 2px;
}
.helix-app .helix-sheet-section { margin-bottom: 18px; }
.helix-app .helix-sheet-heats { display: flex; flex-wrap: wrap; gap: 8px; }
.helix-app .helix-heat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border-1);
  background: var(--bg-elevated);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.helix-app .helix-heat-toggle.is-on {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}
.helix-app .helix-sheet-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-1);
}
.helix-app .helix-sheet-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 10px;
  border-top: 1px solid var(--border-2);
}
.helix-app .helix-sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.helix-app .helix-sheet-action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: 0;
  border-radius: var(--r-md);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.helix-app .helix-sheet-action:hover { background: var(--bg-sunken); }
.helix-app .helix-sheet-action--danger { color: var(--danger); }
.helix-app .helix-sheet-action--danger:hover { background: rgba(255, 59, 48, 0.08); }

/* helix-sheet-in (legacy) reemplazado por helix-sheet-backdrop-in + helix-sheet-slide-up. */

/* ---------- Toast efímero ---------- */
.helix-toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 9500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.helix-toast {
  background: rgba(20,20,22,0.94);
  color: #fff;
  padding: 10px 16px;
  border-radius: 9999px;
  font-family: var(--font-sans, system-ui);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-3);
  animation: helix-toast-in 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.helix-toast.is-out { opacity: 0; transition: opacity 220ms ease-out; }
@keyframes helix-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* =========================================================
   Insights v2 — charts visuales
   ========================================================= */
.helix-app .helix-period-switch {
  display: inline-flex;
  background: var(--bg-sunken);
  border-radius: 9999px;
  padding: 3px;
  gap: 2px;
}
.helix-app .helix-period-btn {
  background: transparent;
  border: 0;
  padding: 5px 12px;
  border-radius: 9999px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.helix-app .helix-period-btn.is-active {
  background: var(--accent-bg);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-bg);
}

.helix-app .helix-insights-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 8px;
}
@media (min-width: 1024px) {
  .helix-app .helix-insights-grid {
    grid-template-columns: 1fr 1fr;
  }
  .helix-app .helix-insights-card--wide { grid-column: 1 / -1; }
}

.helix-app .helix-insights-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.helix-app .signal-border.helix-insights-card { border: none; }
.helix-app .helix-insights-card-inner { padding: 20px; }
.helix-app .helix-insights-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.helix-app .helix-insights-card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

/* ---------- Heat donut ---------- */
.helix-app .helix-donut-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
}
.helix-app .helix-donut {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.helix-app .helix-donut-hole {
  width: 88px;
  height: 88px;
  background: var(--bg-elevated);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.helix-app .helix-donut-hole-num {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-1);
  line-height: 1;
}
.helix-app .helix-donut-hole-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.helix-app .helix-donut-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.helix-app .helix-donut-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-1);
}
.helix-app .helix-donut-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.helix-app .helix-donut-legend-label {
  flex: 1;
  font-weight: 500;
}

/* ---------- Tasas ---------- */
.helix-app .helix-tasas-chart {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.helix-app .helix-tasa-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.helix-app .helix-tasa-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}
.helix-app .helix-tasa-row-num {
  font-size: 14px;
  color: var(--text-1);
  font-weight: 600;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
.helix-app .helix-tasa-delta {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--r-sm);
}
.helix-app .helix-tasa-delta--up { color: var(--positive); background: var(--positive-bg); }
.helix-app .helix-tasa-delta--down { color: var(--danger); background: var(--danger-bg); }
.helix-app .helix-tasa-delta--flat { color: var(--text-3); background: var(--bg-sunken); }
.helix-app .helix-tasa-row-bar {
  height: 8px;
  background: var(--bg-sunken);
  border-radius: 9999px;
  overflow: hidden;
}
.helix-app .helix-tasa-row-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Responsive donut: stack en mobile */
@media (max-width: 640px) {
  .helix-app .helix-donut-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  .helix-app .helix-donut { align-self: center; }
}


/* =========================================================
   Insights v3 — funnel trapezoidal + KPIs con sparkline
   ========================================================= */

/* ---------- KPI cards v2 con sparkline ---------- */
.helix-app .helix-insights-kpis-v2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 480px) {
  .helix-app .helix-insights-kpis-v2 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .helix-app .helix-insights-kpis-v2 { grid-template-columns: repeat(4, 1fr); }
}
.helix-app .helix-kpi-v2 {
  background: var(--bg-elevated);
  border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
}
.helix-app .helix-kpi-v2--signal .helix-kpi-v2-num {
  background: var(--grad-signal);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.helix-app .helix-kpi-v2-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.helix-app .helix-kpi-v2-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.helix-app .helix-kpi-v2-num {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1;
  color: var(--text-1);
  word-break: break-word;
  min-width: 0;
}
/* En pantallas <360px el num puede ser muy ancho con números grandes */
@media (max-width: 360px) {
  .helix-app .helix-kpi-v2-num { font-size: 26px; }
}
.helix-app .helix-kpi-v2-delta {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--r-sm);
}
.helix-app .helix-kpi-v2-delta--up { color: var(--positive); background: var(--positive-bg); }
.helix-app .helix-kpi-v2-delta--down { color: var(--danger); background: var(--danger-bg); }
.helix-app .helix-kpi-v2-delta--flat { color: var(--text-3); background: var(--bg-sunken); }

.helix-app .helix-sparkline {
  display: block;
  width: 100%;
  height: 28px;
  margin-top: 10px;
}


/* =========================================================
   Insights — Area chart multi-serie (sustituye al funnel)
   ========================================================= */
.helix-app .helix-insights-card--chart .helix-insights-card-inner { padding: 20px 20px 8px; }
.helix-app .helix-insights-card--chart .helix-insights-card-head {
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

.helix-app .helix-chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.helix-app .helix-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}
.helix-app .helix-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.helix-app .helix-area-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
}
.helix-app .helix-area-chart {
  width: 100%;
  height: auto;
  /* aspect-ratio se hereda del viewBox del SVG (responsive: el JS usa
     dimensiones distintas en móvil vs desktop, así que NO forzamos ratio). */
  display: block;
}
@media (max-width: 640px) {
  .helix-app .helix-area-axis-label {
    font-size: 11px;
  }
  .helix-app .helix-insights-card--chart .helix-insights-card-inner {
    padding: 16px 12px 8px;
  }
}

/* ---------- Lead info sheet (resumen pre-llamada) ---------- */
.helix-app .helix-info-section {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-2);
}
.helix-app .helix-info-section:last-child {
  border-bottom: none;
}
.helix-app .helix-info-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-1);
}
.helix-app .helix-info-lines b {
  font-weight: 600;
}
.helix-app .helix-info-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.helix-app .helix-info-form-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: var(--bg-sunken);
  border-radius: var(--r-md);
  font-size: 14px;
}
.helix-app .helix-info-bullets {
  margin: 6px 0 0 0;
  padding-left: 20px;
  font-size: 14px;
  color: var(--text-1);
}
.helix-app .helix-info-bullets li {
  margin: 4px 0;
}
.helix-app .helix-info-suggest {
  padding: 10px 12px;
  background: var(--accent-bg);
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--text-1);
  margin-top: 4px;
}

/* ---------- Sección Archivados (snooze permanente, colapsable) ---------- */
.helix-app .helix-inbox-section--archived {
  margin-top: 24px;
  border-top: 1px solid var(--border-2);
  padding-top: 8px;
}
.helix-app .helix-inbox-section-header--toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text-2);
  font-family: var(--font-sans);
  text-align: left;
  border-radius: var(--r-md);
  transition: background var(--dur-fast) var(--ease-out);
}
.helix-app .helix-inbox-section-header--toggle:hover {
  background: var(--bg-sunken);
}
.helix-app .helix-archived-chevron {
  margin-left: auto;
  transition: transform 200ms var(--ease-out);
  display: inline-flex;
  color: var(--text-3);
}
.helix-app .helix-archived-body .helix-lead-row {
  opacity: 0.65;
}
.helix-app .helix-archived-body .helix-lead-row:hover {
  opacity: 1;
}
.helix-app .helix-area-grid {
  stroke: var(--border-2);
  stroke-width: 1;
}
.helix-app[data-theme="dark"] .helix-area-grid { stroke: var(--border-1); opacity: 0.45; }
.helix-app .helix-area-axis-label {
  fill: var(--text-3);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.helix-app .helix-area-crosshair {
  stroke: var(--text-3);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.5;
  pointer-events: none;
}
.helix-app .helix-area-pt {
  opacity: 0;
  transition: opacity 120ms;
  pointer-events: none;
}
.helix-app .helix-area-col.is-hover .helix-area-pt { opacity: 1; }

.helix-app .helix-area-tooltip {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--border-1);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: var(--shadow-2);
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-1);
  pointer-events: none;
  z-index: 10;
  min-width: 160px;
}
.helix-app .helix-area-tooltip-date {
  font-weight: 600;
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.helix-app .helix-area-tooltip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  color: var(--text-2);
}
.helix-app .helix-area-tooltip-row b {
  margin-left: auto;
  color: var(--text-1);
  font-weight: 700;
}


/* =========================================================
   Animaciones globales — paquete completo
   - Stagger bubbles (lead detail)
   - Count-up KPIs (Insights)
   - Bars / donut / sparklines desde 0
   - Sheet spring (overshoot bottom sheet)
   - Row hover lift (Inbox)
   - Tab cross-fade (content swap)
   - Typing dots: ver helix-components.css
   ========================================================= */

/* Stagger entrada — aplicado vía clase desde JS con animation-delay inline. */
.helix-app .helix-chat-bubble-row.helix-anim-bubble-in {
  animation: helix-bubble-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes helix-bubble-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Sheet spring — overshoot al subir desde abajo. */
.helix-app .helix-sheet-backdrop {
  animation: helix-sheet-backdrop-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.helix-app .helix-sheet-backdrop > .helix-sheet {
  animation: helix-sheet-slide-up var(--dur-slow) var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
  .helix-app .helix-sheet-backdrop,
  .helix-app .helix-sheet-backdrop > .helix-sheet { animation: none; }
}
@keyframes helix-sheet-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes helix-sheet-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}


/* Tab cross-fade — la primera capa de #helix-content entra con fade. */
@keyframes helix-content-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.helix-app #helix-content > div:first-child {
  animation: helix-content-in 240ms cubic-bezier(0.16, 1, 0.3, 1);
}


/* ─── Settings: bloques nuevos (Control, Push diagnose, Prompt, Soporte) ─── */
.helix-app .helix-diagnose-output {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg-sunken);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-1);
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.helix-app .helix-diagnose-output > div {
  margin-bottom: 4px;
}

/* Soporte chat bubbles dentro del sheet */
.helix-app .helix-soporte-bubble {
  margin: 8px 0;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 88%;
  word-break: break-word;
}
.helix-app .helix-soporte-bubble--user {
  background: var(--accent-bg);
  color: var(--text-1);
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.helix-app .helix-soporte-bubble--assistant {
  background: var(--bg-sunken);
  color: var(--text-1);
  margin-right: auto;
  border-bottom-left-radius: 4px;
}
.helix-app .helix-soporte-tools {
  margin-top: 8px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.05);
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-3);
}
.helix-app[data-theme="dark"] .helix-soporte-tools {
  background: rgba(255,255,255,0.06);
}
.helix-app .helix-soporte-tool-call {
  padding: 2px 0;
  word-break: break-all;
}

/* ---------- A/B Outbound (V5 pool) — usa la misma estética que tasas ---------- */
.helix-app .helix-ab-row {
  margin-bottom: 14px;
}
.helix-app .helix-ab-row:last-child {
  margin-bottom: 0;
}
.helix-app .helix-ab-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-1);
  margin-bottom: 4px;
}
.helix-app .helix-ab-row-num {
  font-weight: 600;
}
.helix-app .helix-ab-row-bar {
  height: 8px;
  background: var(--bg-sunken);
  border-radius: 4px;
  overflow: hidden;
}
.helix-app .helix-ab-row-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 800ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Status badges row debajo del nombre en lead detail header */
.helix-app .helix-lead-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.helix-app .helix-lead-status-row .helix-tag {
  height: 20px;
  padding: 0 8px;
  font-size: 11px;
}
