/* ══════════════════════════════════════════
   ATINOV — Panel
   Marca "El visto" (11-11-2026, ver ATINOV.md §3): barra lateral en noche
   con el logo en hueso · contenido en hueso con tarjetas blancas y texto en
   tinta · el ámbar solo en la opción activa del menú, la acción principal
   de una pantalla y los subrayados · títulos en Bricolage Grotesque, texto
   en Instrument Sans. Las letras se cargan desde el <head> de index.html.
══════════════════════════════════════════ */

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

:root {
  /* ── Marca */
  --tinta: #141310;
  --noche: #0D0D0B;
  --hueso: #F5F2EA;
  --ambar: #FFB000;
  --display: 'Bricolage Grotesque', 'Instrument Sans', system-ui, sans-serif;

  /* Acento personalizable por el cliente (Ajustes → Apariencia).
     El tema se aplica seteando estas vars en :root desde JS (setTheme en
     main.js); el script del <head> aplica el tema guardado. Estos valores
     son el tema por defecto = la marca: acción principal en TINTA. Los
     temas de color (esmeralda, azul…) siguen disponibles como opción. */
  --accent:      #141310;
  --accent-dark: #000000;
  --accent-bg:   #ECE8DD;
  --on-accent:   #F5F2EA;   /* texto sobre el acento */
  --orange:    #141310;   /* alias histórico del acento — lo usa media app */
  --orange-2:  #6F6A5E;
  --orange-bg: rgba(20, 19, 16, 0.06);
  --grad:      linear-gradient(135deg, #141310 0%, #2B2922 100%);
  --grad-soft: linear-gradient(135deg, rgba(255,176,0,.14) 0%, rgba(255,176,0,.05) 100%);

  /* ── Sidebar: en noche en todos los temas */
  --sidebar-bg:      #0D0D0B;
  --sidebar-border:  rgba(245,242,234,.09);
  --sidebar-text:    rgba(245,242,234,.62);
  --sidebar-text-strong: #F5F2EA;
  --sidebar-active-bg:   rgba(255,176,0,.16);
  --sidebar-active-text: #FFB000;
  --sidebar-hover-bg:  rgba(245,242,234,.07);
  --sidebar-w: 240px;

  /* ── Content */
  --bg:       #F5F2EA;
  --surface:  #ffffff;
  --surface-2:#FAF8F3;
  --card:     var(--surface);
  --border:   rgba(20,19,16,.13);
  --border-2: rgba(20,19,16,.07);

  /* ── Text */
  --text-1:   #141310;
  --text-2:   #6F6A5E;
  --text-3:   #7B7567;

  /* ── Status (estados, no marca) */
  --green:    #10b981;
  --red:      #ef4444;
  --blue:     #3b82f6;

  /* ── Shapes */
  --radius:    14px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(20,19,16,.04);
  --shadow:    0 1px 2px rgba(20,19,16,.04), 0 8px 24px rgba(20,19,16,.06);
  --shadow-md: 0 4px 8px rgba(20,19,16,.06), 0 20px 48px rgba(20,19,16,.10);
  --shadow-lg: 0 8px 16px rgba(20,19,16,.08), 0 32px 64px rgba(20,19,16,.14);
}

html, body {
  height: 100%;
  font-family: 'Instrument Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ══ LAYOUT ══════════════════════════════════════════════════════════════════ */
body { display: flex; }
#app-shell { display: flex; width: 100%; min-height: 100vh; }

/* ══ SIDEBAR ══════════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  border-right: 1px solid var(--sidebar-border);
}

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px 20px;
  border-bottom: 1px solid var(--sidebar-border);
}
/* Logo "El visto" (ATINOV.md §3): la palabra "atino" y la v final dibujada
   como visto bueno, del mismo color que las letras (currentColor). Peso 700
   y tamaño óptico 26 fijos, que es como se aprobó. Nunca lleva bajada. */
.atinov-logo {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-variation-settings: 'opsz' 26;
  letter-spacing: -.045em;
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
}
.atinov-logo svg { width: .7em; height: .92em; margin-left: .02em; overflow: visible; flex: none; }
.sidebar-logo .atinov-logo { font-size: 27px; color: var(--sidebar-text-strong); padding-top: 3px; }

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* El menú scrollea DENTRO de sí mismo. Sin esto, con 14 secciones y una
     pantalla de portátil, la navegación empujaba la cuenta y el botón de
     cerrar sesión fuera de la vista: existían, pero nadie los encontraba.
     min-height:0 es lo que permite que un hijo flex se encoja bajo su
     contenido — sin eso, overflow-y no hace nada. */
  overflow-y: auto;
  min-height: 0;
}
/* Barra de scroll discreta: que se note que hay más, sin ensuciar. */
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(245, 242, 234, .22);
  border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }

/* La cuenta y el cerrar sesión quedan clavados al pie, pase lo que pase. */
.sidebar-account, .sidebar-logout { flex-shrink: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 13.5px;
  text-decoration: none;
  transition: background .15s, color .15s;
  position: relative;
  letter-spacing: .01em;
}
.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-strong);
}
/* Opción activa: fondo ámbar muy suave y texto ámbar (sobre la noche se lee). */
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}
.nav-item.active .nav-icon { color: var(--sidebar-active-text); }

.nav-icon {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  opacity: .75;
  transition: opacity .15s;
}
.nav-item:hover .nav-icon { opacity: 1; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-icon svg { width: 16px; height: 16px; fill: currentColor; }

.nav-badge {
  margin-left: auto;
  background: var(--orange);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  display: none;
}
.nav-badge.show { display: block; }
/* El aviso de mensajes nuevos va dentro de la barra en noche: en el color de
   la opción activa (ámbar en el tema de la marca) con el número en tinta. El
   !important es porque index.html le pone el color en línea. */
.sidebar .nav-badge { background: var(--sidebar-active-text) !important; color: #141310 !important; }

/* Sidebar footer account */
.sidebar-account {
  padding: 14px 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--sidebar-text);
}
.account-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px rgba(16,185,129,.25);
  flex-shrink: 0;
}
#sidebar-user-name { font-weight: 600; font-size: 12px; color: var(--sidebar-text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sidebar-username  { font-size: 11px; color: var(--sidebar-text) !important; }

/* Cerrar sesión: fila propia con texto, al pie de la barra. Discreta pero
   legible — no compite con la navegación, pero se encuentra a la primera. */
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 20px);
  margin: 0 10px 12px;
  padding: 9px 12px;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-text);
  text-align: left;
  transition: background .15s, color .15s, border-color .15s;
}
.sidebar-logout svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .75; }
.sidebar-logout:hover {
  background: rgba(248, 113, 113, .12);
  border-color: rgba(248, 113, 113, .3);
  color: #fca5a5;
}
.sidebar-logout:hover svg { opacity: 1; }
.sidebar-logout:focus-visible {
  outline: 2px solid #fca5a5;
  outline-offset: 2px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 14px;
  padding: 5px;
  border-radius: var(--radius-xs);
  transition: color .15s, background .15s;
  line-height: 1;
}
.btn-icon:hover { color: #f87171; background: rgba(239,68,68,.1); }

/* ══ MAIN CONTENT ═════════════════════════════════════════════════════════════ */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  overflow-y: auto;
}

/* ══ SECTIONS ═════════════════════════════════════════════════════════════════ */
.section { display: none; padding: 36px 40px; }
.section.active { display: block; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}
.page-header h1 {
  font-family: var(--display);
  font-size: 27px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -.025em;
  line-height: 1.1;
  margin-bottom: 5px;
}
.page-header p { color: var(--text-2); font-size: 13.5px; line-height: 1.5; }

/* ══ BUTTONS ══════════════════════════════════════════════════════════════════ */
/* Acción principal: en tinta (o en el acento que eligió el cliente). */
.btn-primary {
  background: var(--accent);
  color: var(--on-accent, #F5F2EA);
  border: none;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
  letter-spacing: .01em;
  box-shadow: 0 1px 2px rgba(20,19,16,.08);
}
.btn-primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(20,19,16,.22);
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  font-weight: 500;
}
/* .btn-secondary se usa 61 veces y no tenía regla base en el tema claro (solo
   en .auth-screen y .theme-dark): se veía como botón gris del navegador.
   Segundo escaneo 12-09. */
.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(20,19,16,.04);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn-secondary:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: var(--orange-bg);
}
.btn-full { width: 100%; text-align: left; }
.btn-success {
  color: var(--green) !important;
  border-color: var(--green) !important;
}
.btn-success:hover {
  background: rgba(16,185,129,.08) !important;
  border-color: var(--green) !important;
  color: var(--green) !important;
}

/* ══ HOME ═════════════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
}
.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.stat-icon {
  width: 44px; height: 44px;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; fill: currentColor; }
.stat-val   { font-size: 28px; font-weight: 800; color: var(--text-1); letter-spacing: -.5px; line-height: 1; }
.stat-label { color: var(--text-3); font-size: 12px; font-weight: 500; margin-top: 3px; }

.home-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.home-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-sm);
}
.home-card h3 {
  margin-bottom: 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}
.home-card ol { padding-left: 18px; color: var(--text-2); line-height: 2.1; font-size: 13.5px; }
.home-card li strong { color: var(--text-1); font-weight: 600; }

.code-block {
  background: var(--sidebar-bg);
  border: 1px solid rgba(245,242,234,.1);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12.5px;
  color: #EDE9DF;
  word-break: break-all;
  letter-spacing: .01em;
}

/* ══ AGENTS ═══════════════════════════════════════════════════════════════════ */
.agents-layout {
  display: grid;
  grid-template-columns: 220px 1fr 300px;
  gap: 20px;
  align-items: start;
}
.agent-tabs-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.agent-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-2);
  transition: background .1s;
}
.agent-tab:last-child { border-bottom: none; }
.agent-tab:hover { background: var(--bg); }
.agent-tab.selected {
  background: var(--orange-bg);
  border-left: 3px solid var(--orange);
}
.agent-tab-avatar { font-size: 20px; }
.agent-tab-info   { flex: 1; min-width: 0; }
.agent-tab-name   { font-weight: 600; font-size: 13px; color: var(--text-1); }
.agent-tab-status { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.agent-tab-status.on { color: var(--green); }

.agent-builder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 500px;
  box-shadow: var(--shadow-sm);
}
.agent-builder-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 500px;
  color: var(--text-3);
  gap: 12px;
  font-size: 13.5px;
}

.builder-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.builder-tab {
  padding: 13px 22px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  transition: all .15s;
  letter-spacing: .01em;
}
.builder-tab.active { color: var(--orange); border-bottom-color: var(--orange); }

.builder-content { padding: 22px; }

.builder-sub-tabs { display: flex; gap: 6px; margin-bottom: 20px; }
.builder-sub-tab {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--border);
  transition: all .15s;
}
.builder-sub-tab.active {
  background: var(--orange-bg);
  color: var(--orange);
  border-color: var(--orange);
  font-weight: 600;
}

.instructions-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-1);
}
.instructions-area {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 280px;
  line-height: 1.65;
  color: var(--text-1);
  transition: border .15s, box-shadow .15s;
  background: var(--surface);
}
.instructions-area:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255,176,0,.28);
}

.agent-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}
.toggle { position: relative; width: 44px; height: 24px; cursor: pointer; }
.toggle input { display: none; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 12px;
  transition: background .2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: white;
  top: 3px; left: 3px;
  transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--orange); }
.toggle input:checked + .toggle-slider::after { transform: translateX(20px); }

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

.links-checkboxes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.link-checkbox {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s;
}
.link-checkbox input { accent-color: var(--orange); }
.link-checkbox:has(input:checked) {
  background: var(--orange-bg);
  border-color: var(--orange);
}

/* Live tester */
.agent-tester {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  height: 500px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.tester-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 13px;
  background: var(--surface-2);
}
.tester-status {
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
  margin-right: auto;
}
.tester-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}
.tester-hint { color: var(--text-3); font-size: 13px; text-align: center; margin: auto; }
.tester-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}
.tester-msg.user  { background: var(--surface); border: 1px solid var(--border); align-self: flex-end; border-radius: 14px 14px 4px 14px; }
.tester-msg.agent {
  background: var(--grad);
  color: white;
  align-self: flex-start;
  border-radius: 14px 14px 14px 4px;
  box-shadow: 0 2px 8px rgba(20,19,16,.16);
}
.tester-msg.loading { background: var(--surface); color: var(--text-3); align-self: flex-start; font-style: italic; border: 1px solid var(--border); }

.tester-classification {
  align-self: center;
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
}
.tester-input-row {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px;
  background: var(--surface);
}
.tester-input-row input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  background: var(--bg);
  transition: border .15s;
}
.tester-input-row input:focus {
  border-color: var(--orange);
  background: var(--surface);
}

/* ══ KNOWLEDGE ════════════════════════════════════════════════════════════════ */
.knowledge-list { display: flex; flex-direction: column; gap: 14px; }
.knowledge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.knowledge-card:hover { box-shadow: var(--shadow); }
.kc-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.kc-title  { font-weight: 700; font-size: 15px; color: var(--text-1); }
.kc-sub    { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.kc-actions { display: flex; gap: 8px; }
.kc-tag {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: var(--orange-bg);
  color: var(--orange);
  margin-bottom: 12px;
  letter-spacing: .02em;
}
.kc-content {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  max-height: 120px;
  overflow: hidden;
}
.kc-content.expanded { max-height: none; }
.kc-show-more { color: var(--orange); font-size: 12px; cursor: pointer; margin-top: 6px; display: inline-block; font-weight: 600; }
.kc-agents { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.kc-agent-badge {
  padding: 3px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}

/* ══ LEADS ════════════════════════════════════════════════════════════════════ */
.leads-tabs {
  display: flex; gap: 4px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.leads-tab {
  padding: 10px 22px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-2);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  transition: all .15s;
}
.leads-tab.active { color: var(--orange); border-bottom-color: var(--orange); }

.leads-filters {
  display: flex; gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-input {
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  min-width: 160px;
  background: var(--surface);
  transition: border .15s;
}
.filter-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,176,0,.28); }
.filter-select {
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  background: var(--surface);
  cursor: pointer;
  color: var(--text-1);
  transition: border .15s;
}
.filter-select:focus { border-color: var(--orange); }

.refresh-indicator { font-size: 12px; color: var(--text-3); font-style: italic; }

.leads-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.leads-table th {
  text-align: left;
  padding: 12px 18px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: .06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.leads-table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-2);
  font-size: 13.5px;
}
.leads-table tr:last-child td { border-bottom: none; }
.leads-table tr:hover td {
  background: rgba(20,19,16,.03);
  cursor: pointer;
}
.lead-handle { font-weight: 700; color: var(--text-1); }
.lead-time   { color: var(--text-3); font-size: 12px; }

.status-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot.automated { background: var(--green); box-shadow: 0 0 0 2px rgba(16,185,129,.2); }
.status-dot.manual    { background: var(--blue); }
.status-dot.paused    { background: var(--text-3); }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-green  { background: rgba(16,185,129,.1); color: #059669; border: 1px solid rgba(16,185,129,.2); }
.badge-orange { background: var(--orange-bg); color: var(--orange); border: 1px solid rgba(20,19,16,.14); }
.badge-gray   { background: var(--bg); color: var(--text-2); border: 1px solid var(--border); }
.badge-hot    { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.badge-warm   { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.badge-cold   { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }

.qualification-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}

/* ══ AUTH SCREEN ══════════════════════════════════════════════════════════════ */
/* Pantalla de entrada: un bloque en NOCHE con la luz ámbar suave de la
   marca. Acá "Entrar" es LA acción de la pantalla: va en ámbar con texto en
   tinta. Los colores van fijos (no dependen del tema elegido en Apariencia). */
.auth-screen {
  position: fixed; inset: 0;
  background: #0D0D0B;
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  overflow: hidden;
  padding: 16px;
}
.auth-screen::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(720px 520px at 0% 100%, rgba(255,176,0,.2), transparent 70%),
    radial-gradient(620px 520px at 100% 0%, rgba(120,84,20,.28), transparent 70%);
  pointer-events: none;
}

.auth-box {
  background: #171612;
  border: 1px solid rgba(245,242,234,.1);
  border-radius: 20px;
  padding: 42px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4), 0 2px 0 rgba(245,242,234,.04) inset;
  position: relative;
}
.auth-logo {
  font-size: 34px;
  color: #F5F2EA;
  margin-bottom: 22px;
  line-height: 1;
}
.auth-title {
  font-family: var(--display);
  font-size: 23px;
  font-weight: 700;
  margin-bottom: 5px;
  color: #F5F2EA;
  letter-spacing: -.025em;
}
.auth-sub {
  font-size: 13.5px;
  color: rgba(245,242,234,.62);
  margin-bottom: 28px;
  line-height: 1.55;
}
.auth-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(245,242,234,.14);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 12px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  background: rgba(245,242,234,.05);
  color: #F5F2EA;
}
.auth-input::placeholder { color: rgba(245,242,234,.42); }
.auth-input:focus {
  border-color: rgba(245,242,234,.45);
  box-shadow: 0 0 0 3px rgba(255,176,0,.22);
  background: rgba(245,242,234,.04);
}
.auth-btn { width: 100%; padding: 14px; font-size: 15px; font-weight: 600; margin-top: 6px; border-radius: 12px; }
.auth-screen .btn-primary { background: #FFB000; color: #141310; border: none; box-shadow: 0 8px 24px rgba(255,176,0,.2); }
.auth-screen .btn-primary:hover { background: #FFBB1F; box-shadow: 0 10px 28px rgba(255,176,0,.28); }
.auth-screen .btn-secondary { background: transparent; color: #F5F2EA; border: 1px solid rgba(245,242,234,.24); border-radius: 12px; }
.auth-screen .btn-secondary:hover { background: rgba(245,242,234,.07); border-color: rgba(245,242,234,.4); }
.auth-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: #f87171;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}
.auth-footer { text-align: center; font-size: 12.5px; color: rgba(245,242,234,.6); margin-top: 16px; }
/* Los enlaces de la entrada traen el color en línea (var(--orange) = tinta,
   que sobre la noche no se ve): acá van en hueso con la línea ámbar. */
.auth-screen a { color: #F5F2EA !important; text-decoration: underline; text-decoration-color: #FFB000; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.auth-screen a:hover { color: #FFB000 !important; }
.auth-screen [style*="--text-3"] { color: rgba(245,242,234,.58) !important; }
.auth-screen label, .auth-screen .auth-check { color: rgba(245,242,234,.75); }

/* ══ BYPASSED USERS ═══════════════════════════════════════════════════════════ */
.bypass-add { display: flex; gap: 10px; margin-bottom: 22px; }
.bypassed-list-table { display: flex; flex-direction: column; gap: 8px; }
.bypassed-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.bypassed-handle { font-weight: 700; font-size: 13px; color: var(--text-1); }
.bypassed-date   { color: var(--text-3); font-size: 12px; }

/* ══ LEAD MODAL ═══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20,19,16,.6);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-panel {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
/* Los modales chicos (crear agente, nueva entrada de conocimiento) son una
   columna simple SIN un .modal-body que scrollee. Con el max-height: 90vh y el
   overflow: hidden de .modal-panel, en una pantalla de notebook el pie con el
   botón de guardar quedaba cortado y sin forma de llegar a él. Visto en
   producción el 2026-09-10: "no me aparece en ningún momento para crearlo". */
.modal-sm { max-width: 520px; padding: 28px 32px; overflow-y: auto; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--text-1); }
.modal-body {
  display: grid;
  grid-template-columns: 230px 1fr;
  flex: 1; overflow: hidden;
}
.modal-side {
  padding: 22px 20px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 13px;
  overflow-y: auto;
  background: var(--surface-2);
}
.modal-side label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.modal-chat { display: flex; flex-direction: column; overflow: hidden; }
.chat-header {
  padding: 13px 22px;
  font-weight: 700;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2);
  color: var(--text-1);
}
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 18px 22px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg);
}
.chat-msg {
  max-width: 72%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}
.chat-msg.user   { background: var(--surface); border: 1px solid var(--border); align-self: flex-start; border-radius: 14px 14px 14px 4px; }
.chat-msg.agent  {
  background: var(--grad);
  color: white;
  align-self: flex-end;
  border-radius: 14px 14px 4px 14px;
  box-shadow: 0 2px 8px rgba(20,19,16,.16);
}
.chat-msg.manual {
  background: #0f766e;
  color: white;
  align-self: flex-end;
  border-radius: 14px 14px 4px 14px;
}
.chat-msg-time { font-size: 10px; opacity: .55; margin-top: 4px; }
.chat-input-row {
  padding: 13px 22px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px;
  align-items: flex-end;
  background: var(--surface);
}
.chat-input-row textarea {
  flex: 1;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; resize: none;
  font-family: inherit; outline: none;
  background: var(--bg);
  transition: border .15s;
}
.chat-input-row textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255,176,0,.28);
  background: var(--surface);
}

/* ══ LINKS ════════════════════════════════════════════════════════════════════ */
.links-info {
  background: var(--orange-bg);
  border: 1px solid rgba(20,19,16,.14);
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  color: var(--orange);
  font-size: 13.5px;
  margin-bottom: 22px;
  font-weight: 500;
}
.links-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.link-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
}
.link-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.link-card-name { font-weight: 700; margin-bottom: 6px; color: var(--text-1); font-size: 14px; }
.link-card-url  { color: var(--orange); font-size: 12px; word-break: break-all; margin-bottom: 6px; }
.link-card-desc { color: var(--text-2); font-size: 12.5px; }
.link-card-actions { display: flex; gap: 8px; margin-top: 16px; }

.inline-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  max-width: 520px;
  margin-top: 4px;
  box-shadow: var(--shadow-sm);
}
.inline-form h4 { margin-bottom: 20px; font-size: 15px; font-weight: 700; color: var(--text-1); }

/* ══ SETTINGS ═════════════════════════════════════════════════════════════════ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.settings-card:hover { box-shadow: var(--shadow); }
.settings-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; color: var(--text-1); }
.settings-card > p { color: var(--text-2); font-size: 13.5px; margin-bottom: 22px; line-height: 1.5; }

/* ══ FORMS ════════════════════════════════════════════════════════════════════ */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-row label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.form-input {
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  color: var(--text-1);
  background: var(--surface);
  transition: border .15s, box-shadow .15s;
}
.form-input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255,176,0,.28);
}
textarea.form-input { resize: vertical; line-height: 1.65; }

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

.checkbox-label { display: flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; color: var(--text-1); }
.checkbox-label input { accent-color: var(--orange); width: 15px; height: 15px; }

.checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.checkbox-group label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 400;
  color: var(--text-1);
  text-transform: none; letter-spacing: 0;
  cursor: pointer;
}
.checkbox-group input { accent-color: var(--orange); }

.tag {
  padding: 3px 11px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: var(--orange-bg);
  color: var(--orange);
  letter-spacing: .02em;
}

/* ══ INSTAGRAM CONNECT ════════════════════════════════════════════════════════ */
.btn-ig-connect {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: white; border: none;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700; font-size: 14px;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
  width: 100%; justify-content: center;
  box-shadow: 0 4px 16px rgba(220,39,67,.3);
}
.btn-ig-connect:hover { opacity: .9; transform: translateY(-1px); }

.ig-connected-box {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: rgba(16,185,129,.05);
  border: 1px solid rgba(16,185,129,.25);
  border-radius: var(--radius-sm);
}

/* ══ SCROLLBAR ════════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ══ TOAST ════════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed !important;
  bottom: 28px !important; right: 28px !important;
  background: #141310 !important;
  color: #F5F2EA !important;
  border: 1px solid rgba(245,242,234,.12) !important;
  border-radius: var(--radius-sm) !important;
  padding: 13px 20px !important;
  font-size: 13.5px !important;
  font-weight: 500 !important;
  box-shadow: 0 8px 32px rgba(0,0,0,.3) !important;
  z-index: 99999 !important;
  max-width: 380px !important;
}

/* ══ TRIAL BANNER ═════════════════════════════════════════════════════════════ */
.trial-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 28px;
  background: #141310;
  color: #F5F2EA;
  font-size: 13.5px;
  font-weight: 500;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.trial-banner-text strong { font-weight: 800; }
.trial-upgrade-btn {
  margin-left: auto;
  background: #FFB000;
  color: #141310;
  border: 1.5px solid #FFB000;
  padding: 5px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: background .15s;
  white-space: nowrap;
}
.trial-upgrade-btn:hover { background: #FFBB1F; }
.trial-close-btn {
  background: none;
  border: none;
  color: rgba(245,242,234,.7);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  line-height: 1;
  transition: color .15s;
}
.trial-close-btn:hover { color: #fff; }

/* ══ UPGRADE / PRICING MODAL ══════════════════════════════════════════════════ */
.upgrade-panel {
  /* --card no existe: el panel quedaba transparente y el texto gris no se leía. */
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px;
  max-width: 940px;
  width: 95%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
}
.upgrade-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}
.upgrade-header h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0 0 6px;
  font-family: var(--display);
  letter-spacing: -.025em;
  color: var(--text-1);
}
.upgrade-header p { color: var(--text-2); font-size: 14px; margin: 0; }
.upgrade-close-btn { flex-shrink: 0; }
.upgrade-expired-msg {
  background: rgba(239,68,68,.10);
  border: 1px solid rgba(239,68,68,.28);
  color: #b91c1c;
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
  font-size: 13.5px;
  font-weight: 500;
}
.upgrade-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 28px;
  flex-wrap: wrap;
  gap: 10px;
}
.upgrade-guarantee {
  font-size: 12px;
  color: var(--text-3);
}

/* Pricing grid */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.pricing-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.pricing-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.pricing-card-featured {
  border-color: var(--orange);
  background: var(--surface);
  box-shadow: 0 4px 24px rgba(20,19,16,.12);
}
.pricing-badge-top {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--grad);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 16px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: .03em;
}
.pricing-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-1);
  margin-bottom: 10px;
  margin-top: 4px;
}
.pricing-price {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--text-1);
  line-height: 1;
  margin-bottom: 22px;
}
.pricing-period { font-size: 1rem; font-weight: 500; color: var(--text-3); }
.pricing-features {
  list-style: none;
  padding: 0;
  margin: 0 0 28px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.pricing-features li { font-size: 13px; color: var(--text-2); line-height: 1.4; }
.pricing-btn { width: 100%; justify-content: center; }

/* ══ PROVIDER TABS (Lemon Squeezy vs Mercado Pago) ═══════════════════════════ */
.provider-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 0 0 24px;
  padding: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}
.provider-tab {
  flex: 1;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.provider-tab:hover { color: var(--text-1); }
.provider-tab.active {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 2px 10px rgba(20,19,16,.22);
}
.provider-tab .provider-tab-sub {
  font-size: 11px;
  font-weight: 500;
  opacity: .85;
}
.provider-panel { display: block; }
.provider-note {
  margin-top: 18px;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
  line-height: 1.5;
}
.provider-note strong { color: var(--text-1); }

/* ══ RESPONSIVE ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .agents-layout { grid-template-columns: 200px 1fr; }
  .agent-tester  { display: none !important; }
}
@media (max-width: 900px) {
  .agents-layout { grid-template-columns: 1fr; }
  .home-cards    { grid-template-columns: 1fr; }
  .modal-body    { grid-template-columns: 1fr; }
  .modal-side    { border-right: none; border-bottom: 1px solid var(--border); }
  .section       { padding: 24px 20px; }
  .pricing-grid  { grid-template-columns: 1fr; }
  .upgrade-panel { padding: 24px 18px; }
  .provider-tabs { max-width: 100%; }
  .provider-tab  { padding: 8px 12px; font-size: 12px; }
}
/* Menú móvil: bajo 700 px la sidebar se esconde; este botón la abre.
   Antes desaparecía sin forma de volver a abrirla: el panel era inutilizable
   en un celular (auditoría 12-09). */
#menu-toggle { display: none; position: fixed; top: 10px; left: 10px; z-index: 101; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-1); align-items: center; justify-content: center; cursor: pointer; }
#sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 99; }
@media (max-width: 700px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.35); }
  #menu-toggle { display: flex; }
  .main    { margin-left: 0; padding-top: 52px; }
  .section { padding: 20px 16px; }
  .trial-banner { padding: 10px 14px; font-size: 12.5px; }
}

/* Toggle switch para notificaciones */
.switch { position: relative; display: inline-block; width: 46px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); transition: .2s; border-radius: 24px;
}
.switch .slider::before {
  position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; transition: .2s; border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: var(--orange, #f97316); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* ── INBOX UNIFICADO ─────────────────────────────────────────────────────── */
.inbox-filter {
  background: #fff; border: 1px solid var(--border); color: var(--text-2);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  font-weight: 500; transition: all .15s; display: inline-flex; align-items: center; gap: 6px;
}
.inbox-filter:hover { background: #FAF8F3; color: var(--text-1); }
.inbox-filter.active { background: var(--orange); color: #fff; border-color: var(--orange); }
.inbox-filter .cnt {
  background: rgba(0,0,0,.08); color: inherit; font-size: 11px;
  padding: 1px 7px; border-radius: 10px; font-weight: 700;
}
.inbox-filter.active .cnt { background: rgba(255,255,255,.25); }

/* Lista de chats (rediseño 18-10-2026: logo del canal, hora tipo chat) */
.inbox-item {
  padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background .12s; display: flex; gap: 12px; align-items: center;
}
.inbox-item:hover { background: #fff; }
.inbox-item.selected { background: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.inbox-item .meta { flex: 1; min-width: 0; }
.inbox-item .top-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.inbox-item .ig-name { font-size: 14px; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-item .when { font-size: 11.5px; color: var(--text-3); white-space: nowrap; flex-shrink: 0; }
.inbox-item.unread .when { color: #16a34a; font-weight: 600; }
.inbox-item .bottom-row { display: flex; align-items: center; gap: 8px; }
.inbox-item .preview { flex: 1; min-width: 0; font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
.inbox-item.unread .preview { color: var(--text-1); font-weight: 500; }
.inbox-item .unread-dot { width: 10px; height: 10px; border-radius: 50%; background: #16a34a; flex-shrink: 0; }
.inbox-item .badges { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.badge-q { font-size: 10.5px; padding: 1px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.badge-q.hot  { background: #fef2f2; color: #dc2626; }
.badge-q.warm { background: #fef3c7; color: #b45309; }
.badge-q.cold { background: #dbeafe; color: #2563eb; }
.badge-q.bypassed { background: #EFEBE1; color: #57534A; }
.badge-q.converted { background: #dcfce7; color: #15803d; }
.inbox-vacio { padding: 48px 24px; text-align: center; color: var(--text-3); font-size: 13px; line-height: 1.5; }
.inbox-vacio-titulo { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }

/* Avatar con el logo del canal encima */
.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar-wrap .avatar {
  width: 100%; height: 100%; border-radius: 50%; color: #fff; display: flex; align-items: center;
  justify-content: center; font-weight: 600; font-size: 14px; letter-spacing: .02em;
}
.avatar-wrap .canal-badge {
  position: absolute; right: -3px; bottom: -3px; display: flex; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface, #fff); background: var(--surface, #fff);
}
.ico-canal { display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* Chat */
.thread-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: center; flex-shrink: 0; background: #fff; }
.thread-header .info { flex: 1; min-width: 0; }
.thread-header .info h3 { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.thread-nombre { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.thread-header .actions { display: flex; gap: 6px; align-items: center; }
.thread-header .actions .btn-primary, .thread-header .actions .btn-ghost { padding: 7px 12px; font-size: 12.5px; }
.thread-abrir { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.estado-chip { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.estado-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.estado-chip.ia { background: #dcfce7; color: #15803d; }
.estado-chip.pausa { background: #fef3c7; color: #b45309; }
.estado-chip.espera { background: #EFEBE1; color: #57534A; }
.icon-btn { border: 1px solid var(--border); background: transparent; color: var(--text-2); border-radius: 8px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.icon-btn:hover { background: #F3F0E8; color: var(--text-1); }
.icon-btn.peligro:hover { color: #dc2626; border-color: #fecaca; }

.thread-body { flex: 1; overflow-y: auto; padding: 18px 22px; background: #F3F0E8; display: flex; flex-direction: column; gap: 3px; }
.thread-vacio { margin: auto; color: var(--text-3); padding: 30px; text-align: center; font-size: 13px; }
.chat-dia { align-self: center; margin: 12px 0 8px; }
.chat-dia span { font-size: 11.5px; font-weight: 600; color: var(--text-2); background: #fff; border: 1px solid var(--border); padding: 3px 12px; border-radius: 999px; }
.chat-dia span::first-letter { text-transform: uppercase; }
.chat-sistema { align-self: center; max-width: 80%; margin: 8px 0; text-align: center; }
.chat-sistema span { font-size: 12px; color: var(--text-3); background: rgba(20,19,16,.05); padding: 4px 12px; border-radius: 10px; display: inline-block; }
.chat-autor { align-self: flex-end; font-size: 11.5px; font-weight: 600; color: var(--text-3); margin: 10px 6px 2px; }
.msg { max-width: min(72%, 560px); padding: 8px 12px 6px; border-radius: 16px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(20,19,16,.06); }
.msg.inicio { margin-top: 8px; }
.chat-autor + .msg.inicio { margin-top: 0; }
.msg.in { align-self: flex-start; background: #fff; color: var(--text-1); border: 1px solid var(--border); }
.msg.in.inicio { border-top-left-radius: 5px; }
.msg.out { align-self: flex-end; color: #fff; }
.msg.out.inicio { border-top-right-radius: 5px; }
.msg.agent { background: #141310; }
.msg.manual { background: #0f766e; }
.msg .txt { white-space: pre-wrap; }
.msg .hora { float: right; font-size: 10.5px; opacity: .65; margin: 6px 0 -2px 10px; line-height: 1; }
.msg .chat-media { font-size: 11.5px; font-weight: 600; opacity: .75; margin-bottom: 2px; }
.msg.pendiente { opacity: .7; }
.msg.fallido { background: #b91c1c; opacity: 1; }

.thread-input { padding: 10px 14px 12px; border-top: 1px solid var(--border); background: #fff; flex-shrink: 0; }
.thread-input .composer { display: flex; gap: 8px; align-items: flex-end; background: #F3F0E8; border: 1px solid var(--border); border-radius: 22px; padding: 5px 5px 5px 6px; }
.thread-input .composer:focus-within { border-color: var(--text-3); background: #fff; }
.thread-input .composer .icon-btn { border: 0; border-radius: 50%; }
.thread-input textarea { flex: 1; border: 0; background: transparent; padding: 8px 4px; font-family: inherit; font-size: 14px; resize: none; min-height: 22px; max-height: 140px; line-height: 1.4; color: var(--text-1); }
.thread-input textarea:focus { outline: none; }
.thread-input .send-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.thread-input .send-btn:hover { filter: brightness(1.15); }
.thread-input .hint { font-size: 11.5px; color: var(--text-3); margin: 6px 6px 0; }
.thread-input .hint-teclas { opacity: .8; white-space: nowrap; }

@media (max-width: 1100px) {
  .thread-header { flex-wrap: wrap; }
  .thread-header .actions { width: 100%; justify-content: flex-end; }
}

@media (max-width: 880px) {
  #inbox-layout { grid-template-columns: 1fr !important; height: auto !important; min-height: 500px; }
  #inbox-list { max-height: 50vh; }
}

/* ═══ CRM — Pipeline Kanban + Lista ═══════════════════════════════════════ */
.crm-viewtoggle { display:inline-flex; background:var(--surface); border:1px solid var(--border); border-radius:8px; overflow:hidden; }
.crm-vt { padding:8px 16px; border:none; background:transparent; color:var(--text-2); font-size:13px; font-weight:600; cursor:pointer; transition:all .15s; }
.crm-vt.active { background:var(--orange); color:#fff; }
.crm-loading { padding:60px; text-align:center; color:var(--text-3); }

.crm-kanban { display:flex; gap:14px; overflow-x:auto; padding:4px 4px 20px; min-height:60vh; }
.crm-col { flex:0 0 280px; background:var(--bg); border:1px solid var(--border); border-radius:12px; display:flex; flex-direction:column; max-height:75vh; }
.crm-col-head { padding:12px 14px; border-bottom:1px solid var(--border); position:sticky; top:0; background:var(--bg); border-radius:12px 12px 0 0; }
.crm-col-head .crm-col-title { display:flex; align-items:center; gap:8px; font-weight:700; font-size:13.5px; color:var(--text-1); }
.crm-col-head .crm-col-dot { width:9px; height:9px; border-radius:50%; flex-shrink:0; }
.crm-col-head .crm-col-meta { font-size:11.5px; color:var(--text-3); margin-top:3px; }
.crm-col-body { padding:10px; overflow-y:auto; flex:1; display:flex; flex-direction:column; gap:8px; }
.crm-col-body.dragover { background:rgba(255,176,0,.14); outline:2px dashed var(--orange); outline-offset:-4px; }

.crm-card { background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:11px 13px; cursor:pointer; transition:all .12s; }
.crm-card:hover { border-color:var(--orange); box-shadow:0 4px 14px rgba(0,0,0,.06); transform:translateY(-1px); }
.crm-card.dragging { opacity:.4; }
.crm-card-top { display:flex; justify-content:space-between; align-items:flex-start; gap:8px; }
.crm-card-name { font-weight:700; font-size:13px; color:var(--text-1); }
.crm-card-ch { font-size:13px; flex-shrink:0; }
.crm-card-val { font-size:12.5px; font-weight:700; color:var(--orange); margin-top:4px; }
.crm-card-tags { display:flex; flex-wrap:wrap; gap:4px; margin-top:7px; }
.crm-tag { font-size:10px; background:rgba(20,19,16,.07); color:var(--orange); padding:2px 7px; border-radius:10px; font-weight:600; }
.crm-card-meta { display:flex; justify-content:space-between; font-size:10.5px; color:var(--text-3); margin-top:7px; }
.crm-card-fu { color:#f59e0b; font-weight:600; }
.crm-card-q { font-size:9.5px; text-transform:uppercase; letter-spacing:.05em; font-weight:800; padding:1px 6px; border-radius:6px; }
.crm-q-hot  { background:rgba(34,197,94,.15);  color:#16a34a; }
.crm-q-warm { background:rgba(245,158,11,.15); color:#d97706; }
.crm-q-cold { background:rgba(100,116,139,.15); color:#6F6A5E; }

/* Lista */
.crm-list-filters { display:flex; gap:10px; margin-bottom:14px; flex-wrap:wrap; }
.crm-list-filters input, .crm-list-filters select { padding:9px 12px; border:1px solid var(--border); border-radius:8px; font-size:13px; background:var(--surface); color:var(--text-1); }
.crm-list-filters input { flex:1; min-width:200px; }
.crm-table { width:100%; border-collapse:collapse; font-size:13px; }
.crm-table th { text-align:left; padding:10px 12px; color:var(--text-3); font-weight:600; font-size:11.5px; text-transform:uppercase; letter-spacing:.04em; border-bottom:1px solid var(--border); }
.crm-table td { padding:11px 12px; border-bottom:1px solid var(--border); color:var(--text-1); }
.crm-table tr:hover td { background:var(--bg); cursor:pointer; }
.crm-stage-pill { font-size:11px; font-weight:700; padding:3px 9px; border-radius:12px; color:#fff; display:inline-block; }

/* Drawer */
.crm-drawer-overlay { position:fixed; inset:0; background:rgba(20,19,16,.45); backdrop-filter:blur(2px); z-index:9000; display:none; }
.crm-drawer-overlay.open { display:block; }
.crm-drawer { position:absolute; top:0; right:0; height:100%; width:440px; max-width:92vw; background:var(--surface); box-shadow:-12px 0 40px rgba(0,0,0,.18); display:flex; flex-direction:column; animation:crmSlide .22s ease-out; }
@keyframes crmSlide { from{transform:translateX(40px);opacity:0;} to{transform:translateX(0);opacity:1;} }
.crm-drawer-head { display:flex; justify-content:space-between; align-items:flex-start; padding:22px 24px 16px; border-bottom:1px solid var(--border); }
.crm-drawer-head h2 { font-size:1.2rem; margin:0; color:var(--text-1); }
.crm-d-iglink { font-size:12.5px; color:var(--orange); text-decoration:none; }
.crm-drawer-body { padding:20px 24px; overflow-y:auto; flex:1; }
.crm-field { margin-bottom:14px; }
.crm-field label { display:block; font-size:11.5px; font-weight:700; color:var(--text-3); text-transform:uppercase; letter-spacing:.04em; margin-bottom:5px; }
.crm-field input, .crm-field select { width:100%; padding:9px 12px; border:1px solid var(--border); border-radius:8px; font-size:13.5px; background:var(--surface); color:var(--text-1); font-family:inherit; }
.crm-field-row { display:flex; gap:10px; }
.crm-field-row .crm-field { flex:1; }
.crm-timeline-head { margin:24px 0 10px; border-top:1px solid var(--border); padding-top:18px; }
.crm-timeline-head h3 { font-size:.95rem; margin:0; color:var(--text-1); }
.crm-addnote { display:flex; gap:6px; margin-bottom:14px; }
.crm-addnote select { width:auto; padding:8px; border:1px solid var(--border); border-radius:8px; font-size:12px; background:var(--surface); color:var(--text-1); }
.crm-addnote input { flex:1; padding:8px 11px; border:1px solid var(--border); border-radius:8px; font-size:13px; background:var(--surface); color:var(--text-1); }
.crm-addnote button { padding:8px 14px; }
.crm-timeline { display:flex; flex-direction:column; gap:10px; }
.crm-tl-item { display:flex; gap:10px; font-size:12.5px; }
.crm-tl-icon { flex-shrink:0; width:26px; height:26px; border-radius:50%; background:var(--bg); display:flex; align-items:center; justify-content:center; font-size:12px; }
.crm-tl-content { flex:1; }
.crm-tl-text { color:var(--text-1); line-height:1.45; }
.crm-tl-meta { color:var(--text-3); font-size:10.5px; margin-top:2px; }
.crm-tl-del { color:var(--text-3); cursor:pointer; font-size:11px; opacity:0; transition:opacity .15s; }
.crm-tl-item:hover .crm-tl-del { opacity:1; }
.crm-tl-empty { color:var(--text-3); font-size:12.5px; text-align:center; padding:16px; }
.crm-drawer-foot { margin-top:22px; padding-top:16px; border-top:1px solid var(--border); }
@media (max-width:760px){ .crm-col{flex:0 0 240px;} .crm-drawer{width:100%;} }

/* ══ MODO OSCURO (Ajustes → Apariencia → Fondo "Oscuro") ═══════════════════════
   La paleta del dashboard de referencia (16-08-2026): página #141310,
   tarjetas #1A1915, texto #F5F2EA, verde #4ade80. Las variables las setea
   main.js (DARK_VARS); acá solo se cubren los colores que quedaron FIJOS en
   el CSS/HTML (background:#fff en tarjetas inline, inputs, bandeja) para que
   no queden parches blancos sobre negro. Reversible: sin la clase no aplica. */
.theme-dark .settings-card,
.theme-dark .stat-card,
.theme-dark .inbox-item:hover,
.theme-dark .thread-header,
.theme-dark .thread-input,
.theme-dark .bubble.user,
.theme-dark #analytics-kpis .stat-card,
.theme-dark #voz-gasto-card,
.theme-dark [style*="background:#fff"],
.theme-dark [style*="background: #fff"],
.theme-dark [style*="background:#ffffff"] { background: var(--surface) !important; }

.theme-dark #voz-gasto-card > div > div,
.theme-dark [style*="background:var(--bg-2)"],
.theme-dark [style*="background: var(--bg-2)"],
.theme-dark [style*="background:var(--bg-1)"] { background: var(--surface-2) !important; }

.theme-dark input, .theme-dark select, .theme-dark textarea, .theme-dark .form-input, .theme-dark .auth-input {
  background: var(--surface-2); color: var(--text-1); border-color: var(--border);
}
.theme-dark input::placeholder, .theme-dark textarea::placeholder { color: var(--text-3); }
.theme-dark code { background: rgba(255,255,255,.08); color: var(--text-1); }
.theme-dark .btn-ghost, .theme-dark .btn-secondary { color: var(--text-1); border-color: var(--border); background: transparent; }
.theme-dark .btn-ghost:hover, .theme-dark .btn-secondary:hover { background: var(--surface-2); }
.theme-dark .btn-primary { background: var(--accent); color: #141310; }
.theme-dark .nav-item.active { background: var(--sidebar-active-bg); }
.theme-dark .nav-item svg { fill: currentColor; }
.theme-dark table th { color: var(--text-3); }
.theme-dark table td, .theme-dark table th { border-color: var(--border); }
.theme-dark .toast { background: var(--surface); color: var(--text-1); border: 1px solid var(--border); }
.theme-dark .modal, .theme-dark .modal-content, .theme-dark .modal-box { background: var(--surface); color: var(--text-1); }
/* Deltas y estados positivos en el verde del dashboard de referencia */
.theme-dark .stat-val[style*="#22c55e"], .theme-dark [style*="color:#22c55e"], .theme-dark [style*="color:#16a34a"], .theme-dark [style*="color:#10b981"] { color: #4ade80 !important; }
/* Chips de estado con fondo claro (aprobada/en revisión/rechazada) → versión oscura */
.theme-dark [style*="background:#dcfce7"] { background: rgba(74,222,128,.15) !important; color: #4ade80 !important; }
.theme-dark [style*="background:#fef9c3"] { background: rgba(250,204,21,.15) !important; color: #facc15 !important; }
.theme-dark [style*="background:#fee2e2"] { background: rgba(248,113,113,.15) !important; color: #f87171 !important; }
.theme-dark [style*="background:#e5e7eb"] { background: rgba(255,255,255,.1) !important; color: var(--text-2) !important; }
/* Vista previa de WhatsApp en Plantillas: se mantiene clara a propósito (es el teléfono del cliente) */
.theme-dark #wat-preview { background: #e5ddd5 !important; }
.theme-dark #wat-preview > div, .theme-dark #wat-pv-buttons > div { background: #fff !important; color: #111 !important; }
/* Home en oscuro: la card de uso (fondo #fff inline) y el checklist de setup (gradiente naranja claro) */
.theme-dark #usage-card { background: var(--surface) !important; }
.theme-dark #onboarding-card { background: var(--surface) !important; border-color: rgba(251,146,60,.35) !important; }
.theme-dark #onboarding-card h3 { color: #fdba74 !important; }
.theme-dark #onboarding-card [style*="background:#fff"], .theme-dark #onboarding-card [style*="background: #fff"] { background: var(--surface-2) !important; }
.theme-dark [style*="background:#fef2f2"], .theme-dark [style*="background:#fff7ed"], .theme-dark [style*="background:#fffbeb"], .theme-dark [style*="background:#eff6ff"], .theme-dark [style*="background:#ecfdf5"], .theme-dark [style*="background:#f0fdf4"] { background: var(--surface-2) !important; }
.theme-dark .stat-icon { filter: saturate(.9); }
/* Inbox en oscuro: lista, filtros, hilo (fondos #FAF8F3/#fff inline y en css) */
.theme-dark #inbox-list, .theme-dark .thread-body { background: var(--bg) !important; }
.theme-dark [style*="background:#FAF8F3"], .theme-dark [style*="background: #FAF8F3"] { background: var(--bg) !important; }
.theme-dark .inbox-item { border-color: var(--border); }
.theme-dark .inbox-item:hover { background: var(--surface) !important; }
.theme-dark .inbox-item.selected { background: rgba(255,255,255,.06) !important; }
.theme-dark .inbox-filter { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.theme-dark .inbox-filter:hover { background: var(--surface-2); color: var(--text-1); }
.theme-dark .inbox-filter.active { background: var(--accent); color: #141310; border-color: var(--accent); }
.theme-dark .inbox-filter .cnt { background: rgba(255,255,255,.12); }
.theme-dark .inbox-item .badge-q.hot  { background: rgba(248,113,113,.15); color: #fca5a5; }
.theme-dark .inbox-item .badge-q.warm { background: rgba(250,204,21,.15); color: #fde68a; }
.theme-dark .inbox-item .badge-q.cold { background: rgba(147,197,253,.15); color: #bfdbfe; }
.theme-dark .bubble.agent, .theme-dark .bubble.assistant { background: rgba(255,255,255,.08); color: var(--text-1); }
.theme-dark .bubble.user { background: var(--surface) !important; color: var(--text-1); }
.theme-dark .bubble.sistema { background: transparent; color: var(--text-3); }

/* Inbox rediseñado en oscuro */
.theme-dark .inbox-item.selected { box-shadow: inset 3px 0 0 var(--accent); }
.theme-dark .msg.in { background: var(--surface) !important; border-color: var(--border); color: var(--text-1); }
.theme-dark .msg.agent { background: #2B2922; }
.theme-dark .msg.manual { background: #115e59; }
.theme-dark .chat-dia span { background: var(--surface); border-color: var(--border); }
.theme-dark .chat-sistema span { background: rgba(255,255,255,.06); }
.theme-dark .thread-input .composer { background: var(--surface-2); border-color: var(--border); }
.theme-dark .thread-input .composer:focus-within { background: var(--surface); }
.theme-dark .thread-input .send-btn { color: #141310; }
.theme-dark .icon-btn:hover { background: var(--surface-2); }
.theme-dark .estado-chip.ia { background: rgba(74,222,128,.15); color: #86efac; }
.theme-dark .estado-chip.pausa { background: rgba(250,204,21,.15); color: #fde68a; }
.theme-dark .estado-chip.espera { background: rgba(148,163,184,.15); color: #CFCABD; }
.theme-dark .avatar-wrap .canal-badge { box-shadow: 0 0 0 2px var(--surface); background: var(--surface); }

/* ── Mensajes v2 (18-10-2026): una pestaña por canal y chat limpio ─────────── */
.canal-barra { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.canal-tabs { display: inline-flex; gap: 4px; background: #ECE8DD; padding: 4px; border-radius: 12px; }
.canal-tab {
  display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent;
  color: var(--text-2); font: inherit; font-size: 14px; font-weight: 600; padding: 8px 14px;
  border-radius: 9px; cursor: pointer; transition: background .15s, color .15s;
}
.canal-tab:hover { color: var(--text-1); }
.canal-tab.active { background: #fff; color: var(--text-1); box-shadow: 0 1px 2px rgba(20,19,16,.08); }
.canal-tab .cnt:empty { display: none; }
.canal-tab .cnt { background: #16a34a; color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; }
.canal-buscar { margin-left: auto; padding: 9px 14px; border: 1px solid var(--border); border-radius: 10px; font: inherit; font-size: 13.5px; width: 240px; background: #fff; color: var(--text-1); }
.canal-buscar:focus { outline: none; border-color: var(--text-3); }
.inbox-vacio-ico { display: flex; justify-content: center; margin-bottom: 10px; opacity: .9; }
.thread-vacio-titulo { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }

.thread-nombre.enlace { color: var(--text-1); text-decoration: none; }
.thread-nombre.enlace:hover { text-decoration: underline; }
.thread-sub .estado.ia { color: #15803d; }
.thread-sub .estado.pausa { color: #b45309; }
.icon-btn.red { border-color: transparent; }
.icon-btn.red:hover { background: #F3F0E8; }
.icon-btn.sin-enlace { cursor: default; }
.thread-control { padding: 8px 14px !important; font-size: 13px !important; border-radius: 9px !important; }

.thread-input { position: relative; }
.emoji-panel {
  position: absolute; bottom: calc(100% - 4px); left: 14px; z-index: 5; background: #fff;
  border: 1px solid var(--border); border-radius: 14px; padding: 8px; display: grid;
  grid-template-columns: repeat(7, 36px); gap: 2px; box-shadow: 0 10px 30px rgba(20,19,16,.14);
}
.emoji-panel[hidden] { display: none; }
.emoji-panel button { width: 36px; height: 36px; border: 0; background: transparent; font-size: 20px; border-radius: 8px; cursor: pointer; line-height: 1; }
.emoji-panel button:hover { background: #F3F0E8; }

@media (max-width: 760px) {
  .canal-tabs { width: 100%; }
  .canal-tab { flex: 1; justify-content: center; padding: 8px 6px; }
  .canal-buscar { width: 100%; margin-left: 0; }
}

.theme-dark .canal-tabs { background: var(--surface-2); }
.theme-dark .canal-tab.active { background: var(--surface); }
.theme-dark .canal-buscar { background: var(--surface); border-color: var(--border); }
.theme-dark .emoji-panel { background: var(--surface); border-color: var(--border); }
.theme-dark .emoji-panel button:hover, .theme-dark .icon-btn.red:hover { background: var(--surface-2); }
.theme-dark .thread-sub .estado.ia { color: #86efac; }
.theme-dark .thread-sub .estado.pausa { color: #fde68a; }

/* El botón del copiloto tapaba el de enviar en Mensajes: se sube sobre el cuadro de texto. */
body:has(#section-inbox.active) #copi-fab { bottom: 112px !important; }

/* Estado de entrega en las burbujas enviadas (✓ / ✓✓ / ✓✓ leído) */
.msg .tick { display: inline-block; vertical-align: -1px; margin-left: 4px; opacity: .9; }
.msg .tick.leido { color: #53bdeb; opacity: 1; }
.msg .tick.fallo { font-weight: 700; color: #fecaca; }

/* Fotos, documentos y notas de voz en el chat (18-10-2026) */
.msg.con-adjunto { padding: 4px 4px 6px; }
.msg.con-adjunto .txt { display: block; padding: 6px 8px 0; }
.msg.con-adjunto .hora { margin-right: 6px; }
.msg-foto { display: block; }
.msg-foto img { display: block; max-width: 280px; max-height: 320px; width: 100%; object-fit: cover; border-radius: 12px; }
.msg-audio { display: block; width: 260px; max-width: 100%; height: 40px; }
.msg-doc { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.12); color: inherit; text-decoration: none; min-width: 200px; }
.msg.in .msg-doc { background: #F3F0E8; }
.msg-doc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13px; }
.grabacion-barra { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 8px 12px; border-radius: 12px; background: #fef2f2; color: #991b1b; font-size: 13px; font-weight: 600; }
.grabacion-barra .btn-ghost, .grabacion-barra .btn-primary { padding: 6px 12px; font-size: 12.5px; }
.grabacion-barra .btn-ghost { margin-left: auto; }
.grabacion-punto { width: 10px; height: 10px; border-radius: 50%; background: #dc2626; animation: grabacion-latido 1s ease-in-out infinite; }
.grabacion-tiempo { font-variant-numeric: tabular-nums; }
@keyframes grabacion-latido { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .grabacion-punto { animation: none; } }
.theme-dark .msg.in .msg-doc { background: var(--surface-2); }
.theme-dark .grabacion-barra { background: rgba(248,113,113,.15); color: #fca5a5; }

/* Responder citando y reacciones (18-10-2026) */
.msg { position: relative; }
.msg-acciones { position: absolute; top: -14px; display: none; gap: 2px; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px; box-shadow: 0 4px 12px rgba(20,19,16,.12); z-index: 2; }
.msg.in .msg-acciones { right: -8px; }
.msg.out .msg-acciones { left: -8px; }
.msg:hover .msg-acciones, .msg:focus-within .msg-acciones { display: flex; }
.msg-acciones button { border: 0; background: transparent; width: 28px; height: 26px; border-radius: 999px; cursor: pointer; font-size: 15px; line-height: 1; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; }
.msg-acciones button:hover { background: #F3F0E8; color: var(--text-1); }
.msg-cita { border-left: 3px solid currentColor; opacity: .85; background: rgba(20,19,16,.06); border-radius: 6px; padding: 4px 8px; margin: 2px 0 6px; font-size: 12.5px; display: flex; flex-direction: column; max-width: 100%; }
.msg.out .msg-cita { background: rgba(255,255,255,.14); }
.msg-cita b { font-size: 11.5px; }
.msg.con-reaccion { margin-bottom: 12px; }
.msg-reaccion { position: absolute; bottom: -12px; right: 8px; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 0 5px; font-size: 13px; line-height: 20px; box-shadow: 0 1px 2px rgba(20,19,16,.1); }
.msg.in .msg-reaccion { right: auto; left: 8px; }
.cita-barra { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 6px 6px 6px 12px; border-left: 3px solid #0f766e; background: #F3F0E8; border-radius: 10px; }
.cita-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 12.5px; color: var(--text-2); }
.cita-texto b { color: #0f766e; font-size: 12px; }
.cita-texto span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cita-barra .icon-btn { border: 0; font-size: 18px; }
.theme-dark .msg-acciones, .theme-dark .msg-reaccion { background: var(--surface); border-color: var(--border); }
.theme-dark .msg-acciones button:hover { background: var(--surface-2); }
.theme-dark .cita-barra { background: var(--surface-2); }
.theme-dark .msg-cita { background: rgba(255,255,255,.06); }

/* ══ MARCA "EL VISTO" — LETRAS ════════════════════════════════════════════════
   Títulos en Bricolage Grotesque (600–700, espaciado −0,02em); el resto en
   Instrument Sans (lo hereda todo del body). Va al final para ganarle a las
   reglas de cada sección sin tener que tocarlas una por una. */
h1, h2, h3,
.modal-header h3, .settings-card h3, .home-card h3, .inline-form h4,
.pricing-name, .pricing-price, .stat-val, .crm-drawer-head h2 {
  font-family: var(--display);
  letter-spacing: -.02em;
}
.stat-val { font-weight: 700; letter-spacing: -.03em; }
.home-card h3, .settings-card h3, .modal-header h3 { font-size: 16.5px; font-weight: 650; }
button, input, select, textarea { font-family: inherit; }
/* Subrayado tipo marcador, para resaltar una palabra dentro de un título. */
.marca-marcador { background: linear-gradient(transparent 58%, rgba(255,176,0,.55) 58%); }
/* Íconos de las tarjetas de resumen: tinta sobre hueso (sin verdes ni azules). */
.stat-icon { background: var(--accent-bg); color: var(--accent); }
/* Lo seleccionado en el panel se marca con tinta; el ámbar queda para el menú. */
::selection { background: rgba(255,176,0,.38); color: #141310; }

/* ══ MENÚ DE CLÍNICA (15-11-2026) ═════════════════════════════════════════════
   Tu día (Hoy, Mensajes) + tarjeta del agente + los 6 pasos del recorrido del
   paciente. Cada paso muestra adentro las secciones de siempre (main.js, PASOS). */
.nav-grupo { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--sidebar-text); padding: 14px 12px 6px; }
.nav-icon svg.trazo { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.nav-agente { display: flex; align-items: center; gap: 10px; margin: 12px 2px 2px; padding: 10px 12px; border: 1px solid var(--sidebar-border); border-radius: 10px; text-decoration: none; color: var(--sidebar-text-strong); flex-shrink: 0; }
.nav-agente:hover { background: var(--sidebar-hover-bg); }
.nav-agente-av { width: 30px; height: 30px; border-radius: 50%; background: var(--sidebar-text-strong); color: var(--sidebar-bg); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.nav-agente-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.nav-agente-nombre { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-agente-estado { font-size: 12px; color: var(--sidebar-text); display: flex; align-items: center; gap: 6px; }
.nav-agente-estado::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3FB27F; flex: none; }
.nav-agente.pausado .nav-agente-estado::before { background: #8C8676; }
.paso-num { width: 21px; height: 21px; border-radius: 50%; border: 1.5px solid currentColor; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex: none; box-sizing: border-box; }
.nav-espacio { flex: 1; min-height: 16px; }
.seccion-paso .paso-cab { max-width: 780px; }
.paso-etiqueta { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.seccion-paso .paso-cab h1 { margin: 6px 0; }
.seccion-paso .paso-cab p { color: var(--text-2); font-size: 15px; line-height: 1.5; margin: 0; }
.paso-cuerpo > .section.en-paso, #section-settings > .section.en-paso { padding: 0; margin-top: 30px; }
.paso-cuerpo > .paso-tarjetas { margin-top: 26px; }
.retirado { display: none !important; }

/* ══ HOY DE CLÍNICA (15-11-2026) ═════════════════════════════════════════════ */
.hoy-resumen { font-size: 16.5px; line-height: 1.5; margin: -6px 0 22px; max-width: 820px; color: var(--text-1); }
.hoy-resumen:empty { display: none; }
.hoy-grid { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; margin-bottom: 22px; }
.hoy-col { flex: 3 1 460px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.hoy-col.hoy-lateral { flex: 2 1 320px; }
.hoy-card { background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 14px; padding: 18px 18px 10px; }
.hoy-cab { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.hoy-cab h2 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 19px; font-weight: 700; letter-spacing: -.03em; margin: 0; }
.hoy-sub { font-size: 13.5px; color: var(--text-2); }
a.hoy-sub { color: var(--text-1); font-weight: 600; text-decoration: underline; text-decoration-color: #FFB000; text-underline-offset: 3px; }
.hoy-ayuda { margin: 0 0 4px; }
.hoy-fila { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 13px 0; border-top: 1px solid var(--border); }
.hoy-fila:first-child { border-top: 0; }
.hoy-quien { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hoy-quien b { font-size: 15px; font-weight: 600; }
.hoy-quien span { font-size: 13.5px; color: var(--text-2); line-height: 1.4; }
.hoy-acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.hoy-btn { min-height: 38px; padding: 0 14px; border-radius: 10px; border: 0; background: #FFB000; color: #141310; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.hoy-btn:hover { background: #F0A400; }
.hoy-btn2 { min-height: 38px; padding: 0 13px; border-radius: 10px; border: 1.5px solid var(--text-1); background: transparent; color: var(--text-1); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.hoy-chip { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--text-1); color: var(--bg, #F5F2EA); }
.hoy-chip.borde { background: transparent; color: var(--text-1); border: 1.5px solid var(--text-1); }
.hoy-hora { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 19px; letter-spacing: -.03em; width: 60px; flex: none; }
.hoy-vacio { font-size: 14px; color: var(--text-2); padding: 12px 0 10px; line-height: 1.5; }
.hoy-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 6px 0 12px; }
.hoy-kpi b { display: block; font-family: 'Bricolage Grotesque', sans-serif; font-size: 28px; font-weight: 700; letter-spacing: -.04em; line-height: 1.05; }
.hoy-kpi span { font-size: 13px; color: var(--text-2); display: block; margin-top: 3px; line-height: 1.35; }
/* Dentro de un paso, el título y la bajada genérica de cada sección sobran. */
.paso-cuerpo .section.en-paso > .page-header p { display: none; }
.paso-cuerpo .section.en-paso > .page-header h1 { font-size: 20px; }
#hoy-ultimas .hoy-quien span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
