/* ═══════ Reset / base ═══════ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font: inherit; }
/* El atributo [hidden] debe ganar SIEMPRE — reglas amplias como
   `input,select,textarea{}` o estilos de textarea no deben hacer visible
   un elemento marcado hidden (bug: sbTriggerValue oculto se veía en el bot). */
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

:root {
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-active: #2563eb;
  --bg-bubble-in: #f1f5f9;
  --bg-bubble-out: #dbeafe;

  --text: #0f172a;
  --text-muted: #64748b;
  --text-sidebar: #94a3b8;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #ef4444;
  --success: #10b981;
  --warn: #f59e0b;

  /* Aliases usados en componentes nuevos */
  --surface: #ffffff;
  --bg: #f8fafc;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-modal: 0 24px 64px rgba(15, 23, 42, 0.18);
}

/* ═══════ Layout principal ═══════ */
.app {
  display: grid;
  grid-template-columns: 80px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ═══════ Sidebar ═══════ */
.sidebar {
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 16px 12px;
  gap: 8px;
  color: var(--text-sidebar);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
  position: relative;
}
body:not(.nav-collapsed) .sidebar-top,
body.nav-expanded .sidebar-top { justify-content: space-between; }

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
}
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}
.brand-mark img { width: 100%; height: 100%; display: block; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; margin-top: 8px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  color: var(--text-sidebar);
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  position: relative; /* anchor del badge */
}
/* :not(.nav-badge) excluye el badge — sin esto el selector tan amplio
   pisaba al badge y lo forzaba a mostrarse como circulo rojo vacio cuando
   el body tenia .nav-expanded (ver regla con !important mas abajo). */
.nav-item span:not(.nav-badge) { display: none; }
.nav-item:hover { background: rgba(255,255,255,0.04); color: #fff; }
.nav-item.is-active { background: var(--bg-sidebar-active); color: #fff; }

/* Badge rojo de no leídos en la nav lateral — visible siempre, incluso colapsado */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  line-height: 18px;
  text-align: center;
  letter-spacing: 0.02em;
  margin-left: 6px;
  box-shadow: 0 0 0 2px var(--bg-sidebar, #0f172a);
  animation: navBadgePulse 2s ease-in-out infinite;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}
.nav-badge[hidden] { display: none !important; }
.nav-badge:empty   { display: none !important; }
/* Cuando la nav está colapsada (modo icono), el badge se posiciona absoluto en
   la esquina superior-derecha del icono — clásico estilo iOS notificación */
body.nav-collapsed .nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  margin: 0;
  min-width: 16px;
  height: 16px;
  font-size: 9px;
  padding: 0 4px;
  line-height: 16px;
}
@keyframes navBadgePulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--bg-sidebar, #0f172a); }
  50%      { box-shadow: 0 0 0 2px var(--bg-sidebar, #0f172a), 0 0 0 6px rgba(220, 38, 38, 0.25); }
}

/* ── Nav advisor bar ── */
.nav-advisor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 4px;
  background: rgba(255,255,255,.04);
  border-radius: var(--radius);
}
.nav-advisor-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  cursor: pointer;
  flex: 1;
  border-radius: 6px;
  padding: 2px 4px;
  transition: background .15s;
}
.nav-advisor-info:hover { background: rgba(255,255,255,.08); }
.nav-advisor-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.nav-advisor-name {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: none;
}
body:not(.nav-collapsed) .nav-advisor-name,
body.nav-expanded .nav-advisor-name { display: block; }
.nav-logout-btn {
  background: none;
  border: none;
  color: var(--text-sidebar);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: none;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.nav-logout-btn:hover { color: #fff; background: rgba(239,68,68,.2); }
body:not(.nav-collapsed) .nav-logout-btn,
body.nav-expanded .nav-logout-btn { display: flex; align-items: center; }
.nav-cache-btn {
  background: none;
  border: none;
  color: var(--text-sidebar);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: none;
  flex-shrink: 0;
  transition: color .15s, background .15s, transform .4s;
}
.nav-cache-btn:hover { color: #fff; background: rgba(59,130,246,.2); }
.nav-cache-btn.is-spinning svg { animation: nav-cache-spin .8s linear infinite; }
@keyframes nav-cache-spin { to { transform: rotate(360deg); } }
body:not(.nav-collapsed) .nav-cache-btn:not([hidden]),
body.nav-expanded .nav-cache-btn:not([hidden]) { display: flex; align-items: center; }

/* ── Account modal ── */
.account-modal-box { max-width: 540px; width: 100%; }
.account-modal-body { padding: 0 24px 24px; display: flex; flex-direction: column; gap: 20px; }

.account-avatar-section {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 0 4px;
}
.account-avatar-wrap {
  width: 72px; height: 72px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff;
}
.account-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }
.account-avatar-initials { font-size: 24px; font-weight: 700; color: #fff; }
.account-avatar-name { font-size: 18px; font-weight: 700; margin-bottom: 2px; }
.account-avatar-role { font-size: 12px; color: var(--text-muted); }

/* ── Sidebar collapse button ── */
.nav-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px;
  margin-bottom: 4px;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--text-sidebar);
  cursor: pointer;
  transition: background 150ms, color 150ms;
}
.nav-collapse-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-collapse-btn svg { transition: transform 250ms ease; flex-shrink: 0; }

/* Sidebar expandido: manual toggle OR wide screen */
@media (min-width: 1100px) {
  body:not(.nav-collapsed) .app { grid-template-columns: 240px 1fr; }
  body:not(.nav-collapsed) .sidebar { padding: 20px 16px; }
  body:not(.nav-collapsed) .nav-item span:not(.nav-badge) { display: inline; }
  body:not(.nav-collapsed) .user-meta { display: block; }
  body:not(.nav-collapsed) .user-card-chevron { display: block; }
  body:not(.nav-collapsed) .brand { justify-content: flex-start; padding-left: 8px; }
}
/* Forced-expanded via class (any screen size) */
body.nav-expanded .app { grid-template-columns: 240px 1fr; }
body.nav-expanded .sidebar { padding: 20px 16px; }
body.nav-expanded .nav-item span:not(.nav-badge) { display: inline !important; }
body.nav-expanded .user-meta { display: block !important; }
body.nav-expanded .user-card-chevron { display: block !important; }
body.nav-expanded .brand { justify-content: flex-start; padding-left: 8px; }
/* Forced-collapsed: arrow flips */
body.nav-collapsed .nav-collapse-btn svg { transform: rotate(180deg); }

/* ═══════ Notificaciones in-app (campana sidebar top) ═══════ */
.nav-notif-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: rgba(255,255,255,.08);
  border: none;
  border-radius: 10px;
  color: var(--text-sidebar);
  cursor: pointer;
  transition: background 150ms, color 150ms;
}
.nav-notif-btn:hover { background: rgba(255,255,255,.15); color: #fff; }

/* Badge en la campana */
.nav-notif-btn .nav-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  font-size: 10px;
  padding: 0 4px;
}

/* Colapsado: sidebar-top se apila en columna → campana queda debajo de la W */
body.nav-collapsed .sidebar-top {
  flex-direction: column;
  gap: 6px;
}

/* Panel de notificaciones */
.nav-notif-panel {
  position: fixed;
  top: 68px;
  left: 12px;
  width: 320px;
  max-height: 420px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.14);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999;
}
.nav-notif-panel[hidden] { display: none; }
/* Colapsado: panel abre desde debajo de la campana */
body.nav-collapsed .nav-notif-panel {
  top: 110px;
  left: 12px;
}

.nav-notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}
.nav-notif-read-all {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.nav-notif-read-all:hover { background: #eff6ff; }

.nav-notif-list {
  overflow-y: auto;
  flex: 1;
}
.nav-notif-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  padding: 32px 16px;
  margin: 0;
}
.nav-notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #f8fafc;
  cursor: pointer;
  transition: background 100ms;
  text-decoration: none;
  color: inherit;
}
.nav-notif-item:hover { background: #f8fafc; }
.nav-notif-item.unread { background: #eff6ff; }
.nav-notif-item.unread:hover { background: #dbeafe; }
.nav-notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2563eb;
  flex-shrink: 0;
  margin-top: 5px;
}
.nav-notif-item:not(.unread) .nav-notif-dot { background: transparent; }
.nav-notif-content { flex: 1; min-width: 0; }
.nav-notif-title {
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
  margin: 0 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-notif-body {
  font-size: 12px;
  color: #64748b;
  margin: 0 0 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-notif-time {
  font-size: 11px;
  color: #94a3b8;
}

/* ═══════ Main ═══════ */
.main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-app);
}

/* ═══════ Topbar ═══════ */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.topbar-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  min-width: 180px;
}
.topbar-search {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--text-muted);
  transition: border-color .15s, background .15s;
}
.topbar-search:focus-within { background: #fff; border-color: var(--accent); }
.topbar-search input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--text);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar-customers-extras { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.topbar-customers-extras[hidden] { display: none; }
.topbar-exp-extras { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.topbar-exp-extras[hidden] { display: none; }
.topbar-exp-extras .kf-filter-btn { background: #f1f5f9; border: 1px solid transparent; border-radius: 999px; color: var(--text-muted); padding: 8px 14px; }
.topbar-exp-extras .kf-filter-btn:hover,
.topbar-exp-extras .kf-filter-btn.has-filters { background: #fff; border-color: var(--accent); color: var(--text); }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-muted);
  position: relative;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-bubble-in); color: var(--text); }
.icon-btn--ghost { width: auto; height: 32px; padding: 0 8px; border-radius: var(--radius-sm); }

.has-badge .badge {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid; place-items: center;
}

.org-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-weight: 500;
}
.org-btn:hover { border-color: var(--border-strong); }

/* ═══════ Vistas ═══════ */
.view { flex: 1; overflow: hidden; }
.view-chats {
  display: grid;
  grid-template-columns: 340px 1fr 320px;
  height: 100%;
}
.view-placeholder { display: grid; place-items: center; padding: 40px; }
.placeholder { text-align: center; color: var(--text-muted); max-width: 480px; }
.placeholder h2 { color: var(--text); margin-top: 0; }

/* ═══════ Chat list ═══════ */
.chat-list {
  border-right: 1px solid var(--border);
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-list-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { background: var(--bg-bubble-in); color: var(--text); }
.tab.is-active { color: var(--accent); background: rgba(37, 99, 235, 0.08); }
.tab-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-bubble-in);
  color: var(--text-muted);
}
.tab.is-active .tab-count { background: rgba(37, 99, 235, 0.12); color: var(--accent); }
.tab-count--alert { background: rgba(239, 68, 68, 0.12); color: var(--danger); }

.chat-list-items { flex: 1; overflow-y: auto; }

.chat-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: background .15s;
}
.chat-item:hover { background: #fafbfc; }
.chat-item.is-selected { background: #fafbfc; }
.chat-item.is-selected::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent);
}

.chat-item-avatar {
  position: relative;
  width: 44px; height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.chat-item-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-item-avatar .channel-dot {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
}
.channel-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; }
.channel-whatsapp { background: #25d366; }
.channel-messenger { background: #0084ff; }
.channel-instagram {
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}
.channel-tiktok { background: #000; }

.chat-item-body { flex: 1; min-width: 0; }
.chat-item-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.chat-item-name { font-weight: 600; color: var(--text); }
.chat-item-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.chat-item-snippet {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item-unread {
  margin-top: 6px;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid; place-items: center;
}

/* ═══════ Chat window ═══════ */
.chat-window {
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 700;
}
.chat-header-phone { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--bg-bubble-in);
  color: var(--text-muted);
}
.chip--success { background: rgba(16, 185, 129, 0.12); color: #047857; }
.chip--warn { background: rgba(245, 158, 11, 0.16); color: #b45309; }

.btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
}
.btn--ghost { border: 1px solid var(--border); background: #fff; color: var(--text); }
.btn--ghost:hover { border-color: var(--border-strong); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.4;
  position: relative;
}
.bubble-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}
.bubble--in {
  align-self: flex-start;
  background: var(--bg-bubble-in);
  border-bottom-left-radius: 4px;
}
.bubble--out {
  align-self: flex-end;
  background: var(--bg-bubble-out);
  border-bottom-right-radius: 4px;
}
.bubble--out .bubble-meta { color: #2563eb; }
.bubble--file {
  display: flex; align-items: center; gap: 12px;
}
.file-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.file-info { display: flex; flex-direction: column; }
.file-name { font-weight: 600; }
.file-size { font-size: 11px; color: var(--text-muted); }

.chat-composer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.chat-composer input {
  flex: 1;
  border: 0;
  outline: none;
  padding: 12px 0;
  background: transparent;
}
.send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  margin-left: 4px;
  transition: background .15s;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn svg { width: 18px; height: 18px; }

/* ═══════ Contact panel ═══════ */
.contact-panel {
  border-left: 1px solid var(--border);
  background: var(--bg-app);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.panel-filters { display: flex; gap: 8px; }
.select-soft {
  flex: 1;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.select-soft:hover { border-color: var(--border-strong); }
.select-soft--inline { padding: 4px 10px; font-size: 13px; }
.select-soft--status { gap: 6px; }
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.panel-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.panel-card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.panel-subhead {
  margin: 16px 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.panel-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.panel-card-header h3 { margin: 0; }

.panel-tabs {
  display: flex;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.panel-tab {
  padding: 8px 0;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
}
.panel-tab.is-active { color: var(--accent); border-color: var(--accent); }

.panel-list { margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.panel-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.panel-row dt { color: var(--text-muted); font-size: 13px; margin: 0; }
.panel-row dd { margin: 0; font-size: 13px; font-weight: 500; color: var(--text); }
.value-money { color: var(--success); font-weight: 700 !important; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
.tag--amber { background: rgba(245, 158, 11, 0.16); color: #b45309; }
.tag--green { background: rgba(16, 185, 129, 0.16); color: #047857; }
.tag--purple { background: rgba(168, 85, 247, 0.16); color: #6b21a8; }
.tag--blue { background: rgba(37, 99, 235, 0.12); color: var(--accent); }

/* ═══════ Vista: Ajustes ═══════ */
.view-settings { padding: 0; overflow-y: auto; }
.settings-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100%;
  max-width: 1080px;
  margin: 0 auto;
}
.settings-nav {
  border-right: 1px solid var(--border);
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.settings-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  text-align: left;
}
.settings-tab:hover { background: var(--bg-bubble-in); color: var(--text); }
.settings-tab.is-active { background: rgba(37,99,235,.08); color: var(--accent); }
.settings-tab svg { width: 16px; height: 16px; }

.settings-content { padding: 32px 40px; overflow-y: auto; }
.settings-pane { display: none; }
.settings-pane.is-active { display: block; }

.settings-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 24px;
}
.settings-head h2 { margin: 0 0 6px; font-size: 22px; }
.settings-head p { margin: 0; color: var(--text-muted); max-width: 600px; }

/* Estadísticas de bot */
.bot-stats-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.bot-stats-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}
.bot-stats-tab:hover { color: var(--text); }
.bot-stats-tab.is-active { color: var(--accent, #2563eb); border-bottom-color: var(--accent, #2563eb); font-weight: 600; }
.bot-stats-pane { display: none; }
.bot-stats-pane.is-active { display: block; }

.bot-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.bot-stats-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bot-stats-card.accent-green { background: linear-gradient(135deg, #dcfce7 0%, #fff 60%); border-color: #86efac; }
.bot-stats-card.accent-amber { background: linear-gradient(135deg, #fef3c7 0%, #fff 60%); border-color: #fcd34d; }
.bot-stats-card.accent-red   { background: linear-gradient(135deg, #fee2e2 0%, #fff 60%); border-color: #fca5a5; }
.bot-stats-card-ico {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(37,99,235,0.08); color: #2563eb;
  margin-bottom: 8px;
}
.bot-stats-card-ico svg { width: 18px; height: 18px; }
.bot-stats-card-ico.is-target  { background: rgba(37,99,235,0.10);  color: #2563eb; }
.bot-stats-card-ico.is-rocket  { background: rgba(168,85,247,0.10); color: #9333ea; }
.bot-stats-card-ico.is-active  { background: rgba(16,185,129,0.10); color: #10b981; }
.bot-stats-card-ico.is-success { background: rgba(16,185,129,0.10); color: #059669; }
.bot-stats-card-ico.is-warn    { background: rgba(245,158,11,0.10); color: #d97706; }
.bot-stats-card-ico.is-stop    { background: rgba(239,68,68,0.10);  color: #dc2626; }
.bot-stats-card-ico.is-active svg { width: 14px; height: 14px; }

/* Tabs del modal con icono + texto */
.bot-stats-tab { display: inline-flex; align-items: center; gap: 7px; }
.bot-stats-card-val { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1.1; }
.bot-stats-card-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.bot-stats-card-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.bot-stats-chart {
  background: #f8fafc;
  border-radius: 10px;
  padding: 14px;
}
.bot-stats-chart-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 12px; }
.bot-stats-spark {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 80px;
}
.bot-stats-spark-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  cursor: help;
}
.bot-stats-spark-bar {
  width: 100%;
  max-width: 24px;
  background: linear-gradient(180deg, var(--accent, #2563eb), #93c5fd);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: opacity .12s;
}
.bot-stats-spark-col:hover .bot-stats-spark-bar { opacity: 0.75; }
.bot-stats-spark-day {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
}
.bot-stats-no-data {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}
.bot-stats-error { color: #ef4444; padding: 12px; }

/* Historial de runs */
.bot-stats-history {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 460px;
  overflow-y: auto;
}
.bsh-head, .bsh-row {
  display: grid;
  grid-template-columns: 130px 1.4fr 130px 130px;
  gap: 12px;
  padding: 8px 12px;
  align-items: center;
}
.bsh-head {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
.bsh-row {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}
.bsh-when-rel { font-weight: 500; color: var(--text); }
.bsh-when-abs { color: var(--text-muted); font-size: 10px; margin-top: 2px; }
.bsh-who-name { font-weight: 500; color: var(--text); }
.bsh-who-phone, .bsh-who-exp { color: var(--text-muted); font-size: 10px; margin-top: 2px; }
.bsh-progress-bar { background: #e2e8f0; border-radius: 4px; height: 4px; overflow: hidden; }
.bsh-progress-fill { background: var(--accent, #2563eb); height: 100%; transition: width .3s; }
.bsh-progress-text { color: var(--text-muted); font-size: 10px; margin-top: 4px; }
.bsh-status { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 500; }
.bsh-status.running { background: #dcfce7; color: #14532d; }
.bsh-status.paused  { background: #fef3c7; color: #78350f; }
.bsh-status.done    { background: #dbeafe; color: #1e3a8a; }
.bsh-status.error   { background: #fee2e2; color: #991b1b; }
.bsh-status.killed  { background: #f1f5f9; color: var(--text-muted); }
.bsh-duration { color: var(--text-muted); font-size: 10px; margin-top: 4px; }
.bsh-err { color: #b91c1c; font-size: 10px; margin-top: 2px; }

@media (max-width: 700px) {
  .bot-stats-grid { grid-template-columns: 1fr 1fr; }
  .bsh-head, .bsh-row { grid-template-columns: 1fr 1fr; gap: 6px; }
  .bsh-head { display: none; }
}

/* Reportes / Soporte */
.reports-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.reports-filter {
  background: #f1f5f9;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
}
.reports-filter.is-active { background: #fff; border-color: var(--accent, #2563eb); color: var(--accent, #2563eb); }
.reports-list { display: flex; flex-direction: column; gap: 10px; }
.report-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.report-card:hover { border-color: var(--accent, #2563eb); box-shadow: 0 2px 6px rgba(15,23,42,.06); }
.report-card.status-resolved { opacity: .65; }
.report-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.report-type, .report-prio, .report-status, .report-attach-count {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
}
.report-type { background: #f1f5f9; color: var(--text); }
.report-prio.prio-low      { background: #dbeafe; color: #1e40af; }
.report-prio.prio-medium   { background: #fef3c7; color: #78350f; }
.report-prio.prio-high     { background: #fed7aa; color: #9a3412; }
.report-prio.prio-urgent   { background: #fecaca; color: #991b1b; }
.report-status.status-open        { background: #dcfce7; color: #14532d; }
.report-status.status-in_progress { background: #dbeafe; color: #1e3a8a; }
.report-status.status-resolved    { background: #ede9fe; color: #5b21b6; }
.report-status.status-wontfix     { background: #f1f5f9; color: var(--text-muted); }
.report-attach-count { background: #f1f5f9; color: var(--text-muted); }
.report-title { font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 4px; }
.report-body-preview { font-size: 12px; color: var(--text-muted); line-height: 1.4; margin-bottom: 8px; }
.report-meta { display: flex; gap: 6px; font-size: 11px; color: var(--text-muted); }
.reports-empty { padding: 40px; text-align: center; color: var(--text-muted); font-size: 13px; }

.report-files-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.report-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 10px;
  background: #f1f5f9;
  border-radius: 99px;
  font-size: 11px;
}
.report-file-chip button {
  background: rgba(0,0,0,.1);
  border: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.report-detail-meta { font-size: 13px; margin-bottom: 4px; }
.report-detail-meta-2 { font-size: 11px; color: var(--text-muted); margin-bottom: 14px; }
.report-detail-body { background: #f8fafc; padding: 12px; border-radius: 8px; font-size: 13px; white-space: pre-wrap; line-height: 1.5; margin-bottom: 12px; }
.report-detail-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.report-attach-img, .report-attach-video {
  max-width: 200px;
  max-height: 200px;
  border-radius: 6px;
  display: block;
}
.report-admin-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #fef3c7;
  border-radius: 8px;
  margin-top: 12px;
}
.report-admin-controls select, .report-admin-controls textarea {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.report-admin-response { background: #ede9fe; border-radius: 8px; padding: 12px; margin-top: 12px; }
.report-admin-response strong { font-size: 12px; color: #5b21b6; }
.report-admin-response p { margin: 4px 0 0; font-size: 13px; line-height: 1.5; white-space: pre-wrap; }

/* Configuraciones — secciones tipo card con filas de switches */
.cfg-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.cfg-section-title {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.cfg-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 0;
  border-top: 1px solid #f1f5f9;
}
.cfg-row:first-of-type { border-top: none; padding-top: 0; }
.cfg-row-info { flex: 1; min-width: 0; }
.cfg-row-title { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.cfg-row-desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.cfg-switch {
  position: relative;
  display: inline-block;
  width: 40px; height: 22px;
  flex-shrink: 0;
  margin-top: 2px;
}
.cfg-switch input { opacity: 0; width: 0; height: 0; }
.cfg-switch-slider {
  position: absolute; inset: 0;
  background: #cbd5e1;
  border-radius: 99px;
  cursor: pointer;
  transition: background .18s;
}
.cfg-switch-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(15,23,42,.2);
  transition: transform .18s;
}
.cfg-switch input:checked + .cfg-switch-slider { background: var(--primary); }
.cfg-switch input:checked + .cfg-switch-slider::before { transform: translateX(18px); }

/* Select dentro de Configuraciones (selector de idioma, etc.) */
.cfg-select {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 32px 8px 12px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  outline: none;
  font-family: inherit;
  flex-shrink: 0;
  min-width: 200px;
  transition: border-color .12s, box-shadow .12s;
}
.cfg-select:hover { border-color: var(--accent, #2563eb); }
.cfg-select:focus { border-color: var(--accent, #2563eb); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }

.settings-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.settings-card h3 { margin: 0 0 8px; font-size: 14px; }
.settings-note { color: var(--text-muted); font-size: 13px; margin: 0 0 12px; }

.btn--primary {
  background: var(--accent); color: #fff;
}
.btn--primary:hover { background: var(--accent-hover); }
/* Botón primario (Guardar) cuando NO hay cambios pendientes: gris.
   Al primer cambio se le quita .is-clean y vuelve a azul ("ya puedes guardar").
   Lo usan el bot builder (#botBuilderSave) y el detalle de lead (#expDetailSaveBtn). */
.btn--primary.is-clean {
  background: #e2e8f0; color: #94a3b8; cursor: default; box-shadow: none;
}
.btn--primary.is-clean:hover { background: #e2e8f0; }

.settings-actions { display: flex; gap: 8px; margin-top: 16px; }

/* Banner persistente: canal de WhatsApp desconectado (no se ignora entre las notifs).
   Responsive: en desktop es una píldora centrada; en móvil ocupa el ancho y los
   botones bajan a su propia fila (antes se desbordaban). */
.integ-down-banner {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 9998; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  width: max-content; max-width: min(760px, calc(100vw - 20px));
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  padding: 12px 16px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: 13.5px;
  animation: integDownIn .25s ease-out;
}
@keyframes integDownIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.integ-down-txt { flex: 1 1 240px; line-height: 1.4; }
.integ-down-actions { display: flex; gap: 8px; flex-shrink: 0; }
.integ-down-btn {
  background: #dc2626; color: #fff; border: 0;
  padding: 8px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.integ-down-btn:hover { background: #b91c1c; }
.integ-down-dismiss {
  background: transparent; color: #991b1b; border: 1px solid #fecaca;
  padding: 8px 12px; border-radius: 8px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.integ-down-dismiss:hover { background: #fee2e2; }
@media (max-width: 600px) {
  .integ-down-banner { left: 10px; right: 10px; bottom: 10px; transform: none; width: auto; max-width: none; }
  .integ-down-txt { flex: 1 1 100%; }
  .integ-down-actions { width: 100%; }
  .integ-down-actions > button { flex: 1 1 0; text-align: center; }
}

/* Users table */
.users-table { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.users-row {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr 1fr 40px;
  gap: 12px;
  padding: 14px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.users-row:last-child { border-bottom: 0; }
.users-row--head { font-weight: 600; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; background: #fafbfc; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell img { width: 36px; height: 36px; border-radius: 50%; }
.user-cell-name { font-weight: 600; }
.user-cell-sub { font-size: 11px; color: var(--text-muted); }

/* AI providers */
.ai-providers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.ai-provider {
  display: block;
  position: relative;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ai-provider input { display: none; }
.ai-provider:hover { border-color: var(--border-strong); }
.ai-provider.is-selected,
.ai-provider:has(input:checked) {
  border-color: var(--accent);
  background: rgba(37,99,235,.04);
}
.ai-provider-name { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.ai-provider-desc { font-size: 11px; color: var(--text-muted); }
.ai-provider-connected-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10px;
  font-weight: 700;
  background: #16a34a;
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  letter-spacing: .02em;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.form-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.form-field--full { grid-column: 1 / -1; }
.form-field span { font-weight: 600; color: var(--text-muted); }
.form-field input,
.form-field select,
.form-textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.form-field input:focus,
.form-field select:focus,
.form-textarea:focus { border-color: var(--accent); }
.form-field input:disabled { background: #f5f7fb; color: var(--text-muted); }
.form-textarea { width: 100%; resize: vertical; font-family: inherit; line-height: 1.5; }

/* ═══════ Responsive ═══════ */
@media (max-width: 1100px) {
  .view-chats { grid-template-columns: 320px 1fr 300px; }
}
@media (max-width: 900px) {
  .view-chats { grid-template-columns: 280px 1fr; }
  .contact-panel { display: none; }
}

/* ═══════ Vista: Integraciones ═══════ */
.view-integrations {
  padding: 24px 32px;
  overflow-y: auto;
}

/* ─── Tabs ─── */
.int-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.int-tab { background: none; border: none; padding: 10px 20px; font-size: 14px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s; }
.int-tab:hover { color: var(--text); }
.int-tab--active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Vote tab ─── */
.vote-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.vote-desc { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.55; flex: 1; min-width: 200px; }
.vote-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.vote-badge--ok { background: #d1fae5; color: #065f46; }
.vote-badge--wait { background: #fef3c7; color: #92400e; }
.vote-badge--mine { background: #ede9fe; color: #5b21b6; font-size: 11px; padding: 3px 8px; border-radius: 12px; }
.vote-search-wrap { margin-bottom: 20px; max-width: 360px; }
.vote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 32px; }
.vote-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; transition: border-color .15s; position: relative; }
.vote-card:hover { border-color: var(--primary); }
.vote-card--top { border-color: #f59e0b; background: #fffbeb; }
.vote-card--mine { border-color: #8b5cf6; }
.vote-card-crown { position: absolute; top: -10px; left: 12px; font-size: 11px; background: #f59e0b; color: #fff; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.vote-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; letter-spacing: -0.5px; }
.vote-info { flex: 1; min-width: 0; }
.vote-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vote-cat { font-size: 11px; color: var(--text-muted); }
.vote-count-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 60px; }
.vote-bar-bg { width: 60px; height: 4px; background: var(--border); border-radius: 2px; }
.vote-bar-fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width .4s; }
.vote-count { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.vote-btn { margin-left: 4px; flex-shrink: 0; font-size: 12px; padding: 4px 12px; }
.vote-custom-wrap { border-top: 1px solid var(--border); padding-top: 24px; }
.vote-custom-label { margin: 0 0 10px; font-size: 13px; color: var(--text-muted); }
.vote-custom-row { display: flex; gap: 10px; max-width: 480px; }
.integrations-intro {
  margin-bottom: 24px;
  max-width: 720px;
}
.integrations-intro h2 { margin: 0 0 6px; font-size: 22px; }
.integrations-intro p { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.55; }

.integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.int-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color .15s, box-shadow .15s;
  position: relative;
}
.int-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.int-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.int-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.int-icon svg {
  width: 26px; height: 26px;
  display: block;
}
.int-name {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.int-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.int-status-dot.is-connected  { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.int-status-dot.is-connecting { background: #f59e0b;       box-shadow: 0 0 0 3px rgba(245,158,11,.15); animation: int-pulse 1.4s ease-in-out infinite; }
.int-status-dot.is-error      { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.15); }
@keyframes int-pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

.int-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.int-instances {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.int-instance {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .12s;
}
.int-instance:hover { border-color: var(--accent); }
.int-instance-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
.int-instance-dot.is-error { background: var(--danger); }
.int-instance-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.int-instance-meta { font-size: 11px; color: var(--text-muted); }

.int-badge-connecting {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #b45309;
  background: rgba(245,158,11,.12);
  padding: 2px 8px;
  border-radius: 99px;
}

/* Connected badge */
.int-badge-connected {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--success);
  background: rgba(16,185,129,.1);
  padding: 2px 8px;
  border-radius: 99px;
}

/* Account rows inside cards */
.int-accounts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.int-account-row {
  /* Dos renglones: arriba identidad + ✕ (destructiva, lejos del uso diario);
     abajo los controles. Antes iba todo en una línea y con el switch de bots,
     la campanita y Grupos el número quedaba cortado ("+52 1 ..."). */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 12px;
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.int-account-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.int-account-x { margin-left: auto; flex-shrink: 0; }
.int-account-row .int-account-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-left: 40px;   /* alineado con el texto, no con el avatar */
}
.int-account-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}
.int-account-avatar svg { width: 18px; height: 18px; }
.int-account-info { flex: 1; min-width: 0; }
.int-account-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.int-account-meta { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.int-account-meta.is-error { color: var(--danger); }
.int-account-meta.is-connecting { color: #d97706; font-weight: 600; }
.int-account-actions { display: flex; gap: 4px; flex-shrink: 0; align-items: center; }

/* Campanita por canal — prendida = suena; tachada = silencio total */
.int-bell-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.int-bell-toggle:hover { background: var(--bg, #f1f5f9); color: var(--text, #0f172a); }
.int-bell-toggle:disabled { opacity: .5; cursor: default; }
.int-bell-toggle.is-off {
  color: #b45309;
  background: rgba(245, 158, 11, .12);
  border-color: rgba(245, 158, 11, .35);
}
.int-bell-toggle.is-off:hover { background: rgba(245, 158, 11, .2); color: #92400e; }

/* OAuth connect button */
.btn--oauth {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: #1877f2;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  width: 100%;
  justify-content: center;
}
.btn--oauth:hover { background: #166fe5; }
[data-auth="oauth_tiktok"].btn--oauth { background: #010101; }
[data-auth="oauth_tiktok"].btn--oauth:hover { background: #2a2a2a; }

/* Extra-small button */
.btn--xs {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 5px;
}
.btn--danger-ghost {
  color: var(--danger);
  background: transparent;
  border: 1px solid rgba(239,68,68,.3);
}
.btn--danger-ghost:hover { background: rgba(239,68,68,.07); border-color: var(--danger); }

/* Webhooks salientes card */
.int-card--webhooks .int-icon--webhook {
  background: #4f46e5 !important;
}
.wh-row { cursor: default; }
.wh-active-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.wh-active-dot.is-on { background: var(--success); }
.wh-url { font-family: ui-monospace, monospace; font-size: 10px; }

/* Routing modal */
.routing-intro {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 20px;
  line-height: 1.6;
}
.routing-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.routing-fields .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.routing-fields label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.routing-fields select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.routing-fields select:focus { border-color: var(--accent); }

/* Webhook events grid */
.wh-events-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin-top: 4px;
}
.wh-event-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 0;
}
.wh-event-check input { cursor: pointer; accent-color: var(--accent); }

.int-card-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  flex-wrap: wrap;
}
.int-card-actions .btn { flex: 1; }

/* Modal de integración */
.int-modal-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.int-modal-title h3 { margin: 0 0 2px; font-size: 16px; }
.int-modal-desc { margin: 0; font-size: 12px; color: var(--text-muted); }

.int-form-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.int-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.int-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.int-field input,
.int-field textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.int-field input:focus,
.int-field textarea:focus { border-color: var(--accent); }
.int-field-help {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}
.int-field-required {
  color: var(--danger);
  margin-left: 2px;
}
.int-field-optional {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 11px;
  margin-left: 4px;
}
.int-advanced-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 0;
  user-select: none;
  margin-top: 4px;
}
.int-advanced-toggle::after {
  content: '▸';
  font-size: 11px;
  transition: transform .15s;
}
.int-advanced-toggle.int-advanced-open::after {
  transform: rotate(90deg);
}
.int-advanced-toggle:hover { opacity: .8; }
.int-advanced-fields {
  border-left: 2px solid var(--border);
  padding-left: 12px;
  margin-top: 4px;
}
/* Input de valor del lead en modal */
.exp-value-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.exp-value-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 15%, transparent);
}
.exp-value-prefix, .exp-value-suffix {
  padding: 0 10px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg);
  border: none;
  white-space: nowrap;
  line-height: 36px;
}
.exp-value-suffix { border-left: 1px solid var(--border); }
.exp-value-prefix { border-right: 1px solid var(--border); }
.exp-value-wrap input {
  flex: 1;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  min-width: 0;
  height: 36px;
}
/* Badge de valor en el detail panel */
.edf-value-badge {
  font-size: 13px;
  font-weight: 700;
  color: #059669;
}
.int-error {
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--danger);
}
.int-docs-link {
  display: inline-block;
  margin-top: 16px;
  font-size: 12px;
  color: var(--accent);
}

/* Webhook box */
.int-webhook-box {
  margin-top: 20px;
  padding: 14px 16px;
  background: rgba(37, 99, 235, 0.04);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: var(--radius-sm);
}

/* ─── Banner de conexión global ─── */
.conn-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  padding: 8px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.conn-banner.is-offline   { background: #ef4444; }
.conn-banner.is-degraded  { background: #f59e0b; }
.conn-banner.is-recovered { background: #10b981; }

/* ─── Modal: colisión de bot ─── */
.bc-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.bc-bot-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-2, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
}
.bc-bot-icon { font-size: 18px; flex-shrink: 0; }
.bc-bot-info { flex: 1; min-width: 0; }
.bc-bot-name { font-size: 13px; font-weight: 600; color: var(--text, #111); }
.bc-bot-meta { font-size: 11px; color: var(--text-muted, #6b7280); margin-top: 2px; }
.bc-options { display: flex; flex-direction: column; gap: 8px; }
.bc-option {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color .12s, background .12s, transform .08s;
}
.bc-option:hover { border-color: var(--primary, #2563eb); background: rgba(37,99,235,.04); }
.bc-option:active { transform: scale(.99); }
.bc-option--primary { border-color: var(--primary, #2563eb); background: rgba(37,99,235,.06); }
.bc-option--primary:hover { background: rgba(37,99,235,.12); }
.bc-option-icon { font-size: 20px; flex-shrink: 0; line-height: 1; }
.bc-option-text { flex: 1; min-width: 0; }
.bc-option-text strong { display: block; font-size: 13px; font-weight: 600; color: var(--text, #111); margin-bottom: 2px; }
.bc-option-text small { display: block; font-size: 11px; color: var(--text-muted, #6b7280); line-height: 1.35; }

/* ─── Barra global de bulk jobs ─── */
.bulk-job-bar {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9998;
  width: 360px;
  max-width: calc(100vw - 40px);
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  overflow: hidden;
  animation: bulk-job-slide-in .25s ease-out;
}
@keyframes bulk-job-slide-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.bulk-job-bar-inner { padding: 12px 14px 10px; }
.bulk-job-bar-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.bulk-job-bar-icon { font-size: 16px; flex-shrink: 0; }
.bulk-job-bar-label {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: 600;
  color: var(--text, #111);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bulk-job-bar-stats {
  font-size: 11px; color: var(--text-muted, #6b7280);
  font-weight: 500; flex-shrink: 0;
}
.bulk-job-bar-close {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  background: none; border: none;
  color: var(--text-muted, #9ca3af);
  font-size: 18px; line-height: 1;
  cursor: pointer; border-radius: 6px;
  transition: background .1s, color .1s;
}
.bulk-job-bar-close:hover { background: #fee2e2; color: #dc2626; }
.bulk-job-bar-progress {
  height: 6px;
  background: var(--bg-2, #f3f4f6);
  border-radius: 99px;
  overflow: hidden;
}
.bulk-job-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  border-radius: 99px;
  transition: width .3s ease-out;
}
.bulk-job-bar.is-done .bulk-job-bar-fill {
  background: linear-gradient(90deg, #10b981, #34d399);
}
.bulk-job-bar.is-error .bulk-job-bar-fill {
  background: linear-gradient(90deg, #dc2626, #ef4444);
}
.bulk-job-bar-hint {
  font-size: 11px; color: var(--text-muted, #9ca3af);
  margin-top: 6px;
  font-style: italic;
}

/* ─── Pane Notificaciones ─── */
.notif-card {
  margin-top: 12px;
  padding: 18px 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.notif-status {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
}
.notif-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.notif-hint {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.notif-section-title {
  margin: 28px 0 12px;
  font-size: 14px;
  font-weight: 700;
}
.notif-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.notif-log-item {
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.notif-log-item .meta {
  font-size: 11px;
  color: var(--text-muted);
}
.notif-log-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ─── WhatsApp Lite QR ─── */
.int-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px 0 8px;
}
.int-oauth-connected {
  padding: 14px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  margin-bottom: 4px;
}
.int-oauth-connected-name {
  font-size: 14px;
  font-weight: 600;
  color: #065f46;
}
.int-oauth-connected-sub {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}
.int-qr-status {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}
.int-qr-status.is-ok    { color: #10b981; }
.int-qr-status.is-error { color: #ef4444; }
.int-qr-image-wrap {
  width: 320px;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.int-qr-image-wrap img {
  width: 100%;
  height: 100%;
  display: block;
}
.int-qr-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: int-qr-spin 0.9s linear infinite;
}
@keyframes int-qr-spin { to { transform: rotate(360deg); } }
.int-qr-steps {
  margin: 0;
  padding-left: 22px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  align-self: stretch;
}
.int-qr-steps li strong { color: var(--text); }
.int-webhook-box h4 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}
.int-webhook-help {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.int-webhook-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.int-webhook-row code {
  flex: 1;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  overflow-x: auto;
  white-space: nowrap;
}
.int-webhook-events {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

/* ═══════ Vista: Expedientes ═══════ */
.view-expedients {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.exp-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.exp-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  flex: 1;
  min-width: 200px;
}
.exp-search svg { color: var(--text-muted); flex-shrink: 0; }
.exp-search input { border: none; background: transparent; outline: none; font-size: 13px; color: var(--text); width: 100%; }
.exp-toolbar-actions { display: flex; align-items: center; gap: 8px; }

/* Table */
.exp-table-wrap { flex: 1; overflow-y: auto; padding: 0; }
.exp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.exp-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  position: sticky; top: 0; z-index: 1;
}
.exp-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.exp-table tr:hover td { background: #f7f8fa; }
.exp-table tr:last-child td { border-bottom: none; }

.exp-name { font-weight: 600; color: var(--text); }
.exp-name.is-auto-name { color: var(--text-muted); font-weight: 500; }
.exp-contact { color: var(--text-muted); font-size: 12px; }
.exp-pipeline-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(37,99,235,.08);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}
.exp-pipeline-badge-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  white-space: nowrap;
}
.exp-pipeline-arrow { color: var(--text-muted); font-size: 10px; }
/* Tinted pill style — fondo color a ~14%, borde a ~33%, texto siempre oscuro
   para legibilidad sin importar qué color escoja el usuario. */
.exp-pipeline-pill,
.exp-stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.exp-stage-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,0.35),
    0 0 0 1.5px rgba(255,255,255,0.85);
}
.exp-tag {
  display: inline-block;
  padding: 1px 7px;
  background: #e0e7ff;
  color: #4f46e5;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  margin: 1px 2px 1px 0;
}
.exp-date { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.exp-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Empty state */
.exp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 24px;
  color: var(--text-muted);
  text-align: center;
}
.exp-empty svg { opacity: .3; }
.exp-empty p { margin: 0; font-size: 15px; }

/* Expedient form */
.exp-form-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.exp-form-main { display: flex; flex-direction: column; gap: 16px; }
.exp-form-row  { display: flex; gap: 12px; }

/* Contact search */
.exp-contact-search { position: relative; }
.exp-contact-search input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}
.exp-contact-search input:focus { border-color: var(--accent); }
.exp-contact-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
}
.exp-contact-result-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: background .1s;
}
.exp-contact-result-item:hover { background: #f1f5f9; }
.exp-contact-result-name { font-weight: 600; }
.exp-contact-result-meta { font-size: 11px; color: var(--text-muted); }
.exp-contact-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(37,99,235,.06);
  border: 1px solid rgba(37,99,235,.25);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.exp-contact-clear { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 14px; padding: 0 4px; }
.exp-contact-clear:hover { color: var(--danger); }

.exp-contact-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.exp-contact-label-row label { margin-bottom: 0; }

.exp-quick-contact {
  margin-top: 10px;
  padding: 14px 16px;
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideDown .15s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.exp-quick-contact-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
}
.exp-quick-contact-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Tags input */
.exp-tags-input {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: text;
  min-height: 40px;
  align-items: center;
}
.exp-tags-input:focus-within { border-color: var(--accent); }
.exp-tags-chips { display: contents; }
.exp-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e0e7ff;
  color: #4f46e5;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px 2px 10px;
}
.exp-tag-chip button { background: none; border: none; cursor: pointer; color: #6366f1; padding: 0; font-size: 14px; line-height: 1; }
.exp-tag-chip button:hover { color: var(--danger); }
.exp-tags-input input {
  border: none; outline: none; font-size: 13px; font-family: inherit;
  background: transparent; min-width: 120px; flex: 1;
}

/* Custom fields below the main form */
.exp-form-custom {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.exp-form-custom-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.exp-form-custom-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px 0;
}
.exp-form-custom-empty a { color: var(--accent); cursor: pointer; }
.custom-field-input select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  outline: none;
}
.custom-field-input select:focus { border-color: var(--accent); }
.custom-field-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.toggle-switch {
  position: relative;
  width: 36px; height: 20px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0;
  background: #cbd5e1;
  border-radius: 99px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-track::after { transform: translateX(16px); }

/* Custom fields definitions modal */
.fields-defs-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field-def-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.field-def-label { flex: 1; font-weight: 600; }
.field-def-actions { display: flex; gap: 6px; flex-shrink: 0; }
.field-def-type {
  font-size: 11px;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 99px;
}
.field-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 6px;
}
.field-type-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  transition: border-color .12s, background .12s;
}
.field-type-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(37,99,235,.06);
  color: var(--accent);
  font-weight: 600;
}
.field-type-option input { display: none; }
.fields-add-row { margin-top: 8px; }
.fields-new-form {
  margin-top: 16px;
  padding: 16px;
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ═══════ Vista: Contactos ═══════ */
.view-customers {
  padding: 24px 32px;
  overflow-y: auto;
}
.customers-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.customers-search {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  color: var(--text-muted);
}
.customers-search:focus-within { border-color: var(--accent); }
.customers-search input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
}

.customers-table {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.customers-row {
  display: grid;
  grid-template-columns: 1.5fr 1.1fr 1.4fr 1.2fr 1.4fr 0.9fr 80px;
  gap: 12px;
  padding: 14px 18px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.customers-row--head { padding: 10px 18px; }

/* Header (display-only, no sortable) */
.th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
}

/* ─── Sort dropdown ─── */
.sort-menu { position: relative; }
.sort-wrapper { position: relative; }
.sort-menu .btn {
  display: inline-flex;
  align-items: center;
}
.sort-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  padding: 6px;
  display: flex;
  flex-direction: column;
  animation: sortIn 0.12s ease-out;
}
@keyframes sortIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.sort-option {
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background .12s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sort-option:hover { background: var(--bg-bubble-in); }
.sort-option-ico {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
}
.sort-option.is-active .sort-option-ico,
.sort-option:hover .sort-option-ico { color: var(--accent); }
.sort-option.is-active {
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent);
  font-weight: 600;
}
.sort-option.is-active::after {
  content: "✓";
  margin-left: auto;
  font-weight: 700;
}
.sort-separator {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Celda fecha */
.customer-date {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}
.customer-date strong { color: var(--text); font-weight: 500; }
.customers-row:last-child { border-bottom: 0; }
.customers-row--head {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fafbfc;
}
.customer-cell-name {
  display: flex; align-items: center; gap: 10px;
}
.customer-avatar {
  width: 36px; height: 36px;
  min-width: 36px; min-height: 36px;
  flex-shrink: 0; /* No se estira aunque el nombre tome 2 líneas */
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 13px;
  aspect-ratio: 1 / 1;
}
.customer-name { font-weight: 600; color: var(--text); }
.customer-cell-name--clickable { cursor: pointer; border-radius: 6px; padding: 2px 4px; margin: -2px -4px; transition: background .12s, color .12s; }
.customer-cell-name--clickable:hover { background: rgba(59, 130, 246, .06); }
.customer-cell-name--clickable:hover .customer-name { color: var(--accent); }
.customer-sub { font-size: 11px; color: var(--text-muted); }

.customer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.customer-row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.customers-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* ═══════ Modal genérico ═══════ */
/* ── Overlay contenedor (patrón legacy: .modal > .modal-backdrop + .modal-card) ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.55);
}
/* backdrop hijo solo actúa como zona clickeable, sin fondo propio */
.modal > .modal-backdrop {
  position: absolute;
  inset: 0;
  background: none;
  z-index: 0;
  display: block;
}
/* ── Overlay contenedor (patrón nuevo: .modal-backdrop standalone) ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
/* modal-card = legacy; modal-box = new unified */
.modal-card, .modal-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  animation: modalIn 0.18s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2, .modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--text-muted);
  padding: 2px 6px; border-radius: 4px; transition: color 120ms, background 120ms;
}
.modal-close:hover { color: var(--text); background: var(--bg); }
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

/* ── Account drawer (slides from right) ── */
.view-cuenta { overflow-y: auto; }
.cuenta-shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.cuenta-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.cuenta-hero .account-avatar-name { font-size: 18px; font-weight: 700; }
.cuenta-hero .account-avatar-role { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.required { color: var(--danger); }

/* ═══════ Paginador ═══════ */
.paginator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 12px 4px;
  flex-wrap: wrap;
}
.paginator-left,
.paginator-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.paginator select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  outline: none;
}
.paginator select:focus { border-color: var(--accent); }
.paginator-summary {
  margin-left: 4px;
  color: var(--text-muted);
}

.page-btn {
  min-width: 32px; height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .12s;
}
.page-btn:hover:not(:disabled):not(.is-active) {
  border-color: var(--border-strong);
  background: var(--bg-bubble-in);
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.page-btn.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.page-btn--ellipsis {
  border: 0;
  background: transparent;
  cursor: default;
  color: var(--text-muted);
}
.page-btn svg { width: 14px; height: 14px; }

/* ═══════ Expediente chips en tabla de contactos ═══════ */
.customer-expedients {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.exp-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  max-width: 100%;
}
.exp-chip-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 2px;
}
/* Tinted pills — texto siempre oscuro para legibilidad con cualquier color */
.exp-chip-pipeline,
.exp-chip-stage {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}
.exp-chip-arrow { color: var(--text-muted); font-size: 10px; }
.exp-chip-empty { color: var(--text-muted); font-size: 12px; }
.exp-chip--clickable { cursor: pointer; transition: opacity 0.12s, transform 0.1s; }
.exp-chip--clickable:hover { opacity: 0.85; transform: translateY(-1px); }
.exp-chip--clickable:active { transform: translateY(0); }

/* ═══════ Global Loader (barra arriba, aparece durante requests) ═══════ */
.global-loader {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 99999;
  background: linear-gradient(90deg, transparent 0%, var(--primary, #6366f1) 30%, var(--primary, #6366f1) 60%, transparent 100%);
  background-size: 50% 100%;
  background-repeat: no-repeat;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.global-loader.is-active {
  opacity: 1;
  animation: global-loader-slide 1.1s cubic-bezier(.4,0,.2,1) infinite;
}
@keyframes global-loader-slide {
  0%   { background-position: -50% 0; }
  100% { background-position: 150% 0; }
}

/* ═══════ Toast ═══════ */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  animation: toastIn 0.22s cubic-bezier(0.2, 1, 0.3, 1);
}
.toast.is-leaving {
  animation: toastOut 0.18s ease-in forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px) scale(0.95); }
}
.toast-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.toast--success { border-left: 3px solid var(--success); }
.toast--success .toast-icon { background: var(--success); }
.toast--error   { border-left: 3px solid var(--danger); }
.toast--error   .toast-icon { background: var(--danger); }
.toast--info    { border-left: 3px solid var(--accent); }
.toast--info    .toast-icon { background: var(--accent); }
.toast-message { flex: 1; line-height: 1.4; }
.toast-close {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
}
.toast-close:hover { background: var(--bg-bubble-in); color: var(--text); }

/* ═══════ Política de duplicados en import ═══════ */
.import-dupe-policy {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.import-dupe-policy > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.import-dupe-options {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.import-dupe-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.import-dupe-options input[type="radio"] { accent-color: var(--accent); }

.import-status--dupe { background: rgba(245, 158, 11, 0.16); color: #b45309; }

/* ═══════ Importar contactos ═══════ */
.modal-card--lg { width: min(560px, 100%); }

.import-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: -20px -20px 20px;
  padding: 12px 20px 0;
  background: #fafbfc;
}
.import-tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.import-tab:hover { color: var(--text); }
.import-tab.is-active { color: var(--accent); border-color: var(--accent); }

.import-pane { display: none; }
.import-pane.is-active { display: block; }

.import-help {
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(37, 99, 235, 0.05);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.import-template-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 0 4px;
}
.import-template-link .link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--accent, #2563eb);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background .12s;
}
.import-template-link .link-btn:hover { background: rgba(37, 99, 235, 0.08); text-decoration: underline; }
.import-help code {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.import-example {
  margin-bottom: 12px;
}
.import-example-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.import-example pre {
  margin: 6px 0 0;
  padding: 10px 14px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
}

#importTextarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}
#importTextarea:focus { border-color: var(--accent); }

.import-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.import-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: #fafbfc;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.import-dropzone:hover,
.import-dropzone.is-dragover {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.04);
}
.import-dropzone svg { width: 28px; height: 28px; color: var(--accent); }
.import-dropzone-title { font-weight: 600; color: var(--text); font-size: 13px; }
.import-dropzone-sub { font-size: 12px; color: var(--text-muted); }
.import-file-name {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(37, 99, 235, 0.06);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

.import-preview {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.import-preview-summary {
  font-size: 13px;
  margin-bottom: 12px;
  color: var(--text);
}
.import-preview-summary strong { color: var(--accent); }
.import-preview-table {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
}
.import-preview-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr 1.2fr 80px;
  gap: 8px;
  padding: 8px 12px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.import-preview-row:last-child { border-bottom: 0; }
.import-preview-row--head {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fafbfc;
  position: sticky;
  top: 0;
}
.import-preview-row > div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.import-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.import-status--ok { background: rgba(16, 185, 129, 0.12); color: #047857; }
.import-status--warn { background: rgba(245, 158, 11, 0.16); color: #b45309; }
.import-status--err { background: rgba(239, 68, 68, 0.12); color: #b91c1c; }
.import-preview-row--err { opacity: 0.6; }

.import-bulk-tag {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.import-bulk-tag span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}
.import-bulk-tag input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}
.import-bulk-tag input:focus { border-color: var(--accent); }

/* ═══════ Modal: sección Expedientes ═══════ */
.modal-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.modal-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-section-head h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.modal-section-head h4 small {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 6px;
}

.edit-exp-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* El modal de contacto trae bastante (datos + editor de leads con varios campos):
   un poco más ancho para que quepan 3-4 campos por fila sin apretar. */
#customerModal .modal-card { max-width: 660px; }

.edit-exp-row {
  display: grid;
  /* Responsivo: cada campo ≥150px y envuelve a filas nuevas según el ancho.
     Antes era un grid fijo de 5 columnas cuyos <select> (con opciones largas)
     forzaban un min-content > 560px → el modal desbordaba y se clipeaba a la
     izquierda. auto-fit + min-width:0 en los hijos lo mantiene siempre dentro. */
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 12px;
  align-items: start;
  padding: 10px 12px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  position: relative;
}
.edit-exp-row.is-new {
  border-color: rgba(37, 99, 235, 0.4);
  background: rgba(37, 99, 235, 0.04);
}
.edit-exp-row > label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.edit-exp-row input,
.edit-exp-row select,
.edit-exp-row textarea {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s;
  min-width: 0;
  resize: vertical;
}
.edit-exp-row input:focus,
.edit-exp-row select:focus,
.edit-exp-row textarea:focus { border-color: var(--accent); }
.edit-exp-row input[type="checkbox"] {
  width: 18px; height: 18px;
  align-self: flex-start;
  margin-top: 2px;
}
.edit-exp-optional {
  display: inline-block;
  font-size: 9px;
  background: #f1f5f9;
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 99px;
  margin-left: 4px;
  text-transform: lowercase;
  letter-spacing: 0;
  font-weight: 500;
}
.edit-exp-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}
.edit-exp-select-wrap select {
  padding-left: 28px;
  width: 100%;
  flex: 1;
}
.edit-exp-color-dot {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,0.35),
    0 0 0 1.5px rgba(255,255,255,0.85);
}
.edit-exp-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
}
.edit-exp-delete {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.edit-exp-delete:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger, #ef4444); }
.edit-exp-delete svg { width: 16px; height: 16px; }

.edit-exp-open {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent, #2563eb);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
  font-family: inherit;
}
.edit-exp-open:hover { background: var(--accent-dark, #1d4ed8); }
.edit-exp-open svg { width: 12px; height: 12px; flex-shrink: 0; }

@media (max-width: 600px) {
  .edit-exp-row { grid-template-columns: 1fr 1fr; }
  .edit-exp-actions { grid-column: 2; justify-self: end; }
}

/* ═══════ Tag colors — contactos=verde, expedientes=azul ═══════ */
/* Contacto tags (en modal de edición de contacto) */
.tag-chip {
  background: rgba(16,185,129,.12) !important;
  color: #047857 !important;
}
.tag-chip-remove { color: #047857 !important; }
.tag-chip-remove:hover { background: rgba(16,185,129,.2) !important; }

/* Expediente tags (tabla + modal) */
.exp-tag {
  background: rgba(37,99,235,.1) !important;
  color: #1d4ed8 !important;
}
.exp-tag-chip {
  background: rgba(37,99,235,.1) !important;
  color: #1d4ed8 !important;
}
.exp-tag-chip button { color: #1d4ed8 !important; }

/* ═══════ Tag input (chips) ═══════ */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  min-height: 42px;
  cursor: text;
  transition: border-color .15s;
}
.tag-input:focus-within { border-color: var(--accent); }
.tag-input-chips { display: contents; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 10px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.tag-chip-remove {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
}
.tag-chip-remove:hover { background: rgba(37, 99, 235, 0.2); }
#tagInputField {
  flex: 1;
  min-width: 100px;
  border: 0;
  outline: none;
  font-size: 13px;
  background: transparent;
}

/* ════════════════════════════════════════════════════════════════════
   ═══════ Clon Reelance Hub — vista de Chats (estilo iMessage/Mac) ═══
   ═══════ Aislado bajo .rh-clone para no chocar con el resto.    ═══
   ════════════════════════════════════════════════════════════════════ */

/* Cuando la vista activa es Chats, escondemos la topbar global y el
   layout grid de view-chats colapsa en una sola columna. */
.view-chats { display: block; }
body[data-view-active="chats"] .topbar { display: none; }
body[data-view-active="exp-detail"] .topbar { display: none; }
body[data-view-active="inicio"] .topbar { display: none; }
body[data-view-active="chats"] .main { background: #f2f2f7; }

/* Variables del look de WhatsApp/iMessage. Se aplican tanto al "clon" del
   chat principal como al panel de chat dentro del detalle de expediente,
   para que las burbujas (.rh-bubble, .rh-message) tengan colores donde
   se renderizan ambos. */
.rh-clone,
.exp-detail-right {
  /* Variables propias — no contaminan el resto. */
  --rh-bg: #f2f2f7;
  --rh-panel: #ffffff;
  --rh-border: rgba(0, 0, 0, 0.09);
  --rh-border-strong: rgba(0, 0, 0, 0.14);
  --rh-text: #1c1c1e;
  --rh-muted: #8e8e93;
  --rh-muted-light: #aeaeb2;
  --rh-brand: #007aff;
  --rh-brand-soft: rgba(0, 122, 255, 0.1);
  --rh-brand-dark: #0063d1;
  --rh-danger: #ff3b30;
  --rh-incoming-bg: #e9e9eb;
  --rh-incoming-text: #1c1c1e;
  --rh-outgoing-bg: #007aff;
  --rh-outgoing-text: #ffffff;
  --rh-shadow-md: 0 4px 24px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.06);

  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  color: var(--rh-text);
  background: var(--rh-bg);
}

.rh-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100%;
  overflow: hidden;
  background: var(--rh-bg);
}

/* ─── Sidebar interna ─── */
.rh-sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--rh-panel);
  border-right: 1px solid var(--rh-border);
  overflow: hidden;
}
.rh-brand-card {
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--rh-border);
}
.rh-eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 500;
  color: var(--rh-muted);
  text-transform: uppercase;
}
.rh-brand-card h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--rh-text);
}

.rh-search-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rh-border);
  position: relative;
}
.rh-search-icon {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--rh-muted);
  pointer-events: none;
}
.rh-search-wrap input {
  width: 100%;
  background: rgba(120, 120, 128, 0.12);
  border: none;
  border-radius: 9px;
  padding: 7px 12px 7px 30px;
  font: inherit;
  font-size: 14px;
  color: var(--rh-text);
  outline: none;
  transition: background 150ms;
}
.rh-search-wrap input::placeholder { color: var(--rh-muted); }
.rh-search-wrap input:focus { background: rgba(120, 120, 128, 0.18); }

.rh-filter-pills {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--rh-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.rh-filter-pills::-webkit-scrollbar { display: none; }
.rh-filter-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--rh-border-strong);
  border-radius: 999px;
  background: var(--rh-panel);
  color: var(--rh-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.rh-filter-pill:hover { background: rgba(120, 120, 128, 0.08); }
.rh-filter-pill.rh-active {
  background: var(--rh-brand);
  color: #fff;
  border-color: var(--rh-brand);
}
.rh-filter-pill-count {
  background: rgba(120, 120, 128, 0.18);
  color: inherit;
  border-radius: 10px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
}
.rh-filter-pill.rh-active .rh-filter-pill-count {
  background: rgba(255, 255, 255, 0.25);
}

.rh-sidebar-actions { padding: 8px 12px 4px; }

.rh-ghost-button {
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 7px 12px;
  color: var(--rh-brand);
  background: transparent;
  transition: background 120ms;
}
.rh-ghost-button:hover { background: var(--rh-brand-soft); }
.rh-wide-button { width: 100%; text-align: center; display: block; }

.rh-chat-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0;
}
/* ── Avatar en lista de chats ── */
.rh-chat-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 100ms;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font: inherit;
}
.rh-chat-av {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: #64748b;
  position: relative;
}
.rh-chat-av img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.rh-chat-body { flex: 1; min-width: 0; }

/* ── Avatar en header de conversación ── */
.rh-header-av-wrap {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.rh-header-av-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.rh-header-av-initials {
  font-size: 13px; font-weight: 600; color: #64748b;
}
.rh-chat-item:hover { background: rgba(0, 0, 0, 0.04); }
.rh-chat-item.rh-active { background: var(--rh-brand-soft); }
.rh-chat-item:focus-visible { outline: 2px solid var(--rh-brand); outline-offset: -2px; }
.rh-chat-item.rh-pinned { background: #fdfaef; }
.rh-chat-item.rh-pinned:hover { background: #f7efd6; }

.rh-chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.rh-chat-name-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

/* 24h WhatsApp countdown pill */
.rh-wa24-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(239,68,68,.35);
  background: rgba(239,68,68,.07);
  color: #ef4444;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1;
  flex-shrink: 0;
}
.rh-wa24-pill.is-expired {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.rh-chat-pin-icon { color: #c2952a; flex-shrink: 0; line-height: 0; }
.rh-chat-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--rh-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rh-chat-time {
  font-size: 12px;
  color: var(--rh-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.rh-chat-phone {
  margin: 0 0 2px;
  font-size: 12px;
  color: var(--rh-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rh-chat-preview {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--rh-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.rh-chat-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.rh-chat-origin {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: #e6f4d6;
  color: #466423;
  border: 1px solid #d3e6b8;
  letter-spacing: 0.02em;
}
.rh-chat-meta-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.rh-chat-unread-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rh-brand, #3b82f6);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, .15);
}
.rh-chat-unread-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--rh-brand, #3b82f6);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}
/* Tipografía más viva en chats no leídos (estilo WhatsApp/iOS) */
.rh-chat-item.is-unread .rh-chat-name { font-weight: 700; }
.rh-chat-item.is-unread .rh-chat-time {
  color: var(--rh-brand, #3b82f6);
  font-weight: 600;
}
.rh-chat-item.is-unread .rh-chat-preview { color: var(--rh-text); font-weight: 500; }
.rh-pipeline-stage {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 500;
  background: #f1f1f3;
  color: #888;
  letter-spacing: 0.01em;
  line-height: 1.5;
}
.rh-channel-badge { display: inline-flex; align-items: center; gap: 5px; }
.rh-channel-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.rh-channel-whatsapp { background: #25d366; }
.rh-channel-whatsapp-lite { background: #25d366; }
.rh-channel-messenger { background: #0084ff; }
.rh-channel-instagram { background: linear-gradient(45deg, #f09433, #dc2743 50%, #bc1888); }
.rh-channel-telegram { background: #2ca5e0; }
.rh-channel-tiktok { background: #000; }

.rh-chat-empty, .rh-messages-empty {
  text-align: center;
  color: var(--rh-text-muted, #94a3b8);
  font-size: 13px;
  padding: 32px 16px;
  line-height: 1.6;
}

/* Toast persistente de "Hay nueva versión" tras deploy */
.app-update-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1d4ed8;
  color: #fff;
  padding: 12px 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(30, 64, 175, 0.35);
  z-index: 9999;
  max-width: 92vw;
  animation: appUpdateSlide .3s ease-out;
}
.app-update-toast button {
  background: #fff;
  color: #1d4ed8;
  border: none;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.app-update-toast button:hover { background: #eff6ff; }
.app-update-toast button[aria-label="Cerrar"] {
  background: transparent;
  color: #fff;
  padding: 4px 8px;
  font-size: 16px;
  line-height: 1;
}
.app-update-toast button[aria-label="Cerrar"]:hover { background: rgba(255,255,255,.15); }
@keyframes appUpdateSlide {
  from { transform: translate(-50%, 30px); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}

/* Mobile: toast como barra arriba del bottom nav, no pill flotante */
@media (max-width: 768px) {
  .app-update-toast {
    left: 12px;
    right: 12px;
    bottom: calc(80px + env(safe-area-inset-bottom, 0)); /* arriba del bottom nav */
    transform: none;
    max-width: none;
    width: auto;
    border-radius: 12px;
    padding: 10px 12px;
    gap: 8px;
    font-size: 12px;
    box-shadow: 0 4px 16px rgba(30, 64, 175, 0.4);
  }
  .app-update-toast > span {
    flex: 1;
    min-width: 0;
    line-height: 1.3;
  }
  .app-update-toast button {
    padding: 6px 10px;
    font-size: 11px;
    flex-shrink: 0;
  }
  .app-update-toast button[aria-label="Cerrar"] {
    padding: 4px 6px;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
  }
  @keyframes appUpdateSlide {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }
}

/* Empty state cuando no hay conversación seleccionada */
.rh-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 40px 20px;
  color: var(--rh-text-muted, #94a3b8);
  height: 100%;
  min-height: 240px;
}
.rh-conversation-panel.rh-empty .rh-conversation-header,
.rh-conversation-panel.rh-empty .rh-reply-form { visibility: hidden; }
.rh-empty-state svg { color: #cbd5e1; opacity: .8; }
.rh-empty-state h3 { margin: 6px 0 0; font-size: 16px; font-weight: 600; color: #475569; }
.rh-empty-state p { margin: 0; font-size: 13px; max-width: 320px; }

/* Banner de "Activar notificaciones" en /chats */
.rh-push-cta {
  display: inline-flex;
  align-items: stretch;
  margin: 6px 12px 0;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: transparent;
  overflow: hidden;
  transition: background .15s, border-color .15s;
  align-self: flex-start;
}
.rh-push-cta:hover { background: #f8fafc; }
.rh-push-cta-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  color: #64748b;
  border: none;
  padding: 3px 9px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: color .15s;
  line-height: 1.4;
}
.rh-push-cta-btn:hover { color: #334155; }
.rh-push-cta-btn:disabled { opacity: .5; cursor: not-allowed; }
.rh-push-cta-icon { flex-shrink: 0; }
.rh-push-cta-close {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-left: 1px solid #e2e8f0;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 6px;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.rh-push-cta-close:hover { color: #475569; background: #f1f5f9; }

/* ─── Panel de conversación ─── */
.rh-conversation-panel {
  /* Flex column (antes era grid de 3 filas 'auto 1fr auto', pero al agregar
     el owner-badge quedaron 4 elementos → el badge caía en la fila 1fr y se
     estiraba altísimo). Con flex, SOLO los mensajes crecen; header, badge y
     composer toman su contenido. El badge oculto (display:none) no descuadra. */
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--rh-bg);
}
.rh-conversation-panel > .rh-conversation-header { flex: 0 0 auto; }
.rh-conversation-panel > .rh-owner-badge         { flex: 0 0 auto; }
.rh-conversation-panel > .rh-messages            { flex: 1 1 0; }
.rh-conversation-panel > .rh-reply-form          { flex: 0 0 auto; }
.rh-conversation-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--rh-border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  min-height: 58px;
}
.rh-conversation-heading { min-width: 0; flex: 1; display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

/* ── Lead tags bar (next to channel tab) ── */
.exp-lead-tags-bar { display:flex; align-items:center; gap:4px; flex-wrap:wrap; }
.exp-tag-pill { display:inline-flex; align-items:center; gap:3px; padding:2px 7px 2px 9px; background:#f1f5f9; border:1px solid #e2e8f0; border-radius:20px; font-size:11px; color:#475569; cursor:pointer; white-space:nowrap; transition:background .15s; }
.exp-tag-pill:hover { background:#e2e8f0; }
.exp-tag-pill-del { background:none; border:none; padding:0; margin-left:1px; font-size:13px; line-height:1; color:#94a3b8; cursor:pointer; display:flex; align-items:center; }
.exp-tag-pill-del:hover { color:#ef4444; }
.exp-tag-add-btn { background:none; border:1.5px dashed #cbd5e1; border-radius:20px; padding:2px 8px; font-size:11px; color:#94a3b8; cursor:pointer; white-space:nowrap; transition:all .15s; }
.exp-tag-add-btn:hover { border-color:#6366f1; color:#6366f1; }
.exp-tag-input-wrap { display:inline-flex; }
.exp-tag-input { border:1px solid #6366f1; border-radius:20px; padding:2px 10px; font-size:11px; outline:none; width:130px; color:#1e293b; background:#fff; }

/* ── Bot toggle button in chat header ── */
.rh-bot-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1.5px solid #34c759;
  background: rgba(52,199,89,.08);
  color: #1a7a32;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms, border-color 150ms, color 150ms;
  flex-shrink: 0;
}
.rh-bot-toggle:hover { background: rgba(52,199,89,.18); }
.rh-bot-toggle-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #34c759;
  flex-shrink: 0;
  transition: background 150ms;
}
.rh-bot-toggle.is-paused {
  border-color: var(--rh-border, #e2e8f0);
  background: rgba(0,0,0,.04);
  color: var(--rh-text-muted, #94a3b8);
}
.rh-bot-toggle.is-paused .rh-bot-toggle-dot { background: var(--rh-text-muted, #94a3b8); }

/* ── Exp-detail chat search ── */
.exp-chat-search-wrap {
  display: flex; align-items: center; gap: 6px;
  background: var(--sidebar-bg, #f1f5f9); border-radius: 8px;
  padding: 5px 10px; max-width: 260px; flex-shrink: 0;
  border: 1.5px solid transparent; transition: border-color 150ms;
}
.exp-chat-search-wrap:focus-within { border-color: var(--accent); }
.exp-chat-search-wrap.no-results { border-color: #ef4444; }
.exp-chat-search-icon { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }
.exp-chat-search-input {
  flex: 1; min-width: 0; border: none; background: transparent;
  font-size: 12px; outline: none; color: var(--text);
}
.exp-chat-search-input::placeholder { color: var(--text-muted); }
.exp-chat-search-clear {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  font-size: 13px; padding: 0; line-height: 1; flex-shrink: 0;
}
.exp-chat-search-clear:hover { color: var(--text); }
.exp-chat-search-count {
  font-size: 10px; font-weight: 700; color: var(--accent);
  background: rgba(var(--accent-rgb, 99,102,241),.12); border-radius: 999px;
  padding: 1px 6px; flex-shrink: 0;
}
.no-results .exp-chat-search-count { color: #ef4444; background: rgba(239,68,68,.12); }
mark.rh-chat-hl { background: #fef08a; border-radius: 2px; padding: 0 1px; color: inherit; }
.rh-conversation-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--rh-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rh-conversation-title.is-clickable {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: -6px;
  transition: background .12s, color .12s;
}
.rh-conversation-title.is-clickable:hover {
  background: rgba(37, 99, 235, .08);
  color: var(--accent, #2563eb);
}

/* Badge de error de entrega en el header del chat — colores por categoría */
.rh-delivery-error-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
  cursor: pointer;
  font-family: inherit;
  transition: transform .12s, box-shadow .12s;
}
.rh-delivery-error-badge:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(15,23,42,.12); }
.rh-delivery-error-badge.blocked,
.rh-delivery-error-badge.no_whatsapp,
.rh-delivery-error-badge.invalid_number,
.rh-delivery-error-badge.payment_issue,
.rh-delivery-error-badge.account_restricted,
.rh-delivery-error-badge.suspended {
  background: #fee2e2; color: #991b1b; border-color: #fca5a5;
}
.rh-delivery-error-badge.window_closed,
.rh-delivery-error-badge.template,
.rh-delivery-error-badge.marketing_limit,
.rh-delivery-error-badge.template_paused,
.rh-delivery-error-badge.meta_experiment,
.rh-delivery-error-badge.meta_down,
.rh-delivery-error-badge.self_send,
.rh-delivery-error-badge.privacy {
  background: #fef3c7; color: #78350f; border-color: #fcd34d;
}
.rh-delivery-error-badge.rate_limit,
.rh-delivery-error-badge.other {
  background: #fef3c7; color: #92400e; border-color: #fcd34d;
}
.rh-delivery-error-label { letter-spacing: 0.01em; }

/* Ícono de error de entrega en la tarjeta del kanban */
.pl-card-deliv-err {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid;
  background: #fff;
  cursor: pointer;
  margin-left: 6px;
  flex-shrink: 0;
  transition: transform .12s;
  padding: 0;
}
.pl-card-deliv-err:hover { transform: scale(1.15); }
.pl-card-deliv-err.blocked,
.pl-card-deliv-err.no_whatsapp,
.pl-card-deliv-err.invalid_number,
.pl-card-deliv-err.payment_issue,
.pl-card-deliv-err.account_restricted,
.pl-card-deliv-err.suspended {
  background: #fee2e2; color: #dc2626; border-color: #fca5a5;
}
.pl-card-deliv-err.window_closed,
.pl-card-deliv-err.template,
.pl-card-deliv-err.marketing_limit,
.pl-card-deliv-err.template_paused,
.pl-card-deliv-err.meta_experiment,
.pl-card-deliv-err.meta_down,
.pl-card-deliv-err.self_send,
.pl-card-deliv-err.privacy,
.pl-card-deliv-err.rate_limit,
.pl-card-deliv-err.other {
  background: #fef3c7; color: #d97706; border-color: #fcd34d;
}
.pl-card.has-delivery-error .pl-card-name {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
}

/* Modal de detalle del error de entrega */
.rh-deliv-err-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  background: #fee2e2;
  color: #dc2626;
}
.rh-deliv-err-icon.blocked,
.rh-deliv-err-icon.no_whatsapp,
.rh-deliv-err-icon.invalid_number,
.rh-deliv-err-icon.payment_issue,
.rh-deliv-err-icon.account_restricted,
.rh-deliv-err-icon.suspended { background: #fee2e2; color: #dc2626; }
.rh-deliv-err-icon.window_closed,
.rh-deliv-err-icon.template,
.rh-deliv-err-icon.marketing_limit,
.rh-deliv-err-icon.template_paused,
.rh-deliv-err-icon.meta_experiment,
.rh-deliv-err-icon.meta_down,
.rh-deliv-err-icon.self_send,
.rh-deliv-err-icon.privacy,
.rh-deliv-err-icon.rate_limit,
.rh-deliv-err-icon.other { background: #fef3c7; color: #d97706; }
.rh-deliv-err-icon svg { width: 28px; height: 28px; }

/* Settings → Biblioteca de errores */
.err-lib-list { display: flex; flex-direction: column; gap: 12px; max-width: 780px; }
.err-lib-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 14px 16px;
}
.err-lib-icon.rh-deliv-err-icon { width: 40px; height: 40px; margin: 2px 0 0; flex-shrink: 0; }
.err-lib-icon.rh-deliv-err-icon svg { width: 20px; height: 20px; }
.err-lib-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #0f172a);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.err-lib-codes { font-size: 11px; font-weight: 500; color: var(--text-muted, #64748b); background: #f1f5f9; border-radius: 6px; padding: 2px 7px; }
.err-lib-desc { font-size: 13px; line-height: 1.55; color: var(--text-soft, #475569); margin: 0 0 6px; }
.err-lib-action { font-size: 13px; line-height: 1.55; color: var(--text, #0f172a); margin: 0; }

/* ─── Catálogo crudo de códigos de Meta (debajo de la biblioteca) ─── */
.meta-codes-search { max-width: 780px; margin-bottom: 12px; }
.meta-codes-list { display: flex; flex-direction: column; gap: 8px; max-width: 780px; }
.meta-codes-empty { font-size: 13px; color: var(--text-muted, #64748b); padding: 10px 2px; margin: 0; }
.meta-code-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 11px 14px;
}
.meta-code-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  background: #f1f5f9;
  color: #475569;
  min-width: 72px;
  text-align: center;
}
/* Los 2388xxx llegan como error_subcode junto a code 100 — se marcan distinto
   para que no se confundan con un code de primer nivel. */
.meta-code-num.subcode { background: rgba(37, 99, 235, .1); color: #2563eb; }
.meta-code-body { min-width: 0; }
.meta-code-title { font-size: 13.5px; font-weight: 600; color: var(--text, #0f172a); margin-bottom: 3px; }
.meta-code-fix { font-size: 12.5px; line-height: 1.5; color: var(--text-soft, #475569); margin: 0; }

/* ─── Aviso en vivo de reglas de Meta en el editor de plantillas ─── */
.tpl-body-warn {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(245, 158, 11, .1);
  border: 1px solid rgba(245, 158, 11, .35);
  font-size: 12.5px;
  line-height: 1.5;
  color: #92400e;
}
.tpl-body-warn ul { margin: 6px 0 0; padding-left: 18px; }
.tpl-body-warn li + li { margin-top: 4px; }
.tpl-body-warn code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  background: rgba(146, 64, 14, .12);
  border-radius: 4px;
  padding: 1px 4px;
}

/* ─── Caja negra del lead ─── */
.exp-detail-blackbox-btn { margin-left: 6px; }
.blackbox-box { max-width: 640px; width: 100%; display: flex; flex-direction: column; max-height: 85vh; }
.blackbox-lead { color: var(--text-muted, #64748b); font-weight: 500; }
.blackbox-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 20px; border-bottom: 1px solid var(--border, #e2e8f0); flex-wrap: wrap; }
.blackbox-filters { display: flex; gap: 6px; }
.bb-filter { font-size: 12.5px; padding: 5px 11px; border-radius: 99px; border: 1px solid var(--border, #e2e8f0); background: transparent; color: var(--text-soft, #475569); cursor: pointer; }
.bb-filter.is-active { background: var(--accent, #2563eb); color: #fff; border-color: var(--accent, #2563eb); }
.blackbox-note { font-size: 11px; color: var(--text-muted, #94a3b8); max-width: 300px; line-height: 1.35; }
.blackbox-body { overflow-y: auto; padding: 8px 10px; flex: 1; }
.blackbox-loading { padding: 30px; text-align: center; color: var(--text-muted, #64748b); font-size: 13px; }
.bb-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 8px; border-left: 3px solid transparent; }
.bb-row:hover { background: var(--surface-1, #f8fafc); }
.bb-msg-out { border-left-color: #3b82f6; }
.bb-msg-in  { border-left-color: #22c55e; }
.bb-router  { border-left-color: #a855f7; }
.bb-activity{ border-left-color: #f59e0b; }
.bb-ico { font-size: 15px; width: 22px; text-align: center; flex-shrink: 0; line-height: 1.5; }
.bb-content { flex: 1; min-width: 0; }
.bb-title { font-size: 13px; color: var(--text, #0f172a); line-height: 1.4; word-break: break-word; }
.bb-sub { font-size: 11.5px; color: var(--text-muted, #64748b); margin-top: 2px; line-height: 1.4; }
.bb-when { font-size: 11px; color: var(--text-muted, #94a3b8); white-space: nowrap; flex-shrink: 0; margin-top: 1px; }
.bb-badge { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 5px; background: #f1f5f9; color: #475569; }
.bb-badge.bb-read { background: #dbeafe; color: #1d4ed8; }
.bb-badge.bb-ok   { background: #dcfce7; color: #15803d; }
.bb-badge.bb-fail { background: #fee2e2; color: #b91c1c; }
.bb-badge.bb-in   { background: #ecfccb; color: #4d7c0f; }

/* ─── Monitor (logs + sesiones web) ─── */
.monitor-subtabs { display: flex; gap: 8px; margin: 4px 0 14px; border-bottom: 1px solid var(--border, #e2e8f0); }
.mon-subtab { font-size: 13px; padding: 8px 14px; border: none; background: transparent; color: var(--text-soft, #64748b); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.mon-subtab.is-active { color: var(--accent, #2563eb); border-bottom-color: var(--accent, #2563eb); font-weight: 600; }
.mon-online-badge { font-size: 11px; font-weight: 600; color: #15803d; margin-left: 4px; }
.mon-pane { max-height: 62vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.bb-mon-error { border-left-color: #ef4444; }
.bb-mon-router { border-left-color: #a855f7; }
.bb-mon-alert { border-left-color: #f59e0b; }
.bb-mon-activity { border-left-color: #64748b; }
.mon-web-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 8px; }
.mon-web-row:hover { background: var(--surface-1, #f8fafc); }
.mon-web-row.is-online { background: #f0fdf4; }
.mon-web-dot { width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; flex-shrink: 0; margin-top: 5px; }
.mon-web-dot.on { background: #22c55e; box-shadow: 0 0 0 3px #22c55e33; animation: monPulse 1.6s infinite; }
@keyframes monPulse { 0%,100% { box-shadow: 0 0 0 3px #22c55e33; } 50% { box-shadow: 0 0 0 5px #22c55e22; } }
.mon-web-live { display: inline-block; font-size: 9.5px; font-weight: 700; color: #fff; background: #22c55e; padding: 1px 5px; border-radius: 4px; letter-spacing: .04em; vertical-align: 1px; }
.rh-deliv-err-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 16px;
  text-align: center;
}
.rh-deliv-err-action {
  background: #f8fafc;
  border-left: 3px solid var(--accent, #2563eb);
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
}
.rh-deliv-err-action strong { display: block; font-size: 12px; color: var(--accent, #2563eb); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.rh-deliv-err-action p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text); }
.rh-deliv-err-meta {
  font-size: 11px;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 10px 12px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rh-deliv-err-meta strong { color: var(--text); }

/* Pipeline · Etapa pill clickable en el header del chat */
.rh-pipeline-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  padding: 2px 0;
  font-size: 11px;
  color: var(--rh-text);
  cursor: pointer;
  font-family: inherit;
}
.rh-pipeline-pill:hover .rh-pipeline-pill-name,
.rh-pipeline-pill:hover .rh-pipeline-pill-stage {
  filter: brightness(0.96);
}
/* Tinted style — fondo color a ~14%, borde a ~33%, texto siempre oscuro */
.rh-pipeline-pill-name,
.rh-pipeline-pill-stage {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid transparent;
  color: var(--rh-text);
  line-height: 1.4;
}
.rh-pipeline-pill-arrow { color: var(--rh-muted); font-size: 10px; margin: 0 1px; }
.rh-pipeline-pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.rh-conversation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
  font-size: 12px;
  color: var(--rh-muted);
}
.rh-conversation-origin {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: #e6f4d6;
  color: #466423;
  border: 1px solid #d3e6b8;
  letter-spacing: 0.02em;
}

/* ─── Mensajes ─── */
.rh-messages {
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  background: var(--rh-bg);
}
/* Spacer: empuja los mensajes al fondo cuando hay pocos (estilo WhatsApp/
   Messenger), sin romper el scroll cuando hay muchos (el spacer se comprime
   a 0). Antes con 1-2 mensajes quedaban flotando con un hueco grande arriba. */
.rh-messages::before { content: ''; flex: 1 0 auto; }
.rh-message {
  display: flex;
  flex-direction: column;
  max-width: min(72%, 380px);
  margin-bottom: 6px;
}
.rh-message.rh-outgoing { align-self: flex-end; }
.rh-message.rh-incoming { align-self: flex-start; }

.rh-message-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  padding: 0 3px;
  font-size: 10.5px;
  color: rgba(0,0,0,.42);
  line-height: 1;
  flex-wrap: wrap;
}
.rh-message-foot.rh-foot-out { justify-content: flex-end; }

.rh-bubble {
  border-radius: 14px;
  padding: 6px 10px;
  line-height: 1.45;
  white-space: pre-wrap;
  font-size: 13.5px;
  word-break: break-word;
  position: relative;
}
.rh-message.rh-incoming .rh-bubble {
  background: var(--rh-incoming-bg);
  color: var(--rh-incoming-text);
  border-bottom-left-radius: 4px;
}
.rh-message.rh-outgoing .rh-bubble {
  background: var(--rh-outgoing-bg);
  color: var(--rh-outgoing-text);
  border-bottom-right-radius: 4px;
}

.rh-message-meta {
  font-size: 10.5px;
  color: rgba(0,0,0,.42);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1;
}
.rh-bubble-attachment { margin: -3px -8px 4px; }
.rh-bubble-attachment img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 12px;
  object-fit: cover;
}
.rh-bubble-attachment-link {
  display: inline-block;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
}
.rh-message.rh-incoming .rh-bubble-attachment-link { background: rgba(0, 0, 0, 0.06); }
.rh-msg-status { display: inline-flex; line-height: 0; align-items: center; cursor: help; }
.rh-msg-status svg { height: 12px; width: auto; }
.rh-msg-status.rh-sent      { color: rgba(255,255,255,.55); }
.rh-msg-status.rh-delivered { color: rgba(255,255,255,.85); }
.rh-msg-status.rh-read      { color: #34b7f1; }
.rh-msg-status.rh-failed {
  color: #fca5a5;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  padding: 0 2px;
}

/* Burbuja con borde rojo punteado cuando el mensaje no se entregó */
.rh-bubble.is-failed {
  border: 1.5px dashed #ef4444;
  background: rgba(239, 68, 68, .08) !important;
  color: var(--rh-text);
}
.rh-message.rh-outgoing .rh-bubble.is-failed {
  background: rgba(239, 68, 68, .12) !important;
  color: var(--rh-text);
}
.rh-msg-error {
  margin-top: 4px;
  font-size: 11px;
  color: #b91c1c;
  font-weight: 500;
  line-height: 1.3;
  padding: 0 4px;
  text-align: right;
}

/* ─── Actividad del expediente (en el chat) ─── */
.rh-act-event {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 16px;
  padding: 0;
  opacity: .62;
}
.rh-act-event:hover { opacity: .85; }
.rh-act-icon {
  font-size: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-style: normal;
}
.rh-act-text {
  font-size: 11px;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.rh-act-by {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  opacity: .85;
}
.rh-act-time {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: .7;
}

/* Colores por tipo de evento */
.rh-act-event[data-type="stage_change"]        .rh-act-icon { background: rgba(59,130,246,.15); color: #3b82f6; }
.rh-act-event[data-type="pipeline_change"]     .rh-act-icon { background: rgba(139,92,246,.15); color: #8b5cf6; }
.rh-act-event[data-type="bot_start"]           .rh-act-icon { background: rgba(234,179,8,.15);  color: #ca8a04; }
.rh-act-event[data-type="bot_done"]            .rh-act-icon { background: rgba(34,197,94,.15);  color: #16a34a; }
.rh-act-event[data-type="bot_error"]           .rh-act-icon { background: rgba(239,68,68,.12);  color: #dc2626; }
.rh-act-event[data-type="bot_killed"]          .rh-act-icon { background: rgba(239,68,68,.12);  color: #dc2626; }
.rh-act-event[data-type="bot_error"]           { border-left: 2px solid rgba(239,68,68,.4); }
.rh-act-event[data-type="bot_killed"]          { border-left: 2px solid rgba(239,68,68,.4); }
.rh-act-event[data-type="bot_paused_manual"]   .rh-act-icon { background: rgba(245,158,11,.15); color: #d97706; }
.rh-act-event[data-type="bot_resumed"]         .rh-act-icon { background: rgba(34,197,94,.15);  color: #16a34a; }
.rh-act-event[data-type="tag_add"]             .rh-act-icon { background: rgba(20,184,166,.15); color: #0d9488; }
.rh-act-event[data-type="tag_remove"]          .rh-act-icon { background: rgba(148,163,184,.15);color: #64748b; }
.rh-act-event[data-type="name_change"]         .rh-act-icon,
.rh-act-event[data-type="contact_name_change"] .rh-act-icon,
.rh-act-event[data-type="phone_change"]        .rh-act-icon { background: rgba(249,115,22,.15); color: #ea580c; }
.rh-act-event[data-type="created"]             .rh-act-icon { background: rgba(99,102,241,.15); color: #6366f1; }

/* ─── Reply form ─── */
.rh-reply-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--rh-border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* Menú contextual en chat list (click derecho / long-press) */
.rh-chat-ctx-menu {
  position: fixed;
  z-index: 9999;
  background: #fff;
  border: 1px solid var(--rh-border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15,23,42,.18);
  padding: 4px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
}
.rh-ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: var(--rh-text);
  cursor: pointer;
  border-radius: 6px;
}
.rh-ctx-item:hover { background: var(--bg, #f8fafc); }
.rh-ctx-sep { border: none; border-top: 1px solid var(--rh-border, #f1f5f9); margin: 4px 0; }

/* Iconos de fijado y silenciado en la fila del chat */
.rh-chat-pin-icon {
  display: inline-block;
  font-size: 11px;
  margin-right: 4px;
  vertical-align: middle;
  filter: hue-rotate(40deg) saturate(1.3);
}
.rh-chat-muted-icon {
  display: inline-block;
  font-size: 11px;
  margin-right: 4px;
  vertical-align: middle;
  opacity: .7;
}
.rh-chat-item.is-pinned {
  background: linear-gradient(to right, rgba(251, 191, 36, .08), transparent 60%);
}

/* Acciones del header del chat (modo personal: etiquetas) */
.rh-conversation-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.rh-conversation-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.rh-personal-tags-wrap { position: relative; }
.rh-personal-tags-btn { position: relative; }
.rh-personal-tags-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--rh-brand, #3b82f6);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.rh-personal-tags-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border: 1px solid var(--rh-border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15,23,42,.16);
  padding: 14px;
  width: 320px;
  max-width: calc(100vw - 24px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (max-width: 720px) {
  .rh-personal-tags-popover {
    position: fixed;
    top: 64px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
  }
}
.rh-ptp-header { display: flex; flex-direction: column; gap: 2px; }
.rh-ptp-header strong { font-size: 13px; color: var(--rh-text); }
.rh-ptp-header span { font-size: 11px; color: var(--rh-muted); }
.rh-ptp-assigned { display: flex; flex-wrap: wrap; gap: 4px; min-height: 28px; padding: 4px 0; border-top: 1px solid #f1f5f9; padding-top: 8px; }
.rh-ptp-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.rh-ptp-pill-x {
  background: rgba(255,255,255,.22);
  border: none;
  color: #fff;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.rh-ptp-pill-x:hover { background: rgba(255,255,255,.4); }
.rh-ptp-empty { font-size: 11px; color: var(--rh-muted); font-style: italic; padding: 4px; }
.rh-ptp-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--rh-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}
.rh-ptp-input:focus { border-color: var(--accent, #2563eb); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.rh-ptp-suggest { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 8px; border-top: 1px solid #f1f5f9; }
.rh-ptp-suggest-label { width: 100%; font-size: 10px; color: var(--rh-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.rh-ptp-suggest-btn {
  border: none;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: transform .08s, box-shadow .08s;
}
.rh-ptp-suggest-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(15,23,42,.15); }

/* Botón Adjuntar — menú flotante con opciones (Imagen / Documento) */
.rh-attach-wrap { position: relative; display: inline-block; }
.rh-attach-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: #fff;
  border: 1px solid var(--rh-border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15,23,42,.12);
  padding: 6px;
  min-width: 240px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rh-attach-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: var(--rh-text);
}
.rh-attach-option:hover { background: var(--bg, #f8fafc); }

/* ─── Selector de canal de envío en el composer (compacto) ─── */
.rh-channel-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
/* Versión compacta: solo icono + chevron diminuto (28x24, mismo size que rh-icon-button) */
.rh-channel-mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--rh-muted, #94a3b8);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  height: 28px;
}
.rh-channel-mini-btn:hover {
  background: var(--bg-soft, #f1f5f9);
  color: var(--text, #0f172a);
  border-color: var(--rh-border, #e2e8f0);
}
.rh-channel-mini-btn .rh-channel-mini-ico { display: inline-flex; }
.rh-channel-mini-btn .rh-channel-mini-chev { opacity: .6; }
.rh-channel-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid var(--rh-border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(15,23,42,.12);
  padding: 5px;
  min-width: 240px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rh-channel-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  color: #334155;
  text-align: left;
  width: 100%;
}
.rh-channel-option:hover { background: #f1f5f9; }
.rh-channel-option.is-selected { background: #eff6ff; color: #2563eb; font-weight: 600; }
.rh-channel-option .rh-channel-ico { font-size: 14px; line-height: 1; }
.rh-channel-option .rh-channel-check { margin-left: auto; color: #10b981; }

/* Icono del provider junto al timestamp en cada mensaje (sutil, gris) */
.rh-msg-provider {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 4px;
  opacity: 0.65;
  line-height: 0;
}
.rh-msg-provider svg { display: block; }
.rh-msg-provider:hover { opacity: 1; }
.rh-attach-option:hover .rh-attach-ico {
  background: var(--accent, #2563eb);
  color: #fff;
  border-color: transparent;
}
.rh-attach-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--bg, #f1f5f9);
  color: var(--accent, #2563eb);
  border: 1px solid var(--rh-border, #e2e8f0);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.rh-attach-ico svg { width: 18px; height: 18px; display: block; }
.rh-attach-label { font-weight: 600; font-size: 13px; }
.rh-attach-hint { font-size: 11px; color: var(--rh-muted); margin-top: 2px; }

/* Modal de preview del adjunto */
.rh-attach-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 16px;
  min-height: 180px;
}
/* Barra de progreso al enviar adjunto (subida real + fase de procesado indeterminada) */
.rh-attach-progress { margin-top: 14px; }
.rh-attach-progress[hidden] { display: none; }
.rh-attach-progress__label {
  font-size: 12.5px;
  color: var(--text-soft, #64748b);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.rh-attach-progress__pct { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text, #0f172a); }
.rh-attach-progress__track {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}
.rh-attach-progress__bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent, #2563eb);
  transition: width 0.18s ease;
}
/* Fase de servidor (transcode + envío a WhatsApp): opaca → animación en vez de % falso */
.rh-attach-progress__bar--indeterminate {
  width: 40% !important;
  transition: none;
  animation: rhAttachIndet 1.05s ease-in-out infinite;
}
@keyframes rhAttachIndet {
  0%   { margin-left: -40%; }
  100% { margin-left: 100%; }
}
.rh-attach-img-preview {
  max-width: 100%;
  max-height: 360px;
  border-radius: 6px;
  display: block;
}
.rh-attach-video-preview {
  max-width: 100%;
  max-height: 360px;
  border-radius: 6px;
  display: block;
  background: #000;
}
.rh-attach-audio-preview {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--rh-border);
  border-radius: 10px;
}
.rh-attach-audio-icon { font-size: 36px; }
.rh-attach-audio-info { width: 100%; text-align: center; }
.rh-attach-audio-name { font-size: 13px; font-weight: 500; color: var(--rh-text); margin-bottom: 4px; }

/* Render de video y audio dentro del chat */
.rh-msg-media-video {
  display: block;
  max-width: 320px;
  width: 100%;
  border-radius: 8px;
  background: #000;
}
.rh-msg-media-audio {
  display: block;
  max-width: 320px;
  width: 100%;
  margin: 4px;
}

/* Wrapper de media con botón de descarga + arrastrar al escritorio */
.rh-msg-media-wrap {
  position: relative;
  display: inline-block;
  max-width: 320px;
  border-radius: 8px;
  cursor: grab;
}
.rh-msg-media-wrap:active { cursor: grabbing; }
.rh-msg-media-wrap.is-audio { display: block; cursor: default; }
.rh-media-dl-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, .62);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s, transform .1s;
  z-index: 3;
  backdrop-filter: blur(2px);
}
.rh-msg-media-wrap:hover .rh-media-dl-btn,
.rh-media-dl-btn:focus-visible { opacity: 1; }
.rh-media-dl-btn:hover { background: rgba(15, 23, 42, .85); }
.rh-media-dl-btn:active { transform: scale(.9); }
/* En audio el botón va al lado, no encima de los controles */
.rh-msg-media-wrap.is-audio .rh-media-dl-btn {
  position: static;
  opacity: .7;
  background: rgba(15, 23, 42, .12);
  color: var(--text, #0f172a);
  margin-left: 4px;
  vertical-align: middle;
}
.rh-msg-media-wrap.is-audio:hover .rh-media-dl-btn { opacity: 1; }
/* Táctil: sin hover, el botón siempre visible */
@media (hover: none) {
  .rh-media-dl-btn { opacity: .85; }
}

/* Overlay y panel de grabación de audio en vivo */
.rh-recorder-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(6px);
}
.rh-recorder-panel {
  background: #fff;
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  min-width: 320px;
}
.rh-recorder-pulse {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle, #ef4444 0%, #dc2626 80%);
  animation: rhRecPulse 1.2s infinite ease-in-out;
}
@keyframes rhRecPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .6); transform: scale(1); }
  50%      { box-shadow: 0 0 0 18px rgba(239, 68, 68, 0);  transform: scale(1.08); }
}
.rh-recorder-time {
  font-size: 28px;
  font-weight: 700;
  color: var(--rh-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.rh-recorder-hint { color: var(--rh-muted); font-size: 13px; margin: 0; }
.rh-recorder-actions { display: flex; gap: 10px; margin-top: 8px; }
.rh-attach-doc-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: #fff;
  border: 1px solid var(--rh-border);
  border-radius: 10px;
  width: 100%;
  max-width: 380px;
}
.rh-attach-doc-icon { font-size: 32px; }
.rh-attach-doc-info { flex: 1; min-width: 0; }
.rh-attach-doc-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--rh-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rh-attach-doc-meta { font-size: 11px; color: var(--rh-muted); margin-top: 4px; }

/* Media dentro de las burbujas del chat */
.rh-bubble.has-media { padding: 4px; max-width: 320px; }
.rh-bubble-text {
  padding: 6px 10px 4px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}
.rh-msg-media-img {
  display: block;
  border-radius: 8px;
  overflow: hidden;
  cursor: zoom-in;
  background: #f1f5f9;
}
.rh-msg-media-img img {
  display: block;
  width: 100%;
  max-width: 320px;
  max-height: 320px;
  object-fit: cover;
}
.rh-msg-media-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.15);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  border: 1px solid rgba(255,255,255,.2);
  margin: 4px;
  cursor: pointer;
  transition: background .12s;
}
.rh-msg-media-doc:hover { background: rgba(255,255,255,.25); }
.rh-message.rh-incoming .rh-msg-media-doc {
  background: #f1f5f9;
  border-color: var(--rh-border);
  color: var(--rh-text);
}
.rh-message.rh-incoming .rh-msg-media-doc:hover { background: #e2e8f0; }
.rh-msg-media-icon { font-size: 22px; flex-shrink: 0; line-height: 1; }
.rh-msg-media-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.rh-msg-media-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rh-msg-media-ext {
  font-size: 10px;
  opacity: .7;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Banner: ventana de 24h cerrada — bloquea envío de texto libre */
.rh-window-closed-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 4px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  border-radius: 10px;
  color: #78350f;
}
.rh-wcb-icon { font-size: 20px; flex-shrink: 0; }
.rh-wcb-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rh-wcb-text strong { font-size: 13px; color: #78350f; }
.rh-wcb-text span { font-size: 11px; color: #92400e; line-height: 1.4; }
.rh-wcb-text em { font-style: normal; font-weight: 600; }
.rh-wcb-btn {
  background: #b45309;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .12s;
}
.rh-wcb-btn:hover { background: #92400e; }

/* Form bloqueado cuando la ventana cerró */
.rh-reply-form.is-window-closed .rh-reply-compose {
  background: rgba(120, 120, 128, .04);
  opacity: .6;
}
.rh-reply-form.is-window-closed textarea {
  cursor: not-allowed;
}
.rh-reply-form.is-window-closed .rh-send-button {
  opacity: .4;
  cursor: not-allowed;
}
.rh-reply-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.rh-reply-tools {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex-shrink: 0;
}
.rh-reply-compose {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(120, 120, 128, 0.1);
  border-radius: 20px;
  padding: 8px 14px;
  border: 1px solid transparent;
  transition: border-color 150ms, background 150ms;
}
.rh-reply-compose:focus-within {
  background: #fff;
  border-color: var(--rh-border-strong);
}
.rh-reply-compose textarea {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  font-size: 14px;
  color: var(--rh-text);
  resize: none;
  min-height: 22px;
  max-height: 120px;
  outline: none;
  line-height: 1.4;
}
.rh-reply-compose textarea::placeholder { color: var(--rh-muted); }

.rh-icon-button {
  width: 34px; height: 34px;
  border: none;
  border-radius: 50%;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  color: var(--rh-brand);
  background: var(--rh-brand-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms, transform 100ms;
  flex-shrink: 0;
}
.rh-icon-button:hover { background: rgba(0, 122, 255, 0.18); }
.rh-icon-button:active { transform: scale(0.94); }
.rh-quick-reply-trigger {
  color: #fff;
  background: #34aadc;
  font-size: 10px;
  font-weight: 700;
}
.rh-quick-reply-trigger:hover { background: #2b96c4; }

/* ── Template picker ── */
.rh-tpl-picker {
  position: fixed;
  z-index: 9999;
  width: 340px;
  max-height: 420px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.rh-tpl-picker-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  color: var(--text-muted);
}
.rh-tpl-picker-head span { font-size: 13px; font-weight: 600; color: var(--text); flex-shrink: 0; }
.rh-tpl-search {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}
.rh-tpl-search:focus { border-color: var(--accent); }
.rh-tpl-picker-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 14px; padding: 2px 4px;
  line-height: 1; flex-shrink: 0;
}
.rh-tpl-picker-close:hover { color: var(--text); }
.rh-tpl-list {
  overflow-y: auto;
  flex: 1;
  padding: 6px 0;
}
.rh-tpl-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: 8px 14px 4px;
}
.rh-tpl-item {
  width: 100%;
  display: grid;
  grid-template-columns: 16px 1fr auto;
  grid-template-rows: auto auto;
  gap: 1px 8px;
  padding: 8px 14px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background 100ms;
  align-items: start;
}
.rh-tpl-item:hover:not([disabled]) { background: var(--bg); }
.rh-tpl-item.is-locked { opacity: .55; cursor: not-allowed; }
.rh-tpl-item-icon {
  grid-row: 1 / 3;
  margin-top: 2px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.rh-tpl-item-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rh-tpl-item-preview {
  grid-column: 2;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rh-tpl-lock {
  grid-row: 1 / 3;
  color: #ef4444;
  margin-top: 2px;
  flex-shrink: 0;
}
.rh-tpl-reason {
  grid-column: 2 / 4;
  font-size: 10px;
  color: #ef4444;
  font-weight: 500;
}
.rh-tpl-empty {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.rh-send-button {
  width: 34px; height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--rh-brand);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 120ms, transform 100ms;
  font-weight: 700;
}
.rh-send-button:hover { background: var(--rh-brand-dark); }
.rh-send-button:active { transform: scale(0.92); }

/* ════════════════════════════════
   BOT VIEW
   ════════════════════════════════ */
.view-bot { display: flex; flex-direction: column; overflow: hidden; }

/* ── List view ── */
#botListView { padding: 28px 32px; overflow-y: auto; flex: 1; }
#botListView .view-toolbar { margin-bottom: 24px; }
.view-title  { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.view-subtitle { font-size: 13px; color: var(--text-muted); margin: 0; }

.bot-list-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.bot-list-head {
  display: grid;
  grid-template-columns: 1.4fr 1fr 90px 90px 70px 40px;
  column-gap: 16px;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.bot-list-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 90px 90px 70px 76px;
  column-gap: 16px;
  padding: 14px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background 120ms;
  cursor: pointer;
}
/* Cuando está en modo manual (draggable) añadimos una columna inicial para el handle */
.bot-list-row[draggable="true"] {
  grid-template-columns: 20px 1.4fr 1fr 90px 90px 70px 76px;
  cursor: grab;
}
.bot-list-row[draggable="true"]:active { cursor: grabbing; }
.bot-list-row.is-dragging { opacity: .4; }
.bot-list-row.drag-over {
  border-top: 2px solid var(--accent, #2563eb);
  background: rgba(37,99,235,.06);
}
.bot-row-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: .6;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
.bot-list-row:hover .bot-row-drag-handle { opacity: 1; color: var(--accent, #2563eb); }
.bot-list-row:last-child { border-bottom: 0; }
.bot-list-row:hover { background: var(--bg); }
.bot-row-name-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bot-row-name { font-weight: 600; font-size: 13px; }
.bot-row-date { font-size: 11px; color: var(--text-muted); }
.bot-row-trigger { font-size: 12px; color: var(--text-muted); }
.bot-row-steps { font-size: 12px; }
.bot-row-actions { display: inline-flex; align-items: center; gap: 4px; justify-content: flex-end; }
.bot-row-active { font-size: 13px; display: flex; align-items: center; }
.bot-active-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 24px;
  padding: 0 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-family: inherit;
  line-height: 1;
}
.bot-active-pill.is-on {
  background: rgba(34,197,94,.12);
  border-color: rgba(34,197,94,.35);
  color: #15803d;
  cursor: pointer;
  transition: background 120ms, transform 120ms;
}
.bot-active-pill.is-on:hover {
  background: rgba(34,197,94,.22);
  transform: translateY(-1px);
}
.bot-active-pill.is-zero { opacity: .5; }

/* Conflict warning del modal Agendar Cita */
.appt-conflict-warn {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 10px;
  font-size: 13px;
  color: #991b1b;
}
.appt-conflict-header {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}
.appt-conflict-header svg { flex-shrink: 0; color: #dc2626; }
.appt-conflict-slots {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #fecaca;
}
.appt-conflict-slots-label {
  font-size: 12px;
  color: #7f1d1d;
  margin-bottom: 6px;
  font-weight: 500;
}
.appt-conflict-slots-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.appt-conflict-slot {
  background: #fff;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.appt-conflict-slot:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

/* ─── User Switching: botón flotante "Volver a super-admin" ─────────────
   Estilo distintivo (naranja como el plugin User Switching de WP) para que
   sea obvio que estás impersonando. Posicionado abajo-derecha, arriba del
   bottom nav móvil. */
.impersonation-float-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(234, 88, 12, .35), 0 2px 6px rgba(0,0,0,.15);
  transition: transform 150ms, box-shadow 150ms;
}
.impersonation-float-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(234, 88, 12, .45), 0 4px 10px rgba(0,0,0,.15);
}
.impersonation-float-btn:active { transform: translateY(0); }
.impersonation-float-btn:disabled { opacity: .65; cursor: wait; }
.impersonation-float-btn svg { flex-shrink: 0; }
.impersonation-float-txt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
.impersonation-float-label { font-size: 13px; font-weight: 700; }
.impersonation-float-sub {
  font-size: 10px;
  font-weight: 500;
  opacity: .9;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* Subir el botón arriba del bottom nav en mobile */
@media (max-width: 720px) {
  .impersonation-float-btn {
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
    right: 12px;
    padding: 8px 12px;
  }
  .impersonation-float-sub { display: none; } /* solo el texto principal en mobile */
}

/* Modal: leads activos por bot */
.bot-active-leads-list { display: flex; flex-direction: column; gap: 8px; }
.bot-active-leads-loading,
.bot-active-leads-empty,
.bot-active-leads-error {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.bot-active-leads-error { color: #b91c1c; }
.bot-active-lead-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: background 120ms, border-color 120ms, transform 120ms;
}
.bot-active-lead-row.is-clickable { cursor: pointer; }
.bot-active-lead-row.is-clickable:hover {
  background: var(--bg);
  border-color: var(--accent, #2563eb);
  transform: translateY(-1px);
}
.bot-active-lead-main { min-width: 0; flex: 1; }
.bot-active-lead-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bot-active-lead-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.bot-active-lead-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.bot-active-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.bot-active-status.is-running {
  background: rgba(34,197,94,.15);
  color: #15803d;
}
.bot-active-status.is-waiting {
  background: rgba(245,158,11,.18);
  color: #b45309;
}
.bot-active-status.is-paused {
  background: rgba(148,163,184,.2);
  color: #475569;
}
.bot-active-meta-item {
  font-size: 12px;
  color: var(--text-muted);
}
@media (max-width: 560px) {
  .bot-active-lead-row { flex-direction: column; align-items: flex-start; }
  .bot-active-lead-meta { justify-content: flex-start; }
}
.sb-clone-btn:hover { color: var(--accent); }

/* ── Inline toggle ── */
.sb-toggle {
  position: relative;
  display: inline-flex;
  width: 36px; height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}
.sb-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.sb-thumb {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 180ms;
}
.sb-thumb::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 180ms;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.sb-toggle input:checked + .sb-thumb { background: var(--primary); }
.sb-toggle input:checked + .sb-thumb::after { transform: translateX(16px); }

/* ── Builder ── */
#botBuilder { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

.bot-builder-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.bot-builder-name-input {
  flex: 1;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 15px;
  font-weight: 600;
  background: transparent;
  color: var(--text);
  transition: border-color 150ms, background 150ms;
}
.bot-builder-name-input:hover { border-color: var(--border); background: var(--bg); }
.bot-builder-name-input:focus { outline: 2px solid var(--primary); background: var(--bg); border-color: transparent; }
.bot-builder-topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.bot-enabled-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; cursor: pointer; }

.bot-builder-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px 20px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── View tabs (Lista / Código) ── */
.bb-view-tabs {
  width: 100%;
  max-width: 560px;
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--bg-2);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.bb-view-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.bb-view-tab:hover { color: var(--text); }
.bb-view-tab.is-active {
  background: var(--surface, #fff);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.bb-view-content { width: 100%; display: flex; flex-direction: column; align-items: center; }
.bb-view-content[hidden] { display: none; }
/* La vista Editable necesita todo el ancho — su contenido es un grid que ya
   maneja sidebar/canvas/inspector. align-items: center la apretaba. */
.bb-view-content[data-view="editable"] { align-items: stretch; }
.bb-view-content[data-view="editable"] .bb-ve-wrap { width: 100%; }

/* ── Code view ── */
.bb-code-toolbar {
  width: 100%;
  max-width: 720px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.bb-code-hint { font-size: 12px; color: var(--text-muted); }
.bb-code-block {
  width: 100%;
  max-width: 720px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 8px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}
.bb-code-block code { font-family: inherit; }
.bb-code-block .json-key    { color: #93c5fd; }
.bb-code-block .json-string { color: #86efac; }
.bb-code-block .json-number { color: #fcd34d; }
.bb-code-block .json-bool   { color: #f472b6; }
.bb-code-block .json-null   { color: #94a3b8; font-style: italic; }

/* ── Indented tree view ── */
.bb-tree-toolbar {
  width: 100%;
  max-width: 720px;
  margin-bottom: 8px;
}
.bb-tree {
  width: 100%;
  max-width: 720px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
}
.bb-tree-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: rgba(37,99,235,.06);
  border: 1px dashed var(--accent);
  border-radius: 8px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--accent);
}
.bb-tree-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
  margin-bottom: 4px;
}
.bb-tree-step:hover { background: var(--bg-2); }
.bb-tree-step-num {
  flex-shrink: 0;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 6px;
}
.bb-tree-step-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--accent);
  margin-top: 1px;
}
.bb-tree-step-body {
  flex: 1;
  min-width: 0;
}
.bb-tree-step-type {
  font-weight: 600;
  font-size: 13px;
}
.bb-tree-step-summary {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 1px;
  word-break: break-word;
}
.bb-tree-branches {
  margin-left: 18px;
  padding-left: 12px;
  border-left: 2px dashed var(--border);
  margin-top: 4px;
  margin-bottom: 8px;
}
.bb-tree-branch-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  padding: 6px 0 4px;
}
.bb-tree-branch-empty {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 10px;
}
.bb-tree-empty {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════
   Visual bot builder — rewrite 2026-05-09
   Read-only top→bottom flow with branches.
   ═══════════════════════════════════════════════════ */

.bb-visual-toolbar {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-muted);
}

.bb-visual-canvas {
  position: relative;
  flex: 1;
  display: flex;
  overflow: hidden;
  width: 100%;       /* sin esto el canvas toma el ancho de su contenido (2780px+ con muchas ramas) */
  min-width: 0;
  min-height: 0;
}

.bb-visual-stage {
  flex: 1;
  min-width: 0;     /* permite encoger debajo del tamaño del contenido para que overflow:auto active scroll */
  min-height: 0;
  position: relative;
  overflow: auto;
  background:
    radial-gradient(circle, rgba(15,23,42,.06) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--bg-2);
}

.bb-canvas {
  position: relative;
  margin: 0 auto;
}

/* SVG con conectores ortogonales detrás de los nodos */
/* width/height set via JS inline styles to override global "svg{width:20px;height:20px}" */
.bb-edges {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
  flex-shrink: 0;
}

.bb-edge {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.bb-edge-label rect {
  fill: var(--surface, #fff);
  stroke: #cbd5e1;
  stroke-width: 1;
}
.bb-edge-label text {
  fill: var(--text);
  font-size: 11px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  pointer-events: none;
  user-select: none;
}

/* ── Nodes ── */
.bb-node {
  position: absolute;
  background: var(--surface, #fff);
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  z-index: 2;
  box-sizing: border-box;
  overflow: hidden;
}
.bb-node:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(37, 99, 235, .15), 0 2px 4px rgba(15, 23, 42, .06);
  transform: translateY(-1px);
}

.bb-node__head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.bb-node__num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bb-node__icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.bb-node__title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bb-node__summary {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Trigger node — distinto: gradient azul + dashed border */
.bb-node--trigger {
  border: 2px dashed var(--accent);
  background: linear-gradient(135deg, rgba(37, 99, 235, .07) 0%, rgba(37, 99, 235, .02) 100%);
}
.bb-node--trigger .bb-node__icon {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  width: 24px;
  height: 24px;
}
.bb-node--trigger .bb-node__title {
  color: var(--accent);
}

/* Step node — coloreado por grupo (border-left) */
.bb-node--step {
  border-left-width: 4px;
}
.bb-node--grp-comunicacion  { border-left-color: #2563eb; }
.bb-node--grp-flujo         { border-left-color: #9333ea; }
.bb-node--grp-lead          { border-left-color: #16a34a; }
.bb-node--grp-citas         { border-left-color: #f59e0b; }
.bb-node--grp-integraciones { border-left-color: #06b6d4; }

/* Rama vacía — círculo "+" prominente con label debajo */
.bb-empty-branch {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  z-index: 2;
  box-sizing: border-box;
}
.bb-empty-branch-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface, #fff);
  border: 1.5px dashed #94a3b8;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  transition: all .15s;
  user-select: none;
}
.bb-empty-branch:hover .bb-empty-branch-btn {
  border: 1.5px solid var(--accent, #2563eb);
  color: var(--accent, #2563eb);
  background: rgba(37, 99, 235, .08);
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .18);
}
.bb-empty-branch-label {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 6px;
  font-weight: 500;
  transition: color .15s;
}
.bb-empty-branch:hover .bb-empty-branch-label {
  color: var(--accent, #2563eb);
}

/* ── Add-step button on edges ── */
.bb-add-btn {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface, #fff);
  border: 1.5px solid #94a3b8;
  color: #64748b;
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 4;
  padding: 0;
  opacity: 0;
  transition: opacity .15s, transform .15s, border-color .15s, color .15s;
  transform: scale(0.8);
}
.bb-canvas:hover .bb-add-btn {
  opacity: 1;
  transform: scale(1);
}
.bb-add-btn:hover {
  border-color: var(--accent, #2563eb);
  color: var(--accent, #2563eb);
  background: rgba(37, 99, 235, .07);
  transform: scale(1.1);
}

/* ── Editor modal centrado ── */
.bb-visual-editor {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 480px;
  max-width: 92vw;
  max-height: 85vh;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
}
.bb-visual-editor[hidden] { display: none; }
.bb-visual-editor::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  z-index: -1;
}

.bb-visual-trigger-editor { width: 480px; }

.bb-visual-editor-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.bb-visual-editor-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}
.bb-visual-editor-title svg { color: var(--accent); }

.bb-visual-editor-body {
  flex: 1;
  overflow: auto;
  padding: 14px;
}
.bb-visual-editor-body label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 8px 0 4px;
}
.bb-visual-editor-body input[type="text"],
.bb-visual-editor-body input[type="number"],
.bb-visual-editor-body input[type="url"],
.bb-visual-editor-body select,
.bb-visual-editor-body textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface, #fff);
  color: var(--text);
  box-sizing: border-box;
}
.bb-visual-editor-body textarea {
  resize: vertical;
  min-height: 60px;
}
.bb-visual-editor-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.bb-visual-editor-foot .btn--ghost { color: var(--text); }

.bb-visual-mobile-hint {
  display: none;
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
}
@media (max-width: 768px) {
  .bb-visual-mobile-hint { display: block; }
  .bb-visual-canvas { height: 400px; }
  .bb-visual-editor { width: 100%; }
}

/* ═══════ Vista de Comentarios Redes Sociales ═══════ */
.view-comments { display: flex; height: 100%; overflow: hidden; }
.comments-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
}
.comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: #fff;
}
.comments-header h1 { margin: 0; font-size: 20px; font-weight: 700; }
.comments-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-2);
  border-radius: 8px;
  padding: 3px;
}
.comments-tab {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}
.comments-tab.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comments-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.comment-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .12s, box-shadow .12s;
}
.comment-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.comment-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.comment-card-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
  overflow: hidden;
}
.comment-card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.comment-card-meta { flex: 1; min-width: 0; }
.comment-card-from { font-weight: 600; font-size: 13.5px; color: var(--text); }
.comment-card-context {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.comment-card-provider-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.comment-card-provider-pill.is-fb { background: #1877f211; color: #1877f2; }
.comment-card-provider-pill.is-ig { background: #e1306c11; color: #e1306c; }
.comment-card-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  padding: 8px 12px;
  background: var(--bg-2);
  border-radius: 8px;
  word-break: break-word;
}
.comment-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.comment-card-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.comment-card-link:hover { text-decoration: underline; }
.comment-card-time { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.comment-card-status-replied {
  font-size: 11px;
  color: #16a34a;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.comment-card-btn {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
}
.comment-card-btn:hover { border-color: var(--accent); color: var(--accent); }
.comment-card-btn.is-primary {
  background: #f59e0b;
  color: #fff;
  border-color: #f59e0b;
}
.comment-card-btn.is-primary:hover { background: #d97706; border-color: #d97706; color: #fff; }

/* Modal de responder */
.comment-reply-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.comment-reply-overlay[hidden] { display: none; }
.comment-reply-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.comment-reply-header {
  display: flex;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.comment-reply-header h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.comment-reply-public-warning {
  margin: 0;
  font-size: 12px;
  color: #b45309;
  background: #fef3c7;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
}
.comment-reply-body { padding: 16px 20px; overflow-y: auto; }
.comment-reply-original {
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.5;
}
.comment-reply-body textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  box-sizing: border-box;
}
.comment-reply-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.comment-reply-submit-btn {
  background: #f59e0b;
  color: #fff;
  border: 1px solid #f59e0b;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.comment-reply-submit-btn:hover { background: #d97706; border-color: #d97706; }
.comment-reply-submit-btn:disabled { opacity: .5; cursor: default; }

/* ── Galería de plantillas de bot ── */
.bot-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.bot-template-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .12s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bot-template-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(37,99,235,.1);
  transform: translateY(-1px);
}
.bot-template-card-icon {
  font-size: 28px;
  line-height: 1;
}
.bot-template-card-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.bot-template-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}
.bot-template-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.bot-template-card-tag {
  font-size: 10px;
  font-weight: 600;
  background: var(--bg-2);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 2px 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.bot-template-card-tag--cat {
  background: rgba(37,99,235,.08);
  color: var(--accent);
}

/* ── Step branch (multi-case) ── */
.sb-branch-cases { display: flex; flex-direction: column; gap: 6px; }
.sb-branch-case {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-2);
}
.sb-branch-case[open] { background: #fff; border-color: var(--accent); }
.sb-branch-case > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 12px;
}
.sb-branch-case > summary::-webkit-details-marker { display: none; }
.sb-branch-case-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.sb-branch-case-label { flex: 1; color: var(--text); font-weight: 500; }
.sb-branch-case-state {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-muted);
}
.sb-branch-case-state.is-set { background: rgba(34,197,94,.12); color: #166534; }
.sb-branch-case-del {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  padding: 0 4px;
  line-height: 1;
}
.sb-branch-case-del:hover { color: #dc2626; }
.sb-branch-case-body {
  padding: 8px 10px 10px;
  border-top: 1px solid var(--border);
}
.sb-branch-case-body textarea,
.sb-branch-default-text {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
  margin-top: 6px;
}
.sb-branch-add-case {
  align-self: flex-start;
}
.sb-branch-default {
  margin-top: 8px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

/* Weekday checkboxes para scheduled_daily */
.bb-weekday {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-2);
  cursor: pointer;
  user-select: none;
}
.bb-weekday:hover { border-color: var(--accent); }
.bb-weekday input[type="checkbox"] { margin: 0; }

/* ── Trigger card ── */
.sb-trigger-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 16px 18px;
}
.sb-card-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--primary);
  margin-bottom: 10px;
}
.sb-trigger-row { display: flex; gap: 10px; flex-wrap: wrap; }
.sb-trigger-row select,
.sb-trigger-row input {
  flex: 1;
  min-width: 140px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}
.sb-trigger-row select:focus,
.sb-trigger-row input:focus { outline: 2px solid var(--primary); border-color: transparent; }

/* ── Connector line ── */
.sb-connector {
  width: 2px;
  height: 28px;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Step cards ── */
#sbStepsFlow { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 560px; }

.sb-step-wrap { display: flex; flex-direction: column; align-items: center; width: 100%; }
/* Indentación de cards nested (pasos dentro de una rama de Condición) */
.sb-step-wrap--nested { width: calc(100% - 32px); margin-left: 32px; position: relative; }
.sb-step-wrap--nested.sb-step-wrap--depth-2 { margin-left: 64px; width: calc(100% - 64px); }
.sb-step-wrap--nested.sb-step-wrap--depth-3 { margin-left: 96px; width: calc(100% - 96px); }
.sb-step-wrap--nested.sb-step-wrap--depth-4 { margin-left: 128px; width: calc(100% - 128px); }
.sb-step-wrap--nested::before {
  content: ''; position: absolute; left: -16px; top: 0; bottom: 0;
  width: 2px; background: #c7d2fe; border-radius: 2px;
}
.sb-step-branch-badge {
  display: inline-block; padding: 2px 8px; margin-right: 6px;
  background: #eef2ff; color: #1e3a8a; border-radius: 6px;
  font-size: 11px; font-weight: 600;
}

/* Pills para el campo Mensaje en condición/branch (estilo chip clickable) */
.sb-branch-rule-value[data-pills="1"] {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 6px 8px; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; min-height: 38px; cursor: text;
  transition: border-color 0.15s;
}
.sb-branch-rule-value[data-pills="1"]:focus-within {
  border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.sb-branch-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 6px 3px 10px; background: #eef2ff; color: #1e3a8a;
  border-radius: 999px; font-size: 13px; line-height: 1; font-weight: 500;
}
.sb-branch-pill-del {
  width: 18px; height: 18px; border-radius: 50%; border: 0;
  background: transparent; color: #1e3a8a; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.sb-branch-pill-del:hover { background: rgba(30,58,138,0.15); }
.sb-branch-pill-input {
  flex: 1; min-width: 100px; border: 0; outline: 0;
  font-size: 13px; padding: 2px 4px; background: transparent;
}

.sb-fallback-note {
  margin: 8px 0 -4px;
  padding: 6px 12px;
  background: #fef3c7;
  border: 1px dashed #d97706;
  color: #92400e;
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
  cursor: help;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sb-fallback-arrow { font-size: 14px; color: #d97706; }
.sb-step-connector {
  width: 100%; height: 34px;
  position: relative; display: flex; align-items: center; justify-content: center;
}
/* Línea punteada vertical al centro — marca el "salto" al siguiente step */
.sb-step-connector::before {
  content: '';
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 0; border-left: 2px dashed #cbd5e1; transform: translateX(-50%);
}
.sb-insert-between {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; border: 2px dashed #94a3b8;
  color: #475569; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.85; transition: opacity .15s, border-color .15s, color .15s, background .15s, transform .12s;
  z-index: 2; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.sb-step-connector:hover .sb-insert-between,
.sb-insert-between:focus { opacity: 1; border-color: var(--accent); color: var(--accent); }
.sb-insert-between:hover { opacity: 1; border-style: solid; border-color: var(--accent); color: var(--accent); transform: translateX(-50%) scale(1.12); background: color-mix(in srgb, var(--accent) 8%, #fff); }

.sb-step-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 150ms, box-shadow 150ms;
}
.sb-step-card:hover { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,122,255,.08); }
.sb-step-card.has-error {
  border-color: #ef4444;
  background: linear-gradient(180deg, #fef2f2 0%, var(--surface) 80%);
}
.sb-step-card.has-error:hover { border-color: #dc2626; box-shadow: 0 0 0 3px rgba(239,68,68,.12); }
.sb-step-card.has-warn {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, var(--surface) 80%);
}
.sb-step-error-pill {
  display: inline-block;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sb-step-warn-pill {
  display: inline-block;
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sb-step-issues {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sb-step-issues.is-error { background: #fef2f2; color: #991b1b; }
.sb-step-issues.is-warn  { background: #fffbeb; color: #78350f; }
.sb-step-issue-line { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; }
.sb-issue-ico { font-size: 14px; line-height: 1; flex-shrink: 0; }
.sb-issue-msg { font-weight: 500; line-height: 1.4; }
.sb-issue-hint { color: var(--text-muted); font-size: 11px; margin-top: 2px; line-height: 1.4; }
.sb-trigger-issue {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  margin: 0 0 12px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  color: #991b1b;
  font-size: 13px;
  font-weight: 500;
}

/* Badge en la fila de la lista de bots */
.bot-row-issues {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 6px;
  cursor: help;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bot-row-issues.is-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.bot-row-issues.is-warn  { background: #fef3c7; color: #78350f; border: 1px solid #fcd34d; }

.sb-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
}
.sb-step-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: rgba(0,122,255,.1);
  color: var(--primary);
}
.sb-step-icon.type-message  { background: rgba(52,199,89,.12);  color: #34c759; }
.sb-step-icon.type-timer    { background: rgba(255,159,10,.12); color: #ff9f0a; }
.sb-step-icon.type-condition{ background: rgba(175,82,222,.12); color: #af52de; }
.sb-step-icon.type-stage    { background: rgba(0,122,255,.12);  color: #007aff; }
.sb-step-icon.type-tag      { background: rgba(255,59,48,.12);  color: #ff3b30; }
.sb-step-icon.type-assign   { background: rgba(90,200,250,.12); color: #5ac8fa; }

.sb-step-info { flex: 1; min-width: 0; }
.sb-step-title { font-size: 13px; font-weight: 600; }
.sb-step-summary { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sb-step-del {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: 6px;
  transition: color 120ms, background 120ms;
  flex-shrink: 0;
}
.sb-step-del:hover { color: #ff3b30; background: rgba(255,59,48,.1); }

.sb-step-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
  display: none;
}
.sb-step-body.is-open { display: block; }
.sb-step-body label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; margin-top: 12px; }
.sb-step-body label:first-child { margin-top: 10px; }
.sb-step-body textarea,
.sb-step-body input[type="text"],
.sb-step-body input[type="number"],
.sb-step-body select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}
.sb-step-body textarea { resize: vertical; min-height: 80px; }
.sb-step-body textarea:focus,
.sb-step-body input:focus,
.sb-step-body select:focus { outline: 2px solid var(--primary); border-color: transparent; }
.sb-step-body .sb-row { display: flex; gap: 8px; }
.sb-step-body .sb-row input,
.sb-step-body .sb-row select { flex: 1; }

/* wait_response — acordeón de las 4 ramas */
.sb-wait-branches { display: flex; flex-direction: column; gap: 8px; }
.sb-wait-branch {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}
.sb-wait-branch[open] { border-color: var(--primary); }
.sb-wait-branch summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  list-style: none;
  user-select: none;
}
.sb-wait-branch summary::-webkit-details-marker { display: none; }
.sb-wait-branch summary::before {
  content: '▸';
  font-size: 11px;
  color: var(--text-muted);
  transition: transform .15s ease;
}
.sb-wait-branch[open] summary::before { transform: rotate(90deg); }
.sb-wait-branch-label { flex: 1; color: var(--text); }
.sb-wait-branch-state {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0,0,0,.05);
  color: var(--text-muted);
}
.sb-wait-branch-state.is-set {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
}
.sb-wait-branch-body {
  padding: 4px 12px 12px;
  border-top: 1px solid var(--border);
}
.sb-wait-branch-body label { margin-top: 8px !important; }
.sb-wait-branch-body textarea { min-height: 60px !important; }

/* Chip que indica el origen del texto de un step "Enviar mensaje" — cuando
   el texto vino de una plantilla básica (botón Usar plantilla básica). */
.sb-msg-from-tpl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(37, 99, 235, 0.06);
  border: 1px dashed rgba(37, 99, 235, 0.3);
  padding: 4px 8px 4px 10px;
  border-radius: 6px;
  margin-top: 4px;
  width: fit-content;
}
.sb-msg-from-tpl strong { color: var(--accent, #2563eb); font-weight: 600; }
.sb-msg-from-tpl-clear {
  background: rgba(0,0,0,.06);
  border: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  color: var(--text-muted);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sb-msg-from-tpl-clear:hover { background: #fee2e2; color: #dc2626; }

/* Chips para el step "Agregar etiqueta" — soporta varias etiquetas con coma */
.sb-tag-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  background: var(--bg);
  min-height: 38px;
  box-sizing: border-box;
}
.sb-tag-chip-wrap:focus-within {
  outline: 2px solid var(--primary);
  border-color: transparent;
}
.sb-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 10px;
  background: #2563eb;
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.sb-tag-chip-x {
  background: rgba(255,255,255,.18);
  border: none;
  color: #fff;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background .12s;
}
.sb-tag-chip-x:hover { background: rgba(255,255,255,.32); }
.sb-step-body input.sb-tag-chip-add {
  flex: 1 1 120px;
  min-width: 120px;
  width: auto;
  border: none;
  outline: none;
  padding: 4px 0;
  background: transparent;
  font-size: 13px;
}
.sb-step-body input.sb-tag-chip-add:focus { outline: none; }

.sb-timer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sb-appt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sb-hint { font-size: 11px; color: var(--text-muted); margin: 4px 0 0; line-height: 1.4; }

/* ═══ Modal Agendar Cita ═══ */
.appt-label { display: block; font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 5px; }
.appt-input {
  width: 100%; padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 13px; background: #fff; box-sizing: border-box;
}
.appt-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.appt-slots-grid { display: flex; flex-wrap: wrap; gap: 8px; min-height: 40px; }
.appt-slot {
  padding: 6px 12px; border: 1px solid #e2e8f0; border-radius: 6px;
  font-size: 13px; cursor: pointer; background: #f8fafc; transition: all 120ms;
  user-select: none;
}
.appt-slot:hover:not(.unavailable) { border-color: var(--accent); background: #eff6ff; color: var(--accent); }
.appt-slot.selected { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.appt-slot.unavailable { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.appt-slot-loading { color: #94a3b8; font-size: 13px; padding: 8px 0; }

/* branch v2 builder — multi-regla AND/OR + sub-flujo por rama */
.sb-branch-case-v2 {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
  background: #fff;
}
.sb-branch-case-v2-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.sb-branch-case-v2-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #475569);
}
.sb-branch-case-del-v2 {
  background: none; border: none; cursor: pointer;
  color: #94a3b8; font-size: 16px; line-height: 1; padding: 0 2px;
}
.sb-branch-case-del-v2:hover { color: #ef4444; }
.sb-branch-rules { padding: 8px 12px 4px; }
.sb-branch-rule {
  display: flex; align-items: center; gap: 5px; margin-bottom: 5px; flex-wrap: wrap;
}
.sb-branch-rule-field,
.sb-branch-rule-op {
  padding: 5px 8px; border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px; font-size: 12px; background: #fff; flex-shrink: 0;
}
.sb-branch-rule-value {
  flex: 1; min-width: 90px;
  padding: 5px 8px; border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px; font-size: 12px;
}
.sb-branch-rule-del {
  background: none; border: none; cursor: pointer;
  color: #94a3b8; font-size: 14px; padding: 2px 4px; flex-shrink: 0;
}
.sb-branch-rule-del:hover { color: #ef4444; }
.sb-branch-rule-connector {
  padding: 0 12px 6px;
}
.sb-branch-rules-op {
  font-size: 11px; padding: 3px 8px;
  border: 1px solid var(--accent, #2563eb);
  border-radius: 4px;
  background: rgba(37,99,235,.07);
  color: var(--accent, #2563eb);
  font-weight: 600;
  cursor: pointer;
}
.sb-branch-add-rule {
  display: block; font-size: 11px; color: var(--accent, #2563eb);
  background: none; border: none; cursor: pointer;
  padding: 2px 12px 8px; text-align: left;
}
.sb-branch-add-rule:hover { text-decoration: underline; }
.sb-branch-case-steps {
  padding: 8px 12px;
  background: #f1f5f9;
  border-top: 1px solid var(--border, #e2e8f0);
}
.sb-branch-case-steps-label {
  font-size: 10px; font-weight: 700; color: #94a3b8;
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px;
}
/* Divisor "Entonces ejecuta" entre las condiciones de la rama y sus pasos */
.sb-branch-then {
  display: flex; align-items: center; justify-content: center;
  margin: 10px 12px 2px;
}
.sb-branch-then span {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; padding: 3px 12px;
  border: 1px dashed currentColor; border-radius: 999px; background: #fff;
}
.sb-branch-case-add-step-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--accent, #2563eb);
  background: none;
  border: 1px dashed var(--accent, #2563eb);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; margin-top: 6px;
}
.sb-branch-case-add-step-btn:hover { background: rgba(37,99,235,.06); }
/* Meter los pasos (sub-steps) hacia adentro para que el fondo de color de la
   rama los ENVUELVA por los lados, en vez de ir de borde a borde. */
.sb-branch-case-v2 .sb-rem-substeps { padding: 0 12px; }
.sb-branch-case-v2 > .sb-branch-case-add-step-btn { margin-left: 12px; margin-bottom: 10px; }
.sb-branch-add-case-v2 {
  display: block; width: 100%; padding: 8px;
  border: 1.5px dashed var(--border, #e2e8f0);
  border-radius: 8px; background: none;
  color: var(--text-secondary, #475569);
  font-size: 13px; cursor: pointer; margin-bottom: 10px; text-align: center;
}
.sb-branch-add-case-v2:hover {
  border-color: var(--accent, #2563eb);
  color: var(--accent, #2563eb);
}
.sb-branch-default-section {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px; overflow: hidden;
}
.sb-branch-default-header {
  padding: 7px 12px; background: #f8fafc;
  border-bottom: 1px solid var(--border, #e2e8f0);
  font-size: 12px; font-weight: 600; color: #94a3b8;
}
.sb-branch-default-steps {
  padding: 8px 12px; background: #f1f5f9;
}

/* reminder_timer builder */
.sb-reminder-branch {
  border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 12px;
  margin-bottom: 8px; background: #f8fafc; position: relative;
}
.sb-reminder-branch-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.sb-reminder-branch-header select,
.sb-reminder-branch-header input[type="number"],
.sb-reminder-branch-header input[type="time"] {
  padding: 4px 8px; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 12px;
}
.sb-reminder-del-btn {
  margin-left: auto; flex-shrink: 0;
  background: none; border: none; cursor: pointer; color: #94a3b8; font-size: 18px; line-height: 1; padding: 0 2px;
}
.sb-reminder-del-btn:hover { color: #ef4444; }
.sb-reminder-add-btn {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px;
  background: #eff6ff; border: 1px dashed #93c5fd; border-radius: 8px;
  color: #2563eb; font-size: 12px; cursor: pointer; width: 100%;
  justify-content: center; margin-top: 4px;
}
.sb-reminder-add-btn:hover { background: #dbeafe; }
.sb-timer-unit { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.sb-timer-unit input { width: 100%; text-align: center; }
.sb-timer-unit span { font-size: 11px; color: var(--text-muted); }
.sb-info-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 12px 14px; }
.sb-info-box p { margin: 0; font-size: 13px; line-height: 1.5; }

/* reminder_timer sub-steps */
.sb-rem-substeps { margin: 8px 0 6px; display: flex; flex-direction: column; gap: 6px; }
.sb-rem-substep { border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; overflow: hidden; }
.sb-rem-substep-header {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  cursor: pointer; user-select: none; background: #f8fafc;
}
.sb-rem-substep-header:hover { background: #f1f5f9; }
.sb-rem-substep-label { flex: 1; font-size: 13px; font-weight: 500; color: var(--text); }
.sb-rem-substep-del {
  background: none; border: none; cursor: pointer; color: #94a3b8;
  font-size: 18px; line-height: 1; padding: 0 2px; flex-shrink: 0;
}
.sb-rem-substep-del:hover { color: #ef4444; }
.sb-rem-substep .sb-step-body { padding: 10px 12px; border-top: 1px solid #e2e8f0; }
.sb-rem-substep .sb-step-body:not(.is-open) { display: none; }
.sb-rem-add-step-btn {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px; width: 100%;
  background: #f0fdf4; border: 1px dashed #86efac; border-radius: 7px;
  color: #16a34a; font-size: 12px; cursor: pointer; justify-content: center;
  margin-top: 4px;
}
.sb-rem-add-step-btn:hover { background: #dcfce7; }

/* ── Add step button + picker ── */
.sb-add-step-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 560px;
  position: relative;
}
.sb-add-step-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 140ms, border-color 140ms, background 140ms;
  margin-top: 24px;
}
.sb-add-step-btn:hover { color: var(--primary); border-color: var(--primary); background: rgba(0,122,255,.05); }

.sb-step-picker {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  min-width: 300px;
  z-index: 50;
}
.sb-step-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
  text-align: center;
}
.sb-step-type-btn:hover { background: var(--bg); border-color: var(--border); }

/* ════════════════════════════════
   PIPELINES KANBAN
   ════════════════════════════════ */
.view-pipelines {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  height: 100%;
  min-height: 0;
}
.pl-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  min-height: 50px;
}
.pl-tabs {
  display: flex;
  gap: 0;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.pl-tabs::-webkit-scrollbar { display: none; }
.pl-tab {
  padding: 14px 18px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 140ms, border-color 140ms;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pl-tab:hover { color: var(--text); }
.pl-tab.is-active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.pl-tab.drag-over { background: color-mix(in srgb, var(--accent) 12%, transparent); border-bottom-color: var(--accent); color: var(--accent); border-radius: 6px 6px 0 0; }
.pl-tab.is-pl-dragging { opacity: .45; }
.pl-tab.pl-tab-drop-target { background: color-mix(in srgb, var(--accent) 10%, transparent); border-bottom-color: var(--accent); border-radius: 6px 6px 0 0; }

.pl-tab-drag-handle {
  display: flex; align-items: center; justify-content: center;
  cursor: grab; color: var(--text-muted); opacity: 0;
  transition: opacity 150ms; margin-right: -2px;
}
.pl-tab:hover .pl-tab-drag-handle { opacity: 1; }
.pl-tab-drag-handle:active { cursor: grabbing; }
.pl-tab-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pl-topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Board */
.pl-board {
  flex: 1;
  display: flex;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 20px;
  align-items: stretch;
  min-height: 0;
}
.pl-column {
  flex-shrink: 0;
  width: 260px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: calc(100vh - 160px);
  margin-right: 12px;
}
.pl-column:last-child { margin-right: 0; }
.pl-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pl-col-drag-handle {
  display: flex; align-items: center; justify-content: center;
  width: 18px; flex-shrink: 0; cursor: grab;
  color: var(--text-muted); opacity: 0;
  transition: opacity 150ms;
}
.pl-col-header:hover .pl-col-drag-handle { opacity: 1; }
.pl-col-drag-handle:active { cursor: grabbing; }

.pl-col-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pl-col-name { font-size: 13px; font-weight: 600; flex: 1; }
.pl-col-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.pl-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pl-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 140ms, box-shadow 140ms;
}
.pl-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,122,255,.1); }
.pl-card.is-dragging { opacity: .4; }

/* Column reorder drag states */
.pl-column.is-col-dragging { opacity: .45; }
.pl-column.col-drag-over .pl-col-header {
  background: rgba(99,102,241,.1);
  border-bottom-color: var(--accent);
}
.pl-column.col-drag-over .pl-col-name { color: var(--accent); }
.pl-column.drag-over {
  background: rgba(37,99,235,.06);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,.25), 0 4px 16px rgba(37,99,235,.1);
  transform: translateY(-1px);
  transition: all 120ms ease;
}
.pl-column.drag-over .pl-col-header {
  background: rgba(37,99,235,.08);
}
.pl-card-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.pl-card-name.is-auto-name { color: var(--text-muted); font-weight: 500; }
.pl-card-contact { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.pl-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.pl-card-footer-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.pl-card-date { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.pl-card-tags { display: flex; gap: 4px; flex-wrap: wrap; }
/* Valor del lead en tarjeta kanban */
.pl-card-value {
  font-size: 10px;
  font-weight: 700;
  color: #059669;
  background: #d1fae5;
  padding: 1px 6px;
  border-radius: 99px;
  white-space: nowrap;
}
/* Total por columna en header */
.pl-col-value {
  font-size: 10px;
  font-weight: 700;
  color: #059669;
  background: #d1fae5;
  padding: 2px 7px;
  border-radius: 99px;
  margin-left: auto;
  white-space: nowrap;
}
/* Total del pipeline completo en topbar */
.pl-pipeline-total {
  font-size: 12px;
  font-weight: 700;
  color: #059669;
  background: #d1fae5;
  padding: 4px 10px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}
.pl-card-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(37,99,235,.1);
  color: #1d4ed8;
  font-weight: 600;
}
.pl-col-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 24px 8px;
}

/* Footer de columna con botón de alarma de estancado */
.pl-col-footer {
  padding: 6px 8px 12px;
  border-top: 1px dashed transparent;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* Hint sutil del bot que corre en esta etapa — clickable para abrir el bot */
.pl-col-bot-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.08);
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  align-self: stretch;
  justify-content: center;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  font-family: inherit;
  transition: color .12s, background .12s, border-color .12s;
}
.pl-col-bot-hint:hover {
  color: var(--accent, #2563eb);
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.25);
}
.pl-col-bot-hint svg { flex-shrink: 0; opacity: 0.85; }
.pl-col-bot-hint:hover svg { opacity: 1; }
.pl-col-bot-hint-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.pl-col-alarm-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  border: 1px dashed #fecaca;
  background: transparent;
  color: #dc2626;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity .12s, background .12s, border-style .12s;
}
.pl-col-alarm-btn:hover {
  opacity: 1;
  background: #fef2f2;
  border-style: solid;
}
.pl-col-alarm-btn.is-active {
  opacity: 1;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  font-weight: 600;
}

/* IA por etapa: toggle on/off en el footer de la columna, junto a la alarma.
   El footer pasa a fila: el chip de bot ocupa su propia línea y el toggle de IA
   + la alarma (ahora más chica) comparten la línea de abajo. */
.pl-col-footer { flex-flow: row wrap; align-items: stretch; }
.pl-col-bot-hint { flex: 1 1 100%; }
.pl-col-alarm-btn { flex: 2 1 0; width: auto; min-width: 0; }   /* alarma ≈ 66% */
.pl-col-alarm-btn--sm { padding: 5px 8px; font-size: 11px; gap: 4px; }
.pl-col-ai-toggle {
  flex: 1 1 0; min-width: 0;   /* toggle IA ≈ 33% */
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 5px 8px; font-size: 11.5px; font-weight: 600; font-family: inherit;
  border: 1px solid #e2e8f0; background: #f8fafc; color: #64748b;
  border-radius: 8px; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.pl-col-ai-toggle:hover { border-color: #cbd5e1; background: #f1f5f9; }
.pl-col-ai-toggle.is-on { background: #ecfdf5; border-color: #6ee7b7; color: #047857; }
.pl-col-ai-lbl { line-height: 1; }
.pl-col-ai-ico { flex-shrink: 0; opacity: .9; }
.pl-col-ai-sw {
  position: relative; width: 26px; height: 15px; border-radius: 999px;
  background: #cbd5e1; flex-shrink: 0; transition: background .15s;
}
.pl-col-ai-sw::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px;
  border-radius: 50%; background: #fff; transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.pl-col-ai-toggle.is-on .pl-col-ai-sw { background: #10b981; }
.pl-col-ai-toggle.is-on .pl-col-ai-sw::after { transform: translateX(11px); }

/* Tarjetas estancadas — borde rojo y leve tinte */
.pl-card.is-stale {
  border-color: #fca5a5;
  background: #fff7f7;
  box-shadow: 0 0 0 1px #fca5a566 inset;
}
.pl-card-stale-pill {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  background: #fee2e2;
  color: #b91c1c;
  margin-right: 4px;
}

/* Vigilante 24 h: el cliente escribió, nadie le contestó y su ventana cierra en 3 h o menos */
.pl-card.has-window-alert:not(.is-stale) {
  border-color: #fdba74;
  box-shadow: 0 0 0 1px #fdba7466 inset;
}
/* Mismo alto que .pl-card-tag: si fuera más alta, estiraría a las etiquetas vecinas */
.pl-card-window-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 99px;
  background: #ffedd5;
  color: #c2410c;
  white-space: nowrap;
}
.pl-card-window-pill svg { flex: none; width: 10px; height: 10px; }

/* Bot de ventana AGENDADO: tiene hora, no está atorado. A propósito en azul
   tranquilo y NO en naranja — el naranja es "córrele, contéstale". */
.pl-card-bot-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 99px;
  background: #e0e7ff;
  color: #4338ca;
  white-space: nowrap;
}
.pl-card-bot-pill svg { flex: none; width: 10px; height: 10px; }

.bot-row-window-note { color: #64748b; font-size: 0.92em; }

/* Modal de alarma de etapa */
.alarm-help {
  margin: 0 0 18px;
  padding: 10px 12px;
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  border-radius: 6px;
  font-size: 12px;
  color: #78350f;
  line-height: 1.5;
}
.alarm-type-desc {
  margin: 8px 0 16px;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  min-height: 36px;
}
.alarm-time-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}
.alarm-time-row .form-field { margin-bottom: 0; }

/* Multi-alarmas: cada alarma es una "tarjeta" dentro del modal */
.alarm-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: #fafbfc;
}
.alarm-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.alarm-row-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(0,0,0,.04);
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: .5px;
}
.alarm-row-del {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  font-weight: 400;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.alarm-row-del:hover {
  background: #fee2e2;
  color: #dc2626;
}
.alarm-row .alarm-type-desc {
  margin: 4px 0 12px;
  min-height: 0;
}
#alarmModal .form-field { margin-bottom: 14px; }
#alarmModal .form-field > span { display: block; font-size: 12px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
#alarmModal .form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  outline: none;
  box-sizing: border-box;
}
#alarmModal .form-input:focus { border-color: var(--accent); }

/* Empty state */
.pl-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* Manage modal — stages list */
.pl-stages-section { border-top: 1px solid var(--border); padding-top: 16px; }
.pl-stages-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
}
.pl-stage-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 6px;
  background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}
.pl-stage-row.is-dragging { opacity: .4; }
.pl-stage-row.drag-over-stage { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.18); }
.pl-stage-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 2px;
  flex-shrink: 0;
}
.pl-stage-drag-handle:active { cursor: grabbing; }
.pl-stage-color-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pl-stage-name { flex: 1; font-size: 13px; }
.pl-stage-kind {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 8px;
}
/* Botón eliminar etapa: cuadrito rojo claro con × roja, para que se vea
   claramente como acción destructiva. Se intensifica en hover. */
.pl-stage-del {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  cursor: pointer;
  color: #dc2626;
  font-size: 14px;
  font-weight: 700;
  width: 24px;
  height: 24px;
  padding: 0;
  line-height: 1;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 120ms, color 120ms, border-color 120ms, transform 120ms;
}
.pl-stage-del:hover {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
  transform: scale(1.05);
}
.pl-stage-edit-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 3px 5px; border-radius: 4px;
  display: flex; align-items: center; transition: color 120ms, background 120ms;
}
.pl-stage-edit-btn:hover { color: var(--primary); background: rgba(37,99,235,.08); }
.pl-stage-bot-chip {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 2px 8px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer; transition: all 120ms;
  white-space: nowrap;
}
.pl-stage-bot-chip:hover { border-color: var(--primary); color: var(--primary); }
.pl-stage-bot-chip.has-bot { border-color: var(--primary); color: var(--primary); background: rgba(37,99,235,.07); }
.pl-stage-bot-chip-wrap { display: inline-flex; align-items: center; gap: 4px; }
.pl-stage-bot-clear {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border: none; border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px; line-height: 1;
  cursor: pointer; padding: 0;
  transition: background 120ms, color 120ms;
}
.pl-stage-bot-clear:hover { background: #fee2e2; color: #dc2626; }
.pl-stage-edit-row, .pl-stage-bot-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 8px;
  margin: -2px 0 6px;
  background: var(--surface);
  border: 1px solid var(--primary);
  border-top: none;
  border-radius: 0 0 8px 8px;
}
.pl-stage-edit-color {
  width: 34px; height: 30px; padding: 2px 3px;
  border: 1px solid var(--border); border-radius: 6px; flex-shrink: 0; cursor: pointer;
}
.pl-stage-edit-name { flex: 1; }
.pl-stage-edit-kind, .pl-stage-bot-select {
  height: 32px; border: 1px solid var(--border); border-radius: 6px;
  padding: 0 8px; font-size: 12px; background: var(--bg); color: var(--text);
}

/* ─── Responsive del clon ─── */
@media (max-width: 900px) {
  .rh-shell { grid-template-columns: 260px 1fr; }
}
@media (max-width: 660px) {
  .rh-shell { grid-template-columns: 1fr; }
  /* El display del panel de conversación se controla con data-chat-mobile-view (ver más abajo) */
}

/* ═══════ Expedient Detail View ═══════ */
.exp-detail-shell {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100%;
  overflow: hidden;
}

.exp-detail-left {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;          /* Lead panel scroll fix — scroll all the side */
  overflow-x: hidden;
  background: var(--surface);
}

.exp-detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  position: sticky;          /* Lead panel scroll fix — topbar fijo arriba */
  top: 0;
  z-index: 10;
  background: var(--surface);
}

.exp-detail-back {
  display: flex;
  align-items: center;
  gap: 6px;
}

.exp-detail-info {
  /* Lead panel scroll fix — el scroll vive en .exp-detail-left ahora */
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.exp-detail-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.exp-detail-section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 11px 14px 9px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
}

.exp-detail-field {
  display: flex;
  align-items: flex-start;       /* start, no center — los valores largos no se desalinean */
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  min-height: 38px;
}
.exp-detail-field:last-child { border-bottom: none; }
.exp-detail-field-label {
  color: var(--text-muted);
  min-width: 90px;
  flex-shrink: 0;
  padding-top: 2px;              /* compensa el flex-start con el valor */
  font-size: 12px;
}
.exp-detail-field-value {
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;       /* fuerza wrap incluso en strings sin espacios */
  flex: 1;
  min-width: 0;                  /* permite que flex child se encoja */
  line-height: 1.45;
}
.edf-cell {
  flex: 1;
  min-width: 0;
}
.edf-display {
  display: block;
  word-break: break-word;
  overflow-wrap: anywhere;
}


/* Right panel */
/* exp-detail-right usa rh-conversation-panel directamente — sin estilos propios de layout */

.exp-detail-convo-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.exp-detail-convo-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  cursor: pointer;
  transition: background .15s;
}
.exp-detail-convo-tab:hover { background: rgba(255,255,255,.1); }
.exp-detail-convo-tab.is-active { background: #1e3a5f; color: #93c5fd; border-color: #1e3a5f; }
.exp-detail-convo-tab .rh-channel-dot { width: 7px; height: 7px; }

/* ── Pipeline board toolbar (search + sort) ── */
.pl-board-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 10px;
}
.pl-board-search-wrap {
  position: relative;
  flex: 1;
  max-width: 280px;
}
.pl-board-search-icon {
  position: absolute;
  left: 9px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.pl-board-search-wrap input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px 6px 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.pl-board-search-wrap input:focus { border-color: var(--primary); }
.pl-sort-wrap select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  cursor: pointer;
  outline: none;
}
.pl-sort-wrap select:focus { border-color: var(--primary); }

/* ── Pipeline icon picker ── */
.pl-icon-picker-wrap { position: relative; }
.pl-icon-btn {
  width: 40px; height: 38px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.pl-icon-btn:hover { border-color: var(--primary); }
.pl-icon-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  min-width: 240px;
}
.pl-icon-option {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  transition: background .12s;
}
.pl-icon-option:hover { background: var(--bg); }
.pl-icon-option.is-active { background: rgba(37,99,235,.12); border-color: var(--primary); }
.pl-icon-clear { font-size: 11px; grid-column: 1/-1; color: var(--text-muted); padding: 4px 8px; height: auto; width: auto; }
.pl-tab-icon { display: flex; align-items: center; }

/* ── Exp-detail inline editing ── */
.editable-field { cursor: pointer; border-radius: 6px; transition: background .12s; }
.editable-field:hover { background: rgba(255,255,255,.04); }
.edf-empty { color: var(--text-muted); }

/* edf-cell: stable container — display and input share the same space */
.edf-cell {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.edf-cell .edf-display {
  display: block;
  width: 100%;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity .1s;
}
.edf-cell .edf-input {
  position: absolute;
  inset: -4px -8px;
  width: calc(100% + 16px);
  background: var(--surface);
  border: 1.5px solid var(--primary);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 8px;
  outline: none;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity .1s;
  z-index: 2;
}
.edf-cell.is-editing .edf-display { opacity: 0; }
.edf-cell.is-editing .edf-input {
  opacity: 1;
  pointer-events: auto;
}
/* Select inherits absolute positioning from .edf-input */
.edf-select { cursor: pointer; height: calc(100% + 8px); appearance: auto; }

/* ── Bot tags ── */
.bot-tag-filter-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 0 16px;
  align-items: center;
}
.bot-tag-filter {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.bot-tag-filter:hover { border-color: var(--accent); color: var(--text); }
.bot-tag-filter.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.bot-tag-filter.is-active .bot-tag-dot { box-shadow: 0 0 0 2px #fff inset; }

/* Pill de filtro 'Errores' — siempre con tinte rojo, más prominente */
.bot-tag-filter.is-error-pill {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #b91c1c;
  font-weight: 600;
}
.bot-tag-filter.is-error-pill:hover {
  border-color: #ef4444;
  background: #fee2e2;
  color: #991b1b;
}
.bot-tag-filter.is-error-pill.is-active {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

/* Pill de filtro 'Avisos' — tinte ámbar (warning) */
.bot-tag-filter.is-warn-pill {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #92400e;
  font-weight: 600;
}
.bot-tag-filter.is-warn-pill:hover {
  border-color: #f59e0b;
  background: #fef3c7;
  color: #78350f;
}
.bot-tag-filter.is-warn-pill.is-active {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #fff;
}
.bot-tag-filter.is-warn-pill .bot-tag-filter-count {
  background: rgba(245, 158, 11, 0.15);
}
.bot-tag-filter.is-warn-pill.is-active .bot-tag-filter-count {
  background: rgba(255, 255, 255, 0.25);
}
.bot-tag-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 99px;
  background: rgba(239, 68, 68, 0.15);
  color: inherit;
  font-size: 10px;
  font-weight: 700;
  margin-left: 2px;
}
.bot-tag-filter.is-error-pill.is-active .bot-tag-filter-count {
  background: rgba(255, 255, 255, 0.25);
}
.bot-sort-select {
  margin-left: auto;
  padding: 6px 28px 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23667085' stroke-width='1.6'><polyline points='3 5 6 8 9 5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}
.bot-sort-select:hover { border-color: var(--accent); }
.bot-tag-manage-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
}
.bot-tag-manage-btn:hover { border-color: var(--accent); color: var(--text); }
.bot-tag-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
  /* Doble anillo para que el punto siempre contraste contra el fondo del pill,
     sin importar si el color es oscuro (negro) o claro (verde, amarillo). */
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,0.45),
    0 0 0 1.5px rgba(255,255,255,0.9);
}
.bot-tag-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.bot-row-tags { display: inline-flex; gap: 5px; margin-left: 8px; flex-wrap: wrap; }
.bot-list-empty-filter {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.bot-builder-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center;
  padding: 4px 0;
}
.bot-tag-add-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
.bot-tag-add-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(59,130,246,.05); border-style: solid; }
.bot-tag-remove {
  margin-left: 2px;
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  opacity: .7;
  padding: 0 2px;
}
.bot-tag-remove:hover { opacity: 1; }

/* Input inline para crear/asignar etiquetas en cadena dentro del bot builder */
.bot-tag-input-wrap {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--accent, #3b82f6);
  border-radius: 999px;
  padding: 0 4px 0 10px;
  height: 26px;
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.bot-tag-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  font-family: inherit;
  width: 220px;
  padding: 0;
  color: var(--text);
}
.bot-tag-input::placeholder { color: var(--text-muted); }
.bot-tag-input-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.bot-tag-input-close:hover { background: #fee2e2; color: #dc2626; }

/* Sugerencias de etiquetas existentes mientras el input está abierto */
.bot-tag-suggest-row {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.bot-tag-suggest-row::before {
  content: 'O elige una existente:';
  width: 100%;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.bot-tag-suggest {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
  font-family: inherit;
}
.bot-tag-suggest:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(15,23,42,.1); }

/* Tag manager modal */
.bot-tag-form {
  display: flex; gap: 8px; align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.bot-tag-form input[type="text"] {
  flex: 1; min-width: 140px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
.bot-tag-form input[type="text"]:focus { border-color: var(--accent); }
.bot-tag-color-picker { display: flex; gap: 4px; }
.bot-tag-swatch, .bot-tag-swatch-sm {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.bot-tag-swatch:hover, .bot-tag-swatch-sm:hover { transform: scale(1.15); }
.bot-tag-swatch.is-selected, .bot-tag-swatch-sm.is-selected { border-color: var(--text); }
.bot-tag-swatch-sm { width: 16px; height: 16px; }
.bot-tag-manager-list { display: flex; flex-direction: column; gap: 8px; }
.bot-tag-manager-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 4px;
  border-radius: 6px;
}
.bot-tag-manager-row:hover { background: #f8fafc; }
.bot-tag-manager-row > .bot-tag-pill { flex-shrink: 0; min-width: 80px; }
.bot-tag-row-colors { display: flex; gap: 3px; flex: 1; flex-wrap: wrap; }
.bot-tag-row-actions { display: flex; gap: 2px; flex-shrink: 0; }
.bot-tag-manager-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ── Bot builder picker buttons (replace native selects for pipeline/stage) ── */
.sb-picker-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .12s, background .12s;
  font-family: inherit;
}
.sb-picker-btn:hover { border-color: var(--accent); background: #fafcff; }
.sb-picker-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: transparent;
}
.sb-picker-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-picker-chev { color: var(--text-muted); flex-shrink: 0; }

/* ── Option picker modal (pipeline / stage chooser) ── */
.option-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  max-height: 60vh;
  overflow-y: auto;
}
.option-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.option-picker-row:hover { background: #f1f5f9; }
.option-picker-row.is-selected { background: #eff6ff; border-color: var(--accent); color: var(--accent); }
.option-picker-row.is-selected:hover { background: #dbeafe; }
.option-picker-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.option-picker-label { flex: 1; }
.option-picker-check { color: var(--accent); flex-shrink: 0; }

/* Stage color dot inside display badge */
.edf-stage-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
/* Stage badge: solo punto de color + texto normal */
.exp-detail-stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 0;
}

.exp-detail-actions-bar {
  display: flex;
  gap: 8px;
  padding: 6px 14px 8px;
}

/* Delete zone — fixed at bottom of left panel */
/* ── Bots del expediente ── */
.exp-detail-bots {
  flex-shrink: 0;
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.exp-bots-section {}
.exp-bot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.exp-bot-row:last-child { border-bottom: none; }
.exp-bot-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.exp-bot-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-bot-trigger { font-size: 10px; color: var(--text-muted); }
.exp-bot-toggle {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px; border: none; cursor: pointer;
  background: rgba(52,199,89,.12); color: #22c55e; font-size: 11px; font-weight: 600;
  flex-shrink: 0; transition: background 140ms, color 140ms;
}
.exp-bot-toggle:hover { background: rgba(52,199,89,.22); }
.exp-bot-toggle.is-paused { background: var(--surface-2, rgba(148,163,184,.12)); color: var(--text-muted); }
.exp-bot-toggle.is-paused:hover { background: rgba(148,163,184,.22); }
.exp-bot-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #22c55e; flex-shrink: 0;
}
.exp-bot-toggle.is-paused .exp-bot-dot { background: var(--text-muted); }
.exp-bot-row.is-paused .exp-bot-name { color: var(--text-muted); }

/* ── Bot runs ── */
.exp-runs-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted); margin: 8px 0 4px;
}
.exp-runs-empty { font-size: 12px; color: var(--text-muted); margin: 4px 0 8px; }

.exp-run-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 12px;
}
.exp-run-row:last-child { border-bottom: none; }

/* running */
.exp-run-running { flex-direction: column; gap: 5px; }
.exp-run-header  { display: flex; align-items: center; gap: 6px; }
.exp-run-pulse {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34,197,94,.5);
  animation: pulse-ring 1.2s ease-out infinite;
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
  70%  { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.exp-run-bar-wrap {
  height: 4px; border-radius: 999px; background: var(--border); overflow: hidden; width: 100%;
}
.exp-run-bar {
  height: 100%; border-radius: 999px; background: #22c55e;
  transition: width 600ms ease;
}

/* done / error */
.exp-run-icon {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; margin-top: 1px;
}
.exp-run-done  .exp-run-icon { background: rgba(34,197,94,.15); color: #22c55e; }
.exp-run-error .exp-run-icon { background: rgba(239,68,68,.12); color: #ef4444; }

.exp-run-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.exp-run-name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-run-error-msg { font-size: 10px; color: #ef4444; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-run-meta  { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
/* ─── Carritos abandonados ─── */
.ac-warn { background:#fffbeb; border:1px solid #fcd34d; border-radius:8px; padding:14px 16px; margin-bottom:14px; display:flex; flex-direction:column; gap:10px; align-items:flex-start; }
.ac-warn p { margin:0; font-size:13px; color:#78350f; }
.ac-history-row { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:8px 10px; border:1px solid var(--border); border-radius:6px; margin-bottom:6px; background:var(--bg-alt); }
.ac-row-main { display:flex; flex-direction:column; gap:2px; min-width:0; flex:1; }
.ac-row-main strong { font-size:12px; }
.ac-row-phone { font-size:11px; color:var(--text-muted); }
.ac-row-meta { display:flex; align-items:center; gap:10px; font-size:11px; color:var(--text-muted); flex-shrink:0; }
.ac-status { padding:2px 8px; border-radius:10px; font-size:10px; font-weight:600; white-space:nowrap; }
.ac-status.ac-sent { background:rgba(34,197,94,.12); color:#15803d; border:1px solid rgba(34,197,94,.25); }
.ac-status.ac-fail { background:rgba(239,68,68,.10); color:#b91c1c; border:1px solid rgba(239,68,68,.25); }

.exp-run-wait-row { display: flex; align-items: center; gap: 6px; }
.exp-run-wait-badge { font-size: 11px; color: #15803d; background: rgba(34,197,94,.10); border: 1px solid rgba(34,197,94,.25); padding: 2px 9px; border-radius: 12px; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.exp-run-wait-badge--manual { color: #b45309; background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.30); }
.exp-run-wait-badge.is-editable { cursor: pointer; transition: background .15s, border-color .15s; }
.exp-run-wait-badge.is-editable:hover { background: rgba(34,197,94,.18); border-color: rgba(34,197,94,.45); }
.exp-run-wait-edit { font-size: 9px; opacity: .6; }
.exp-run-wait-editor { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; padding: 4px 0; }
.exp-run-wait-num  { width: 60px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 5px; font-size: 12px; background: var(--bg); color: var(--text); }
.exp-run-wait-unit { padding: 4px 6px; border: 1px solid var(--border); border-radius: 5px; font-size: 12px; background: var(--bg); color: var(--text); }
.exp-run-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-shrink: 0; }
.exp-run-btn {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 5px; border: none; cursor: pointer;
  background: transparent; transition: background 120ms;
}
.exp-run-btn:hover { background: var(--border); }
.exp-run-btn--pause { color: var(--text-muted); }
.exp-run-btn--pause:hover { color: var(--accent); }
.exp-run-btn--kill  { color: var(--text-muted); }
.exp-run-btn--kill:hover  { color: #ef4444; background: rgba(239,68,68,.1); }
.exp-run-btn:disabled { opacity: .4; cursor: not-allowed; }

/* paused state */
.exp-run-pulse--paused {
  background: #f59e0b;
  box-shadow: none;
  animation: none;
}
.exp-run-bar--paused { background: #f59e0b; }
.exp-run-times { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex-shrink: 0; color: var(--text-muted); }
.exp-run-dur   { font-size: 10px; }

.exp-detail-delete-zone {
  padding: 12px 14px;
  border-top: 1px solid rgba(239,68,68,.18);
}
.btn--danger {
  background: rgba(239,68,68,.10);
  color: #f87171;
  border: 1px solid rgba(239,68,68,.25);
  width: 100%;
  justify-content: center;
}
.btn--danger:hover { background: rgba(239,68,68,.2); }

/* ── Filter panel (shared: kanban + expedients) ── */
.kf-anchor { position: relative; }
.kf-filter-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  position: relative;
  transition: border-color .12s, color .12s;
}
.kf-filter-btn:hover, .kf-filter-btn.has-filters { border-color: var(--primary); color: var(--text); }
.kf-badge {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 16px; height: 16px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 99px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}
.kf-badge[hidden] { display: none !important; }
.kf-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 300;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.22);
  padding: 12px;
  min-width: 320px;
  max-width: 400px;
}
.kf-section { margin-bottom: 12px; }
.kf-section:last-of-type { margin-bottom: 0; }
.kf-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.kf-si-row { display: flex; flex-wrap: wrap; gap: 5px; }
.kf-si-btn {
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background .1s, color .1s, border-color .1s;
}
.kf-si-btn:hover { background: rgba(255,255,255,.06); color: var(--text); }
.kf-si-btn.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.kf-tag-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.kf-tag-chip {
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background .1s, color .1s;
}
.kf-tag-chip:hover { background: rgba(255,255,255,.06); color: var(--text); }
.kf-tag-chip.is-active { background: rgba(37,99,235,.18); border-color: var(--primary); color: #93c5fd; }

/* Pipeline + Stage filter chips */
.kf-pl-chips, .kf-stage-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.kf-pl-chip, .kf-stage-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background .1s, color .1s;
}
.kf-pl-chip:hover, .kf-stage-chip:hover { background: rgba(255,255,255,.06); color: var(--text); }
.kf-pl-chip.is-active, .kf-stage-chip.is-active { background: rgba(37,99,235,.18); border-color: var(--primary); color: #93c5fd; }
.kf-stage-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kf-section-hint { font-size: 10px; font-weight: 400; color: var(--text-muted); text-transform: none; letter-spacing: 0; margin-left: 4px; }
.kf-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.kf-field-label { font-size: 12px; color: var(--text-muted); min-width: 110px; flex-shrink: 0; }
.kf-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
}
.kf-input:focus { border-color: var(--primary); }
.kf-tri-toggle { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.kf-tri-opt {
  flex: 1;
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 6px;
  cursor: pointer;
  transition: background .1s, color .1s;
}
.kf-tri-opt:last-child { border-right: none; }
.kf-tri-opt:hover { background: rgba(255,255,255,.05); color: var(--text); }
.kf-tri-opt.is-active { background: var(--primary); color: #fff; }
.kf-footer { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }
.kf-clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
}
.kf-clear-btn:hover { color: var(--text); }

/* exp-toolbar filter btn placement */
.exp-toolbar .kf-filter-btn { margin-left: 0; }

/* ── Topbar pipeline extras ── */
.topbar-pl-extras {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.pl-sort-select {
  background: #f1f5f9;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  outline: none;
  transition: border-color .15s, background .15s;
}
.pl-sort-select:focus { background: #fff; border-color: var(--accent); }
/* kf-filter-btn in topbar matches topbar pill style */
.topbar-pl-extras .kf-filter-btn {
  background: #f1f5f9;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text-muted);
  padding: 8px 14px;
}
.topbar-pl-extras .kf-filter-btn:hover,
.topbar-pl-extras .kf-filter-btn.has-filters { background: #fff; border-color: var(--accent); color: var(--text); }
/* kf-panel anchored below the topbar search */
#topbarSearchWrap .kf-panel { top: calc(100% + 8px); min-width: 340px; }

/* Cross-pipeline global search results */
#plGlobalSearchPanel { padding: 6px; min-width: 320px; max-width: 440px; }
.pl-gs-hint { font-size: 11px; color: var(--text-muted); padding: 4px 6px 8px; }
.pl-gs-group { margin-bottom: 4px; }
.pl-gs-group-name { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 2px 8px 4px; }
.pl-gs-item { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 7px 8px; border-radius: 7px; text-align: left; background: none; border: none; cursor: pointer; gap: 10px; transition: background .1s; }
.pl-gs-item:hover { background: var(--bg-2); }
.pl-gs-item-name { font-size: 13px; font-weight: 500; color: var(--text); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-gs-item-stage { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.pl-gs-item-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
/* Highlight pulse cuando el card aparece en el kanban */
.is-pl-highlighted { animation: pl-highlight-pulse 2s ease-out forwards; }
@keyframes pl-highlight-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(37,99,235,.45), 0 0 0 0 rgba(37,99,235,.2); background: rgba(37,99,235,.08); }
  60%  { box-shadow: 0 0 0 6px rgba(37,99,235,0), 0 0 0 0 rgba(37,99,235,0); }
  100% { box-shadow: none; background: transparent; }
}

/* date input in filter panel */
.kf-date-input { cursor: pointer; }
.kf-date-input::-webkit-calendar-picker-indicator { cursor: pointer; filter: invert(0.5); }

/* ─────────────────────────────────────────────────────────────
   PIPELINE VIEW SWITCH (kanban / lista)
───────────────────────────────────────────────────────────── */
.pl-view-switch {
  display: inline-flex;
  background: #f1f5f9;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.pl-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.pl-view-btn:hover { color: var(--text); }
.pl-view-btn.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}
.pl-view-btn svg { flex-shrink: 0; }

/* ─────────────────────────────────────────────────────────────
   PIPELINE LIST MODE
───────────────────────────────────────────────────────────── */
.pl-board.pl-board--list {
  display: block;
  padding: 0 24px 24px;
  overflow: auto;
}
.pl-list-bulkbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin: 12px 0;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  opacity: 0.6;
  transition: opacity .15s, background .15s, border-color .15s;
}
.pl-list-bulkbar.is-active {
  opacity: 1;
  background: #eff6ff;
  border-color: #bfdbfe;
}
.pl-list-bulkbar-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.pl-list-bulkbar-info strong { color: #2563eb; font-size: 14px; }
.pl-list-bulkbar-actions { display: flex; align-items: center; gap: 8px; }
.pl-list-bulk-clear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.pl-list-bulk-clear:hover { color: var(--text); }
.pl-list-bulk-stage {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  color: var(--text);
}
.pl-list-bulk-stage:focus { border-color: var(--accent); }
.pl-list-bulkbar:not(.is-active) .pl-list-bulkbar-actions { pointer-events: none; opacity: 0.5; }

.pl-list-table-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.pl-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.pl-list-table thead th {
  background: #f8fafc;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.pl-list-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: var(--text);
}
.pl-list-table tbody tr:last-child td { border-bottom: none; }
.pl-list-row { transition: background .12s; }
.pl-list-row:hover { background: #f8fafc; }
.pl-list-row.is-selected { background: #eff6ff; }
.pl-list-row.is-selected:hover { background: #dbeafe; }
.pl-list-col-check { width: 36px; }
.pl-list-col-check input[type="checkbox"] { cursor: pointer; width: 16px; height: 16px; }
.pl-list-col-name { min-width: 200px; }
.pl-list-col-stage { width: 180px; }
.pl-list-col-contact { width: 160px; }
.pl-list-col-value { width: 100px; text-align: right; }
.pl-list-col-date { width: 140px; color: var(--text-muted); }
.pl-list-name-link {
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}
.pl-list-name-link:hover { color: var(--accent); text-decoration: underline; }
.pl-list-stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.pl-list-stage-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pl-list-empty-row {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 14px;
  font-style: italic;
}

/* ─────────────────────────────────────────────────────────────
   TEMPLATES VIEW
───────────────────────────────────────────────────────────── */
.view-templates { padding: 24px; overflow-y: auto; }
.tpl-layout { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

.tpl-header { display: flex; align-items: center; justify-content: space-between; }
.tpl-title { font-size: 20px; font-weight: 600; color: var(--text); margin: 0; }

/* Tabs */
.tpl-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); }
.tpl-tab {
  background: none; border: none; padding: 10px 18px 9px;
  font-size: 14px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tpl-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tpl-tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-elevated); color: var(--text-muted);
  font-size: 11px; font-weight: 600; border-radius: 999px;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
}
.tpl-tab.is-active .tpl-tab-badge { background: var(--accent-light, #e0e7ff); color: var(--accent); }

/* List */
.tpl-list { display: flex; flex-direction: column; gap: 10px; }
.tpl-empty { text-align: center; padding: 60px 0; color: var(--text-muted); font-size: 14px; }

/* Template card */
.tpl-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: box-shadow .15s;
}
.tpl-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.tpl-card-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.tpl-card-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.tpl-card-icon.wa { background: #dcfce7; }
.tpl-card-icon.free { background: #e0e7ff; }
.tpl-card-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.5;
  cursor: grab;
  user-select: none;
  transition: opacity .12s, color .12s;
}
.tpl-card.is-draggable { cursor: grab; }
.tpl-card.is-draggable:active { cursor: grabbing; }
.tpl-card:hover .tpl-card-drag-handle { opacity: 1; color: var(--accent, #2563eb); }
.tpl-card.is-dragging { opacity: .4; }
.tpl-card.drag-over {
  border-top: 2px solid var(--accent, #2563eb);
  background: rgba(37,99,235,.04);
}
.tpl-card-body { flex: 1; min-width: 0; }
.tpl-card-name { font-size: 14px; font-weight: 600; color: var(--text); }
.tpl-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.tpl-card-body-text {
  font-size: 13px; color: var(--text-secondary, #4b5563);
  margin-top: 6px; white-space: pre-wrap; word-break: break-word;
  max-height: 60px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.tpl-card-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.tpl-card-actions .icon-btn { width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0; }
.tpl-card-action-del:hover { color: var(--danger, #dc2626) !important; background: #fee2e2 !important; }
.tpl-card-action-send { color: var(--accent, #2563eb); }
.tpl-card-action-send:hover { background: var(--accent-light, #e0e7ff) !important; }

/* Status badge */
.tpl-status {
  font-size: 11px; font-weight: 600; border-radius: 999px;
  padding: 2px 9px; display: inline-block;
}
.tpl-status.draft     { background: #f1f5f9; color: #64748b; }
.tpl-status.pending   { background: #fef3c7; color: #92400e; }
.tpl-status.approved  { background: #dcfce7; color: #166534; }
.tpl-status.rejected  { background: #fee2e2; color: #991b1b; }

/* Modal overrides for templates */
/* Template modal card */
.tpl-modal-card { width: min(560px, 100%); }
.tpl-modal-card .modal-body { overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }

/* Type toggle */
.tpl-type-toggle { display: flex; gap: 10px; }
.tpl-type-opt {
  flex: 1; display: flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--border); border-radius: 8px; padding: 10px 14px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.tpl-type-opt:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.tpl-type-opt input { accent-color: var(--accent); flex-shrink: 0; }
.tpl-type-opt span { font-size: 13px; font-weight: 500; color: var(--text); }

/* WA-only fields block */
.tpl-wa-fields { display: flex; flex-direction: column; gap: 14px; transition: opacity .15s; }
/* Plantillas libres: ocultar todo lo que es exclusivo de Meta/wa_api */
.tpl-modal-card.is-free .tpl-wa-fields,
.tpl-modal-card.is-free .tpl-wa-only { display: none; }

/* Two-column row */
.tpl-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Body textarea */
.tpl-body-input { font-family: inherit; resize: vertical; min-height: 110px; }

/* Hints */
.tpl-hint-inline { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.tpl-hint-block { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.tpl-hint-block code { background: var(--bg-elevated); padding: 1px 4px; border-radius: 3px; font-size: 11px; }
.tpl-var-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.tpl-var-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.tpl-var-btn { display: inline-flex; align-items: center; gap: 3px; padding: 3px 10px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-primary); font-size: 12px; font-family: monospace; cursor: pointer; transition: background .15s, border-color .15s; }
.tpl-var-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Error */
.tpl-error-msg { font-size: 13px; color: #dc2626; margin: 0; padding: 8px 12px; background: #fee2e2; border-radius: 6px; }
.tpl-rejected-reason {
  font-size: 11px; color: #991b1b; background: #fee2e2;
  border-radius: 4px; padding: 2px 7px; display: inline-block;
  margin-top: 4px; margin-bottom: 2px;
}

/* ── Setup steps en modal de integración ── */
.int-setup-steps {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 4px;
}
.int-steps-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #0369a1;
  margin: 0 0 8px;
}
.int-steps-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.int-steps-list li {
  font-size: 13px;
  color: #0c4a6e;
  line-height: 1.5;
}
.int-steps-list li b  { font-weight: 600; }
.int-steps-list li code {
  background: #e0f2fe;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  font-family: monospace;
}

/* ═══════════════════════════════════════════
   DASHBOARD / INICIO
   ═══════════════════════════════════════════ */

:root {
  --dash-received: #6366f1;
  --dash-sent:     #10b981;
}

.view-inicio {
  overflow-y: auto;
  background: var(--surface);
}

.dash-shell {
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.dash-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.dash-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 3px 0 0;
  text-transform: capitalize;
}

/* Rows */
.dash-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.dash-row--sm {
  grid-template-columns: repeat(3, 1fr);
}

/* Cards */
.dash-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  position: relative;
  overflow: hidden;
}
.dash-card--sm {
  padding: 16px;
  gap: 12px;
}

/* Accent bar on left */
.dash-card::before {
  content: '';
  position: absolute;
  left: 0; top: 16px; bottom: 16px;
  width: 3px;
  border-radius: 0 3px 3px 0;
}
.dash-card--received::before { background: var(--dash-received); }
.dash-card--sent::before      { background: var(--dash-sent); }
.dash-card--convos::before    { background: #f59e0b; }
.dash-card--contacts::before  { background: #3b82f6; }
.dash-card--exps::before      { background: #8b5cf6; }

/* Icon */
.dash-card-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.dash-card-icon--sm {
  width: 34px; height: 34px;
  border-radius: 8px;
}
.dash-card--received .dash-card-icon { background: rgba(99,102,241,.1); color: var(--dash-received); }
.dash-card--sent     .dash-card-icon { background: rgba(16,185,129,.1); color: var(--dash-sent); }
.dash-card--convos   .dash-card-icon { background: rgba(245,158,11,.1); color: #f59e0b; }
.dash-card--contacts .dash-card-icon { background: rgba(59,130,246,.1); color: #3b82f6; }
.dash-card--exps     .dash-card-icon { background: rgba(139,92,246,.1); color: #8b5cf6; }
.dash-card-icon svg  { width: 20px; height: 20px; }
.dash-card-icon--sm svg { width: 17px; height: 17px; }

/* Text */
.dash-card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.dash-card-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  white-space: nowrap;
}
.dash-card-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -.5px;
}
.dash-card--sm .dash-card-value { font-size: 26px; }
.dash-card-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Sparkline (mini bar chart inside big cards) */
.dash-sparkline {
  position: absolute;
  right: 16px; bottom: 16px;
  width: 80px; height: 36px;
  opacity: .5;
}

/* ── Weekly bar chart ── */
.dash-chart-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px 14px;
}

/* ─── Costo estimado de Meta ─── */
.dash-cost-card {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fcd34d;
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.dash-cost-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.dash-cost-header h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; color: #78350f; }
.dash-cost-sub { margin: 0; font-size: 12px; color: #92400e; }
.dash-cost-amount {
  text-align: right;
  flex-shrink: 0;
}
.dash-cost-usd {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: #78350f;
  line-height: 1;
}
.dash-cost-mxn {
  display: block;
  font-size: 12px;
  color: #92400e;
  margin-top: 4px;
}
.dash-cost-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.dash-cost-stat {
  background: rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  padding: 10px 12px;
}
.dash-cost-stat-label {
  display: block;
  font-size: 11px;
  color: #92400e;
  font-weight: 500;
  margin-bottom: 2px;
}
.dash-cost-stat-value {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: #78350f;
}
.dash-cost-note {
  margin: 0;
  font-size: 11px;
  color: #92400e;
  font-style: italic;
  line-height: 1.4;
}
@media (max-width: 600px) {
  .dash-cost-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .dash-cost-amount { text-align: left; }
  .dash-cost-detail { grid-template-columns: 1fr; }
}

/* ─── Respaldos (Settings > Respaldos) ─── */
.bk-info-box {
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 16px;
}
.bk-info-box strong { display: block; margin-bottom: 4px; }
.bk-info-box code {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
}
.bk-counts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.bk-count-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bg-2, #f9fafb);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.bk-count-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.bk-count-value { font-size: 18px; font-weight: 700; color: var(--text); }
.bk-list { display: flex; flex-direction: column; gap: 8px; }
.bk-empty { text-align: center; padding: 24px 0; color: var(--text-muted); font-size: 13px; }
.bk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: box-shadow .12s;
}
.bk-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.bk-item-main { flex: 1; min-width: 0; }
.bk-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.bk-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.bk-badge--manual  { background: #dbeafe; color: #1e40af; }
.bk-badge--monthly { background: #fef3c7; color: #78350f; }
.bk-item-date { font-size: 12px; color: var(--text); font-weight: 500; }
.bk-item-meta { font-size: 11px; color: var(--text-muted); }
.bk-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .bk-counts { grid-template-columns: 1fr; }
  .bk-item { flex-direction: column; align-items: stretch; gap: 8px; }
  .bk-item-actions { justify-content: flex-end; }
}

/* ─── Calidad de entrega ─── */
.dash-delivery-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.dash-delivery-header { margin-bottom: 14px; }
.dash-delivery-header h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; color: var(--text); }
.dash-delivery-sub { margin: 0; font-size: 12px; color: var(--text-muted); }
.dash-delivery-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.dash-delivery-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: var(--bg-2, #f9fafb);
  border-radius: 10px;
  border: 1px solid var(--border, #e5e7eb);
}
.dash-delivery-value { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1; }
.dash-delivery-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.dash-delivery-stat--success { background: #ecfdf5; border-color: #a7f3d0; }
.dash-delivery-stat--success .dash-delivery-value { color: #047857; }
.dash-delivery-stat--failed  { background: #fef2f2; border-color: #fecaca; }
.dash-delivery-stat--failed  .dash-delivery-value { color: #b91c1c; }

.dash-delivery-failures h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.dash-delivery-failures-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.dash-delivery-failure-item {
  position: relative;
  padding: 10px 12px;
  background: var(--bg-2, #f9fafb);
  border-radius: 8px;
  overflow: hidden;
}
.dash-delivery-failure-bar {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: var(--pct, 0%);
  background: linear-gradient(90deg, #fee2e2, rgba(254, 226, 226, 0.4));
  z-index: 0;
}
.dash-delivery-failure-info {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.dash-delivery-failure-reason { font-size: 13px; color: var(--text); flex: 1; min-width: 0; }
.dash-delivery-failure-count { font-size: 12px; font-weight: 600; color: var(--text-muted); flex-shrink: 0; }

@media (max-width: 768px) {
  .dash-delivery-summary { grid-template-columns: repeat(2, 1fr); }
}
.dash-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.dash-chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.dash-chart-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.dash-legend-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 3px;
}
.dash-legend-received { background: var(--dash-received); }
.dash-legend-sent     { background: var(--dash-sent); }

.dash-chart-wrap {
  width: 100%;
  overflow: hidden;
}
.dash-chart-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--text-muted);
  padding: 0 2px;
}

/* ═══════════════════════════════════════════
   ASESORES — settings pane
   ═══════════════════════════════════════════ */

/* Tabla */
.advisors-table {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
}
.advisors-row {
  display: grid;
  grid-template-columns: 2fr 1.5fr 100px 1fr 140px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.advisors-row:last-child { border-bottom: none; }
.advisors-row--head {
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 8px 14px;
}
.advisors-empty {
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Celda usuario */
.adv-cell-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.adv-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.adv-cell-name { font-weight: 600; color: var(--text); }
.adv-cell-sub  { font-size: 11px; color: var(--text-muted); }
.adv-cell-email { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adv-you {
  display: inline-block;
  background: #e0e7ff;
  color: #4338ca;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  padding: 0 5px;
  vertical-align: middle;
}

/* Chips de rol */
.chip--admin  { background: #fef3c7; color: #92400e; }
.chip--asesor { background: #e0e7ff; color: #3730a3; }

/* Status */
.adv-status { font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 5px; }
.adv-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.adv-status--active::before   { background: #22c55e; }
.adv-status--inactive::before { background: #94a3b8; }
.adv-status--active   { color: #15803d; }
.adv-status--inactive { color: var(--text-muted); }

/* Perms tags en tabla */
.adv-perms-row { display: flex; flex-wrap: wrap; gap: 4px; }
.adv-perm-tag {
  font-size: 10px; font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e0e7ff;
  color: #4338ca;
}
.adv-perm-tag--all  { background: #d1fae5; color: #065f46; }
.adv-perm-tag--none { background: #f1f5f9; color: #94a3b8; }

/* Actions */
.adv-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

/* Pause/activate toggle */
.adv-toggle-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 2px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s;
}
.adv-toggle-btn:hover { color: var(--text); }
.adv-toggle-track {
  width: 32px; height: 18px;
  border-radius: 99px;
  background: #cbd5e1;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.adv-toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform 0.2s;
}
.adv-toggle-btn.is-active .adv-toggle-track { background: #22c55e; }
.adv-toggle-btn.is-active .adv-toggle-thumb { transform: translateX(14px); }

/* ── Mobile: convertir tabla de asesores en cards ──
   En mobile el grid de 5 columnas (2fr 1.5fr 100px 1fr 140px) no cabe.
   Convertimos cada row en una card con áreas:
     [avatar  name+badges]
     [email   email      ]  (oculto en mobile)
     [rol     perms       ]
     [actions actions     ]
*/
@media (max-width: 720px) {
  .advisors-row--head { display: none; }
  .advisors-row {
    grid-template-columns: 48px 1fr;
    grid-template-areas:
      "user user"
      "rol  perms"
      "actions actions";
    row-gap: 10px;
    column-gap: 12px;
    padding: 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .advisors-row > :nth-child(1) { grid-area: user; }
  .advisors-row > :nth-child(2) { display: none; }   /* email — se ve en el modal de edición */
  .advisors-row > :nth-child(3) { grid-area: rol; align-self: center; }
  .advisors-row > :nth-child(4) { grid-area: perms; align-self: center; }
  .advisors-row > :nth-child(5) { grid-area: actions; justify-content: flex-end; }

  .adv-cell-user { gap: 12px; }
  .adv-cell-name {
    font-size: 15px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }
  .adv-cell-sub { font-size: 12px; }
  .adv-perms-row { justify-content: flex-start; }
}
.adv-toggle-btn.is-active { color: #15803d; }

/* ── Modal de asesor ── */
.adv-form { display: flex; flex-direction: column; gap: 0; }
.adv-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin: 20px 0 10px;
}
.adv-form .adv-section-title:first-child { margin-top: 0; }
.adv-row { display: flex; gap: 12px; }

/* Rol selector */
.adv-roles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}
.adv-role-option { cursor: pointer; }
.adv-role-option input { display: none; }
.adv-role-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  transition: border-color .15s, background .15s;
}
.adv-role-option input:checked ~ .adv-role-card {
  border-color: var(--accent);
  background: rgba(37,99,235,.04);
}
.adv-role-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.adv-role-icon--admin  { background: rgba(245,158,11,.12); color: #d97706; }
.adv-role-icon--asesor { background: rgba(99,102,241,.12); color: #6366f1; }
.adv-role-name { font-weight: 600; font-size: 13px; }
.adv-role-desc { font-size: 11px; color: var(--text-muted); }

/* Permisos toggles */
.adv-perms-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.adv-perm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
  gap: 12px;
}
.adv-perm-row:last-child { border-bottom: none; }
.adv-perm-row:hover { background: var(--surface); }
.adv-perm-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.adv-perm-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.adv-perm-name { font-size: 13px; font-weight: 600; }
.adv-perm-desc { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* Toggle switch — permisos (usa input:checked) */
.adv-perm-toggle { position: relative; flex-shrink: 0; }
.adv-toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.adv-perm-toggle .adv-toggle-track {
  display: block;
  width: 36px; height: 20px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background .2s;
  position: relative;
}
.adv-perm-toggle .adv-toggle-track::after {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s;
}
.adv-perm-toggle .adv-toggle-input:checked ~ .adv-toggle-track { background: var(--accent); }
.adv-perm-toggle .adv-toggle-input:checked ~ .adv-toggle-track::after { transform: translateX(16px); }

/* ─── Papelera ─── */
.trash-filters { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.trash-filter-btn { padding: 5px 14px; border-radius: 20px; border: 1px solid var(--border); background: transparent; color: var(--text-secondary); font-size: 13px; cursor: pointer; transition: all .15s; }
.trash-filter-btn.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.trash-filter-btn:hover:not(.is-active) { background: var(--bg-elevated); }

.trash-list { display: flex; flex-direction: column; gap: 8px; }
.trash-loading { padding: 40px; text-align: center; color: var(--text-muted); font-size: 14px; }

.trash-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; transition: border-color .15s; }
.trash-item:hover { border-color: var(--accent); }
.trash-item-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--bg-elevated); display: flex; align-items: center; justify-content: center; color: var(--text-muted); flex-shrink: 0; }
.trash-item-icon svg { width: 18px; height: 18px; }
.trash-item-body { flex: 1; min-width: 0; }
.trash-item-name { font-size: 14px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.trash-item-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.trash-item-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.trash-type-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 500; }
.trash-type-contact   { background: #dbeafe; color: #1d4ed8; }
.trash-type-expedient { background: #dcfce7; color: #166534; }
.trash-type-pipeline  { background: #fef3c7; color: #92400e; }
.trash-type-stage     { background: #f3e8ff; color: #6b21a8; }

.trash-expires { font-weight: 500; }
.trash-expires--urgent { color: #dc2626; }

.trash-empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 60px 20px; color: var(--text-muted); }
.trash-empty-state svg { width: 40px; height: 40px; opacity: .4; }
.trash-empty-state p { font-size: 14px; margin: 0; }

.btn--danger-ghost { color: #dc2626; border: 1px solid #fca5a5; background: transparent; }
.btn--danger-ghost:hover { background: #fee2e2; }
.btn--sm { padding: 5px 12px; font-size: 12px; display: inline-flex; align-items: center; gap: 5px; border-radius: 6px; cursor: pointer; border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-primary); transition: all .15s; }
.btn--sm:hover { background: var(--bg-card); }
/* btn--sm trae su propio fondo gris (var(--bg-elevated)); al combinarse con
   btn--primary, como tienen la MISMA especificidad y .btn--sm está después en
   el archivo, ganaba el gris → el botón Guardar se veía BLANCO aunque hubiera
   cambios. Estas reglas (specificity 0,2,0) restauran el azul cuando hay
   cambios y dejan el gris cuando está limpio (.is-clean). */
.btn--primary.btn--sm { background: var(--accent); color: #fff; border-color: transparent; }
.btn--primary.btn--sm:hover { background: var(--accent-hover); border-color: transparent; }
.btn--primary.btn--sm.is-clean { background: #e2e8f0; color: #94a3b8; border-color: transparent; }
.btn--primary.btn--sm.is-clean:hover { background: #e2e8f0; }

/* ─── Toast notifications ─── */
.rh-toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; border-radius: 10px; font-size: 14px; font-weight: 500; color: #fff; background: #1e293b; box-shadow: 0 4px 20px rgba(0,0,0,.25); z-index: 9999; opacity: 0; transform: translateY(12px); transition: opacity .25s, transform .25s; pointer-events: none; max-width: 360px; }
.rh-toast--show { opacity: 1; transform: translateY(0); }
.rh-toast--success { background: #166534; }
.rh-toast--error   { background: #991b1b; }

/* ═══════ Modo personal /chat ═══════ */
/* Oculta sidebar global (nav del CRM) y demás vistas; deja
   el grid de .app como una sola columna. NO toca el flex interno
   de .view-chats (rh-sidebar + rh-conversation-panel). */
body.personal-mode .app {
  grid-template-columns: 1fr !important;
}
body.personal-mode .sidebar {
  display: none !important;
}
body.personal-mode .view:not(.view-chats),
body.personal-mode [data-view]:not([data-view="chats"]) {
  display: none !important;
}

/* Toggle "Mostrar ocultos" en sidebar */
.rh-personal-toggle {
  padding: 10px 16px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 13px;
}
.rh-personal-toggle label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #475569;
}

/* Botón "ocultar" en cada chat de la lista (solo modo personal) */
.rh-chat-item {
  position: relative;
}
.rh-chat-hide-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.rh-chat-item:hover .rh-chat-hide-btn { display: flex; }
.rh-chat-hide-btn:hover { background: rgba(220, 38, 38, 0.2); }
.rh-chat-hide-btn--unhide {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
  font-size: 12px;
  display: flex;
}
.rh-chat-hide-btn--unhide:hover { background: rgba(34, 197, 94, 0.22); }

/* ═══════ iOS / Android safe area — standalone PWA ═══════ */
/* viewport-fit=cover + black-translucent corre el contenido bajo la barra
   de estado (notch, Dynamic Island, home indicator).
   env(safe-area-inset-*) empuja el layout fuera de esas zonas.
   @supports garantiza que solo aplica donde el browser lo soporta. */
@supports (padding-top: env(safe-area-inset-top)) {
  /* ── Modo personal /chat ── */
  /* Lista de chats: cabecera superior */
  body.personal-mode .rh-brand-card {
    padding-top: calc(20px + env(safe-area-inset-top));
  }
  /* Conversación abierta: header */
  body.personal-mode .rh-conversation-header {
    padding-top: calc(14px + env(safe-area-inset-top));
  }
  /* Conversación abierta: caja de reply (home indicator en iPhone) */
  body.personal-mode .rh-reply-form {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  /* ── CRM PWA /app ── */
  /* Sidebar izquierdo (nav principal) */
  @media (display-mode: standalone) {
    .sidebar-top {
      padding-top: calc(4px + env(safe-area-inset-top));
    }
    /* Área de contenido — header de cada vista */
    .rh-conversation-header {
      padding-top: calc(14px + env(safe-area-inset-top));
    }
    .rh-reply-form {
      padding-bottom: calc(14px + env(safe-area-inset-bottom));
    }
  }
}

/* ═══════ Deploy card ═══════ */
.deploy-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #f0f9ff 0%, #ecfdf5 100%);
  border: 1px solid #bae6fd;
  border-radius: 10px;
}
.deploy-card-info { flex: 1; min-width: 0; }
.deploy-card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: #0c4a6e; }
.deploy-version { margin: 0; font-size: 13px; color: #475569; }
.deploy-version code { background: #fff; padding: 2px 6px; border-radius: 4px; font-size: 12px; color: #0c4a6e; border: 1px solid #e0f2fe; }
.deploy-date { color: #94a3b8; margin-left: 6px; font-size: 12px; }
.deploy-status { margin: 8px 0 0; font-size: 13px; padding: 6px 10px; border-radius: 6px; }
.deploy-status--info { background: #dbeafe; color: #1e40af; }
.deploy-status--ok { background: #d1fae5; color: #065f46; }
.deploy-status--error { background: #fee2e2; color: #991b1b; }

/* ═══════ Tokens de máquina ═══════ */
.mt-actions { display: flex; gap: 8px; }
.mt-help { margin-top: 8px; font-size: 13px; }
.mt-help-link {
  display: inline-block;
  padding: 6px 12px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
.mt-help-link:hover { background: #dbeafe; }
.mt-help-hint { color: #64748b; margin-left: 8px; font-size: 12px; }
.btn--danger-strong {
  background: #dc2626;
  color: #fff;
  border: 1px solid #b91c1c;
  font-weight: 600;
}
.btn--danger-strong:hover { background: #b91c1c; }
.mt-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 12px 0;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
}

/* Manual copy-paste para conectar IA */
.mt-ai-manual {
  margin: 16px 0;
  background: linear-gradient(135deg, #f5f3ff, #eff6ff);
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  overflow: hidden;
}
.mt-ai-manual summary {
  cursor: pointer;
  padding: 14px 16px;
  font-size: 14px;
  color: #312e81;
  list-style: none;
  display: flex;
  gap: 10px;
  align-items: center;
  user-select: none;
}
.mt-ai-manual summary::-webkit-details-marker { display: none; }
.mt-ai-manual summary::after {
  content: '▼';
  margin-left: auto;
  font-size: 10px;
  color: #6366f1;
  transition: transform 0.2s;
}
.mt-ai-manual[open] summary::after { transform: rotate(180deg); }
.mt-ai-manual summary:hover { background: rgba(99, 102, 241, 0.05); }
.mt-ai-manual__icon { font-size: 22px; }
.mt-ai-manual__body {
  padding: 0 16px 16px;
  border-top: 1px solid #c7d2fe;
  background: #fff;
}
.mt-ai-manual__intro {
  margin: 12px 0;
  font-size: 13px;
  color: #475569;
  line-height: 1.5;
}
.mt-ai-manual__textarea {
  width: 100%;
  font-family: 'JetBrains Mono', Menlo, ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.55;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  resize: vertical;
  min-height: 240px;
}
.mt-ai-manual__textarea:focus {
  outline: 2px solid #6366f1;
  outline-offset: -2px;
}
.mt-ai-manual__actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.mt-ai-manual__hint {
  font-size: 12px;
  color: #64748b;
}
.mt-table {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.mt-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1.1fr 1.2fr 0.9fr 0.8fr;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  align-items: center;
  font-size: 14px;
}
.mt-row:last-child { border-bottom: none; }
.mt-row--head {
  background: #f8fafc;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.04em;
}
.mt-row--revoked { opacity: 0.55; }
.mt-prefix code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.mt-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.mt-status--active   { background: #dcfce7; color: #15803d; }
.mt-status--revoked  { background: #fee2e2; color: #b91c1c; }
.mt-empty {
  padding: 32px 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
}
.mt-warn-banner {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.mt-token-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px 16px;
  border-radius: 8px;
}
.mt-token-box code {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
}

/* ═══════ Plantillas — Header type + Botones ═══════ */
.tpl-header-type-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 13px;
}
.tpl-header-type-opt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: #475569;
}
.tpl-header-media {
  margin-top: 6px;
  padding: 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
}
.tpl-header-file { font-size: 13px; }

/* Preview del archivo subido en plantillas WA API */
.tpl-header-media-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  margin-bottom: 10px;
}
.tpl-header-media-preview-thumb {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #d1fae5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tpl-header-media-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tpl-header-media-icon {
  font-size: 28px;
  line-height: 1;
}
.tpl-header-media-preview-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tpl-header-media-preview-label {
  font-size: 12px;
  font-weight: 600;
  color: #065f46;
}
.tpl-header-media-preview-link {
  font-size: 11px;
  color: #047857;
  text-decoration: underline;
  width: fit-content;
}
.tpl-header-media-remove {
  background: transparent;
  border: 1px solid #fca5a5;
  color: #dc2626;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.tpl-header-media-remove:hover {
  background: #fee2e2;
  border-color: #ef4444;
}
.tpl-buttons-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.tpl-btn-row {
  display: grid;
  grid-template-columns: 150px 1fr auto auto;
  gap: 6px;
  align-items: center;
}
.tpl-btn-row .tpl-btn-extra { grid-column: 2 / 4; }
.tpl-btn-extra.is-invalid {
  border-color: #ef4444 !important;
  background: #fef2f2;
  box-shadow: 0 0 0 3px rgba(239,68,68,.12);
}
.tpl-btn-remove {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #b91c1c;
}

/* ═══════ Placeholders del body (paridad con Kommo) ═══════ */
.tpl-placeholders-box {
  margin-top: 6px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
.tpl-placeholders-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}
.tpl-placeholders-head strong { font-size: 14px; color: #0f172a; }
.tpl-placeholders-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tpl-placeholder-row {
  display: grid;
  gap: 6px;
  align-items: center;
}
/* Mapeado a campo del contacto: 3 cols (num · dropdown · preview) */
.tpl-placeholder-row--mapped {
  grid-template-columns: 50px 150px minmax(0, 1fr);
}
/* Manual: 4 cols (num · dropdown · label · example) — minmax(0,1fr)
   permite a los inputs encogerse en lugar de overflow horizontal */
.tpl-placeholder-row--manual {
  grid-template-columns: 50px 130px minmax(0, 1fr) minmax(0, 1fr);
}
.tpl-ph-field {
  font-size: 13px;
  min-width: 0;  /* permite shrink dentro del grid */
}
.tpl-placeholder-row input {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
@media (max-width: 700px) {
  /* Apilado en pantallas chicas */
  .tpl-placeholder-row--mapped,
  .tpl-placeholder-row--manual {
    grid-template-columns: 50px 1fr;
  }
  .tpl-placeholder-row--manual > input {
    grid-column: 1 / -1;
    margin-left: 56px;
  }
}
.tpl-ph-auto-preview {
  font-size: 13px;
  color: #15803d;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 6px 12px;
  border-radius: 6px;
}

/* Modal "Enviar plantilla" */
.send-tpl-meta {
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.send-tpl-name { margin-bottom: 8px; color: #0f172a; }
.send-tpl-name .tpl-hint-inline { margin-left: 6px; font-weight: 400; }
.send-tpl-body {
  font-size: 13px;
  color: #475569;
  white-space: pre-wrap;
  line-height: 1.5;
}
.send-tpl-vars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.send-tpl-var-row {
  display: grid;
  grid-template-columns: 60px 1fr 1.5fr;
  gap: 8px;
  align-items: center;
}
.send-tpl-var-label { font-size: 13px; color: #64748b; }
.send-tpl-var-auto {
  font-size: 13px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 6px 10px;
  border-radius: 6px;
}
.send-tpl-var-input--missing {
  border-color: #fca5a5 !important;
  background: #fef2f2;
}

/* Bot step type "template" — editor */
.sb-tpl-preview {
  margin-top: 8px;
  padding: 10px 12px;
  background: #f1f5f9;
  border-left: 3px solid #6366f1;
  border-radius: 4px;
  font-size: 12px;
  color: #475569;
  white-space: pre-wrap;
  line-height: 1.5;
}
.sb-tpl-phs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sb-tpl-ph-row {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 8px;
  align-items: center;
}
.sb-tpl-ph-num {
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  background: #e2e8f0;
  padding: 4px 6px;
  border-radius: 4px;
}
.sb-tpl-ph-auto {
  font-size: 12px;
  color: #15803d;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 4px 8px;
  border-radius: 4px;
}
.sb-tpl-branches-hint {
  margin-top: 14px;
  padding: 10px 12px;
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.5;
  color: #78350f;
}
/* Bloques de rama por botón (sub-flujo completo, estilo branch) */
.sb-tpl-branch-block {
  margin: 8px 0;
  padding: 10px;
  border: 1px solid #ddd6fe;
  border-left: 3px solid #8b5cf6;
  border-radius: 8px;
  background: #faf5ff;
}
.sb-tpl-branch-block-head {
  font-size: 13px;
  font-weight: 600;
  color: #5b21b6;
  margin-bottom: 8px;
}
.sb-tpl-branch-block .sb-rem-substeps:empty {
  min-height: 0;
}
.sb-tpl-branch-block .sb-rem-substeps:empty::before {
  content: '(sin pasos aún — agrega uno abajo)';
  display: block;
  font-size: 11px;
  color: #a78bda;
  font-style: italic;
  padding: 2px 0 6px;
}
/* Editor de ramas por botón QUICK_REPLY */
.sb-tpl-branches {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #cbd5e1;
}
.sb-tpl-branch-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(110px, 1fr);
  gap: 6px 8px;
  align-items: center;
  margin-bottom: 6px;
}
.sb-tpl-branch-row .sb-tpl-branch-cfg {
  grid-column: 1 / -1;
  margin-top: -2px;
  margin-bottom: 4px;
}
.sb-tpl-branch-label {
  font-size: 12px;
  font-weight: 500;
  color: #334155;
  background: #f1f5f9;
  padding: 5px 8px;
  border-radius: 6px;
  border-left: 3px solid #6366f1;
}
.sb-tpl-branch-action,
.sb-tpl-branch-input {
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
}
.sb-tpl-branch-input {
  width: 100%;
}
textarea.sb-tpl-branch-input {
  resize: vertical;
  min-height: 32px;
  font-family: inherit;
}
.sb-tpl-branch-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.sb-tpl-manual {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
}

/* Filtros de tags en la vista Plantillas (mismo look que bots) */
.tpl-tag-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin: 8px 0 16px;
}

/* Toggle "Agrupar por etiqueta" — switch estilo iOS */
.tpl-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: #475569;
  margin-left: 6px;
}
.tpl-group-toggle input { display: none; }
.tpl-group-toggle-track {
  width: 36px;
  height: 20px;
  background: #cbd5e1;
  border-radius: 999px;
  position: relative;
  transition: background 0.18s;
  flex-shrink: 0;
}
.tpl-group-toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.18s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.tpl-group-toggle input:checked ~ .tpl-group-toggle-track {
  background: #3b82f6;
}
.tpl-group-toggle input:checked ~ .tpl-group-toggle-track .tpl-group-toggle-thumb {
  transform: translateX(16px);
}

/* Headers de grupo cuando agrupa por etiqueta */
.tpl-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 4px 8px;
  border-bottom: 1px solid #e2e8f0;
  margin-top: 18px;
}
.tpl-group-header:first-child { margin-top: 0; }
.tpl-group-no-tag {
  font-size: 13px;
  color: #94a3b8;
  font-style: italic;
}
.tpl-group-count {
  font-size: 12px;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 999px;
}
.tpl-card-date {
  color: #64748b;
  font-size: 12px;
  cursor: help;
}

/* "Usado en: <bot>" — pastilla CUADRADA (no pill redonda) clickable */
.tpl-card-bots {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.tpl-card-bots-label {
  color: #64748b;
  font-weight: 500;
}
.tpl-card-bot-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 4px;  /* cuadrada, NO 999px */
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.tpl-card-bot-pill:hover {
  background: #dbeafe;
  transform: translateY(-1px);
  box-shadow: 0 1px 3px rgba(29,78,216,0.25);
}
.tpl-card-bot-pill:active { transform: translateY(0); }

/* "Mensaje" del bot — header con label y botón "Usar plantilla básica" */
.sb-msg-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  margin-bottom: 4px;
}
.sb-msg-label-row label { margin: 0; }
.sb-tpl-insert-btn {
  font-size: 12px;
  padding: 4px 10px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, transform 0.1s;
}
.sb-tpl-insert-btn:hover {
  background: #dbeafe;
  transform: translateY(-1px);
}
.sb-tpl-insert-btn:active { transform: translateY(0); }

/* Hint en el picker cuando se abre desde el bot builder */
.rh-tpl-mode-hint {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 10px 12px;
  margin: 8px 0;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.45;
}

/* Switch de layout v1/v2 en la barra de filtros de bots */
.bot-layout-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-left: auto;
}
.bot-layout-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: #fff;
  border: none;
  border-right: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.bot-layout-btn:last-child { border-right: none; }
.bot-layout-btn:hover { background: #f8fafc; }
.bot-layout-btn.is-active {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

/* ─── Layout v2 — cards verticales con aire ─── */
.bot-cards-v2 .bot-list-head { display: none; }
.bot-cards-v2 .bot-list-table {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}
.bot-cards-v2 .bot-list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name        actions"
    "trigger     trigger"
    "footer      footer";
  gap: 8px 12px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.bot-cards-v2 .bot-list-row:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(15,23,42,0.07);
  background: #fff;
}
/* Cada hijo del .bot-list-row se asigna a un area según orden */
.bot-cards-v2 .bot-list-row > :nth-child(1) { grid-area: name; min-width: 0; }       /* name-wrap */
.bot-cards-v2 .bot-list-row > :nth-child(2) { grid-area: trigger; }                  /* trigger */
.bot-cards-v2 .bot-list-row > :nth-child(3),
.bot-cards-v2 .bot-list-row > :nth-child(4) { grid-area: footer; }                   /* steps + toggle */
.bot-cards-v2 .bot-list-row > :nth-child(5) { grid-area: actions; align-self: start; } /* delete */

/* Footer (steps + toggle) en una línea, separados con · */
.bot-cards-v2 .bot-row-steps {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 10px;
  background: #f1f5f9;
  border-radius: 6px;
  margin-right: auto;
}
.bot-cards-v2 .bot-list-row > :nth-child(4) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.bot-cards-v2 .bot-list-row > :nth-child(4)::before {
  content: 'Activo';
  font-size: 12px;
  color: var(--text-muted);
}

/* Hijos 3 y 4 (steps + toggle) los ponemos en flex dentro del area footer */
.bot-cards-v2 .bot-list-row {
  /* Truco: usamos un pseudo-grid interno para alinear footer items */
}
.bot-cards-v2 .bot-row-name {
  font-size: 15px;
  font-weight: 600;
}
.bot-cards-v2 .bot-row-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.bot-cards-v2 .bot-row-trigger {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 6px;
  border-left: 3px solid #cbd5e1;
  line-height: 1.5;
}

/* Card de bot — display de pipeline + etapa cuando trigger es pipeline_stage.
   Tinted style: fondo color ~14%, borde ~33%, texto siempre oscuro. */
.bot-row-pipeline-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.bot-row-pipeline-name,
.bot-row-stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid transparent;
  color: var(--text, #0f172a);
  line-height: 1.4;
}
.bot-row-pipeline-arrow { color: #94a3b8; margin: 0 2px; }
.bot-row-stage-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* Modo edición inline en tag manager (templates) */
.tpl-tag-row--editing {
  background: #f8fafc;
  border-color: #93c5fd !important;
  box-shadow: inset 0 0 0 2px #93c5fd33;
}
.tpl-tag-edit-name {
  flex: 0 0 160px;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
}
/* Selector de tags dentro del modal de plantilla */
.tpl-tags-pickers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tpl-tags-pickers .bot-tag-pill {
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s, background 0.15s;
}
.tpl-tags-pickers .bot-tag-pill.is-off { opacity: 0.55; }
.tpl-tags-pickers .bot-tag-pill.is-on { opacity: 1; }

/* Banner de lock cuando la plantilla wa_api ya está en revisión/aprobada */
.tpl-lock-banner {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.45;
}

/* Hint del nombre interno cuando se auto-corrige */
.tpl-name-hint {
  margin: 4px 0 0;
  padding: 6px 10px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
}
.is-locked {
  cursor: not-allowed !important;
  opacity: 0.65;
}
.tpl-placeholder-num {
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  background: #f1f5f9;
  padding: 6px 8px;
  border-radius: 6px;
}
.tpl-var-btn--num {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-weight: 600;
}
.tpl-var-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
/* Variables numéricas {{N}} → solo en wa_api (default, sin .is-free) */
.tpl-modal-card:not(.is-free) .tpl-var-group--free { display: none; }
/* Variables básicas {nombre} → solo en free_form */
.tpl-modal-card.is-free .tpl-var-group--num { display: none; }

/* ═════════ VISTA: SUSCRIPCIÓN (Billing) ═════════ */
.view-billing {
  padding: 32px;
  overflow-y: auto;
}
.billing-wrap {
  max-width: 1100px;
  margin: 0 auto;
}
.billing-header h2 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
}
.billing-sub {
  color: #64748b;
  font-size: 14px;
  margin: 0 0 24px;
}

/* Estado actual */
.billing-status {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.billing-status.is-free { background: #f0fdf4; border-color: #86efac; }
.billing-status.is-free .bs-text strong { color: #14532d; }
.billing-status.is-trial { background: #fef3c7; border-color: #fcd34d; }
.billing-status.is-past_due, .billing-status.is-canceled { background: #fee2e2; border-color: #fca5a5; }
.billing-status .bs-icon { font-size: 20px; }
.billing-status .bs-text { flex: 1; font-size: 14px; }
.billing-status .bs-text strong { display: block; color: #064e3b; }
.billing-status.is-trial .bs-text strong { color: #78350f; }
.billing-status.is-past_due .bs-text strong, .billing-status.is-canceled .bs-text strong { color: #991b1b; }

/* Toggle mensual/anual */
.billing-toggle {
  display: inline-flex;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 32px;
  gap: 4px;
}
.bt-opt {
  background: transparent;
  border: 0;
  padding: 8px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}
.bt-opt.is-active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.bt-save {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  background: #dcfce7;
  color: #14532d;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

/* Cards de planes */
.billing-plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.bp-card {
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all 0.15s;
}
.bp-card.is-featured {
  border-color: #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
  position: relative;
}
.bp-card.is-featured::before {
  content: 'Más popular';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: #2563eb;
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.bp-card.is-current {
  border-color: #10b981;
  background: #ecfdf5;
}
.bp-card.is-current::after {
  content: '✓ Plan actual';
  position: absolute;
  top: -12px;
  right: 16px;
  background: #10b981;
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.bp-name {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}
.bp-tagline {
  color: #64748b;
  font-size: 13px;
  margin: 4px 0 0;
}
.bp-price {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.bp-price .amount {
  font-size: 36px;
  font-weight: 800;
  color: #0f172a;
}
.bp-price .currency {
  font-size: 13px;
  color: #64748b;
}
.bp-price .period {
  font-size: 14px;
  color: #64748b;
  margin-left: 4px;
}
.bp-price-note {
  font-size: 12px;
  color: #64748b;
  margin: -8px 0 0;
}
.bp-usd {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
  align-self: center;
}
.bp-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}
.bp-features li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: #334155;
}
.bp-features li.is-missing {
  color: #94a3b8;
  text-decoration: line-through;
}
.bp-features li::before {
  content: '✓';
  color: #10b981;
  font-weight: 700;
  flex-shrink: 0;
}
.bp-features li.is-missing::before {
  content: '✕';
  color: #cbd5e1;
}
.bp-cta {
  margin-top: auto;
  padding: 12px 16px;
  border: 0;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.bp-cta:hover { background: #1e293b; }
.bp-cta:disabled { background: #94a3b8; cursor: not-allowed; }
.bp-card.is-featured .bp-cta { background: #2563eb; }
.bp-card.is-featured .bp-cta:hover { background: #1d4ed8; }
.bp-card.is-current .bp-cta {
  background: #fff;
  color: #10b981;
  border: 2px solid #10b981;
}

/* Promo badge & real price strikethrough */
.bp-promo-tag {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: -4px;
}
.bp-real-price {
  font-size: 16px;
  color: #94a3b8;
  text-decoration: line-through;
  margin-right: 2px;
  font-weight: 500;
}

/* Limits line under price */
.bp-limits {
  font-size: 12px;
  color: #64748b;
  margin: 4px 0 0;
}

/* Plan Gratis */
.bp-card--free {
  border-color: #22c55e;
  background: #f0fdf4;
}
.bp-card--free .bp-name { color: #15803d; }
.bp-card--free .bp-cta:disabled { background: #86efac; color: #14532d; cursor: default; }
.bp-card--free.is-current .bp-cta:disabled { background: #22c55e; color: #fff; }

/* Ejecutivo / custom plan card */
.bp-card--custom {
  border-color: #7c3aed;
  background: linear-gradient(135deg, #faf5ff 0%, #ede9fe 100%);
}
.bp-price--custom .amount {
  font-size: 28px;
  color: #7c3aed;
}
.bp-cta--contact {
  margin-top: auto;
  display: block;
  text-align: center;
  padding: 12px 16px;
  border: 2px solid #7c3aed;
  border-radius: 8px;
  background: transparent;
  color: #7c3aed;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.bp-cta--contact:hover {
  background: #7c3aed;
  color: #fff;
}

/* Manage subscription */
.billing-manage {
  text-align: center;
  margin-bottom: 24px;
}

/* ─── Add-ons / Usuarios extra ─── */
.billing-addons {
  margin-bottom: 28px;
}
.billing-addons-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.ba-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-wrap: wrap;
}
.ba-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: rgba(37,99,235,.12);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--accent, #2563eb);
}
.ba-icon svg { width: 20px; height: 20px; }
.ba-info { flex: 1; min-width: 140px; }
.ba-name { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.ba-desc { font-size: 12px; color: var(--text-muted); }
.ba-price {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
}
.ba-price span { font-size: 13px; font-weight: 400; color: var(--text-muted); }
.ba-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ba-qty {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.ba-qty-btn {
  width: 34px; height: 34px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.ba-qty-btn:hover:not(:disabled) { background: var(--surface); }
.ba-qty-btn:disabled { opacity: .35; cursor: not-allowed; }
.ba-qty-val {
  min-width: 30px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0 6px;
  line-height: 34px;
}
.ba-btn {
  padding: 0 18px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent, #2563eb);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.ba-btn:hover { background: #1d4ed8; }
.ba-btn:disabled { background: #94a3b8; cursor: not-allowed; }
.ba-btn--ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.ba-btn--ghost:hover { background: var(--surface); }
.ba-confirm {
  width: 100%;
  flex-basis: 100%;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ba-confirm-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.ba-confirm-text strong { color: var(--text-primary); }
.ba-confirm-actions { display: flex; gap: 8px; }

/* Loading */
.billing-loading {
  text-align: center;
  padding: 60px;
  color: #94a3b8;
  grid-column: 1 / -1;
}

/* Footnote */
.billing-footnote {
  text-align: center;
  font-size: 12px;
  color: #94a3b8;
  margin-top: 24px;
}
.billing-footnote a {
  color: #64748b;
}

/* Avatar de contacto en cards de pipeline */
.pl-card-contact-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.pl-card-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  background: #e2e8f0;
}
.pl-card-avatar--initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #94a3b8;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.pl-card-contact-row .pl-card-contact {
  flex: 1;
  margin-top: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Email column en lista de leads */
.exp-contact-email {
  color: #2563eb;
  font-size: 13px;
  text-decoration: none;
}
.exp-contact-email:hover { text-decoration: underline; }
.exp-contact-email.is-empty { color: #94a3b8; cursor: default; }

/* ═══════ Recordatorios / Tasks ═══════ */
.view-tasks { padding: 32px; overflow-y: auto; }
.tasks-wrap { max-width: 900px; margin: 0 auto; }
.tasks-tabs {
  display: flex; gap: 0;
  border-bottom: none;
}
.tt-tab {
  background: transparent; border: 0; padding: 12px 16px;
  font-size: 14px; font-weight: 600; color: #64748b; cursor: pointer;
  border-bottom: 2px solid transparent;
  display: flex; align-items: center; gap: 8px;
}
.tt-tab:hover { color: #0f172a; }
.tt-tab.is-active { color: #2563eb; border-bottom-color: #2563eb; }
.tt-count {
  background: #e2e8f0; color: #475569;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 700;
}
.tt-tab.is-active .tt-count { background: #2563eb; color: #fff; }

.tasks-list { display: flex; flex-direction: column; gap: 8px; }
.tasks-loading, .tasks-empty {
  text-align: center; padding: 60px 20px; color: #94a3b8;
}
.task-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; background: #fff;
  border: 1px solid #e2e8f0; border-radius: 10px;
  transition: all 0.15s;
}
.task-item:hover { border-color: #cbd5e1; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.task-item.is-overdue { border-left: 4px solid #ef4444; }
.task-item.is-completed { opacity: 0.55; }
.task-item.is-completed .task-title { text-decoration: line-through; }

.task-checkbox {
  width: 22px; height: 22px; flex-shrink: 0;
  border: 2px solid #cbd5e1; border-radius: 50%;
  background: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.1s;
  margin-top: 2px;
}
.task-checkbox:hover { border-color: #2563eb; }
.task-item.is-completed .task-checkbox { background: #10b981; border-color: #10b981; color: #fff; }

.task-body { flex: 1; min-width: 0; }
.task-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-title { font-size: 15px; font-weight: 600; color: #0f172a; cursor: pointer; }
.task-duration-badge {
  font-size: 10px; font-weight: 700;
  color: #7c3aed; background: #ede9fe;
  padding: 1px 7px; border-radius: 99px;
  white-space: nowrap; flex-shrink: 0;
}
/* Warning horario laboral en el modal */
.task-hours-warn {
  display: flex; align-items: flex-start; gap: 7px;
  background: #fef3c7; color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 8px; padding: 8px 12px;
  font-size: 12px; font-weight: 500;
}
.task-hours-warn svg { flex-shrink: 0; margin-top: 1px; color: #d97706; }
.task-meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-top: 4px; font-size: 12px; color: #64748b;
}
.task-meta-item { display: flex; align-items: center; gap: 4px; }
.task-due { font-weight: 600; }
.task-due.is-overdue { color: #dc2626; }
.task-due.is-today { color: #d97706; }
.task-desc {
  margin-top: 6px; font-size: 13px; color: #475569;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-link {
  color: #2563eb; text-decoration: none; font-size: 12px;
  background: rgba(37,99,235,.08); padding: 2px 8px; border-radius: 4px;
}
.task-link:hover { background: rgba(37,99,235,.15); }

/* Form fields del modal */
.form-row { margin-bottom: 16px; }
.form-row label {
  display: block; font-size: 13px; font-weight: 600;
  color: #334155; margin-bottom: 6px;
}
.form-row input[type="text"], .form-row input[type="datetime-local"], .form-row select, .form-row textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #e2e8f0;
  border-radius: 8px; font-size: 14px; font-family: inherit;
  background: #fff; color: #0f172a;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: 0; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* Iconos calendario en pipeline cards */
.pl-card-task-icon {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 4px;
  margin-left: 6px;
  font-size: 11px;
  flex-shrink: 0;
}
.pl-card-task-icon.has-pending { background: rgba(16,185,129,.12); color: #10b981; }
.pl-card-task-icon.has-overdue { background: rgba(239,68,68,.12); color: #dc2626; }

.exp-detail-tasks {
  padding: 12px 16px; border-top: 1px solid var(--border, #e2e8f0);
}
.exp-detail-tasks .exp-detail-section-title {
  font-size: 12px; font-weight: 700; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.exp-detail-tasks-body { display: flex; flex-direction: column; gap: 6px; }
.exp-detail-task {
  display: flex; gap: 8px; padding: 6px 8px;
  background: #f8fafc; border-radius: 6px; cursor: pointer;
  font-size: 13px;
}
.exp-detail-task:hover { background: #f1f5f9; }
.exp-detail-task.is-overdue { background: rgba(239,68,68,.08); }
.exp-detail-task-due { color: #475569; font-size: 11px; min-width: 80px; }
.exp-detail-task.is-overdue .exp-detail-task-due { color: #dc2626; font-weight: 600; }
.exp-detail-task-title { flex: 1; color: #0f172a; }
.exp-detail-task-empty { font-size: 13px; color: #94a3b8; margin: 0 0 8px; }

/* ─── Botón mobile back en chat header ─── */
.rh-mobile-back { display: none; }

/* ─── Panel de info del chat (sidebar derecho) ─── */
.rh-chat-info-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 320px;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  z-index: 20;
  display: flex; flex-direction: column;
  box-shadow: -4px 0 12px rgba(0,0,0,.04);
  animation: slideInRight 0.2s ease-out;
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.rh-chat-info-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #e2e8f0;
}
.rh-chat-info-header h3 { margin: 0; font-size: 15px; font-weight: 700; color: #0f172a; }
.rh-chat-info-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 18px;
  font-size: 14px;
}
.ci-section h4 {
  font-size: 11px; font-weight: 700; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 0 0 8px;
}
.ci-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  color: #334155;
}
.ci-row svg { color: #94a3b8; flex-shrink: 0; }
.ci-avatar-block {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 8px 0;
}
.ci-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: #94a3b8; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 22px;
  object-fit: cover;
}
.ci-name { font-size: 17px; font-weight: 700; color: #0f172a; }
.ci-tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.ci-tag {
  background: #f1f5f9; color: #475569;
  padding: 3px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 500;
}
.ci-lead-card {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 8px; padding: 10px 12px;
}
.ci-lead-name { font-weight: 600; color: #0f172a; cursor: pointer; }
.ci-lead-name:hover { color: #2563eb; }
.ci-lead-pipeline {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  font-size: 12px; margin-top: 6px;
}
.ci-lead-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 99px;
  border: 1px solid transparent;
  font-size: 11px; font-weight: 500;
  color: var(--text, #0f172a); line-height: 1.4;
}
.ci-lead-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.ci-lead-arrow { color: var(--text-muted); font-size: 10px; }
.ci-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.ci-actions .btn { font-size: 12px; padding: 6px 12px; }
.ci-empty { color: #94a3b8; font-style: italic; font-size: 13px; }
.ci-muted { color: #94a3b8; font-size: 13px; }

/* ─── Mobile (≤720px) ─── */
@media (max-width: 720px) {
  /* Chat: ocultar uno de los dos paneles según estado */
  body[data-chat-mobile-view="inbox"] .rh-conversation-panel { display: none; }
  body[data-chat-mobile-view="conversation"] .rh-sidebar { display: none; }
  /* Colapsar el grid a 1 columna cuando el sidebar está oculto, para que el
     panel de conversación ocupe todo el ancho (sin esto queda ~90px de ancho) */
  body[data-chat-mobile-view="conversation"] .rh-shell { grid-template-columns: 1fr; }

  /* Botón back visible solo en conversation view */
  body[data-chat-mobile-view="conversation"] .rh-mobile-back { display: inline-flex; }
  body[data-chat-mobile-view="inbox"] .rh-mobile-back { display: none; }

  /* Panel info ocupa toda la pantalla */
  .rh-chat-info-panel { width: 100%; }
}

/* ═══════ Vista Calendario ═══════ */
.view-calendar { padding: 32px; overflow-y: auto; }
.cal-wrap { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.cal-sub-pane { flex: 1; overflow-y: auto; padding: 0 24px 24px; }

/* Header unificado */
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0; flex-wrap: wrap;
}
.cal-header-left { display: flex; align-items: center; gap: 12px; }

/* Extras topbar: calendario */
.topbar-cal-extras {
  display: flex; align-items: center; gap: 10px; margin-left: auto;
}

/* Tabs aplicaciones */
.apps-subtabs { display: flex; align-items: center; gap: 6px; }
.apps-tab-btn {
  padding: 6px 16px; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; font-size: 13px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; transition: all 0.12s;
}
.apps-tab-btn:hover { color: var(--text); background: var(--bg); }
.apps-tab-btn.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Apps tab panes */
.apps-tab-pane { padding: 32px 24px; }
.apps-empty-state {
  text-align: center; padding: 64px 24px; color: var(--text-muted);
}
.apps-empty-state .apps-emoji { font-size: 48px; margin-bottom: 16px; }
.apps-empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.apps-empty-state p { font-size: 14px; max-width: 400px; margin: 0 auto; }

/* Toggle Lista / Mes */
.cal-sub-toggle {
  display: flex; gap: 2px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 3px;
}
.cal-sub-toggle--cta { background: none; border: none; padding: 0; }
.cal-sub-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  padding: 5px 12px; border-radius: 6px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  transition: all 0.12s;
}
.cal-sub-btn:hover { color: var(--text); }
.cal-sub-btn.is-active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* Botón "+ Nueva tarea" — mismo alto y tipografía que el toggle Lista/Mes */
#taskNewBtn.cal-sub-btn--cta {
  background: #2563eb !important;
  color: #fff !important;
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
#taskNewBtn.cal-sub-btn--cta:hover {
  background: #1d4ed8 !important;
  color: #fff !important;
}

/* Nav mes */
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-current-label {
  font-size: 16px; font-weight: 600; color: #0f172a;
  min-width: 140px; text-align: center; text-transform: capitalize;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: #e2e8f0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
}
.cal-day-header {
  padding: 10px 8px;
  background: #f8fafc;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cal-cell {
  background: #fff;
  min-height: 90px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  transition: background 0.1s;
}
.cal-cell:hover { background: #f8fafc; }
.cal-cell.is-other-month { background: #f1f5f9; opacity: 0.5; }
.cal-cell.is-today .cal-day-num {
  background: #2563eb; color: #fff;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.cal-day-num { font-size: 13px; color: #334155; padding: 2px; }
.cal-task-pill {
  font-size: 11px;
  padding: 2px 6px;
  background: rgba(37,99,235,0.1);
  color: #1e3a5f;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-task-pill.is-overdue { background: rgba(239,68,68,0.12); color: #991b1b; }
.cal-task-pill.is-completed { background: rgba(16,185,129,0.1); color: #065f46; text-decoration: line-through; opacity: 0.7; }
.cal-task-more {
  font-size: 10px; color: #64748b; cursor: pointer;
  padding-left: 4px;
}
.cal-foot { color: #94a3b8; font-size: 12px; margin-top: 12px; text-align: center; }

/* ═══════ Vista Aplicaciones (placeholder) ═══════ */
.view-apps { padding: 32px; overflow-y: auto; }
.apps-wrap { max-width: 720px; margin: 0 auto; }
.apps-header { margin-bottom: 32px; }
.apps-header h2 { margin: 0 0 4px; font-size: 24px; font-weight: 700; }
.apps-sub { margin: 0; color: #64748b; font-size: 14px; }
.apps-coming-soon {
  text-align: center;
  padding: 60px 32px;
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
}
.apps-emoji { font-size: 48px; margin-bottom: 16px; }
.apps-coming-soon h3 { margin: 0 0 12px; font-size: 22px; }
.apps-coming-soon p { color: #475569; max-width: 440px; margin: 0 auto 12px; }
.apps-coming-soon-note { color: #64748b; font-size: 13px; margin-top: 16px; }
.apps-coming-soon-note a { color: #2563eb; }

/* ═══════ Fuentes de Conocimiento (IA) ═══════ */
.kb-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.kb-header > div { flex: 1; min-width: 0; }
.kb-header .btn { flex-shrink: 0; align-self: flex-start; white-space: nowrap; }
.kb-list {
  display: flex; flex-direction: column; gap: 8px;
}
.kb-loading, .kb-empty {
  text-align: center; padding: 40px 16px; color: #94a3b8;
  font-size: 14px;
  background: #f8fafc; border: 2px dashed #cbd5e1; border-radius: 12px;
}
.kb-item {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 14px 16px; cursor: pointer;
  transition: all 0.15s;
}
.kb-item:hover { border-color: #cbd5e1; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.kb-item.is-inactive { opacity: 0.55; }
.kb-item-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 6px;
}
.kb-item-title { font-size: 14px; font-weight: 600; color: #0f172a; flex: 1; }
.kb-item-cat {
  font-size: 11px; padding: 2px 8px; border-radius: 4px;
  background: rgba(37,99,235,.1); color: #1e3a5f;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.kb-item-content {
  font-size: 13px; color: #64748b;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.kb-item-toggle {
  width: 32px; height: 18px; background: #cbd5e1; border-radius: 99px;
  position: relative; cursor: pointer; transition: background 0.15s;
  flex-shrink: 0;
}
.kb-item-toggle.is-on { background: #10b981; }
.kb-item-toggle::after {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff; border-radius: 50%;
  transition: transform 0.15s;
}
.kb-item-toggle.is-on::after { transform: translateX(14px); }

/* ═══════ Dashboard Analytics — filtros y team table ═══════ */
.dash-filters {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 16px; margin-bottom: 24px;
  padding: 12px 16px; background: #f8fafc;
  border: 1px solid #e2e8f0; border-radius: 12px;
}
.dash-filter-group { display: flex; gap: 4px; align-items: center; }
.dash-pill {
  background: transparent; border: 1px solid transparent;
  padding: 6px 12px; border-radius: 99px;
  font-size: 13px; font-weight: 600; color: #64748b;
  cursor: pointer; transition: all 0.15s;
}
.dash-pill:hover { background: #e2e8f0; color: #0f172a; }
.dash-pill.is-active { background: #2563eb; color: #fff; }
.dash-filter-label { font-size: 13px; color: #64748b; font-weight: 600; }
.form-select, .dash-filter-group select {
  padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 6px;
  background: #fff; font-size: 13px; color: #0f172a;
}
.dash-filter-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: #475569; cursor: pointer; user-select: none;
  margin-left: auto;
}
.dash-filter-toggle input { cursor: pointer; }

/* Team table (admin only) */
.dash-team-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 20px; margin-top: 24px;
}
.dash-team-header h3 { margin: 0 0 4px; font-size: 17px; font-weight: 700; }
.dash-team-sub { margin: 0 0 16px; color: #64748b; font-size: 13px; }
.dash-team-table-wrap { overflow-x: auto; }
.dash-team-table {
  width: 100%; border-collapse: collapse;
}
.dash-team-table thead th {
  text-align: left; font-size: 12px; font-weight: 700;
  color: #64748b; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 8px 12px; border-bottom: 1px solid #e2e8f0;
}
.dash-team-table tbody td {
  padding: 12px; font-size: 14px; color: #0f172a;
  border-bottom: 1px solid #f1f5f9;
}
.dash-team-table tbody tr:hover { background: #f8fafc; }
.dash-team-name { font-weight: 600; }
.dash-team-role {
  font-size: 11px; color: #64748b; text-transform: uppercase;
  letter-spacing: 0.04em; margin-top: 2px;
}

/* ═══════ Negocio: horarios maestros y por asesor ═══════ */
.biz-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  max-width: 720px;
}
@media (min-width: 1100px) {
  .biz-shell { grid-template-columns: 1fr 1fr; max-width: none; }
}
.biz-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: 18px 20px;
}
.biz-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text, #0f172a);
}
.biz-card .settings-note { margin-bottom: 14px; }

.biz-master,
.biz-advisor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.biz-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  background: #fafafa;
}
.biz-row.is-closed { opacity: .55; }
.biz-row-day {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #0f172a);
}
.biz-row-day input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--accent, #2563eb);
}
.biz-row-times {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted, #64748b);
}
.biz-row-times input[type="time"] {
  width: 110px;
  padding: 5px 8px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text, #0f172a);
  background: #fff;
}
.biz-row-times input[type="time"]:disabled {
  background: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
}
.biz-row-closed-tag {
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
}

.biz-advisor-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.biz-advisor-selector label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #0f172a);
}
.biz-advisor-selector select {
  flex: 1;
  max-width: 280px;
  padding: 6px 10px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
.biz-advisor-mode {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text, #0f172a);
}
.biz-advisor-mode label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.biz-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

/* Perfil del negocio (card que ocupa el ancho completo arriba del grid) */
.biz-card--full { grid-column: 1 / -1; }

.biz-profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  margin-bottom: 14px;
}
@media (max-width: 720px) {
  .biz-profile-grid { grid-template-columns: 1fr; }
}
.biz-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.biz-field--full { grid-column: 1 / -1; }
.biz-field > span {
  font-weight: 600;
  color: var(--text, #0f172a);
  font-size: 12px;
}
.biz-field input,
.biz-field textarea {
  padding: 8px 10px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text, #0f172a);
  background: #fff;
  resize: vertical;
}
.biz-field input:focus,
.biz-field textarea:focus {
  outline: none;
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}
.biz-field small {
  color: var(--text-muted, #64748b);
  font-size: 11px;
}

.biz-slug-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.biz-slug-row:focus-within {
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}
.biz-slug-prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  border-right: 1px solid var(--border, #e5e7eb);
  white-space: nowrap;
}
.biz-slug-row input {
  border: none;
  outline: none;
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: transparent;
}
.biz-slug-row input:focus { box-shadow: none; }

.biz-logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.biz-logo-upload-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.biz-logo-file-label {
  cursor: pointer;
}
.biz-logo-preview {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--border, #e5e7eb);
  background: #f8fafc center/contain no-repeat;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #94a3b8;
  overflow: hidden;
}
.biz-logo-preview.is-empty::after { content: 'Logo'; }


/* Modal borrado de contacto en cascada */
.modal-card--danger { border-top: 4px solid #ef4444; }
.cdel-warning {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  margin-bottom: 16px;
}
.cdel-warning svg { color: #dc2626; flex-shrink: 0; }
.cdel-warning p { margin: 0; font-size: 14px; line-height: 1.5; color: #7f1d1d; }
.cdel-warning strong { color: #991b1b; }
.cdel-leads-section { margin-top: 12px; }
.cdel-leads-title {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.cdel-leads-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}
.cdel-lead-row {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
}
.cdel-lead-name {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 4px;
}
.cdel-lead-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  flex-wrap: wrap;
}
.cdel-lead-pipeline { font-weight: 600; }
.cdel-lead-arrow { color: #94a3b8; }
.cdel-lead-stage {
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.cdel-lead-date { color: #94a3b8; margin-left: auto; }
.cdel-leads-empty,
.cdel-loading,
.cdel-error {
  font-size: 13px;
  color: #64748b;
  font-style: italic;
  padding: 8px 4px;
}
.cdel-error { color: #b91c1c; font-style: normal; }
.btn--danger {
  background: #dc2626;
  color: #fff;
  border: 1px solid #dc2626;
}
.btn--danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }
.btn--danger:disabled { opacity: 0.6; cursor: not-allowed; }

/* Asignación de leads */
.exp-assignee {
  font-size: 12px;
  font-weight: 600;
  color: #1e40af;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.exp-assignee.is-empty {
  color: #94a3b8;
  background: #f8fafc;
  border-color: #e2e8f0;
  font-weight: 500;
  font-style: italic;
}

/* ─── Vista Pedidos ─── */
.view-pedidos { padding: 0; overflow: hidden; display: flex; flex-direction: column; height: 100%; }
.pedidos-view { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.topbar-pedidos-extras { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
.topbar-pedidos-extras[hidden] { display: none; }
.pedidos-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.pedidos-status-filters { display: flex; align-items: center; gap: 4px; }
.pedidos-sf-chip { padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); background: transparent; color: var(--text-muted); cursor: pointer; transition: all .15s; white-space: nowrap; }
.pedidos-sf-chip:hover { border-color: var(--primary); color: var(--primary); }
.pedidos-sf-chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pedidos-search-wrap { position: relative; display: flex; align-items: center; gap: 6px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; flex: 1; max-width: 340px; }
.pedidos-search-wrap svg { flex-shrink: 0; color: var(--text-muted); }
.pedidos-search-wrap input { border: none; background: transparent; outline: none; font-size: 13px; width: 100%; padding: 7px 0; color: var(--text); }
.pedidos-search-wrap input::placeholder { color: var(--text-muted); }
.pedidos-list { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; }
.pedidos-list .woo-order-row { background: var(--card-bg, var(--bg)); }
.pedidos-list .woo-order-main { flex: 1; }
.pedidos-list .woo-order-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

/* ─── Vista Mail ─── */
.view-mail { padding: 0; overflow: hidden; display: flex; flex-direction: column; height: 100%; }
.mail-layout { display: flex; height: 100%; overflow: hidden; }

/* Sidebar */
.mail-sidebar { width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 0; overflow-y: auto; }
.mail-compose-btn { margin: 0 12px 16px; padding: 10px 16px; background: var(--primary); color: #fff; border: none; border-radius: 24px; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.mail-compose-btn:hover { opacity: .9; }
.mail-folders { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.mail-folder { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--text-muted); cursor: pointer; text-decoration: none; transition: background .12s; }
.mail-folder:hover { background: var(--border); color: var(--text); }
.mail-folder--active { background: var(--primary-light, #ede9fe); color: var(--primary); font-weight: 600; }
.mail-unread-badge { background: var(--primary); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 10px; margin-left: auto; }
.mail-accounts-section { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid var(--border); }
.mail-accounts-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin: 0 0 8px; }
.mail-account-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 12px; color: var(--text-muted); }
.mail-account-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Email list */
.mail-list-col { width: 320px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.mail-list-header { padding: 12px; border-bottom: 1px solid var(--border); }
.mail-search-input { width: 100%; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; color: var(--text); outline: none; box-sizing: border-box; }
.mail-search-input:focus { border-color: var(--primary); }
.mail-list-items { flex: 1; overflow-y: auto; }
.mail-empty-list { padding: 40px; text-align: center; color: var(--text-muted); font-size: 13px; }
.mail-item { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; position: relative; }
.mail-item:hover { background: var(--surface); }
.mail-item--selected { background: var(--primary-light, #ede9fe) !important; }
.mail-item--unread .mail-item-from { font-weight: 700; }
.mail-item--unread .mail-item-subject { font-weight: 600; color: var(--text); }
.mail-item-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mail-item-body { flex: 1; min-width: 0; }
.mail-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.mail-item-from { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-item-date { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.mail-item-subject { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.mail-item-preview { font-size: 12px; color: var(--text-muted); opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-item-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 4px; }

/* Detail col */
.mail-detail-col { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.mail-no-selection { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-muted); font-size: 14px; }
.mail-detail-inner { padding: 32px; max-width: 720px; }
.mail-detail-header { margin-bottom: 24px; border-bottom: 1px solid var(--border); padding-bottom: 16px; }
.mail-detail-subject { font-size: 20px; font-weight: 700; margin: 0 0 8px; }
.mail-detail-meta { font-size: 13px; color: var(--text-muted); }
.mail-thread { display: flex; flex-direction: column; gap: 20px; margin-bottom: 32px; }
.mail-message { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.mail-message--out { background: #f0fdf4; border-color: #bbf7d0; }
.mail-message-meta { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 12px; color: var(--text-muted); }
.mail-message-who { font-weight: 600; color: var(--text); }
.mail-message-body { font-size: 14px; line-height: 1.65; color: var(--text); }
.mail-message-body-text { white-space: pre-wrap; }
.mail-message-iframe { width: 100%; min-height: 120px; border: 0; background: #fff; display: block; border-radius: 6px; }
.mail-loading-skeleton { padding: 8px; display: flex; flex-direction: column; gap: 12px; }
.mail-skel-item { display: flex; gap: 12px; padding: 12px; align-items: center; }
.mail-skel-avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%); background-size: 200% 100%; animation: mail-skel-shimmer 1.4s infinite; flex-shrink: 0; }
.mail-skel-text { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.mail-skel-line { height: 10px; border-radius: 4px; background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%); background-size: 200% 100%; animation: mail-skel-shimmer 1.4s infinite; }
.mail-skel-line.w70 { width: 70%; }
.mail-skel-line.w90 { width: 90%; }
@keyframes mail-skel-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.mail-detail-header-row { display: flex; align-items: flex-start; gap: 14px; }
.mail-detail-avatar { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; flex-shrink: 0; }
.mail-detail-header-text { flex: 1; min-width: 0; }
.mail-detail-from-name { font-weight: 600; color: var(--text); }
.mail-detail-from-email { color: var(--text-muted); margin-left: 6px; font-size: 13px; }
.mail-message-meta-left { display: flex; align-items: center; gap: 8px; }
.mail-message-avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 11px; flex-shrink: 0; }
.mail-reply-box { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.mail-reply-label { padding: 10px 14px; font-size: 12px; color: var(--text-muted); background: var(--surface); border-bottom: 1px solid var(--border); }
.mail-reply-textarea { width: 100%; padding: 14px; border: none; outline: none; resize: vertical; font-size: 14px; font-family: inherit; color: var(--text); background: var(--bg); min-height: 100px; box-sizing: border-box; }
.mail-reply-actions { padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--border); }
.mail-loading, .mail-error { padding: 40px; text-align: center; color: var(--text-muted); }

/* Compose panel (bottom-right floating) */
.mail-compose-panel { position: fixed; bottom: 0; right: 24px; width: 480px; background: var(--bg); border: 1px solid var(--border); border-bottom: none; border-radius: 12px 12px 0 0; box-shadow: 0 -4px 24px rgba(0,0,0,.12); z-index: 200; display: flex; flex-direction: column; }
.mail-compose-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: #1f2937; border-radius: 12px 12px 0 0; }
.mail-compose-title { font-size: 14px; font-weight: 600; color: #fff; }
.mail-compose-close { background: none; border: none; color: #9ca3af; cursor: pointer; font-size: 16px; padding: 2px 6px; }
.mail-compose-close:hover { color: #fff; }
.mail-compose-fields { border-bottom: 1px solid var(--border); }
.mail-compose-row { display: flex; align-items: center; border-bottom: 1px solid var(--border); padding: 0 16px; }
.mail-compose-row:last-child { border-bottom: none; }
.mail-compose-row label { font-size: 12px; color: var(--text-muted); width: 52px; flex-shrink: 0; }
.mail-compose-input { flex: 1; padding: 10px 8px; border: none; outline: none; font-size: 13px; background: transparent; color: var(--text); }
.mail-compose-body { flex: 1; padding: 14px 16px; border: none; outline: none; resize: none; font-size: 14px; font-family: inherit; color: var(--text); background: transparent; min-height: 180px; }
.mail-compose-footer { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* ─── Chat/Mail Split ─── */
.split-companies-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.split-company-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: var(--surface);
}
.split-company-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.split-name-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}
.split-color-picker {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
}
.split-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.split-checklist {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
}
.split-checklist label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  padding: 3px 0;
}
.split-switcher {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.split-switcher--mail {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  margin-top: 0;
}
.split-btn {
  flex: 1;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-soft);
  transition: all .15s;
}
.split-btn--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.split-auto-label {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 0;
  line-height: 1.5;
}
.split-required {
  color: var(--danger);
  margin-left: 2px;
}
.chat-split-tint {
  transition: background .2s;
}


/* ═══════ Copiloto ═══════ */
.view-copiloto { position: relative; display: flex; height: 100%; overflow: hidden; }
.copiloto-shell { display: flex; flex-direction: column; flex: 1; height: 100%; overflow: hidden; background: var(--bg); }
.copiloto-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.copiloto-header-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.copiloto-badge { font-size: 10px; font-weight: 700; background: var(--accent); color: #fff; border-radius: 4px; padding: 1px 5px; letter-spacing: .04em; }
.copiloto-messages { flex: 1; overflow-y: auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 14px; }
.copiloto-welcome { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; color: var(--text-muted); font-size: 14px; line-height: 1.6; margin: auto; padding: 40px 20px; }
.copiloto-suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.copiloto-suggestion { background: var(--bg-2); border: 1px solid var(--border); border-radius: 20px; padding: 6px 14px; font-size: 12px; cursor: pointer; color: var(--text); transition: background .15s, border-color .15s; }
.copiloto-suggestion:hover { background: var(--accent-soft, rgba(99,102,241,.08)); border-color: var(--accent); color: var(--accent); }
.copiloto-msg { display: flex; gap: 10px; max-width: 780px; width: 100%; }
.copiloto-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.copiloto-msg-bubble { padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-width: 640px; }
.copiloto-msg--user .copiloto-msg-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.copiloto-msg--ai .copiloto-msg-bubble { background: var(--bg-2); color: var(--text); border-bottom-left-radius: 4px; border: 1px solid var(--border); }
.copiloto-msg-avatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 13px; background: var(--bg-2); border: 1px solid var(--border); }
.copiloto-msg--ai .copiloto-msg-avatar { background: var(--accent); color: #fff; border-color: var(--accent); }
.copiloto-typing { display: flex; gap: 4px; align-items: center; padding: 10px 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px; border-bottom-left-radius: 4px; width: fit-content; }
.copiloto-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: cpTyping .9s infinite; }
.copiloto-typing span:nth-child(2) { animation-delay: .2s; }
.copiloto-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes cpTyping { 0%,60%,100% { opacity:.3; transform: translateY(0); } 30% { opacity:1; transform: translateY(-4px); } }
.copiloto-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; align-items: flex-end; }
.copiloto-input { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit; background: var(--bg-2); color: var(--text); outline: none; max-height: 140px; overflow-y: auto; line-height: 1.5; }
.copiloto-input:focus { border-color: var(--accent); }
.copiloto-send-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: opacity .15s; }
.copiloto-send-btn:disabled { opacity: .4; cursor: default; }
.copiloto-config-drawer { position: absolute; inset: 0; z-index: 10; display: flex; justify-content: flex-end; background: rgba(0,0,0,.3); }
.copiloto-config-panel { width: 360px; max-width: 100%; background: var(--bg); border-left: 1px solid var(--border); display: flex; flex-direction: column; height: 100%; }
.copiloto-config-header { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--border); }
.copiloto-config-header h3 { font-size: 15px; font-weight: 700; margin: 0; }
.copiloto-config-body { flex: 1; overflow-y: auto; padding: 16px; }
.copiloto-config-footer { padding: 12px 16px; border-top: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════════════════
   APPS SECTION
   ═══════════════════════════════════════════════════════════════ */
.view-apps { height: 100%; overflow-y: auto; background: var(--bg-base); }
.apps-shell { max-width: 900px; margin: 0 auto; padding: 32px 24px; }
.apps-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 28px; }
.apps-title  { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.apps-subtitle { font-size: 13px; color: var(--text-muted); margin: 0; }
.apps-section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin: 0 0 12px; }
.apps-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 28px; }
.apps-loading { color: var(--text-muted); font-size: 13px; }

.app-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
.app-card-icon { font-size: 32px; flex-shrink: 0; }
.app-card-body { flex: 1; min-width: 0; }
.app-card-name { font-weight: 600; font-size: 14px; }
.app-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow-wrap: anywhere;
  word-break: normal;
}
.app-card-reqs { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.app-card-reqs span { font-size: 11px; background: #f1f5f9; color: var(--text-muted); padding: 1px 7px; border-radius: 99px; }
.app-card-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.app-card--paused { opacity: 0.55; }
.app-card-toggle { margin-right: 2px; }

/* Mobile: layout grid — icono y nombre arriba (row 1), descripción debajo
   ocupando todo el ancho (row 2), y botones al final (row 3). Evita que
   la descripción quede atrapada en una columna delgada entre el icono y
   los botones. */
@media (max-width: 640px) {
  .app-card {
    display: grid;
    grid-template-columns: 44px 1fr;
    grid-template-areas:
      "icon name"
      "desc desc"
      "reqs reqs"
      "actions actions";
    align-items: start;
    column-gap: 10px;
    row-gap: 8px;
    padding: 14px;
  }
  .app-card-icon {
    grid-area: icon;
    font-size: 32px;
    line-height: 1;
  }
  .app-card-body {
    grid-area: name;
    width: auto;
    display: contents; /* Que name/desc/reqs hereden el grid del padre */
  }
  .app-card-name { grid-area: name; align-self: center; }
  .app-card-desc { grid-area: desc; margin-top: 0; }
  .app-card-reqs { grid-area: reqs; margin-top: 0; }
  .app-card-actions {
    grid-area: actions;
    justify-content: flex-end;
    flex-wrap: wrap;
    width: 100%;
  }
}
.app-version { font-size: 11px; color: var(--text-muted); }

/* ── Woo Modal ── */
.woo-modal { display: flex; flex-direction: column; max-height: 85vh; width: min(720px, 100%); }
.woo-tabs { display: flex; gap: 0; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--bg-base); flex-shrink: 0; overflow-x: auto; }
.woo-tab { padding: 10px 13px; font-size: 12.5px; font-weight: 500; border: none; background: none; cursor: pointer; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .15s, border-color .15s; }
.woo-tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.woo-body { flex: 1; overflow-y: auto; }
.woo-desc { font-size: 13px; color: var(--text-muted); margin: 0 0 16px; }
.woo-empty { font-size: 13px; color: var(--text-muted); font-style: italic; margin: 8px 0; }
/* ── Tarjeta de pedido ── */
.woo-order-card { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font-size: 13px; flex-shrink: 0; }
.woo-oc-top    { display: flex; align-items: center; gap: 8px; padding: 10px 14px 6px; flex-wrap: wrap; }
.woo-oc-num    { font-size: 13.5px; }
.woo-oc-date   { font-size: 11.5px; color: var(--text-muted); }
.woo-oc-flex   { flex: 1; }
.woo-oc-client { display: flex; align-items: center; gap: 6px; padding: 0 14px 8px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.woo-oc-sep    { color: var(--text-muted); }
.woo-oc-muted  { color: var(--text-muted); }
.woo-addr-btn  { font-size: 11.5px; background: none; border: none; color: var(--primary, #2563eb); cursor: pointer; padding: 0; white-space: nowrap; }
.woo-addr-btn:hover { text-decoration: underline; }
/* Modal domicilio */
.woo-addr-modal-backdrop { position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:9999; display:flex; align-items:center; justify-content:center; padding:20px; }
.woo-addr-modal { background:var(--bg); border-radius:12px; min-width:300px; max-width:460px; width:100%; box-shadow:0 24px 64px rgba(0,0,0,.35); overflow:hidden; }
.woo-addr-modal-hdr { display:flex; align-items:center; justify-content:space-between; padding:14px 18px; border-bottom:1px solid var(--border); }
.woo-addr-modal-hdr strong { font-size:14px; }
.woo-addr-modal-x { background:none; border:none; cursor:pointer; font-size:16px; color:var(--text-muted); padding:2px 6px; border-radius:4px; line-height:1; }
.woo-addr-modal-x:hover { background:var(--bg-alt); }
.woo-addr-modal-body { padding:16px 18px; display:flex; flex-direction:column; gap:11px; }

/* ───────── Embedded Signup block en modal de integración WhatsApp ───────── */
.int-embedded-signup-block {
  background: linear-gradient(135deg, #f0f9ff, #dbeafe);
  border: 1px solid #93c5fd; border-radius: 10px;
  padding: 16px 18px; margin-bottom: 16px;
}
.int-fb-login-btn {
  width: 100%; background: #1877f2 !important; color: #fff !important;
  font-weight: 600; padding: 10px 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
}
.int-fb-login-btn:hover { background: #166fe5 !important; }
.int-fb-login-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.int-or-divider {
  text-align: center; margin-top: 14px; font-size: 12px;
  color: #64748b; text-transform: uppercase; letter-spacing: 0.04em;
}
/* Aviso arriba del formulario de WhatsApp API: link a la guía pública */
.int-guide-box {
  background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 10px;
  padding: 12px 14px; margin-bottom: 16px; font-size: 13px; line-height: 1.5; color: #065f46;
}
.int-guide-box a { color: #047857; font-weight: 700; }
.modal-card--lg { max-width: 720px; }
/* Permitir copiar nombre, teléfono, email, dirección, nota — ningún botón
   long-press ni evento touch debe bloquear la selección de texto aquí. */
.woo-addr-modal-body,
.woo-addr-modal-body * {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
.woo-addr-row { display:flex; gap:12px; align-items:flex-start; font-size:13px; }
.woo-addr-lbl { color:var(--text-muted); min-width:76px; flex-shrink:0; font-size:12px; padding-top:1px; }
.woo-addr-link { color:var(--primary,#2563eb); text-decoration:none; }
.woo-addr-link:hover { text-decoration:underline; }
.woo-addr-multiline { align-items:flex-start; }
.woo-addr-lines { display:flex; flex-direction:column; gap:2px; }
.woo-addr-lines span { font-size:13px; line-height:1.5; }
.woo-addr-lbl2 { font-size:12px !important; color:var(--text-muted); }
.woo-addr-note-row { border-top:1px solid var(--border); padding-top:11px; margin-top:2px; }
.woo-oc-products { display: flex; flex-direction: column; gap: 2px; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.woo-oc-product  { display: flex; align-items: baseline; gap: 6px; }
.woo-oc-dot      { color: var(--text-muted); width: 10px; flex-shrink: 0; }
.woo-oc-pname    { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.woo-oc-qty      { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.woo-oc-ptotal   { font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; margin-left: auto; }
.woo-oc-footer   { display: flex; align-items: center; gap: 6px; padding: 7px 14px; font-size: 12px; flex-wrap: wrap; }
.woo-oc-pay      { color: var(--text-secondary); }
.woo-neto        { color: var(--success, #16a34a); font-weight: 600; }
.woo-oc-notes    { padding: 5px 14px 8px; font-size: 12px; font-style: italic; color: var(--text-secondary); border-top: 1px solid var(--border); }
.woo-tracking-form { padding: 8px 14px 12px; border-top: 1px solid var(--border); background: var(--bg-alt); }

.woo-status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.woo-status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.woo-status-dot--on  { background: #22c55e; box-shadow: 0 0 6px #22c55e80; }
.woo-status-dot--off { background: var(--text-muted); }

.woo-token-box { background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.woo-token-box label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 6px; }
.woo-token-row { display: flex; align-items: center; gap: 8px; }
.woo-token-code { font-family: monospace; font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--primary); }

.woo-products-list, .woo-rules-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.woo-product-row, .woo-rule-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; background: var(--bg-card); }
.woo-product-name { flex: 1; font-weight: 500; }
.woo-rule-days  { font-weight: 700; min-width: 60px; }
.woo-rule-dest  { flex: 1; }
.woo-rule-row--warn { border-color: #fbbf24; background: #fffbeb; }
.woo-rule-warn  { font-size: 11px; color: #d97706; }
.woo-days-input { width: 70px !important; }
.woo-add-product-row, .woo-add-rule-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.woo-status-chip { display:inline-flex;align-items:center;gap:5px;padding:4px 10px;border:1.5px solid var(--border);border-radius:20px;font-size:12px;cursor:pointer;user-select:none;transition:border-color .15s,background .15s; }
.woo-status-chip:has(input:checked) { border-color:var(--primary);background:color-mix(in srgb,var(--primary) 10%,transparent);font-weight:600; }
.woo-status-chip input { display:none; }
.woo-rules-count { font-size: 11px; font-weight: 600; color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); padding: 2px 10px; border-radius: 20px; }
.woo-add-rule-box { border: 1.5px dashed var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 4px; background: var(--bg-muted, #fafafa); }
.woo-add-rule-title { font-size: 11px; font-weight: 600; color: var(--text-muted); margin: 0 0 8px; }
.woo-add-rule-lbl { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.woo-plugin-instructions { font-size: 13px; }
.woo-plugin-instructions h4 { margin: 0 0 12px; font-size: 15px; }
.woo-plugin-instructions ol { padding-left: 20px; line-height: 2; }
.woo-requirements { margin-top: 16px; padding: 10px 14px; background: var(--bg-base); border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.woo-orders-toolbar { display:flex; gap:8px; align-items:center; margin-bottom:12px; }
.woo-orders-list { display:flex; flex-direction:column; gap:8px; max-height:400px; overflow-y:auto; }
.woo-order-row { background:var(--bg); border:1px solid var(--border); border-radius:8px; padding:12px 14px; }
.woo-order-header { display:flex; align-items:center; gap:8px; margin-bottom:4px; }
.woo-order-date { font-size:11px; color:var(--text-muted); margin-left:auto; }
.woo-order-customer { font-size:12px; color:var(--text-muted); margin-bottom:2px; }
.woo-order-products { font-size:12px; color:var(--text-secondary); margin-bottom:6px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.woo-order-tracking { margin-top:4px; }
.woo-order-status { display:inline-flex; align-items:center; font-size:11px; font-weight:700; padding:3px 10px; border-radius:20px; white-space:nowrap; background:var(--bg-alt); color:var(--text-secondary); border:1px solid var(--border); }
.woo-order-status--processing { background:#fef3c7; color:#92400e; border-color:#fcd34d; }
.woo-order-status--completed  { background:#d1fae5; color:#065f46; border-color:#6ee7b7; }
.woo-order-status--pending    { background:#f1f5f9; color:#475569; border-color:#cbd5e1; }
.woo-order-status--on-hold    { background:#fef9c3; color:#854d0e; border-color:#fde047; }
.woo-order-status--cancelled  { background:#fee2e2; color:#991b1b; border-color:#fca5a5; }
.woo-order-status--refunded   { background:#ede9fe; color:#5b21b6; border-color:#c4b5fd; }
.woo-order-status--failed     { background:#fee2e2; color:#991b1b; border-color:#fca5a5; }
.woo-tracking-badge { display:inline-flex; align-items:center; font-size:11px; font-weight:600; padding:3px 9px; border-radius:20px; white-space:nowrap; }
.woo-tracking-badge--none { background:var(--bg-alt); color:var(--text-muted); border:1px solid var(--border); }
.woo-tracking-badge--pendiente { background:#fef3c7; color:#92400e; border:1px solid #fcd34d; }
.woo-tracking-badge--en_camino { background:#dbeafe; color:#1e40af; border:1px solid #93c5fd; }
.woo-tracking-badge--entregado { background:#d1fae5; color:#065f46; border:1px solid #6ee7b7; }
.woo-tracking-num { font-size:11px; color:var(--text-secondary); margin-left:5px; }
.woo-tracking-btn { margin-top:8px; }
.woo-tracking-form { padding:10px 0 4px; }
.woo-tracking-fields { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.woo-tracking-fields--second { margin-top:6px; padding-top:6px; border-top:1px dashed var(--border); }
.woo-no-creds-warn { font-size:11px; color:#92400e; background:#fef3c7; border:1px solid #fcd34d; border-radius:6px; padding:6px 10px; margin-bottom:6px; }
.woo-pagination { display:flex; align-items:center; gap:10px; justify-content:center; padding:14px 0 4px; }
.woo-pg-btn { background:var(--bg-alt); border:1px solid var(--border); border-radius:6px; padding:5px 12px; font-size:12px; cursor:pointer; color:var(--text); }
.woo-pg-btn:hover { background:var(--bg-hover,#e2e8f0); }
.woo-pg-info { font-size:12px; color:var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE — bottom navigation + responsive layout
   Breakpoint: <= 768px (tablet portrait y smartphone)
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Layout: 1 columna, sidebar baja al bottom como navbar.
     !important para vencer las reglas de body.nav-collapsed/expanded que
     tienen más especificidad y aplicarían columnas de desktop. */
  .app,
  body.nav-collapsed .app,
  body.nav-expanded .app,
  body:not(.nav-collapsed) .app {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr auto !important;
    height: 100dvh; /* dynamic vh para iOS Safari (no se tapa con barra del navegador) */
  }

  /* La main se queda arriba (row 1), el sidebar se va al bottom (row 2).
     Override del height:100vh global porque ya estamos en grid con 1fr auto. */
  .main {
    grid-row: 1 / 2;
    min-height: 0;
    height: auto !important;
    overflow: hidden;
  }
  .sidebar { grid-row: 2 / 3; }

  /* Sidebar → bottom nav horizontal — altura fija para no estirar items */
  .sidebar {
    flex-direction: row;
    align-items: center; /* IMPORTANTE: center, NO stretch — sino el item activo se estira a toda la altura */
    justify-content: flex-start;
    padding: 4px 6px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0));
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 100;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
    gap: 0;
    height: auto;
    max-height: 76px;
  }
  .sidebar::-webkit-scrollbar { display: none; }

  /* Sidebar-top (logo + campana) ocultos en mobile.
     Las notificaciones siguen llegando por push; el badge de chats
     no leídos se ve en el icono Chats del bottom nav. */
  .sidebar-top { display: none; }

  /* Nav items horizontales — el contenedor también debe ser center */
  .nav {
    flex-direction: row;
    align-items: center;
    gap: 0;
    margin-top: 0;
    width: 100%;
    min-width: max-content; /* permite scroll horizontal cuando overflow */
    flex: 1 1 auto;
    height: auto;
  }
  .nav-item {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 10px;
    font-size: 9px;
    min-width: 64px;
    flex-shrink: 0;
    border-radius: 8px;
    white-space: nowrap;
    line-height: 1.1;
  }
  .nav-item svg { width: 22px; height: 22px; }
  /* Override del display:none de la regla normal — en mobile sí mostramos texto bajo icono */
  body .nav-item span:not(.nav-badge) {
    display: inline !important;
    font-size: 10px;
    font-weight: 500;
  }
  /* Badge ajustado para el layout columnar */
  .nav-item .nav-badge {
    position: absolute;
    top: 2px;
    right: 8px;
  }

  /* Ocultar collapse button (no aplica en mobile) */
  #navCollapseBtn { display: none; }

  /* nav-bottom (profile/logout) — ocultar en mobile, accesible vía Ajustes */
  .nav-bottom, .sidebar-bottom { display: none; }

  /* nav-advisor-bar (avatar + logout) → visible al final del bottom nav.
     Aparece después del scroll de los items de navegación, anclada a la derecha. */
  .nav-advisor-bar {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    margin-left: auto;
    background: transparent;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0;
    flex-shrink: 0;
    height: 100%;
  }
  .nav-advisor-info {
    gap: 4px;
    overflow: visible;
  }
  .nav-advisor-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }
  .nav-advisor-name { display: none; } /* en mobile solo avatar */
  .nav-cache-btn, .nav-logout-btn {
    padding: 6px;
    flex-shrink: 0;
  }
  .nav-logout-btn { color: #fca5a5; }

  /* Topbar: 2 filas en mobile (search arriba, extras abajo con scroll horizontal) */
  .topbar {
    padding: 8px 10px;
    gap: 6px;
    flex-wrap: wrap;
  }
  /* Ocultar título (el bottom nav ya dice en qué vista estás) */
  .topbar-title {
    display: none;
  }
  /* Search ocupa toda la primera fila */
  .topbar-search {
    flex: 1 1 100%;
    min-width: 0;
    order: 1;
    margin: 0;
  }
  .topbar-search input {
    font-size: 14px;
    padding: 8px 12px;
    width: 100%;
  }
  /* Extras (view-switcher, sort, filter, etc.) van en la segunda fila, scroll horizontal */
  .topbar-actions, .topbar-pl-extras, .topbar-exp-extras,
  .topbar-customers-extras, .topbar-cal-extras, .topbar-tpl-extras,
  .topbar-bot-extras, .topbar-pedidos-extras {
    flex: 1 1 100%;
    order: 2;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
    flex-wrap: nowrap;
    padding: 2px 0;
    margin-left: 0;
  }
  .topbar-actions::-webkit-scrollbar,
  .topbar-pl-extras::-webkit-scrollbar,
  .topbar-exp-extras::-webkit-scrollbar,
  .topbar-customers-extras::-webkit-scrollbar,
  .topbar-cal-extras::-webkit-scrollbar,
  .topbar-tpl-extras::-webkit-scrollbar,
  .topbar-bot-extras::-webkit-scrollbar,
  .topbar-pedidos-extras::-webkit-scrollbar { display: none; }
  /* Los botones dentro de los extras no se encojen */
  .topbar-actions > *, .topbar-pl-extras > *, .topbar-exp-extras > *,
  .topbar-customers-extras > *, .topbar-cal-extras > *, .topbar-tpl-extras > *,
  .topbar-bot-extras > *, .topbar-pedidos-extras > * {
    flex-shrink: 0;
  }
  /* Filter btn redondo a la derecha de los extras */
  .kf-filter-btn { padding: 6px 12px !important; font-size: 12px; }

  /* Barra flotante de jobs — un poco más arriba para no chocar con bottom nav */
  .bulk-job-bar {
    bottom: calc(76px + env(safe-area-inset-bottom, 0));
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
  }

  /* Toasts también suben para no chocar con bottom nav */
  .toast-container {
    bottom: calc(80px + env(safe-area-inset-bottom, 0)) !important;
  }
}

/* Smartphone chico (<=420px) — apretar todavía más */
@media (max-width: 420px) {
  .nav-item {
    min-width: 56px;
    padding: 6px 8px;
  }
  .nav-item svg { width: 20px; height: 20px; }
  body .nav-item span:not(.nav-badge) { font-size: 9px; }
  .topbar-title { font-size: 14px; }
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE — vista por vista
   ═══════════════════════════════════════════════════════════════════════ */

/* CHATS — usa el sistema existente data-chat-mobile-view en línea 10444.
   Aquí solo agregamos polish móvil para header/mensajes/composer. */
@media (max-width: 768px) {
  .rh-conversation-header {
    padding: 10px 12px;
    gap: 8px;
  }
  .rh-conversation-title { font-size: 14px; }
  .rh-conversation-meta { font-size: 11px; }
  .rh-messages, #rhMessages { padding: 8px 10px; }
  .msg-bubble, .rh-message-bubble { max-width: 86%; font-size: 14px; }
  .rh-reply-form, .rh-composer {
    padding: 8px 10px;
    gap: 6px;
  }
  .rh-search-wrap input { font-size: 14px; }
}

/* PIPELINES — kanban scrollable + tabs sticky */
@media (max-width: 768px) {
  .pl-board {
    padding: 8px;
    gap: 8px;
  }
  .pl-tabs {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 4px 8px;
  }
  .pl-tabs::-webkit-scrollbar { display: none; }
  .pl-tab { flex-shrink: 0; }
  /* Columnas del kanban — un poco más angostas */
  .pl-col { min-width: 260px; max-width: 280px; }
  .pl-col-title { font-size: 12px; }
  .pl-card { padding: 10px; font-size: 12px; }
  .pl-card-name { font-size: 13px; }
  .pl-card-contact { font-size: 11px; }
  /* Lista de pipeline (modo lista) — tabla scrolleable */
  .pl-list-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pl-list-table { min-width: 540px; }
  .pl-list-bulkbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
}

/* LEAD DETAIL — split de 3 columnas → 1 columna stacked */
@media (max-width: 768px) {
  body[data-view-active="exp-detail"] .topbar { display: flex; padding: 4px 8px; }
  .exp-detail-shell, .exp-detail-grid {
    display: flex !important;
    flex-direction: column;
    grid-template-columns: none !important;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
  }
  .exp-detail-left, .exp-detail-center, .exp-detail-right {
    width: 100%;
    border-right: none !important;
    border-bottom: 1px solid var(--border, #e5e7eb);
    overflow: visible !important; /* sin esto las cards se cortan */
    height: auto !important;
    flex: none !important;
  }
  /* La info del lead — quitar overflow auto y flex:1 (heredados de desktop) */
  .exp-detail-info {
    overflow: visible !important;
    flex: none !important;
    padding: 12px;
    gap: 12px;
  }
  /* Cada sección con padding razonable */
  .exp-detail-section { padding: 10px 12px; }
  .exp-detail-section h3 { font-size: 11px; }
  /* Las filas de info row: label + value verticales si no caben */
  .ed-row, .exp-detail-row { gap: 4px; }
  /* El chat dentro del detalle */
  .exp-detail-right .rh-conversation-panel {
    height: 60vh;
    flex: none !important;
  }
  .exp-detail-back {
    padding: 6px 10px;
    font-size: 13px;
  }
  /* Topbar del detalle más compacto */
  .exp-detail-topbar { padding: 8px 12px; }
}

/* PLANTILLAS — cards stack vertical */
@media (max-width: 768px) {
  .tpl-layout { padding: 8px; max-width: none; }
  .tpl-tabs { overflow-x: auto; scrollbar-width: none; }
  .tpl-tabs::-webkit-scrollbar { display: none; }
  .tpl-card {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 8px;
  }
  .tpl-card-icon-wrap { flex-direction: row; align-items: center; gap: 8px; }
  .tpl-card-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}

/* CONTACTOS — tabla scrolleable */
@media (max-width: 768px) {
  .customers-toolbar { flex-wrap: wrap; gap: 8px; padding: 8px; }
  .customers-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .customers-table { min-width: 600px; font-size: 12px; }
}

/* BOT BUILDER — pasos vertical */
@media (max-width: 768px) {
  .bot-builder-topbar {
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 8px;
  }
  .bot-builder-name-input { width: 100%; font-size: 14px; }
  .bot-builder-topbar-right {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
  .bot-builder-body { padding: 12px 8px 80px; }
  .bb-view-tabs { max-width: none; }
  /* Lista de bots — full width cards */
  .bot-list-row {
    grid-template-columns: 1fr auto !important;
    grid-template-rows: auto auto auto;
    grid-template-areas: "name name" "trigger trigger" "actions actions" !important;
    gap: 6px;
    padding: 10px;
  }
  .bot-list-row > :nth-child(1) { grid-area: name; }
  .bot-list-row > :nth-child(2) { grid-area: trigger; }
  .bot-list-row > :nth-child(3) { display: none; }  /* steps count */
  .bot-list-row > :nth-child(4) { grid-area: trigger; justify-self: end; }  /* active leads pill */
  .bot-list-row > :nth-child(5) { grid-area: actions; justify-self: end; }  /* enabled toggle */
  .bot-list-row > :nth-child(6) { grid-area: actions; justify-self: end; }  /* actions */
  .bot-list-head { display: none; }
}

/* CALENDARIO — toolbar wrap */
@media (max-width: 768px) {
  .cal-toolbar { flex-wrap: wrap; gap: 6px; padding: 8px; }
  .cal-sub-toggle { width: 100%; justify-content: center; }
}

/* PEDIDOS — cards stack */
@media (max-width: 768px) {
  .pedidos-toolbar { flex-wrap: wrap; gap: 8px; padding: 8px; }
  .pedidos-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ANALÍTICAS / DASHBOARD — grids a una columna */
@media (max-width: 768px) {
  .dashboard-grid, .stats-grid, .analytics-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
}

/* MODALES — más espacio aprovechado en mobile */
@media (max-width: 768px) {
  .modal-card, .modal-card--md, .modal-card--lg {
    max-width: calc(100vw - 24px) !important;
    margin: 12px auto;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }
  .modal-header { padding: 12px 14px; }
  .modal-body { padding: 14px; }
  .modal-footer { padding: 10px 14px; flex-wrap: wrap; gap: 6px; }
}

/* SETTINGS — patrón Lista → Detalle como iOS Settings */
.settings-mobile-back { display: none; }
@media (max-width: 768px) {
  .settings-shell {
    grid-template-columns: 1fr !important;
    max-width: none !important;
    position: relative;
    height: 100%;
  }
  /* Default: muestra la lista de categorías, oculta el contenido */
  .settings-nav {
    border-right: none;
    padding: 12px 10px;
    width: 100%;
  }
  .settings-tab {
    padding: 14px 12px;
    font-size: 14px;
    border-radius: 10px;
    /* Chevron derecho para indicar "tap para entrar" */
    position: relative;
  }
  .settings-tab::after {
    content: '›';
    margin-left: auto;
    font-size: 22px;
    color: var(--text-muted, #9ca3af);
    line-height: 1;
  }
  .settings-content { display: none; padding: 16px; }
  /* Al elegir una categoría (clase is-detail-mode en shell), invertir */
  .settings-shell.is-detail-mode .settings-nav { display: none; }
  .settings-shell.is-detail-mode .settings-content { display: block; height: 100%; overflow-y: auto; }
  .settings-shell.is-detail-mode .settings-mobile-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--accent, #2563eb);
    font-size: 14px;
    font-weight: 500;
    padding: 4px 0;
    margin-bottom: 12px;
    cursor: pointer;
  }
  .settings-shell.is-detail-mode .settings-mobile-back:hover { opacity: .7; }
  /* Que el header de cada pane se vea ordenado en mobile */
  .settings-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }
  .settings-head h2 { font-size: 20px; margin: 0 0 4px; }
  .settings-head p { font-size: 13px; margin: 0; }
  .settings-head .btn { width: 100%; justify-content: center; }
  /* Tablas internas con scroll horizontal */
  .settings-pane table { min-width: 480px; }
  .settings-pane .table-wrap, .settings-pane .table-responsive { overflow-x: auto; }
}

/* TOPBAR EXTRAS — botones de texto → solo iconos cuando es posible */
@media (max-width: 480px) {
  /* Hide labels of nav-style btns en topbar — solo iconos */
  .topbar-pl-extras .pl-view-btn span:not(.nav-badge),
  .topbar-actions .btn-label {
    display: none;
  }
  .topbar-search input::placeholder {
    font-size: 12px;
  }
}

/* ═══════ PWA iOS — feels-like-native fixes ═══════
   Soluciona issues reportados con la app instalada en iPhone:
     1) Header se sale por encima de la status bar (safe-area-inset-top)
     2) Se puede deslizar horizontalmente (overscroll-behavior-x)
     3) Doble-tap o pinch hace zoom (touch-action + user-scalable=no)
     4) Aparece el teclado y el layout queda roto (visualViewport + dvh)
     5) El modal de plantillas pierde su posición fija con el teclado
   Combinado con meta viewport "maximum-scale=1, user-scalable=no,
   interactive-widget=resizes-content" + JS visualViewport handler. */

/* — Bloquear gestos no deseados a nivel root — */
html, body {
  overscroll-behavior: none;                    /* bloquea pull-to-refresh y bounce */
  overscroll-behavior-x: none;                  /* refuerza horizontal */
  overflow-x: hidden;                            /* corta cualquier desbordamiento */
  -webkit-text-size-adjust: 100%;               /* iOS no auto-zoom en rotación */
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;     /* sin flash gris al tocar */
  touch-action: pan-y;                           /* solo permite scroll vertical, no pinch ni horizontal */
}
/* NOTA: removido user-select:none global — bloqueaba copiar texto en modals
   (direcciones de pedidos, IDs, etc.). Los botones y elementos no-textuales
   ya tienen su propia regla user-select:none en clases específicas. */
input, textarea, [contenteditable="true"] {
  touch-action: auto;
}
/* Botones / links: eliminar 300ms delay y double-tap zoom */
button, a, [role="button"], .btn, [data-action] {
  touch-action: manipulation;
}

/* — Bloquear zoom de iOS Safari por <input> con font-size < 16px —
   iOS auto-zoomea al hacer focus si el input es <16px. Lo prevenimos. */
@supports (-webkit-touch-callout: none) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select, textarea {
    font-size: max(16px, 1em);
  }
}

/* — En modo standalone PWA, el body es una superficie fija (no scroll) —
   El scroll vive dentro de cada vista. Eso evita que el header se mueva
   cuando el teclado abre/cierra. */
@media (display-mode: standalone) {
  html, body { height: 100dvh; height: 100vh; }
  body { position: fixed; inset: 0; width: 100%; }

  /* Chat header móvil (rh-conversation-header) baja debajo de la barra de
     estado (Dynamic Island / notch). Aplica solo en mobile chat. */
  body[data-chat-mobile-view="conversation"] .rh-conversation-header {
    padding-top: calc(10px + env(safe-area-inset-top));
  }

  /* Topbar normal en otras vistas (analíticas, leads, plantillas, etc.) */
  .topbar {
    padding-top: env(safe-area-inset-top);
  }

  /* Settings — vista detalle en mobile: el contenido se va detrás de la
     status bar / Dynamic Island. Aplicar safe-area al top. */
  .settings-shell.is-detail-mode .settings-content {
    padding-top: calc(16px + env(safe-area-inset-top));
  }
  /* También para la lista de categorías (cuando NO es detalle) — para que
     el primer item no quede pegado a la status bar. */
  .settings-shell:not(.is-detail-mode) .settings-nav {
    padding-top: calc(8px + env(safe-area-inset-top));
  }

  /* Input area del chat móvil se queda pegada al fondo respetando home indicator */
  body[data-chat-mobile-view="conversation"] .rh-reply-form,
  body[data-chat-mobile-view="conversation"] .rh-composer {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
}

/* — Cuando aparece el teclado iOS, visualViewport.height baja. Usamos una
   custom property que el JS actualiza (--keyboard-offset) para reposicionar
   modals y composer. Ver inicialización en app.js startKeyboardTracker(). */
:root { --keyboard-offset: 0px; }

/* Modals que se abren con teclado: que su contenido NO se vaya fuera de la
   zona visible. Aplicamos un translate negativo equivalente al keyboard. */
@media (display-mode: standalone), (max-width: 720px) {
  .modal,
  .modal-backdrop {
    /* En lugar de mover el modal, achicamos su altura útil */
    height: calc(100dvh - var(--keyboard-offset, 0px));
    height: calc(100vh - var(--keyboard-offset, 0px));
  }
  /* Cuando el modal está abierto, el body NO debe hacer scroll detrás */
  body.modal-open {
    overflow: hidden;
    position: fixed;
    inset: 0;
    width: 100%;
  }
}

/* — Refuerzo de safe-area-inset-bottom en cualquier elemento sticky-bottom — */
.app-bottom-bar,
.bottom-fab,
.mobile-bottom-nav {
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

/* ─── MCP Card (Settings → IA) ─────────────────────────────────────── */
.mcp-card {
  margin-top: 32px;
  padding: 22px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 14px;
  background: var(--surface-2, #fafbfc);
}
.mcp-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 6px;
}
.mcp-card-title {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-primary, #111);
}
.mcp-card-title h3 { margin: 0; font-size: 16px; font-weight: 600; }
.mcp-card-title svg { color: var(--accent, #2563eb); }
.mcp-badge {
  font-size: 11px; font-weight: 600; padding: 3px 8px;
  border-radius: 999px; letter-spacing: 0.3px;
}
.mcp-badge--beta {
  background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa;
}
.mcp-card-desc {
  margin: 0 0 18px 0; color: var(--text-secondary, #4b5563);
  font-size: 13.5px; line-height: 1.55;
}
.mcp-row { margin-bottom: 16px; }
.mcp-label {
  display: block; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted, #6b7280); margin-bottom: 6px;
}
.mcp-hint {
  margin: 6px 0 0 0; font-size: 13px; color: var(--text-muted, #6b7280);
  line-height: 1.5;
}
.mcp-hint code {
  background: rgba(0,0,0,0.06); padding: 1px 6px; border-radius: 4px;
  font-size: 12.5px;
}
.mcp-copybox {
  display: flex; gap: 8px; align-items: stretch;
}
.mcp-copybox input {
  flex: 1; min-width: 0; padding: 8px 12px;
  border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px;
  background: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; color: var(--text-primary, #111);
}
.mcp-snippet {
  position: relative; margin-top: 6px;
}
.mcp-snippet pre {
  margin: 0; padding: 14px 16px;
  background: #0f172a; color: #e2e8f0;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; line-height: 1.6;
  overflow-x: auto; white-space: pre;
}
.mcp-snippet .btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,0.1); color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
}
.mcp-snippet .btn:hover { background: rgba(255,255,255,0.18); }
.mcp-tools-list {
  margin: 0; padding-left: 18px; color: var(--text-secondary, #4b5563);
  font-size: 13px; line-height: 1.7;
}
.mcp-tools-list code {
  background: rgba(0,0,0,0.06); padding: 1px 6px; border-radius: 4px;
  font-size: 12px; color: var(--accent, #2563eb); font-weight: 500;
}

/* ─── MCP Connect Modal ────────────────────────────────────────────── */
.mcp-card-actions {
  display: flex; align-items: center; gap: 12px; margin-top: 22px;
  padding-top: 18px; border-top: 1px solid var(--border-color, #e5e7eb);
}
.btn--lg { padding: 11px 22px; font-size: 14.5px; font-weight: 600; }
.mcp-modal {
  max-width: 760px; width: 92vw; max-height: 88vh;
  display: flex; flex-direction: column;
}
.mcp-modal-body { overflow-y: auto; padding: 24px 28px; }

.mcp-step {
  display: flex; gap: 16px; margin-bottom: 28px;
  padding-bottom: 24px; border-bottom: 1px dashed var(--border-color, #e5e7eb);
}
.mcp-step:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.mcp-step-num {
  flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent, #2563eb); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.mcp-step-content { flex: 1; min-width: 0; }
.mcp-step-content h4 {
  margin: 4px 0 8px 0; font-size: 16px; font-weight: 600;
  color: var(--text-primary, #111);
}
.mcp-step-content > p {
  margin: 0 0 14px 0; font-size: 13.5px; line-height: 1.55;
  color: var(--text-secondary, #4b5563);
}

.mcp-token-form-row {
  display: flex; gap: 8px; margin-bottom: 8px;
}
.mcp-token-form-row input {
  flex: 1; min-width: 0; padding: 9px 13px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px; font-size: 14px;
}
.mcp-hint--warn { color: #b45309; }
.mcp-token-success {
  display: flex; gap: 12px; align-items: flex-start;
  background: #ecfdf5; border: 1px solid #a7f3d0;
  padding: 12px 16px; border-radius: 10px;
  margin-bottom: 12px;
}
.mcp-token-success-icon {
  background: #10b981; color: #fff; flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.mcp-token-success p {
  margin: 4px 0 0 0; font-size: 13px; color: #065f46;
}
.btn--link {
  background: none; border: 0; padding: 6px 0; margin-top: 10px;
  color: var(--accent, #2563eb); cursor: pointer; font-size: 13px;
  text-decoration: underline;
}

.mcp-client-tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  margin-bottom: 18px;
}
.mcp-client-tab {
  padding: 9px 14px; background: none; border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer; font-size: 13.5px; font-weight: 500;
  color: var(--text-muted, #6b7280);
  margin-bottom: -1px;
}
.mcp-client-tab:hover { color: var(--text-primary, #111); }
.mcp-client-tab.is-active {
  color: var(--accent, #2563eb);
  border-bottom-color: var(--accent, #2563eb);
}
.mcp-client-panel { display: none; }
.mcp-client-panel.is-active { display: block; }

.mcp-steps-list,
.mcp-test-prompts {
  margin: 0 0 6px 0; padding-left: 20px;
  font-size: 13.5px; line-height: 1.7;
  color: var(--text-primary, #111);
}
.mcp-steps-list li { margin-bottom: 12px; }
.mcp-steps-list ul {
  margin: 6px 0 0 0; padding-left: 18px;
  color: var(--text-secondary, #4b5563); font-size: 13px;
}
.mcp-steps-list code,
.mcp-test-prompts code {
  background: rgba(0,0,0,0.06); padding: 1px 6px; border-radius: 4px;
  font-size: 12.5px; color: var(--accent, #2563eb);
}
.mcp-test-prompts li {
  margin-bottom: 6px; font-style: italic;
  color: var(--text-secondary, #4b5563);
}
.mcp-token-hi {
  background: rgba(56, 189, 248, 0.22);
  color: #67e8f9;
  padding: 1px 4px; border-radius: 3px;
  font-weight: 600;
}

/* ─── Catálogo de WhatsApp ────────────────────────────────────────── */
.view-catalogo { padding: 24px 28px; }
.catalog-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap; margin-bottom: 24px;
}
.catalog-toolbar-left {
  display: flex; align-items: baseline; gap: 12px;
}
.catalog-title {
  margin: 0; font-size: 22px; font-weight: 700; color: var(--text-primary, #111);
}
.catalog-meta {
  font-size: 12.5px; color: var(--text-muted, #6b7280);
}
.catalog-toolbar-right {
  display: flex; gap: 10px; align-items: center;
}
.catalog-search-input {
  padding: 8px 14px; min-width: 240px;
  border: 1px solid var(--border-color, #e5e7eb); border-radius: 999px;
  font-size: 13.5px; outline: none; transition: border-color 0.15s;
}
.catalog-search-input:focus { border-color: var(--accent, #2563eb); }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.catalog-product-card {
  background: #fff;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 12px;
  overflow: hidden; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.catalog-product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  border-color: var(--accent, #2563eb);
}
.catalog-product-img {
  position: relative; aspect-ratio: 1; background: #f8fafc;
  display: flex; align-items: center; justify-content: center;
}
.catalog-product-img img {
  width: 100%; height: 100%; object-fit: cover;
}
.catalog-product-placeholder {
  color: #cbd5e1;
  display: flex; align-items: center; justify-content: center;
}
.catalog-product-placeholder svg { width: 40px; height: 40px; }
.catalog-product-badge {
  position: absolute; top: 8px; right: 8px;
  background: #fee2e2; color: #b91c1c;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
}
.catalog-product-info { padding: 12px; }
.catalog-product-name {
  font-size: 13.5px; font-weight: 600; color: var(--text-primary, #111);
  line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.catalog-product-price {
  margin-top: 4px; font-size: 14px; font-weight: 700;
  color: var(--accent, #2563eb);
}
.catalog-product-sku {
  margin-top: 4px; font-size: 11px; color: var(--text-muted, #6b7280);
  font-family: ui-monospace, monospace;
}

.catalog-pager {
  display: flex; justify-content: center; align-items: center; gap: 16px;
  margin-top: 24px;
}
.catalog-empty {
  text-align: center; padding: 60px 24px; color: var(--text-muted, #6b7280);
  background: #fafbfc; border-radius: 12px;
}
.catalog-empty p { margin: 8px 0; }
.catalog-empty .muted { font-size: 13px; }
.catalog-empty .btn { margin-top: 16px; }

/* ─── Banner sugerencia catálogo ──────────────────────────────────── */
.catalog-suggest-banner {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #93c5fd;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.catalog-suggest-content {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.catalog-suggest-icon {
  flex-shrink: 0; color: #1e40af;
  display: flex; align-items: center; justify-content: center;
}
.catalog-suggest-text {
  flex: 1; min-width: 200px; font-size: 13.5px; color: #1e3a8a; line-height: 1.5;
}
.catalog-suggest-text strong { display: block; margin-bottom: 2px; color: #1e40af; }
.catalog-suggest-actions {
  display: flex; gap: 8px; flex-shrink: 0;
}

/* ─── Centro de Datos ──────────────────────────────────────────────── */
.dc-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  margin: 20px 0 24px 0;
}
.dc-tab {
  padding: 10px 16px; background: none; border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer; font-size: 14px; font-weight: 500;
  color: var(--text-muted, #6b7280); margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 8px;
}
.dc-tab:hover { color: var(--text-primary, #111); }
.dc-tab.is-active {
  color: var(--accent, #2563eb); border-bottom-color: var(--accent, #2563eb);
}
.dc-panel { display: none; }
.dc-panel.is-active { display: block; }

.dc-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.dc-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  background: #fff;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.dc-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  border-color: var(--accent, #2563eb);
}
.dc-card-icon {
  flex-shrink: 0;
  width: 44px; height: 44px; border-radius: 10px;
  background: rgba(37, 99, 235, 0.08);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent, #2563eb);
}
.dc-card-icon svg { width: 22px; height: 22px; }
.dc-card--disabled .dc-card-icon {
  background: rgba(0,0,0,0.05); color: var(--text-muted, #6b7280);
}
.dc-card-body { flex: 1; min-width: 0; }
.dc-card-title {
  font-size: 15px; font-weight: 600; color: var(--text-primary, #111);
}
.dc-card-desc {
  margin-top: 3px; font-size: 12.5px; color: var(--text-muted, #6b7280); line-height: 1.4;
}
.dc-card-desc--muted { font-style: italic; }
.dc-card-count {
  margin-top: 6px; font-size: 11.5px; color: var(--accent, #2563eb); font-weight: 600;
}
.dc-card-arrow {
  color: var(--text-muted, #6b7280); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, color 0.15s;
}
.dc-card-arrow svg { width: 18px; height: 18px; }
.dc-card:hover .dc-card-arrow { transform: translateX(3px); color: var(--accent, #2563eb); }
.dc-card--disabled {
  opacity: 0.55; cursor: not-allowed;
  background: #fafbfc;
}
.dc-card--disabled:hover {
  transform: none; box-shadow: none; border-color: var(--border-color, #e5e7eb);
}
.dc-loading {
  padding: 40px; text-align: center; color: var(--text-muted, #6b7280);
  grid-column: 1 / -1;
}

.dc-backup-hero {
  text-align: center; padding: 48px 32px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-radius: 16px;
}
.dc-backup-icon {
  width: 80px; height: 80px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  background: #fff; color: #2563eb; border-radius: 20px;
  box-shadow: 0 8px 24px rgba(37,99,235,0.18);
}
.dc-backup-hero h3 {
  margin: 0 0 12px 0; font-size: 22px; color: #1e3a8a;
}
.dc-backup-hero p {
  font-size: 14px; color: #1e40af; max-width: 560px; margin: 0 auto 24px auto;
  line-height: 1.6;
}
.dc-backup-hint {
  font-size: 12.5px; color: #6b7280; margin-top: 18px;
}

/* ─── Data Center: Import Wizard ──────────────────────────────────── */
.dc-wizard {
  max-width: 720px; width: 92vw; max-height: 88vh;
  display: flex; flex-direction: column;
}
.dc-wizard-body {
  flex: 1; overflow-y: auto; padding: 0 28px 8px;
}
.dc-wizard-stepper {
  display: flex; align-items: center; padding: 18px 28px;
  background: #fafbfc; border-bottom: 1px solid var(--border-color, #e5e7eb);
  gap: 0;
}
.dc-step {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.dc-step-dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: #e5e7eb; color: #94a3b8;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700;
}
.dc-step.is-active .dc-step-dot {
  background: var(--accent, #2563eb); color: #fff;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.15);
}
.dc-step.is-done .dc-step-dot {
  background: #10b981; color: #fff;
}
.dc-step-label {
  font-size: 12.5px; color: var(--text-muted, #6b7280); font-weight: 500;
}
.dc-step.is-active .dc-step-label { color: var(--accent, #2563eb); font-weight: 600; }
.dc-step-line {
  flex: 1; height: 2px; background: #e5e7eb; margin: 0 12px;
}
.dc-wizard-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 22px; border-top: 1px solid var(--border-color, #e5e7eb);
  background: #fafbfc;
}

.dc-step-content { padding: 22px 0 8px; }
.dc-step-content h4 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.dc-step-desc { margin: 0 0 18px; font-size: 13.5px; color: var(--text-muted, #6b7280); line-height: 1.55; }
.dc-step-hint { font-size: 12.5px; color: var(--text-muted, #6b7280); margin-top: 12px; }

.dc-file-drop {
  border: 2px dashed #cbd5e1; border-radius: 12px;
  padding: 32px 20px; text-align: center;
  background: #fafbfc;
  transition: background 0.15s, border-color 0.15s;
}
.dc-file-drop.is-dragover { background: #eff6ff; border-color: var(--accent, #2563eb); }
.dc-file-drop-inner svg { color: var(--accent, #2563eb); margin-bottom: 12px; }
.dc-file-drop p { margin: 6px 0; font-size: 13.5px; color: var(--text-primary, #111); }
.dc-file-info {
  margin-top: 14px; padding: 10px 14px;
  background: #ecfdf5; border: 1px solid #a7f3d0;
  border-radius: 8px; font-size: 13px; color: #065f46;
}

.dc-mapping-table {
  width: 100%; border-collapse: collapse; margin-bottom: 14px;
}
.dc-mapping-table th, .dc-mapping-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--border-color, #e5e7eb);
  font-size: 13px; text-align: left;
}
.dc-mapping-table th { color: var(--text-muted, #6b7280); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.dc-mapping-table code { background: rgba(0,0,0,0.05); padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.dc-mapping-table select {
  width: 100%; padding: 6px 10px; border: 1px solid #e5e7eb; border-radius: 6px;
  font-size: 13px; background: #fff;
}
.dc-preview-details summary { cursor: pointer; font-size: 12.5px; color: var(--text-muted, #6b7280); margin-top: 10px; }
.dc-preview-details pre {
  background: #0f172a; color: #e2e8f0; padding: 12px;
  border-radius: 8px; font-size: 11.5px; overflow-x: auto;
  margin-top: 8px;
}

.dc-radio-group { display: flex; flex-direction: column; gap: 10px; }
.dc-radio {
  display: flex; gap: 12px; padding: 14px 16px;
  border: 1px solid var(--border-color, #e5e7eb); border-radius: 10px;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.dc-radio:has(input:checked) {
  border-color: var(--accent, #2563eb);
  background: rgba(37,99,235,0.04);
}
.dc-radio input { margin-top: 3px; accent-color: var(--accent, #2563eb); }
.dc-radio strong { display: block; font-size: 13.5px; font-weight: 600; color: var(--text-primary, #111); }
.dc-radio p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-muted, #6b7280); line-height: 1.5; }

.dc-summary {
  background: #fafbfc; border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px; padding: 16px 20px;
  margin: 0 0 14px; font-size: 14px; line-height: 1.8;
  list-style: none;
}
.dc-summary li { padding-left: 18px; position: relative; }
.dc-summary li::before { content: '→'; position: absolute; left: 0; color: var(--accent, #2563eb); }

/* ─── Data Center: Export Panel ────────────────────────────────────── */
.dc-export {
  max-width: 560px; width: 92vw; max-height: 88vh;
  display: flex; flex-direction: column;
}
.dc-export-body { flex: 1; overflow-y: auto; padding: 18px 24px; }
.dc-export-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 22px; border-top: 1px solid var(--border-color, #e5e7eb);
  background: #fafbfc;
}
.dc-export-count { font-size: 12.5px; color: var(--text-muted, #6b7280); }
.dc-export-section { margin-bottom: 20px; }
.dc-export-section h4 { margin: 0 0 10px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted, #6b7280); }
.dc-export-filters {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.dc-filter { display: flex; flex-direction: column; gap: 4px; }
.dc-filter span { font-size: 12px; color: var(--text-muted, #6b7280); font-weight: 500; }
.dc-filter input, .dc-filter select {
  padding: 8px 10px; border: 1px solid #e5e7eb; border-radius: 6px;
  font-size: 13px; background: #fff;
}
.dc-radio-row {
  display: flex; gap: 14px;
}
.dc-radio-row label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13.5px; cursor: pointer;
}

/* ─── Data Center: Relaciones en export panel ────────────────────── */
.dc-relations-list {
  display: flex; flex-direction: column; gap: 6px;
}
.dc-relation-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  font-size: 13px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dc-relation-item:has(input:checked) {
  border-color: var(--accent, #2563eb);
  background: rgba(37,99,235,0.04);
}
.dc-relation-item input { accent-color: var(--accent, #2563eb); }

/* ─── Bot trigger pickers (custom dropdown + popup) ──────────────── */
.sb-field {
  margin-top: 10px;
}
.sb-field-label {
  display: block; font-size: 11.5px; font-weight: 600;
  color: var(--text-muted, #6b7280);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.sb-picker-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px; font-family: inherit;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sb-picker-btn:hover {
  border-color: var(--accent, #2563eb);
}
.sb-picker-btn[aria-expanded="true"] {
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.sb-picker-icon {
  width: 22px; height: 22px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: #f1f5f9; color: var(--text-muted, #6b7280);
  font-size: 11px;
}
.sb-picker-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #cbd5e1; flex-shrink: 0;
  margin-left: 4px;
}
.sb-picker-text {
  flex: 1; color: var(--text-primary, #111);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-picker-text.is-placeholder {
  color: var(--text-muted, #9ca3af);
}
.sb-picker-caret {
  color: var(--text-muted, #9ca3af); flex-shrink: 0;
  transition: transform 0.15s;
}
.sb-picker-btn[aria-expanded="true"] .sb-picker-caret {
  transform: rotate(180deg);
}

/* Popup anchored — usa position absolute respecto al wrap del field */
.sb-field { position: relative; }
.sb-picker-popup {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 320px; overflow-y: auto;
  padding: 6px;
  animation: sbPopIn 0.12s ease-out;
}
@keyframes sbPopIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sb-picker-option {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.1s;
}
.sb-picker-option:hover { background: #f3f4f6; }
.sb-picker-option.is-selected {
  background: rgba(37,99,235,0.08);
  color: var(--accent, #2563eb); font-weight: 500;
}
.sb-picker-option-icon {
  width: 24px; height: 24px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 12px;
}
.sb-picker-option-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
  margin-left: 4px;
}
.sb-picker-option-text { flex: 1; }
.sb-picker-option-meta {
  font-size: 11px; color: var(--text-muted, #6b7280);
}
.sb-picker-empty {
  padding: 16px; text-align: center;
  font-size: 12.5px; color: var(--text-muted, #6b7280);
}

/* ─── iOS-style toggle switches ──────────────────────────────────── */
.sb-modes {
  margin-top: 16px; padding: 14px 16px;
  background: #fafbfc;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
}
.sb-modes-header {
  font-size: 11.5px; font-weight: 600;
  color: var(--text-muted, #6b7280);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.sb-toggle-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; cursor: pointer;
  position: relative;
}
.sb-toggle-text {
  flex: 1; font-size: 13.5px; color: var(--text-primary, #111);
}
.sb-toggle-text strong { color: var(--text-primary, #111); }
.sb-toggle-input {
  position: absolute; opacity: 0; pointer-events: none;
}
.sb-toggle-slider {
  position: relative;
  width: 44px; height: 26px; flex-shrink: 0;
  background: #e2e8f0; border-radius: 13px;
  transition: background 0.2s;
}
.sb-toggle-slider::before {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.2s;
}
.sb-toggle-input:checked ~ .sb-toggle-slider {
  background: var(--accent, #2563eb);
}
.sb-toggle-input:checked ~ .sb-toggle-slider::before {
  transform: translateX(18px);
}
.sb-toggle-input:focus-visible ~ .sb-toggle-slider {
  box-shadow: 0 0 0 3px rgba(37,99,235,0.25);
}

/* ─── Time picker libre (hora + minuto) ──────────────────────────── */
.appt-time-picker {
  display: flex; align-items: center; gap: 6px;
}
.appt-time-input {
  flex: 0 1 90px;
  text-align: center; font-size: 16px; font-weight: 600;
  padding: 10px 12px;
}
.appt-time-sep {
  font-size: 18px; font-weight: 700; color: var(--text-muted, #6b7280);
}
.appt-time-hint {
  margin-left: 12px; font-size: 12.5px;
}

.appt-slots-toggle {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
}
.appt-slots-toggle summary {
  cursor: pointer; font-size: 12.5px; color: var(--accent, #2563eb);
  list-style: none; padding: 6px 0;
}
.appt-slots-toggle summary::-webkit-details-marker { display: none; }
.appt-slots-toggle summary::before {
  content: '▸'; margin-right: 6px; transition: transform 0.15s; display: inline-block;
}
.appt-slots-toggle[open] summary::before { transform: rotate(90deg); }

/* ─── Modal Agendar Cita: botones y validación visual ────────────── */
.appt-modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid #e5e7eb;
}
.appt-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.appt-btn:active:not(:disabled) { transform: scale(0.97); }

.appt-btn--ghost {
  background: #fff;
  color: #475569;
  border-color: #e2e8f0;
}
.appt-btn--ghost:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.appt-btn--primary {
  background: var(--accent, #2563eb);
  color: #fff;
  border-color: var(--accent, #2563eb);
}
.appt-btn--primary:hover:not(:disabled) {
  background: #1d4ed8;
  border-color: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.appt-btn--primary:disabled {
  background: #cbd5e1;
  border-color: #cbd5e1;
  color: #fff;
  cursor: not-allowed;
  box-shadow: none;
}

/* Required field visual feedback */
.appt-input.is-missing,
.appt-time-input.is-missing {
  border-color: #ef4444 !important;
  background: #fef2f2;
}
.appt-input.is-missing:focus,
.appt-time-input.is-missing:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
.appt-label.is-missing {
  color: #b91c1c;
}
.appt-label.is-missing::after {
  content: ' *';
  color: #ef4444;
  font-weight: 700;
}

/* ─── Citas en el calendario (distintas a tareas) ────────────────── */
.cal-task-pill.is-appointment {
  background: rgba(16, 185, 129, 0.12);
  border-left: 3px solid #10b981;
  color: #065f46;
  font-weight: 500;
}
.cal-task-pill.is-appointment:hover {
  background: rgba(16, 185, 129, 0.2);
}
.cal-task-pill.is-appointment.is-completed {
  opacity: 0.55;
  text-decoration: line-through;
}

/* ═══════════════════════════════════════════════════════════════
   BOT BUILDER — Vista Editable (DAG canvas estilo n8n/Kommo)
   ═══════════════════════════════════════════════════════════════ */
.bb-ve-wrap {
  display: grid;
  grid-template-columns: 240px 1fr 320px;
  height: calc(100vh - 200px);
  min-height: 520px;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #0e162a;
}

/* ── Vista Editable "en construcción" ── */
.bb-view-tab--soon { opacity: .75; }
.bb-soon-badge { font-size: 11px; margin-left: 2px; }
.bb-view-content[data-view="editable"] { position: relative; }
/* El editor detrás queda difuminado y no interactivo. */
.bb-view-content[data-view="editable"] .bb-ve-wrap[aria-hidden="true"] {
  filter: blur(3px) grayscale(.4); opacity: .5; pointer-events: none; user-select: none;
}
.bb-ve-construction {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.bb-ve-construction-card {
  background: #fff; border: 1px solid var(--border, #e2e8f0); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.12);
  padding: 32px 36px; max-width: 460px; text-align: center;
}
.bb-ve-construction-emoji { font-size: 48px; line-height: 1; margin-bottom: 12px; }
.bb-ve-construction-card h3 { margin: 0 0 8px; font-size: 19px; color: #0f172a; }
.bb-ve-construction-card p { margin: 0 0 18px; font-size: 14px; color: #475569; line-height: 1.5; }
.bb-ve-wrap.no-inspector { grid-template-columns: 240px 1fr; }

.bb-ve-sidebar { background: #152038; border-right: 1px solid #25334f; overflow-y: auto; }
.bb-ve-sidebar-search {
  padding: 12px 14px;
  border-bottom: 1px solid #25334f;
  position: sticky; top: 0;
  background: #152038;
  z-index: 5;
  display: flex; align-items: center; gap: 8px;
}
.bb-ve-sidebar-search svg { color: #94a3b8; flex-shrink: 0; }
.bb-ve-sidebar-search input {
  flex: 1; background: #0b1220; border: 1px solid #25334f; border-radius: 6px;
  color: #e2e8f0; padding: 6px 9px; font-size: 12px;
}
.bb-ve-sidebar-group { padding: 12px 10px 4px; }
.bb-ve-sidebar-group h5 {
  font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  color: #94a3b8; margin: 0 0 6px; padding: 0 6px; font-weight: 600;
}
.bb-ve-step-tpl {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 6px;
  background: transparent; border: 1px solid transparent;
  cursor: grab; transition: background .15s, border-color .15s;
  user-select: none; color: #e2e8f0;
}
.bb-ve-step-tpl:hover { background: #1d2a48; border-color: #25334f; }
.bb-ve-step-tpl:active { cursor: grabbing; }
.bb-ve-step-tpl.is-dragging { opacity: .35; }
.bb-ve-step-tpl-ico {
  width: 22px; height: 22px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: #94a3b8;
}
.bb-ve-step-tpl-ico svg { width: 14px; height: 14px; }
.bb-ve-step-tpl-name { font-size: 12px; font-weight: 500; }

/* Canvas central */
.bb-ve-canvas-wrap {
  position: relative; overflow: hidden;
  background: #0e162a;
  background-image: radial-gradient(circle, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;
}

/* Botón Pantalla completa — esquina superior derecha del canvas */
.bb-ve-fs-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 30;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(21, 32, 56, 0.92);
  color: #cbd5e1;
  border: 1px solid #25334f;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  transition: background .15s, color .15s, border-color .15s, transform .12s;
  padding: 0;
}
.bb-ve-fs-btn:hover {
  background: rgba(59, 130, 246, 0.95);
  color: #fff;
  border-color: rgba(59, 130, 246, 0.95);
  transform: scale(1.04);
}
.bb-ve-fs-btn .bb-ve-fs-ico-compress { display: none; }
body.bb-ve-fullscreen-on .bb-ve-fs-btn .bb-ve-fs-ico-expand { display: none; }
body.bb-ve-fullscreen-on .bb-ve-fs-btn .bb-ve-fs-ico-compress { display: block; }

/* ─── Modo Pantalla Completa ───
   Cuando body tiene .bb-ve-fullscreen-on, la vista Editable ocupa toda la
   pantalla: oculta nav lateral, top header del builder, y los tabs.
   Salir con click en el botón o tecla Esc. */
body.bb-ve-fullscreen-on {
  overflow: hidden;
}

/* ─── Modo Standalone (ventana nueva) ───
   Cuando body tiene .bot-editor-standalone, oculta TODO menos el bot builder
   en vista Editable. Es similar al fullscreen pero permanente — el botón
   "expandir" del editor se oculta porque ya estás en modo dedicado. */
body.bot-editor-standalone {
  overflow: hidden;
}
body.bot-editor-standalone .nav-bar,
body.bot-editor-standalone .rh-top-nav,
body.bot-editor-standalone .mobile-bottom-nav,
body.bot-editor-standalone .top-mobile-bar,
body.bot-editor-standalone #rhPushCta,
body.bot-editor-standalone .impersonation-floating-btn,
body.bot-editor-standalone #botListView {
  display: none !important;
}
body.bot-editor-standalone .app-shell,
body.bot-editor-standalone .app-shell > * {
  margin: 0 !important;
  padding: 0 !important;
}
body.bot-editor-standalone .view[data-view-name="bot"],
body.bot-editor-standalone #botBuilder {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  background: #0e162a;
  z-index: 9000;
  overflow: hidden;
}
body.bot-editor-standalone .bb-view-tabs,
body.bot-editor-standalone .bb-builder-header,
body.bot-editor-standalone .bb-view-content:not([data-view="editable"]) {
  display: none !important;
}
body.bot-editor-standalone .bb-view-content[data-view="editable"] {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  align-items: stretch !important;
}
body.bot-editor-standalone .bb-ve-wrap {
  height: 100vh !important;
  min-height: 100vh !important;
  width: 100vw !important;
  border-radius: 0 !important;
  border: none !important;
}
/* En modo standalone, ocultar el botón "expandir" del canvas — ya estás en
   modo dedicado, no tiene sentido seguir expandiendo. */
body.bot-editor-standalone .bb-ve-fs-btn {
  display: none !important;
}
body.bb-ve-fullscreen-on .nav-bar,
body.bb-ve-fullscreen-on .rh-top-nav,
body.bb-ve-fullscreen-on .mobile-bottom-nav,
body.bb-ve-fullscreen-on .top-mobile-bar,
body.bb-ve-fullscreen-on #rhPushCta,
body.bb-ve-fullscreen-on .impersonation-floating-btn {
  display: none !important;
}
body.bb-ve-fullscreen-on .view[data-view-name="bot"],
body.bb-ve-fullscreen-on .view[data-view-name="bot"] .view-content,
body.bb-ve-fullscreen-on .view[data-view-name="bot"] .bot-builder {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  max-width: none;
  width: 100vw;
  height: 100vh;
  z-index: 9000;
  background: #0e162a;
  overflow: hidden;
}
/* Ocultar el resto del builder cuando estamos en fullscreen — solo el canvas
   editable se ve. Los tabs/header del builder se esconden. */
body.bb-ve-fullscreen-on .bb-view-tabs,
body.bb-ve-fullscreen-on .bb-builder-header,
body.bb-ve-fullscreen-on .bb-view-content:not([data-view="editable"]) {
  display: none !important;
}
body.bb-ve-fullscreen-on .bb-view-content[data-view="editable"] {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
body.bb-ve-fullscreen-on .bb-ve-wrap {
  height: 100vh !important;
  min-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
}
.bb-ve-canvas {
  position: absolute; inset: 0;
  transform-origin: 0 0;
  overflow: visible;
  cursor: grab;
}
.bb-ve-canvas.is-panning { cursor: grabbing; }
.bb-ve-connections, .bb-ve-nodes {
  position: absolute; inset: 0; overflow: visible;
  pointer-events: none;
}
.bb-ve-nodes > * { pointer-events: auto; }
.bb-ve-connections { z-index: 1; }
.bb-ve-nodes { z-index: 2; }
.bb-ve-helper {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; color: #94a3b8; pointer-events: none;
}
.bb-ve-helper h3 { color: #e2e8f0; margin: 0 0 6px; font-size: 16px; }

/* Nodos */
.bb-ve-node {
  position: absolute; width: 240px;
  background: #152038;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,.4), 0 0 0 1px #25334f;
  user-select: none;
  will-change: transform;
  transition: box-shadow .12s;
}
.bb-ve-node * { user-select: none; }
.bb-ve-node.is-selected { box-shadow: 0 6px 24px rgba(59,130,246,.35), 0 0 0 2px #3b82f6; }
.bb-ve-node.is-dragging { z-index: 100; cursor: grabbing !important; }
.bb-ve-node-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid #25334f;
  cursor: grab;
}
.bb-ve-node-icon {
  width: 28px; height: 28px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.bb-ve-node-icon svg { width: 16px; height: 16px; }
.bb-ve-node-title {
  font-weight: 600; font-size: 13px; color: #e2e8f0;
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bb-ve-node-type {
  font-size: 10px; color: #94a3b8;
  text-transform: uppercase; letter-spacing: .04em;
}
.bb-ve-node-body {
  padding: 10px 12px; font-size: 12px; color: #94a3b8;
  min-height: 20px; line-height: 1.5;
}
.bb-ve-node-empty { font-style: italic; opacity: .6; }
.bb-ve-trigger-badge {
  position: absolute; top: -8px; left: 12px;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  color: #fff; font-size: 9px; font-weight: 700;
  padding: 2px 7px; border-radius: 99px;
  letter-spacing: .06em;
  box-shadow: 0 2px 6px rgba(59,130,246,.4);
}

/* Colores por grupo (mismos que el prototipo) */
.bb-ve-node.grp-trigger { background: linear-gradient(135deg, rgba(59,130,246,.08), #152038); }
.bb-ve-node.grp-trigger .bb-ve-node-icon { background: rgba(59,130,246,.2); color: #60a5fa; }
.bb-ve-node.grp-messages .bb-ve-node-icon { background: rgba(34,197,94,.18); color: #86efac; }
.bb-ve-node.grp-logic .bb-ve-node-icon { background: rgba(168,85,247,.2); color: #c084fc; }
.bb-ve-node.grp-crm .bb-ve-node-icon { background: rgba(249,115,22,.18); color: #fb923c; }
.bb-ve-node.grp-appointments .bb-ve-node-icon { background: rgba(20,184,166,.2); color: #5eead4; }
.bb-ve-node.grp-advanced .bb-ve-node-icon { background: rgba(148,163,184,.2); color: #cbd5e1; }

/* Puertos */
.bb-ve-port {
  position: absolute; width: 14px; height: 14px;
  border-radius: 50%; background: #1d2a48;
  border: 2px solid #364876; cursor: crosshair;
  transition: transform .15s, background .15s;
  z-index: 3;
}
.bb-ve-port:hover, .bb-ve-port.is-target { background: #3b82f6; border-color: #60a5fa; transform: scale(1.3); }
.bb-ve-port-in { top: 50%; left: -7px; transform: translateY(-50%); }
.bb-ve-port-out { top: 50%; right: -7px; transform: translateY(-50%); }

/* Connections */
.bb-ve-connections path.bb-ve-conn {
  stroke: #64748b; stroke-width: 2.5; fill: none;
  pointer-events: stroke;
  stroke-linejoin: round; stroke-linecap: round;
  transition: stroke .15s;
}
.bb-ve-connections path.bb-ve-conn:hover { stroke: #3b82f6; cursor: pointer; }
.bb-ve-connections path.bb-ve-conn.is-temp { stroke: #3b82f6; stroke-dasharray: 5 5; pointer-events: none; }
.bb-ve-connections path.bb-ve-conn-hit { stroke: transparent; stroke-width: 14; fill: none; pointer-events: stroke; cursor: pointer; }
.bb-ve-connections .bb-ve-plus { opacity: 0; cursor: pointer; transition: opacity .15s; pointer-events: all; }
.bb-ve-connections:hover .bb-ve-plus { opacity: .55; }
.bb-ve-connections .bb-ve-plus:hover { opacity: 1; filter: drop-shadow(0 0 6px rgba(59,130,246,.6)); }
.bb-ve-connections .bb-ve-plus:hover circle { r: 14; }

/* Zoom controls */
.bb-ve-controls {
  position: absolute; bottom: 12px; left: 12px;
  display: flex; flex-direction: column; gap: 4px;
  background: #152038; border: 1px solid #25334f;
  border-radius: 8px; padding: 4px;
  z-index: 5;
}
.bb-ve-ctrl-btn {
  background: transparent; border: 0; color: #94a3b8;
  padding: 6px 10px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; cursor: pointer;
  min-width: 42px;
}
.bb-ve-ctrl-btn:hover { background: #1d2a48; color: #e2e8f0; }

/* Minimap */
.bb-ve-minimap {
  position: absolute; bottom: 12px; right: 12px;
  width: 180px; height: 110px;
  background: #152038; border: 1px solid #25334f;
  border-radius: 8px; overflow: hidden; z-index: 5;
}
.bb-ve-minimap svg { display: block; }
.bb-ve-mm-bg { fill: #0e162a; }
.bb-ve-mm-node { fill: #3b82f6; opacity: .6; }

/* Inspector */
.bb-ve-inspector {
  background: #152038; border-left: 1px solid #25334f;
  display: flex; flex-direction: column; overflow: hidden;
}
.bb-ve-inspector-head {
  padding: 14px 16px; border-bottom: 1px solid #25334f;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.bb-ve-inspector-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.bb-ve-inspector-icon {
  width: 32px; height: 32px; border-radius: 7px;
  background: rgba(59,130,246,.2); color: #60a5fa;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.bb-ve-inspector-icon svg { width: 17px; height: 17px; }
.bb-ve-inspector-head h3 { font-size: 14px; font-weight: 600; margin: 0; color: #e2e8f0; }
.bb-ve-inspector-type { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: #94a3b8; margin-top: 2px; }
.bb-ve-inspector-close {
  background: transparent; border: 0; color: #94a3b8;
  font-size: 18px; padding: 4px 8px; border-radius: 4px; cursor: pointer;
}
.bb-ve-inspector-close:hover { background: #1d2a48; color: #e2e8f0; }
.bb-ve-inspector-body {
  flex: 1; overflow-y: auto; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 14px;
}
/* Cuando contiene la trigger card del builder, usar fondo claro para que la
   card se vea correcta (su CSS asume fondo blanco). */
.bb-ve-inspector-body:has(.sb-trigger-card) {
  background: #f8fafc;
  color: #0f172a;
  padding: 12px;
}
.bb-ve-inspector-body .sb-trigger-card {
  margin: 0;
  width: 100%;
  box-shadow: none;
}
.bb-ve-inspector-foot { padding: 12px 16px; border-top: 1px solid #25334f; }
.bb-ve-field { display: flex; flex-direction: column; gap: 4px; }
.bb-ve-field-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: #94a3b8;
}
.bb-ve-input, .bb-ve-textarea, .bb-ve-select {
  width: 100%; background: #0b1220; border: 1px solid #25334f;
  border-radius: 6px; color: #e2e8f0; padding: 7px 10px;
  font-size: 13px; font-family: inherit;
}
.bb-ve-textarea { min-height: 70px; resize: vertical; }
.bb-ve-input:focus, .bb-ve-textarea:focus, .bb-ve-select:focus {
  outline: none; border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* Chat: drag-and-drop de archivos */
.rh-conversation-panel { position: relative; }
.rh-conversation-panel.rh-chat-dragover::after {
  content: '📎  Suelta el archivo aquí para enviarlo';
  position: absolute;
  inset: 0;
  background: rgba(59, 130, 246, 0.18);
  border: 3px dashed #3b82f6;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: #1e40af;
  z-index: 50;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

/* Sección "Campos personalizados" en detalle de lead — scroll interno cuando hay muchos */
.exp-detail-section--custom-fields .exp-detail-section-scroll {
  max-height: 360px;
  overflow-y: auto;
}

/* ─── Productos enviados al lead (módulo catalog) ─── */
.exp-detail-products {
  margin: 0;
}
.exp-products-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.exp-product-item {
  padding: 10px 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  background: #fff;
}
.exp-product-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #0f172a);
}
.exp-product-meta {
  font-size: 11px;
  color: var(--text-muted, #94a3b8);
  margin-top: 2px;
}
.exp-products-more {
  font-size: 12px;
  color: var(--text-muted, #94a3b8);
  margin-top: 6px;
  text-align: center;
}
.exp-detail-section--custom-fields .exp-detail-section-scroll::-webkit-scrollbar { width: 8px; }
.exp-detail-section--custom-fields .exp-detail-section-scroll::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 4px;
}
.exp-detail-section--custom-fields .exp-detail-section-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
.exp-detail-count-pill {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0;
  text-transform: none;
}
/* Sticky title cuando se scrollea adentro */
.exp-detail-section--custom-fields .exp-detail-section-title {
  position: sticky;
  top: 0;
  z-index: 2;
}

/* ─── Live Support (co-browsing) ─── */
.live-support-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  background: var(--bg-soft, #fafafa);
  margin-bottom: 22px;
}
.ls-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.ls-icon {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
}
.ls-text h3 {
  margin: 0 0 4px 0;
  font-size: 16px;
}
.ls-text p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.ls-text code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.ls-actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
}
.ls-active-banner {
  margin-top: 16px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 3px solid #e02d2d;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.ls-rec {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #e02d2d;
}
.ls-rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e02d2d;
  animation: lsRecPulse 1.4s ease-in-out infinite;
}
@keyframes lsRecPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.8); }
}
.ls-code-display {
  font-size: 13px;
  color: var(--text-muted);
}
.ls-code-display strong {
  font-family: ui-monospace, SFMono-Regular, monospace;
  color: var(--text);
  font-size: 14px;
  letter-spacing: 1px;
}
.ls-stats {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}
.ls-code-big {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 48px;
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--accent);
  background: var(--bg-soft, #fafafa);
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 24px 12px;
  user-select: all;
}

/* Banner global persistente (top de la pantalla cuando hay sesión activa) */
.ls-global-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #e02d2d;
  color: #fff;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.ls-global-banner button {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.ls-global-banner button:hover {
  background: rgba(255,255,255,0.3);
}

/* ─── Live Support: Viewer (super-admin) ─── */
.ls-viewer-wrap {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #1a1a1a;
}
.ls-viewer-bar {
  background: #2a2a2a;
  color: #fff;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid #444;
  font-size: 13px;
}
.ls-viewer-bar .ls-viewer-title {
  font-weight: 600;
}
.ls-viewer-bar .ls-viewer-meta {
  color: #aaa;
  font-size: 12px;
}
.ls-viewer-bar .ls-viewer-spacer { flex: 1; }
.ls-viewer-stage {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: #fff;
}
.ls-viewer-iframe-host {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}
.ls-viewer-status {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #888;
  font-size: 14px;
  text-align: center;
}
.ls-active-list {
  padding: 20px;
}
.ls-active-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: #fff;
}
.ls-active-row .ls-active-code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
  letter-spacing: 2px;
}
.ls-active-row .ls-active-info {
  flex: 1;
}
.ls-active-row .ls-active-tenant {
  font-weight: 600;
  font-size: 14px;
}
.ls-active-row .ls-active-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Híbrido IA + Bots: card en Settings → IA ─── */
.ia-hybrid-card { border-left: 3px solid var(--accent); }
.hybrid-toggle-row { margin-bottom: 8px; }
.hybrid-toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  padding: 10px;
  border-radius: 8px;
  transition: background 0.15s;
}
.hybrid-toggle:hover { background: var(--bg-soft, #f6f7f7); }
.hybrid-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.hybrid-toggle-slider {
  position: relative;
  flex: 0 0 38px;
  width: 38px;
  height: 22px;
  background: #ccc;
  border-radius: 11px;
  transition: background 0.2s;
  margin-top: 2px;
}
.hybrid-toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.hybrid-toggle input:checked ~ .hybrid-toggle-slider { background: var(--accent); }
.hybrid-toggle input:checked ~ .hybrid-toggle-slider::after { transform: translateX(16px); }
.hybrid-toggle-text strong { display: block; margin-bottom: 2px; font-size: 14px; }
.hybrid-toggle-text small { color: var(--text-muted); font-size: 12px; line-height: 1.4; }

/* ─── Owner badge en chat header ─── */
.rh-owner-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-soft, #f6f7f7);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.rh-owner-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.rh-owner-badge[data-owner="human"]      .rh-owner-icon,
.rh-owner-badge[data-owner="human_lock"] .rh-owner-icon { background: #2196f3; }
.rh-owner-badge[data-owner="bot_running"] .rh-owner-icon { background: #ff9800; }
.rh-owner-badge[data-owner="ai_active"]   .rh-owner-icon { background: #4caf50; }
.rh-owner-badge[data-owner="idle"]        .rh-owner-icon { background: #999; }
.rh-owner-label { font-weight: 600; }
.rh-owner-meta { color: var(--text-muted); flex: 1; font-size: 12px; }
.rh-owner-actions { display: flex; gap: 6px; }
.rh-owner-btn {
  background: #fff;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.rh-owner-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── Diagrama del wait_response (árbol bifurcado) ─── */
.sb-wait-tree-diagram {
  margin: 12px 0;
  padding: 12px;
  background: var(--bg-soft, #f6f7f7);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.sb-wait-tree-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}
.sb-wait-tree-branches {
  display: flex;
  gap: 10px;
  flex-direction: column;
}
.sb-wait-tree-branch {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: #fff;
  border-radius: 6px;
  border-left: 3px solid;
  align-items: flex-start;
}
.sb-wait-tree-branch--reply   { border-left-color: #2196f3; }
.sb-wait-tree-branch--timeout { border-left-color: #ff9800; }
.sb-wait-tree-branch-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.sb-wait-tree-branch strong {
  display: block;
  font-size: 12px;
  margin-bottom: 2px;
}
.sb-wait-tree-branch span {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}
.sb-wait-tree-branch em {
  font-style: normal;
  font-weight: 600;
  color: var(--accent);
}

/* ─── KB Modal: zona de upload de archivos ─── */
.kb-upload-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px 20px;
  text-align: center;
  background: var(--bg-soft, #fafafa);
  transition: all 0.2s;
  margin-bottom: 14px;
}
.kb-upload-zone.is-dragover {
  border-color: var(--accent);
  background: rgba(0,102,204,0.05);
  transform: scale(1.005);
}
.kb-upload-icon {
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  justify-content: center;
}
.kb-upload-zone.is-dragover .kb-upload-icon { color: var(--accent); }
.kb-upload-text strong {
  display: block;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}
.kb-upload-text span {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.kb-upload-text small {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.8;
}
.kb-upload-link {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  font-weight: 500;
}
.kb-upload-link:hover { color: var(--accent-hover, #0050a0); }

.kb-upload-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  margin-top: 12px;
  text-align: left;
}
.kb-upload-file svg { flex-shrink: 0; color: var(--accent); }
.kb-upload-file span:not(.kb-upload-file-size) { flex: 1; font-weight: 500; }
.kb-upload-file-size {
  color: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.kb-upload-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.kb-upload-remove:hover { color: #ef4444; }

.kb-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 12px;
}
.kb-divider::before, .kb-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.kb-divider span { padding: 0 4px; }

.kb-required { color: #ef4444; }

.kb-char-counter {
  display: block;
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.kb-char-counter.is-large { color: #ff9800; }
.kb-char-counter.is-huge  { color: #ef4444; }

/* ─── KB list: botón eliminar + contador chars ─── */
.kb-item-head { display: flex; align-items: center; gap: 8px; }
.kb-item-chars {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.kb-item-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.kb-item-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}
.kb-item-delete:active { transform: scale(0.95); }

/* ─── Badge "Incompatible con coordinador" en lista de bots ─── */
.bot-incompatible-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  margin-left: 6px;
  white-space: nowrap;
  cursor: help;
}
.bot-incompatible-badge:hover { background: #fee2e2; }

/* ─── Bot Builder: Trigger keyword chips + mode ─── */
.sb-kw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  min-height: 44px;
  cursor: text;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sb-kw-chips:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}
.sb-kw-chips > div { display: contents; }
.sb-kw-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  max-width: 100%;
  word-break: break-word;
}
.sb-kw-chip-remove {
  background: none;
  border: none;
  padding: 0 2px;
  cursor: pointer;
  color: #1d4ed8;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  opacity: 0.6;
}
.sb-kw-chip-remove:hover { opacity: 1; color: #dc2626; }
.sb-kw-chips input {
  flex: 1;
  min-width: 140px;
  border: none !important;
  outline: none !important;
  padding: 4px 2px !important;
  font-size: 13px;
  background: transparent !important;
  font-family: inherit;
}

/* Modo de match (radio buttons) */
.sb-kw-mode {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding: 10px;
  background: var(--bg-soft, #f6f7f7);
  border-radius: 8px;
}
.sb-kw-mode-opt {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.sb-kw-mode-opt:hover { background: rgba(0,0,0,0.03); }
.sb-kw-mode-opt input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--accent);
}
.sb-kw-mode-opt span {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}
.sb-kw-mode-opt strong { font-size: 13px; }
.sb-kw-mode-opt small {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}
.sb-kw-mode-opt em { font-style: normal; font-weight: 600; color: var(--text); }

/* ─── Card de consumo IA ─── */
.ai-credit-card { border-left: 3px solid #10b981; }
.ai-credit-loading { padding: 18px 4px; color: var(--text-muted); font-size: 13px; }

.ai-credit-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.ai-credit-stat {
  flex: 1;
  min-width: 130px;
  background: var(--bg-soft, #f6f7f7);
  border-radius: 10px;
  padding: 12px 14px;
}
.ai-credit-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.ai-credit-stat-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.ai-credit-stat-foot {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.ai-credit-bar-wrap {
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
  height: 10px;
  margin: 8px 0 14px;
}
.ai-credit-bar {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  transition: width 0.6s ease;
}
.ai-credit-bar.is-warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.ai-credit-bar.is-danger { background: linear-gradient(90deg, #ef4444, #f87171); }

.ai-credit-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
.ai-credit-breakdown-block strong {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.ai-credit-breakdown-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.ai-credit-breakdown-row:last-child { border: none; }
.ai-credit-breakdown-row span:last-child { color: var(--text-muted); font-variant-numeric: tabular-nums; }

.ai-credit-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.ai-credit-alert {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 14px;
}
.ai-credit-alert.is-warn {
  background: #fef3c7;
  border-color: #fbbf24;
  color: #92400e;
}

/* ─── Badge "Choca con N bots" (conflicto de keywords) ─── */
.bot-conflict-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fdba74;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  margin-left: 6px;
  white-space: nowrap;
  cursor: help;
}
.bot-conflict-badge:hover { background: #ffedd5; }
.bulk-job-bar-pause {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-right: 4px;
  transition: background .15s;
}
.bulk-job-bar-pause:hover { background: rgba(255,255,255,0.12); }
.bulk-job-bar-pause.is-paused { background: rgba(34,197,94,0.25); border-color: rgba(34,197,94,0.6); }
.kb-item-download {
  background: transparent;
  border: 1px solid var(--border, #e5e7eb);
  color: #3b82f6;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-right: 4px;
  transition: all .15s;
}
.kb-item-download:hover { background: #dbeafe; border-color: #3b82f6; }

/* ─── Elegir grupos de WhatsApp que entran al CRM ─── */
.wa-groups-intro { font-size: 13px; line-height: 1.6; color: var(--text-soft, #475569); margin: 0 0 10px; }
.wa-groups-warn {
  font-size: 12.5px; line-height: 1.5; margin: 0 0 16px; padding: 10px 12px;
  border-radius: 8px; background: rgba(37, 99, 235, .08);
  border: 1px solid rgba(37, 99, 235, .25); color: #1e40af;
}
.wa-groups-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; }
.wa-groups-empty { font-size: 13px; color: var(--text-muted, #64748b); padding: 16px 2px; margin: 0; text-align: center; }
.wa-group-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border, #e2e8f0); border-radius: 8px; cursor: pointer;
}
.wa-group-row:hover { background: var(--bg, #f8fafc); }
.wa-group-row input { flex-shrink: 0; width: 16px; height: 16px; cursor: pointer; }
.wa-group-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 500; color: var(--text, #0f172a);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-group-count { flex-shrink: 0; font-size: 11.5px; color: var(--text-muted, #64748b);
  background: var(--bg, #f1f5f9); border-radius: 999px; padding: 2px 8px; }

/* ─── Burbuja flotante de soporte (WhatsApp con Luis) ─── */
.wa-support-bubble {
  position: fixed;
  right: 20px;
  bottom: 84px;              /* arriba de la barra de escribir en Chats */
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 0;
  height: 52px;
  padding: 0;
  border-radius: 999px;
  background: #25D366;
  color: #fff;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(37, 211, 102, .35), 0 2px 6px rgba(0,0,0,.15);
  transition: box-shadow .15s, transform .15s;
}
.wa-support-bubble[hidden] { display: none; }
.wa-support-bubble:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(37, 211, 102, .45), 0 3px 8px rgba(0,0,0,.18); }
.wa-support-icon { width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.wa-support-label {
  max-width: 0; overflow: hidden; white-space: nowrap;
  font-size: 13.5px; font-weight: 600; padding-left: 0;
  transition: max-width .25s ease, padding .25s ease;
}
.wa-support-bubble:hover .wa-support-label,
.wa-support-bubble:focus-visible .wa-support-label { max-width: 180px; padding-left: 16px; }
@media (max-width: 720px) {
  .wa-support-bubble { right: 14px; bottom: 96px; height: 46px; }
  .wa-support-icon { width: 46px; height: 46px; }
  .wa-support-label { display: none; }
}

/* ─── Monitor › Visitantes (feed estilo reelance /admin/logs) ─── */
.mon-vis-toolbar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 10px 4px 6px; }
.mon-vis-range, .mon-vis-countries { display: flex; flex-wrap: wrap; gap: 6px; }
.mon-vis-chip {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border, #e2e8f0); background: transparent; color: var(--text-soft, #475569);
}
.mon-vis-chip.is-active { background: var(--accent, #2563eb); border-color: var(--accent, #2563eb); color: #fff; }
.mon-vis-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; padding: 4px 4px 12px; }
.mon-vis-stat { background: var(--bg, #f8fafc); border: 1px solid var(--border, #e2e8f0); border-radius: 10px; padding: 10px 12px; }
.mon-vis-stat b { display: block; font-size: 20px; color: var(--text, #0f172a); }
.mon-vis-stat span { font-size: 11.5px; color: var(--text-muted, #64748b); }
.mon-vis-row { border: 1px solid var(--border, #e2e8f0); border-radius: 10px; margin: 0 4px 8px; background: #fff; }
.mon-vis-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; }
.mon-vis-head:hover { background: var(--bg, #f8fafc); }
.mon-vis-flag { font-size: 18px; flex-shrink: 0; }
.mon-vis-main { flex: 1; min-width: 0; }
.mon-vis-title { font-size: 13px; font-weight: 600; color: var(--text, #0f172a); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mon-vis-meta { font-size: 11.5px; color: var(--text-muted, #64748b); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mon-vis-count { font-size: 11.5px; color: var(--text-soft, #475569); background: var(--bg, #f1f5f9); border-radius: 999px; padding: 2px 8px; flex-shrink: 0; }
.mon-vis-pages { display: none; border-top: 1px solid var(--border, #f1f5f9); padding: 6px 12px 8px 40px; }
.mon-vis-row.is-open .mon-vis-pages { display: block; }
.mon-vis-page { display: flex; gap: 10px; font-size: 12px; padding: 3px 0; color: var(--text-soft, #475569); }
.mon-vis-page time { flex-shrink: 0; color: var(--text-muted, #94a3b8); font-variant-numeric: tabular-nums; }
.mon-vis-page code { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--text, #0f172a); }
