/* Wenko design tokens.
   Vista clara (default) y oscura via html[data-theme="dark"].
   Paleta derivada del logo: navy #09263A, verde #1BE39A, cian #22B7FF.
   La sidebar se mantiene navy en ambos temas (identidad de marca). */
:root {
  color-scheme: light;
  --bg: #eef4f7;
  --sidebar: #0b2334;
  --panel: #ffffff;
  --panel-soft: #fbfdfe;
  --panel-deep: #f1f6f9;
  --panel-raised: #ffffff;
  --line: rgba(9, 38, 58, 0.12);
  --text: #16303f;
  --muted: #5c7385;
  --ink: #0c2233;
  --text-soft: #3c5568;
  --purple: #6d5ef0;
  --purple-soft: #7c6ef5;
  --purple-text: #5b4bd8;
  --green: #0c9d68;
  --green-strong: #087a51;
  --green-soft: rgba(16, 185, 129, 0.13);
  --cyan: #0b93b7;
  --red: #dc3d55;
  --red-soft: rgba(220, 61, 85, 0.10);
  --warning: #a16207;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --warning-line: rgba(217, 119, 6, 0.38);
  --overlay-1: rgba(9, 38, 58, 0.045);
  --overlay-2: rgba(9, 38, 58, 0.09);
  --overlay-3: rgba(9, 38, 58, 0.16);
  --code-bg: #0c2233;
  --code-text: #d8f0ff;
  --bubble-out: #0ca678;
  --bubble-ai: #0d84a8;
  --shadow: 0 14px 34px rgba(9, 38, 58, 0.08);
  --chat-doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='110' height='110' viewBox='0 0 110 110'%3E%3Cg fill='%2309263A' fill-opacity='0.05'%3E%3Cpath d='M22 14c5 0 9 4 9 9s-4 9-9 9-9-4-9-9 4-9 9-9zm0 3a6 6 0 1 0 0 12 6 6 0 0 0 0-12z'/%3E%3Cpath d='M78 8c9 2 14 10 12 19-2 8-10 13-19 11-8-2-13-10-11-19 1-6 6-10 11-11-1 4 1 8 5 9 4 1 8-1 9-5 1-2 0-3-1-4h-6z'/%3E%3Cpath d='M18 62c7-3 15 1 18 8s-1 15-8 18-15-1-18-8 1-15 8-18zm2 4c-5 2-7 8-5 12s8 7 12 5 7-8 5-12-8-7-12-5z'/%3E%3Cpath d='M70 58c6 0 11 5 11 11s-5 11-11 11-11-5-11-11 5-11 11-11zm0 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14z'/%3E%3Cpath d='M95 40l4 4-4 4-4-4z'/%3E%3Cpath d='M8 92l4 4-4 4-4-4z'/%3E%3Cpath d='M50 92c4 0 8 3 8 8s-4 8-8 8-8-3-8-8 4-8 8-8zm0 3a5 5 0 1 0 0 10 5 5 0 0 0 0-10z'/%3E%3C/g%3E%3C/svg%3E");
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1f2e;
  --sidebar: #081a27;
  --panel: #10293a;
  --panel-soft: #0e2433;
  --panel-deep: #0b2130;
  --panel-raised: #133045;
  --line: rgba(255, 255, 255, 0.09);
  --text: #dcebf4;
  --muted: #8fa9ba;
  --ink: #f0f7fb;
  --text-soft: #b9cedd;
  --purple: #7a6cf5;
  --purple-soft: #8b7dff;
  --purple-text: #a79cff;
  --green: #1be39a;
  --green-strong: #5df1b6;
  --green-soft: rgba(27, 227, 154, 0.13);
  --cyan: #22b7ff;
  --red: #ff6b81;
  --red-soft: rgba(255, 107, 129, 0.13);
  --warning: #ffd06f;
  --warning-soft: rgba(255, 196, 87, 0.14);
  --warning-line: rgba(255, 208, 111, 0.35);
  --overlay-1: rgba(255, 255, 255, 0.045);
  --overlay-2: rgba(255, 255, 255, 0.09);
  --overlay-3: rgba(255, 255, 255, 0.16);
  --code-bg: #0a1c29;
  --code-text: #d8f0ff;
  --bubble-out: #0e9e72;
  --bubble-ai: #1189ad;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.30);
  --chat-doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='110' height='110' viewBox='0 0 110 110'%3E%3Cg fill='%23ffffff' fill-opacity='0.045'%3E%3Cpath d='M22 14c5 0 9 4 9 9s-4 9-9 9-9-4-9-9 4-9 9-9zm0 3a6 6 0 1 0 0 12 6 6 0 0 0 0-12z'/%3E%3Cpath d='M78 8c9 2 14 10 12 19-2 8-10 13-19 11-8-2-13-10-11-19 1-6 6-10 11-11-1 4 1 8 5 9 4 1 8-1 9-5 1-2 0-3-1-4h-6z'/%3E%3Cpath d='M18 62c7-3 15 1 18 8s-1 15-8 18-15-1-18-8 1-15 8-18zm2 4c-5 2-7 8-5 12s8 7 12 5 7-8 5-12-8-7-12-5z'/%3E%3Cpath d='M70 58c6 0 11 5 11 11s-5 11-11 11-11-5-11-11 5-11 11-11zm0 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14z'/%3E%3Cpath d='M95 40l4 4-4 4-4-4z'/%3E%3Cpath d='M8 92l4 4-4 4-4-4z'/%3E%3Cpath d='M50 92c4 0 8 3 8 8s-4 8-8 8-8-3-8-8 4-8 8-8zm0 3a5 5 0 1 0 0 10 5 5 0 0 0 0-10z'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.sidebar {
  background: var(--sidebar);
  color: #dfe9f2;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 34px;
  min-height: 44px;
}
.brand-logo { width: 34px; height: 34px; border-radius: 50%; }
.brand strong { font-size: 25px; letter-spacing: 0; }
.brand span { display: block; color: #8fa9ba; font-size: 12px; margin-top: 2px; }
.sidebar-collapse {
  position: absolute;
  right: 18px;
  top: 28px;
  width: 34px;
  height: 34px;
  display: grid;
  gap: 4px;
  place-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.sidebar-collapse span {
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: #b6bbcf;
}

/* Switch de tema para movil: siempre visible en la cabecera navy.
   En escritorio se oculta (alli esta el boton "Tema" del topbar). */
.theme-switch-mini {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.tsm-track {
  width: 42px;
  height: 23px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  position: relative;
  display: inline-block;
  transition: background 0.2s ease;
}
.tsm-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s ease;
}
.theme-switch-mini.is-dark .tsm-track {
  background: #0ca678;
}
.theme-switch-mini.is-dark .tsm-thumb {
  transform: translateX(19px);
}

nav { display: grid; gap: 8px; }
nav button {
  border: 0;
  border-radius: 6px;
  color: #c5c9d9;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
}
.nav-ico {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  color: #d7d9e8;
  background: rgba(255, 255, 255, 0.06);
  font-size: 11px;
  font-weight: 900;
}
nav button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}
nav button.active {
  background: linear-gradient(100deg, #0ca678, #0e8aa5);
  color: white;
  box-shadow: 0 10px 24px rgba(27, 227, 154, 0.22);
}
nav button.active .nav-ico, nav button:hover .nav-ico { background: rgba(255, 255, 255, 0.16); color: white; }
.nav-link {
  border: 0;
  border-radius: 6px;
  color: #c5c9d9;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  text-decoration: none;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}
.nav-link.active {
  background: linear-gradient(100deg, #0ca678, #0e8aa5);
  color: white;
  box-shadow: 0 10px 24px rgba(27, 227, 154, 0.22);
}
/* Grupo colapsable del sidebar (ej. "Integraciones"): un boton que despliega
   subitems propios, en vez de mezclar enlaces sueltos con las vistas principales. */
.nav-group { display: grid; gap: 2px; }
.nav-group-toggle {
  border: 0;
  border-radius: 6px;
  color: #c5c9d9;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  width: 100%;
}
.nav-group-toggle:hover { background: rgba(255, 255, 255, 0.08); color: #ffffff; }
.nav-group-toggle:hover .nav-ico { background: rgba(255, 255, 255, 0.16); color: white; }
.nav-group-toggle.active { color: #ffffff; }
.nav-group-toggle.active .nav-ico { background: rgba(255, 255, 255, 0.16); color: white; }
.nav-group-label { flex: 1; }
.nav-group-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  opacity: 0.7;
  margin-right: 2px;
}
.nav-group-toggle[aria-expanded="true"] .nav-group-chevron { transform: rotate(45deg); }
.nav-submenu {
  display: grid;
  gap: 2px;
  padding: 2px 0 4px 34px;
  position: relative;
}
/* Sin esto, [hidden]{display:none} del navegador pierde contra el display:grid
   de arriba (misma especificidad, pero ambas son reglas de autor) y el submenu
   queda visible siempre, sin importar si esta colapsado. */
.nav-submenu[hidden] {
  display: none;
}
/* Linea guia vertical para que se lea como "dentro de" Integraciones, no como items sueltos. */
.nav-submenu::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 0;
  bottom: 10px;
  width: 1px;
  background: rgba(255, 255, 255, 0.12);
}
.nav-sublink {
  border: 0;
  border-radius: 6px;
  color: #b7bdce;
  background: transparent;
  text-align: left;
  padding: 9px 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.nav-sublink:hover { background: rgba(255, 255, 255, 0.08); color: #ffffff; }
.nav-sublink.active {
  background: linear-gradient(100deg, #0ca678, #0e8aa5);
  color: white;
  box-shadow: 0 8px 20px rgba(27, 227, 154, 0.2);
}

main { padding: 16px 28px 28px; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  min-height: 56px;
  padding: 0 18px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.topbar-title { min-width: 190px; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 21px; }
h2 { font-size: 18px; }
p { color: var(--muted); }
.topbar p { margin: 4px 0 0; font-size: 13px; }
.main-menu-toggle {
  display: none;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text-soft);
  cursor: pointer;
  place-content: center;
  gap: 4px;
}
.main-menu-toggle span {
  width: 17px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.main-menu-toggle:hover {
  border-color: var(--green);
  color: var(--green-strong);
  background: var(--green-soft);
}

.trial-pill {
  min-width: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 800;
  font-size: 13px;
}
.trial-pill > span:first-child {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 2px solid currentColor;
  border-radius: 50%;
  display: inline-block;
  position: relative;
}
.trial-pill #trialPillText {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  white-space: normal;
}
.trial-pill { flex-wrap: wrap; text-align: center; }
.trial-pill > span:first-child::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 2px;
  height: 5px;
  background: currentColor;
  border-radius: 2px;
}
.trial-pill strong { color: var(--green-strong); }
.trial-pill.expired {
  background: var(--warning-soft);
  color: var(--warning);
}
.trial-pill.expired strong { color: var(--warning); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--red);
  border-radius: 8px;
  background: transparent;
  color: var(--red);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.logout-btn:hover { background: rgba(220, 38, 38, 0.12); }
.paywall-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(4, 10, 20, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
}
/* Sin esto, [hidden]{display:none} del navegador pierde contra el display:flex
   de arriba (misma especificidad, pero ambas son reglas de autor) y el modal
   queda visible siempre, tapando todo el panel sin importar el atributo hidden. */
.paywall-overlay[hidden] {
  display: none;
}
.paywall-card {
  position: relative;
  width: min(860px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--panel, #0e1726);
  border: 1px solid var(--border, #1f2b3f);
  border-radius: 16px;
  padding: 26px;
}
.paywall-card h2 { margin: 0 0 6px; }
.paywall-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border, #1f2b3f);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 15px;
}
.paywall-plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.paywall-plan {
  border: 1px solid var(--border, #1f2b3f);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.paywall-plan strong { font-size: 17px; }
.paywall-plan .paywall-price { font-size: 22px; font-weight: 800; color: var(--green); }
.paywall-plan ul { margin: 6px 0 10px; padding-left: 18px; font-size: 13px; color: var(--muted); }
.paywall-plan ul li { margin-bottom: 4px; }
.paywall-plan button {
  margin-top: auto;
  padding: 10px;
  border-radius: 8px;
  border: 0;
  background: var(--green);
  color: #04241a;
  font-weight: 800;
  cursor: pointer;
}
.paywall-plan button:disabled { opacity: 0.6; cursor: wait; }
.paywall-invoice {
  border: 1px solid var(--green);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.paywall-note { margin-top: 16px; font-size: 12px; }
.ghost-btn {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  padding: 8px 9px;
}
.user-badge {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(140deg, #0ca678, #0e8aa5);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 900;
}
.status-line {
  margin: -6px 0 22px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}
.status-line.success { color: var(--green); }
.status-line.error { color: var(--red); }

.view { display: none; }
.view.active { display: block; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metrics article, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 6px;
}
.metrics article { padding: 18px; }
.metrics span { display: block; color: var(--muted); font-weight: 700; font-size: 13px; }
.metrics strong { display: block; font-size: 32px; margin-top: 8px; }

.analytics-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin: 54px 0 26px;
}
.analytics-head h2 {
  color: var(--text-soft);
  font-size: 26px;
}
.analytics-head p { margin: 8px 0 0; }
.range-select {
  min-width: 200px;
  display: block;
}
.range-select select {
  margin-top: 0;
  border-color: rgba(113, 98, 233, 0.75);
  color: var(--purple-text);
  background: rgba(113, 98, 233, 0.08);
}
.analytics-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}
.analytics-card {
  min-height: 134px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.analytics-card span {
  display: block;
  color: var(--text-soft);
  font-weight: 800;
  margin-bottom: 10px;
}
.analytics-card strong {
  display: inline-block;
  font-size: 26px;
  color: var(--ink);
  margin-right: 8px;
}
.analytics-card small {
  display: block;
  color: var(--muted);
  margin-top: 10px;
}
.analytics-card b {
  align-self: start;
  color: var(--green);
  font-size: 14px;
  white-space: nowrap;
}
.analytics-card b.negative { color: var(--red); }
.analytics-card b.neutral { color: var(--green); }
.analytics-card::after {
  content: "";
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 7px;
  background: rgba(113, 98, 233, 0.2);
  margin-left: auto;
}
.analytics-card.cyan::after { background: rgba(25, 198, 215, 0.2); }
.analytics-card.green::after { background: rgba(32, 210, 122, 0.2); }
.analytics-card.orange::after { background: rgba(255, 184, 77, 0.2); }
.analytics-card.muted-card::after { background: var(--overlay-2); }
.analytics-card.violet::after { background: rgba(113, 98, 233, 0.28); }
.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 16px;
}
.analytics-panel h2 { font-size: 16px; color: var(--text-soft); }
.analytics-panel .muted { margin: 6px 0 18px; font-size: 12px; }
.analytics-panel.wide { min-height: 348px; }
.line-chart svg {
  width: 100%;
  min-height: 260px;
  display: block;
}
.chart-grid line {
  stroke: var(--overlay-2);
  stroke-width: 1;
}
.chart-grid text, .chart-labels text {
  fill: var(--text-soft);
  font-size: 10px;
}
.chart-line {
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
}
.line-chart circle {
  fill: var(--green);
  stroke: var(--panel);
  stroke-width: 2;
}
.donut-wrap {
  display: grid;
  justify-items: center;
  gap: 12px;
}
.donut {
  width: min(260px, 100%);
  transform: rotate(-90deg);
}
.donut circle { transition: stroke-dasharray 0.2s ease; }
.donut-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 16px;
  color: var(--text-soft);
  font-size: 12px;
}
.donut-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.donut-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.bar-chart, .status-chart {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}
.bar-row, .status-row {
  display: grid;
  grid-template-columns: minmax(92px, 0.8fr) minmax(140px, 1.5fr) 34px;
  gap: 10px;
  align-items: center;
  color: var(--text-soft);
  font-size: 13px;
}
.bar-row div, .status-row div {
  height: 28px;
  border-radius: 5px;
  background: var(--overlay-1);
  overflow: hidden;
}
.bar-row b, .status-row b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--cyan);
}
.status-row b { background: var(--purple-soft); }
.bar-row strong, .status-row strong { text-align: right; }
.dashboard-tools { margin-top: 18px; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { padding: 24px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 14px 0; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { color: var(--muted); font-weight: 800; font-size: 13px; }
input, textarea, select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font: inherit;
  background: var(--overlay-1);
}
input[readonly] { color: var(--text-soft); background: var(--overlay-1); }
/* Desplegable nativo de los <select>: Chrome deriva los colores del popup del
   propio select y sus options. Como el select usa fondos rgba translucidos, en
   tema oscuro el popup compone a casi blanco y el texto queda gris sobre blanco
   (ilegible, ej. "Respuestas rapidas"). Colores solidos por tema, siempre. */
select option, select optgroup {
  background-color: var(--panel);
  color: var(--text);
}
select option:disabled { color: var(--muted); }
textarea { min-height: 90px; resize: vertical; }
.prompt-editor-wrap {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--overlay-1);
  overflow: hidden;
}
.prompt {
  min-height: 410px;
  border: 0;
  border-radius: 0;
  margin: 0;
  background: transparent;
  font-family: Consolas, monospace;
  line-height: 1.45;
}
.prompt:focus { outline: 1px solid rgba(113, 98, 233, 0.7); outline-offset: -1px; }
.prompt-editor-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.prompt-editor-footer strong {
  color: var(--text-soft);
  white-space: nowrap;
}
.prompt-editor-footer strong.warning { color: var(--warning); }
.prompt-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.prompt-action-row button { padding: 9px 12px; }
.prompt-action-row .ai-action {
  background: rgba(32, 210, 122, 0.11);
  border-color: rgba(32, 210, 122, 0.44);
  color: var(--green);
}
.agent-status {
  color: var(--muted);
  font-size: 12px;
  margin-left: 4px;
}
.agent-status.success { color: var(--green); }
.agent-status.error { color: var(--red); }
.agent-editor-panel .panel-head { align-items: flex-start; }
.agent-editor-panel .button-row { margin-top: 0; }
.media-btn {
  color: var(--text-soft);
  border-color: var(--overlay-3);
  min-width: 190px;
}
.agent-config-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.agent-config-section h2 {
  margin-bottom: 14px;
  font-size: 18px;
}
.agent-config-section label { max-width: 620px; display: block; }
.config-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 14px; }
.config-row input[type="checkbox"] { display: inline-block; width: auto; margin: 0 6px 0 0; }
.config-row input[type="number"] { width: 90px; display: inline-block; }

button {
  border: 1px solid var(--line);
  background: var(--overlay-1);
  color: var(--text);
  border-radius: 6px;
  padding: 11px 14px;
  font-weight: 800;
  cursor: pointer;
}
button.primary { background: linear-gradient(160deg, #0ca678, #087a5c); color: white; border-color: transparent; box-shadow: 0 8px 18px rgba(12, 166, 120, 0.24); }
button.primary:hover { background: linear-gradient(160deg, #0b9268, #066a4f); }
button.danger { background: var(--red-soft); color: var(--red); border-color: rgba(255, 100, 124, 0.4); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.button-row.compact { margin-top: 0; }

.admin-page main { padding-top: 18px; }
.compact-range { min-width: 190px; }
.admin-summary-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.admin-panel { margin-bottom: 18px; }
.admin-list {
  display: grid;
  gap: 14px;
}
.admin-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 18px;
  background: var(--overlay-1);
}
.admin-card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.admin-card-head strong {
  display: block;
  color: var(--ink);
  font-size: 17px;
}
.admin-card-head span {
  display: block;
  color: var(--muted);
  margin-top: 5px;
  font-size: 12px;
}
.admin-card h3 {
  margin: 18px 0 4px;
  color: var(--text-soft);
  font-size: 14px;
}
.suspended-banner {
  background: var(--red-soft);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 12px 18px;
  border-radius: 7px;
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 700;
}
.verify-banner {
  background: var(--warning-soft);
  border-color: var(--warning-line);
  color: var(--warning);
}
.announce-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cyan-soft, rgba(34, 183, 255, 0.12));
  border: 1px solid var(--cyan, #22b7ff);
  color: var(--ink);
  padding: 12px 18px;
  border-radius: 7px;
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 600;
}
.announce-banner .announce-ico { font-size: 18px; line-height: 1; }
.entity-overview {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.entity-overview h3 {
  margin-top: 0;
}
.mini-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-soft);
  white-space: nowrap;
}
.mini-check input {
  width: auto;
  margin: 0;
}
.clear-row {
  align-self: end;
  min-height: 42px;
}
.secret-preview {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.secret-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.secret-preview-row code {
  word-break: break-all;
}
.model-test-result {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 600;
  word-break: break-word;
}
.model-test-result.success { color: var(--green); }
.model-test-result.error { color: var(--red); }
.secret-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: stretch;
  gap: 6px;
}
.secret-input input {
  min-width: 0;
}
.icon-eye-btn {
  min-width: 42px;
  padding: 0 10px;
  display: inline-grid;
  place-items: center;
  border-color: rgba(129, 117, 255, 0.38);
  color: var(--purple-text);
  background: rgba(113, 98, 233, 0.12);
}
.icon-eye-btn.active-eye {
  background: rgba(25, 198, 215, 0.18);
  border-color: rgba(25, 198, 215, 0.55);
  color: var(--cyan);
}
.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.inline-actions.align-end { align-items: flex-end; }
.client-search-input { min-width: 220px; }
.billing-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}
.billing-summary div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--overlay-1);
}
.billing-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.billing-summary strong {
  display: block;
  color: var(--ink);
  font-size: 19px;
  margin-top: 5px;
}
.usage-grid { margin-top: 8px; }
.plans-admin-list textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
}
.wide-label {
  display: block;
  margin-top: 14px;
}
.plan-rule-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.plan-rule-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: var(--overlay-1);
}
.plan-rule-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.plan-rule-grid strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
}
.usage-progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--overlay-2);
  border: 1px solid var(--overlay-2);
}
.usage-progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #10b981, #22b7ff);
  transition: width 0.2s ease;
}
.usage-progress.over span,
.plan-consumption-state.over + .usage-progress span {
  background: linear-gradient(90deg, #ffba68, var(--red));
}
.admin-progress {
  margin: -4px 0 10px;
}
.plan-consumption-panel {
  margin-bottom: 18px;
}
.plan-consumption-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.plan-consumption-head span,
.plan-consumption-head small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}
.plan-consumption-head strong {
  display: block;
  margin: 5px 0;
  color: var(--ink);
  font-size: 24px;
}
.plan-consumption-state {
  border: 1px solid rgba(32, 210, 122, 0.35);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 900;
}
.plan-consumption-state.over {
  border-color: rgba(255, 100, 124, 0.45);
  background: var(--red-soft);
  color: var(--red);
}
.plan-consumption-grid {
  margin-bottom: 12px;
}

pre {
  white-space: pre-wrap;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 14px;
  border-radius: 8px;
  overflow: auto;
}
.events { display: grid; gap: 10px; }
.event {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
}
.event small { color: var(--muted); }
.big-status {
  margin: 0;
  padding: 11px 22px;
  border-radius: 6px;
  background: var(--overlay-1);
  border: 1px solid var(--overlay-2);
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 900;
  min-width: 150px;
  text-align: center;
}
.big-status.connected { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.big-status.warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-line); }
.big-status.disconnected { background: var(--overlay-1); color: var(--text-soft); }
.qr-box {
  min-height: 242px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--overlay-3);
  border-radius: 6px;
  background: var(--panel-deep);
  color: var(--muted);
  margin-top: 18px;
  padding: 18px;
  text-align: center;
  line-height: 1.35;
}
.qr-box.small { min-height: 126px; padding: 14px; text-align: center; }
.qr-box img { max-width: 230px; width: 100%; height: auto; border-radius: 6px; background: white; padding: 10px; }
.muted { color: var(--muted); font-size: 13px; }
.required { color: var(--red); }
table { width: 100%; border-collapse: collapse; margin-top: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 12px; text-align: left; }
th { background: var(--overlay-1); font-size: 13px; }
code { background: var(--overlay-2); padding: 3px 6px; border-radius: 5px; }

.login-shell {
  /* El body usa el grid del panel (sidebar + contenido); las paginas de auth
     deben ocupar todo el ancho para poder centrar la tarjeta. */
  grid-column: 1 / -1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 12px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--overlay-1);
}
.login-card h1 { display: flex; align-items: center; gap: 10px; font-size: 22px; margin: 0 0 6px; }
.login-card p.muted { margin: 0 0 24px; }
.login-card label { display: block; margin-bottom: 16px; font-size: 13px; }
.login-card input {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--overlay-2);
  color: inherit;
}
.login-card button { width: 100%; margin-top: 8px; }
.terms-row { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; margin-bottom: 18px; }
.terms-row input { width: auto; margin-top: 3px; }
.terms-row label { margin: 0; }
.auth-footer-link { text-align: center; margin-top: 16px; }
.auth-footer-link.tight { margin-top: 8px; }
#loginError, #registerError, #formError, #twoFactorError { color: var(--red); font-size: 13px; margin: 12px 0 0; min-height: 18px; }
#formSuccess { color: var(--green-strong); font-size: 13px; margin: 12px 0 0; min-height: 18px; }

.whatsapp-shell {
  max-width: 1060px;
  margin: 0 auto;
  padding-top: 28px;
}
.whatsapp-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 28px;
}
.whatsapp-identity {
  display: flex;
  align-items: center;
  gap: 16px;
}
.wa-glyph {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--text-soft);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 900;
}
.whatsapp-identity h2 {
  font-size: 26px;
  color: var(--text-soft);
}
.whatsapp-identity p { margin: 8px 0 6px; }
.tutorial-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--purple-soft);
  font-size: 13px;
  text-decoration: underline;
}
.wa-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-button {
  width: auto;
  min-width: 44px;
  border-color: var(--overlay-3);
  color: var(--text-soft);
}
.whatsapp-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(420px, 1.45fr);
  gap: 18px;
}
.connection-panel { min-height: 420px; }
.provider-chip {
  color: var(--muted);
  background: var(--overlay-1);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.connection-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.panel-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}
.panel-title p { margin: 8px 0 0; }
.gear-dot {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border: 2px solid var(--text-soft);
  border-radius: 50%;
  display: inline-block;
  position: relative;
}
.gear-dot::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--text-soft);
}
.settings-list {
  display: grid;
  gap: 19px;
  margin-top: 16px;
}
.switch-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: start;
  color: var(--text);
}
.switch-row input { display: none; }
.switch-ui {
  width: 30px;
  height: 18px;
  margin-top: 1px;
  border-radius: 999px;
  background: var(--overlay-3);
  position: relative;
  transition: background 0.2s ease;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}
.switch-row input:checked + .switch-ui {
  background: var(--green);
}
.switch-row input:checked + .switch-ui::after {
  transform: translateX(12px);
}
.switch-row strong {
  display: block;
  color: var(--text-soft);
  font-size: 15px;
}
.switch-row small {
  display: block;
  color: var(--muted);
  margin-top: 7px;
  font-size: 13px;
  line-height: 1.35;
}
.webhook-panel { margin-top: 18px; }

.hidden { display: none !important; }
.agent-wizard-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 11, 20, 0.72);
  backdrop-filter: blur(5px);
}
.prompt-ai-backdrop, .media-library-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 11, 20, 0.72);
  backdrop-filter: blur(5px);
}
.prompt-ai-modal, .media-library-modal {
  position: relative;
  width: min(620px, 100%);
  background: var(--panel-raised);
  border: 1px solid var(--overlay-2);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  padding: 28px 28px 0;
}
.media-library-modal {
  width: min(800px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
  padding-bottom: 0;
}
.prompt-ai-modal h2 {
  font-size: 24px;
  color: var(--ink);
  margin: 0 40px 8px 0;
}
.media-library-modal h2 {
  color: var(--ink);
  font-size: 22px;
  margin: 0 40px 24px 0;
}
.prompt-ai-modal p {
  color: var(--muted);
  margin-bottom: 16px;
}
.prompt-ai-modal textarea {
  min-height: 150px;
  margin-bottom: 16px;
}
.prompt-ai-modal .wizard-actions {
  margin: 0 -28px;
}
.media-drive-box {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--overlay-1);
}
.inline-input {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: end;
  margin-top: 8px;
}
.inline-input input { margin-top: 0; }
.media-empty-state, .media-connected-state {
  min-height: 210px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 10px;
  padding: 38px 18px;
  color: var(--muted);
}
.media-empty-state strong, .media-connected-state strong {
  display: block;
  color: var(--text-soft);
  font-size: 20px;
}
.media-empty-state.error strong { color: var(--red); }
.media-connected-state {
  place-items: center;
  border: 1px dashed rgba(113, 98, 233, 0.45);
  border-radius: 8px;
  margin-top: 16px;
}
.media-connected-state a {
  color: var(--purple-text);
  font-weight: 800;
  text-decoration: none;
}
.media-connected-state p {
  max-width: 560px;
  margin: 0;
  line-height: 1.45;
}
.media-manual-add {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.media-modal-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin: 20px -28px 0;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.media-modal-footer b {
  color: var(--red);
}
.agent-wizard {
  width: min(1080px, 100%);
  max-height: min(780px, calc(100vh - 48px));
  display: grid;
  grid-template-columns: 240px 1fr;
  background: var(--panel-raised);
  border: 1px solid var(--overlay-2);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  overflow: hidden;
}
.wizard-steps {
  padding: 34px 24px;
  background: var(--overlay-1);
  border-right: 1px solid var(--overlay-2);
}
.wizard-step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: start;
  color: var(--muted);
}
.wizard-step + .wizard-step { margin-top: 22px; }
.wizard-step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--overlay-2);
  color: var(--muted);
  font-weight: 900;
}
.wizard-step.active { color: var(--ink); }
.wizard-step.active .wizard-step-number {
  background: var(--purple);
  color: white;
}
.wizard-step.done .wizard-step-number {
  background: rgba(32, 210, 122, 0.18);
  color: var(--green);
}
.wizard-step strong {
  display: block;
  font-size: 14px;
  margin-bottom: 3px;
}
.wizard-step small {
  display: block;
  font-size: 12px;
  color: currentColor;
  opacity: 0.72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wizard-step-line {
  width: 2px;
  height: 30px;
  margin: 12px 0 0 13px;
  background: rgba(129, 114, 245, 0.46);
}
.wizard-main {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 620px;
}
.wizard-close {
  position: absolute;
  right: 18px;
  top: 16px;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: 20px;
  padding: 8px;
}
.wizard-content {
  padding: 40px 32px 24px;
  overflow: auto;
}
.wizard-content h2 {
  font-size: 26px;
  color: var(--ink);
  margin-bottom: 10px;
}
.wizard-content > p { margin: 0 0 28px; }
.wizard-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.wizard-card {
  min-height: 124px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: var(--overlay-1);
  color: var(--text-soft);
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 18px;
  text-align: center;
}
.wizard-card:hover, .wizard-card.active {
  border-color: var(--purple);
  background: rgba(113, 98, 233, 0.16);
}
.wizard-card-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(113, 98, 233, 0.2);
  color: var(--purple-text);
  font-weight: 900;
}
.wizard-form {
  display: grid;
  gap: 16px;
}
.wizard-form textarea { min-height: 136px; }
.wizard-helper {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
  margin-top: -8px;
}
.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.option-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--overlay-2);
  border-radius: 5px;
  background: var(--overlay-1);
}
.option-row input { margin: 3px 0 0; }
.option-row:has(input:checked) {
  border-color: var(--purple);
  background: rgba(113, 98, 233, 0.14);
}
.option-row strong {
  display: block;
  color: var(--text-soft);
  font-size: 14px;
}
.option-row small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.35;
}
.wizard-review {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(320px, 1.2fr);
  gap: 18px;
}
.review-card {
  border: 1px solid var(--overlay-2);
  border-radius: 6px;
  padding: 16px;
  background: var(--overlay-1);
}
.review-card ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--text-soft);
}
.prompt-preview {
  min-height: 330px;
  max-height: 430px;
  overflow: auto;
  white-space: pre-wrap;
  background: var(--code-bg);
  border: 1px solid var(--overlay-2);
  color: var(--text-soft);
  font: 12px/1.48 Consolas, monospace;
  padding: 16px;
  border-radius: 6px;
}
.launch-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.launch-summary div {
  padding: 16px;
  border-radius: 6px;
  background: var(--overlay-1);
  border: 1px solid var(--overlay-2);
}
.launch-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}
.launch-summary strong { color: var(--ink); }
.interview-chat { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.interview-log {
  max-height: 44vh;
  min-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--overlay-2);
  border-radius: 10px;
  background: var(--overlay-1);
}
.interview-q-wrap { display: flex; flex-direction: column; align-items: flex-start; }
.interview-progress {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--purple-soft);
  border-bottom: 2px solid var(--purple-soft);
  padding-bottom: 3px;
  margin-bottom: 6px;
}
.interview-bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
}
.interview-bubble.q {
  background: var(--overlay-1);
  border: 1px solid var(--overlay-2);
  color: var(--text-soft);
  align-self: flex-start;
  display: flex;
  gap: 8px;
}
.interview-bubble.a {
  background: linear-gradient(90deg, var(--purple), var(--purple-soft));
  color: white;
  align-self: flex-end;
  font-weight: 600;
}
.interview-ai-ico { flex: none; }
.interview-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin: 4px 0;
}
.interview-separator::before, .interview-separator::after { content: ""; flex: 1; border-top: 1px dashed var(--overlay-3); }
.interview-input-row { display: flex; gap: 8px; align-items: stretch; }
.interview-input-row textarea { flex: 1; margin-top: 0; resize: none; }
.interview-send { min-width: 54px; font-size: 17px; }
.interview-status { color: var(--muted); font-size: 13px; text-align: center; padding: 8px; }
.interview-status.error { color: var(--red); }
.interview-skip-row { display: flex; justify-content: flex-end; }
.wizard-generated-label { display: block; margin-top: 14px; }
.wizard-generated-prompt {
  min-height: 280px;
  max-height: 46vh;
  font: 12.5px/1.5 Consolas, monospace;
  white-space: pre;
  overflow: auto;
}
.wizard-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 32px 22px;
  border-top: 1px solid var(--overlay-2);
}
.wizard-actions button {
  min-width: 118px;
}

@media (max-width: 920px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; padding: 14px 16px 14px; }
  /* Menu (hamburguesa) a la IZQUIERDA en movil; la marca se corre a su lado. */
  .sidebar-collapse { left: 10px; right: auto; top: 14px; z-index: 2; min-width: 44px; min-height: 44px; }
  .brand { margin: 0 96px 0 52px; min-height: 44px; }
  .brand strong { font-size: 21px; }
  /* Switch de tema visible a la derecha de la cabecera movil. */
  .theme-switch-mini { display: inline-flex; position: absolute; right: 10px; top: 14px; z-index: 2; }
  /* En movil el switch reemplaza al boton "Tema" del topbar. */
  #themeToggleBtn { display: none; }
  .sidebar nav { display: none; }
  .sidebar.nav-open nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    margin-top: 18px;
  }
  nav button, .nav-link {
    padding: 13px 14px;
    font-size: 15px;
  }
  .metrics, .grid.two, .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  main { padding: 18px; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px; }
  .trial-pill { min-width: 0; width: 100%; }
  .analytics-head {
    flex-direction: column;
    margin-top: 24px;
  }
  .analytics-head h2 { font-size: 24px; }
  .range-select { width: 100%; }
  .analytics-cards, .analytics-grid { grid-template-columns: 1fr; gap: 14px; }
  .admin-summary-cards, .billing-summary, .plan-rule-grid { grid-template-columns: 1fr; }
  .admin-card-head {
    flex-direction: column;
    align-items: stretch;
  }
  .plan-consumption-head { display: grid; }
  .inline-actions { justify-content: flex-start; }
  .analytics-card {
    min-height: 116px;
    padding: 18px;
  }
  .analytics-card strong { font-size: 25px; }
  .bar-row, .status-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .bar-row strong, .status-row strong { text-align: left; }
  .media-library-backdrop { padding: 0; align-items: stretch; }
  .media-library-modal {
    width: 100%;
    max-height: none;
    min-height: 100vh;
    border-radius: 0;
    padding: 54px 18px 0;
  }
  .inline-input { grid-template-columns: 1fr; }
  .media-modal-footer {
    flex-direction: column;
    align-items: stretch;
    margin-left: -18px;
    margin-right: -18px;
  }
  .whatsapp-shell { padding-top: 8px; }
  .whatsapp-hero, .wa-toolbar { flex-direction: column; align-items: flex-start; }
  .whatsapp-grid { grid-template-columns: 1fr; }
  .whatsapp-identity h2 { font-size: 21px; }
  .connection-panel .panel-head { align-items: flex-start; flex-direction: column; }
  .provider-chip { white-space: normal; }
  .agent-editor-panel .panel-head { flex-direction: column; }
  .agent-editor-panel .button-row { width: 100%; }
  .agent-editor-panel .button-row button { flex: 1 1 140px; }
  .prompt-editor-footer { flex-direction: column; }
  .prompt-action-row button { flex: 1 1 140px; }
  .agent-status { flex: 1 1 100%; margin-left: 0; }
  .agent-wizard-backdrop { padding: 0; align-items: stretch; }
  .agent-wizard {
    min-height: 100vh;
    max-height: none;
    grid-template-columns: 1fr;
    border-radius: 0;
  }
  .wizard-steps {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    padding: 14px 18px;
    border-right: 0;
    border-bottom: 1px solid var(--overlay-2);
  }
  .wizard-step {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0;
  }
  .wizard-step span:not(.wizard-step-number) { display: none; }
  .wizard-step + .wizard-step { margin-top: 0; }
  .wizard-step-number { width: 34px; height: 34px; }
  .wizard-step-line { display: none; }
  .wizard-main { min-height: 0; }
  .wizard-content { padding: 54px 18px 18px; }
  .wizard-content h2 { font-size: 24px; line-height: 1.16; }
  .wizard-card-grid, .option-grid, .wizard-review, .launch-summary { grid-template-columns: 1fr; }
  .wizard-actions { padding: 14px 18px 18px; }
  .wizard-actions button { min-width: 0; flex: 1; }
}

.table-scroll { overflow-x: auto; }
.table-scroll select[data-field="pipelineStage"] { min-width: 130px; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 13px; }
.admin-table th, .admin-table td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; white-space: nowrap; }
.admin-table th { background: var(--overlay-1); font-weight: 600; color: var(--muted); }
.admin-table tr:hover td { background: var(--overlay-1); }
.status-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-badge.active { background: var(--green-soft); color: var(--green); }
.status-badge.trial { background: rgba(120, 156, 255, 0.16); color: var(--purple-text); }
.status-badge.paused { background: var(--warning-soft); color: var(--warning); }
.status-badge.cancelled { background: var(--red-soft); color: var(--red); }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table-actions button { padding: 5px 9px; font-size: 12px; }

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
  display: flex;
  justify-content: flex-end;
}
.drawer-overlay[hidden] {
  display: none;
}
.drawer {
  width: 100%;
  max-width: 640px;
  height: 100%;
  overflow-y: auto;
  background: var(--panel);
  padding: 28px;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}
.drawer-close { padding: 6px 12px; }

.log-row {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.log-row .log-level { text-transform: uppercase; font-size: 11px; font-weight: 700; min-width: 42px; }
.log-row .log-level.warn { color: var(--warning); }
.log-row .log-level.info { color: var(--purple-text); }
.log-row .log-level.error { color: var(--red); }
.log-row .log-time { color: var(--muted); font-size: 12px; white-space: nowrap; }

.inbox-panel { padding: 0; }
.inbox-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 680px;
}
.inbox-list-pane {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.inbox-list-head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.inbox-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.inbox-tab {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  background: var(--overlay-1);
  color: var(--muted);
  border-radius: 999px;
}
.inbox-tab.active { background: var(--green-soft); color: var(--green-strong); border-color: var(--green); }
.inbox-list-head input { margin-top: 0; font-size: 13px; padding: 9px 10px; }
.inbox-list { flex: 1; overflow-y: auto; }
.inbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  border-radius: 0;
  font-weight: 400;
}
.inbox-row:hover { background: var(--overlay-1); }
.inbox-row.active { background: var(--green-soft); }
.inbox-row-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  background: linear-gradient(140deg, #0ca678, #0e8aa5);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 13px;
}
.inbox-row-body { min-width: 0; flex: 1; }
.inbox-row-top { display: flex; justify-content: space-between; gap: 8px; }
.inbox-row-top strong { font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-row-time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.inbox-row-preview {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inbox-row.unread .inbox-row-preview { color: var(--text-soft); font-weight: 700; }
.inbox-row.unread .inbox-row-top strong { color: var(--ink); font-weight: 900; }
.inbox-row-tags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.inbox-row-tag {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(113, 98, 233, 0.16);
  color: var(--purple-text);
}
.inbox-row-tag.agent { background: rgba(25, 198, 215, 0.18); color: #8fe4ee; }
.inbox-unread-badge {
  flex: 0 0 auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--purple);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
  margin-top: 2px;
}
.inbox-empty-list { padding: 24px 16px; color: var(--muted); font-size: 13px; text-align: center; }

.inbox-thread-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.inbox-empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 6px;
  color: var(--muted);
  padding: 24px;
}
.inbox-empty strong { color: var(--text-soft); font-size: 16px; }
.inbox-empty[hidden] { display: none; }
.inbox-thread { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.inbox-thread[hidden] { display: none; }
.inbox-thread-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.inbox-back { display: none; padding: 8px 10px; }
.inbox-thread-contact { flex: 1 1 auto; min-width: 180px; }
.inbox-thread-actions { flex: 0 1 auto; justify-content: flex-end; }
.inbox-thread-contact strong { display: block; font-size: 15px; color: var(--ink); }
.inbox-thread-contact span { font-size: 12px; }
.inbox-thread-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inbox-thread-actions button, .inbox-thread-actions select { padding: 7px 10px; font-size: 12px; }
.inbox-thread-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inbox-thread-tools select, .inbox-thread-tools button { width: auto; margin-top: 0; }
.inbox-delete-chat-btn {
  color: var(--red) !important;
  border: 1px solid var(--red) !important;
  background: transparent !important;
  font-weight: 600;
}
.inbox-delete-chat-btn:hover { background: rgba(220, 38, 38, 0.12) !important; }
.inbox-tools-toggle { display: none; }
.inbox-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--panel-deep);
  background-image: var(--chat-doodle);
  background-repeat: repeat;
}
.inbox-bubble {
  max-width: 72%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.4;
  word-break: break-word;
}
.inbox-bubble-text { white-space: pre-wrap; }
.inbox-bubble.in { align-self: flex-start; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-bottom-left-radius: 2px; }
.inbox-bubble.out { align-self: flex-end; background: var(--bubble-out); color: #fff; border-bottom-right-radius: 2px; }
.inbox-bubble.out.ai { background: var(--bubble-ai); }
/* Mensaje escrito por el dueno desde su propio telefono: color propio + badge, solo visible en wenko */
.inbox-bubble.out.from-phone { background: #0e7490; }
.inbox-phone-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.02em;
}
.inbox-bubble.out.note {
  align-self: center;
  background: var(--warning-soft);
  border: 1px dashed rgba(255, 208, 111, 0.45);
  color: var(--warning);
  max-width: 90%;
}
.inbox-bubble-meta { margin-top: 5px; font-size: 10.5px; opacity: 0.68; display: flex; align-items: center; gap: 3px; }
.receipt-tick { display: inline-flex; align-items: center; opacity: 0.85; }
.wa-tick { width: 16px; height: 15px; display: block; }
.wa-tick-clock { width: 13px; height: 13px; }
.receipt-tick.read { color: #53bdeb; opacity: 1; }
.receipt-tick.failed { color: #ff6c6c; opacity: 1; font-size: 13px; }
.receipt-tick.pending { opacity: 0.7; }
.inbox-composer { border-top: 1px solid var(--line); padding: 12px 16px 16px; }
.inbox-composer-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.inbox-composer-tab {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--overlay-1);
  color: var(--muted);
}
.inbox-composer-tab.active { background: var(--green-soft); color: var(--green-strong); border-color: var(--green); }
.inbox-composer-tab[data-mode="note"].active { background: var(--warning-soft); color: var(--warning); border-color: rgba(255, 208, 111, 0.45); }
.inbox-composer textarea { min-height: 64px; margin-top: 0; }
.inbox-attachment-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  background: rgba(113, 98, 233, 0.12);
  border: 1px solid rgba(113, 98, 233, 0.3);
  font-size: 12.5px;
  color: var(--purple-text);
}
.inbox-attachment-preview button { padding: 2px 8px; }
.inbox-attachment-preview[hidden] { display: none; }
.inbox-bubble-media-image { max-width: 220px; max-height: 220px; border-radius: 8px; display: block; margin-bottom: 4px; }
.inbox-bubble-media-audio { max-width: 240px; display: block; margin-bottom: 4px; }
.inbox-bubble-media-video { max-width: 260px; border-radius: 8px; display: block; margin-bottom: 4px; }
.inbox-bubble-media-doc { color: inherit; text-decoration: underline; display: block; margin-bottom: 4px; }
.canned-row { display: flex; gap: 8px; margin-bottom: 8px; }
.canned-row select { margin-top: 0; flex: 1; }
.canned-row button { white-space: nowrap; }

.wa-composer-row { display: flex; align-items: flex-end; gap: 4px; }
#inboxComposerText.wa-composer-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  margin-top: 0;
  padding: 9px 14px;
  border-radius: 20px;
  resize: none;
  line-height: 1.35;
}
.icon-btn {
  flex: none;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 0;
  background: transparent;
  font-size: 19px;
  padding: 0;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--overlay-1); color: var(--ink); }
.wa-action-btn.wa-send-btn {
  background: var(--green);
  color: #fff;
  font-size: 16px;
}
.wa-action-btn.wa-send-btn:hover { background: var(--green-strong); }
.icon-btn.recording { background: var(--red-soft); color: var(--red); }
@media (max-width: 640px) {
  .wa-composer-input { min-height: 36px; padding: 8px 12px; font-size: 13px; }
  .icon-btn { width: 34px; height: 34px; font-size: 17px; }
}

.inbox-dept-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.inbox-dept-row select { margin-top: 0; flex: 1; min-width: 120px; font-size: 12px; padding: 7px 8px; }
.inbox-dept-row button { white-space: nowrap; font-size: 12px; padding: 7px 9px; }

.inbox-contact-name-row { display: flex; align-items: center; gap: 6px; }
.inbox-contact-name-row .icon-eye-btn { min-width: 26px; padding: 0 6px; font-size: 12px; }
.inbox-contact-name-edit { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.inbox-contact-name-edit[hidden] { display: none; }
.inbox-contact-name-edit input { margin-top: 0; font-size: 13px; padding: 6px 8px; flex: 1 1 140px; min-width: 0; }
.inbox-contact-name-edit button { padding: 6px 10px; font-size: 12px; white-space: nowrap; }
#inboxRecordBtn { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#inboxRecordBtn.recording {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(255, 100, 124, 0.4);
  transform: scale(1.18);
  animation: record-pulse 1.2s ease-in-out infinite;
}
@keyframes record-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 100, 124, 0.45); }
  50% { box-shadow: 0 0 0 9px rgba(255, 100, 124, 0); }
}
#inboxAttachInput { display: none; }
.office-days { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.office-days label { display: flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 700; color: var(--text); }
.office-days input { width: auto; margin-top: 0; }

.contact-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.contact-tags span { cursor: pointer; }
.tag-input { margin-top: 0; font-size: 12px; padding: 6px 8px; }

.tag-defs-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0 2px; }
.tag-def-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.tag-def-chip button { border: 0; background: transparent; cursor: pointer; opacity: .65; font-size: 13px; line-height: 1; padding: 2px; color: inherit; }
.tag-def-chip button:hover { opacity: 1; }
#tagColorInput { width: 44px; padding: 2px; height: 34px; cursor: pointer; }

.msg-system { display: flex; justify-content: center; margin: 6px 0; }
.msg-system span { font-size: 12px; color: var(--text-soft); background: var(--panel-raised, var(--surface-2)); padding: 4px 12px; border-radius: 999px; }
.msg-transcript { font-size: 12.5px; color: var(--text-soft); margin-top: 4px; font-style: italic; }

.kb-article { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.kb-article h4 { margin: 0 0 4px; font-size: 14px; }
.kb-article p { margin: 0; font-size: 13px; color: var(--text-soft); white-space: pre-wrap; }
.kb-article .button-row { margin-top: 6px; }

@media (max-width: 920px) {
  .inbox-shell { grid-template-columns: 1fr; height: auto; }
  .inbox-list-pane { border-right: 0; height: 72vh; min-height: 420px; }
  .inbox-shell:not(.thread-open) .inbox-thread-pane { display: none; }
  .inbox-shell.thread-open {
    position: fixed;
    inset: 0;
    z-index: 45;
    background: var(--bg);
    display: flex;
  }
  .inbox-shell.thread-open .inbox-list-pane { display: none; }
  .inbox-shell.thread-open .inbox-thread-pane { height: 100%; width: 100%; }
  /* Cabecera del hilo estilo WhatsApp: una sola fila compacta, opciones tras el boton de menu */
  .inbox-thread-head { flex-wrap: nowrap; padding: 6px 10px; gap: 8px; align-items: center; }
  .inbox-thread-contact { flex: 1 1 auto; min-width: 0; }
  .inbox-thread-contact strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .inbox-thread-contact > span { font-size: 11px; }
  .inbox-back { display: inline-flex; padding: 6px 9px; }
  .inbox-thread-actions { flex: 0 0 auto; gap: 6px; position: relative; flex-wrap: nowrap; }
  .inbox-tools-toggle { display: inline-flex; font-size: 18px; line-height: 1; padding: 5px 11px; }
  .inbox-thread-tools { display: none; }
  .inbox-thread-tools.open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    padding: 12px;
    border-radius: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
    z-index: 60;
  }
  .inbox-thread-tools.open button, .inbox-thread-tools.open select { width: 100%; padding: 9px 10px; font-size: 13px; }

  /* Mensajes compactos: mas conversacion visible sin scroll */
  .inbox-messages { padding: 10px; gap: 4px; }
  .inbox-bubble { max-width: 82%; padding: 6px 9px; font-size: 13px; border-radius: 9px; }
  .inbox-bubble-meta { margin-top: 2px; font-size: 9.5px; justify-content: flex-end; }
  .inbox-bubble-media-audio { max-width: 205px; height: 36px; }
  .inbox-bubble-media-image { max-width: 180px; max-height: 180px; }
  .inbox-bubble-media-video { max-width: 200px; }

  /* Compositor delgado */
  .inbox-composer { padding: 6px 8px 8px; }
  .inbox-composer-tabs { margin-bottom: 4px; }
  .inbox-composer-tab { padding: 4px 9px; font-size: 11px; }
  .canned-row { margin-bottom: 4px; }
  .canned-row select { font-size: 12px; padding: 6px 8px; }
  .canned-row button { font-size: 12px; padding: 6px 8px; }
  .inbox-composer textarea { min-height: 38px; font-size: 13px; padding: 8px 10px; }
  .inbox-attachment-preview { margin-top: 4px; padding: 4px 8px; font-size: 11.5px; }
  #inboxAttachBtn, #inboxRecordBtn { font-size: 0; padding: 8px 11px; }
  #inboxAttachBtn::before { content: "\1F4CE"; font-size: 15px; }
  #inboxRecordBtn::before { content: "\1F3A4"; font-size: 15px; }
}

/* Boton de chat nuevo: circulo verde con + al final de la fila de pestanas
   (Abiertas / Pendientes / Resueltas / Todas) de la bandeja */
.new-chat-fab {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #fff;
  background: linear-gradient(160deg, #0ca678, #087a5c);
  box-shadow: 0 4px 10px rgba(12, 166, 120, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.new-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 14px rgba(12, 166, 120, 0.42);
}
.new-chat-fab:active { transform: scale(0.95); }
.new-chat-error {
  color: var(--red);
  background: var(--red-soft);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  margin: 8px 0 0;
}
#newChatDialog textarea {
  width: 100%;
  resize: vertical;
  min-height: 64px;
}

/* Filtro por categoria de contacto en el CRM (Todos / Clientes / Proveedores / Aliados ISP...) */
.crm-category-filter {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 10px;
}
.crm-cat-chip {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.crm-cat-chip:hover { border-color: var(--green); color: var(--green-strong); }
.crm-cat-chip.active {
  background: var(--green-soft);
  color: var(--green-strong);
  border-color: var(--green);
  font-weight: 600;
}

/* Tabla CRM compacta: texto mas pequeno, columnas ajustables y celdas recortadas */
.crm-table { table-layout: fixed; min-width: 1280px; }
.crm-table th, .crm-table td { font-size: 12px; padding: 6px 8px; }
.crm-table input, .crm-table select { font-size: 12px; padding: 4px 6px; width: 100%; box-sizing: border-box; }
.crm-table th { position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-cell-clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-funnel-card .crm-cell-clip { display: block; max-width: 100%; }
.crm-table td.crm-cell-clip, .crm-table td { overflow: hidden; }
.crm-th-select { width: 34px; }
.crm-th-actions { width: 128px; }
.crm-td-select { text-align: center; }
.crm-td-actions { white-space: nowrap; }
.crm-actions-wrap { display: flex; gap: 5px; align-items: center; flex-wrap: nowrap; }
.crm-table td { vertical-align: middle; }
.crm-table .contact-tags { display: flex; flex-wrap: wrap; gap: 3px; }
/* Anchos iniciales por columna (ajustables con la agarradera del encabezado) */
.crm-table th:nth-child(3) { width: 112px; }  /* Telefono */
.crm-table th:nth-child(4) { width: 128px; }  /* Nombre */
.crm-table th:nth-child(5) { width: 104px; }  /* Categoria */
.crm-table th:nth-child(6) { width: 132px; }  /* Empresa */
.crm-table th:nth-child(7) { width: 116px; }  /* Cargo */
.crm-table th:nth-child(8) { width: 126px; }  /* Sitio web */
.crm-table th:nth-child(9) { width: 96px; }   /* Estado */
.crm-table th:nth-child(10) { width: 104px; } /* Etapa CRM */
.crm-table th:nth-child(11) { width: 130px; } /* Etiquetas */
.crm-table th:nth-child(12) { width: 170px; } /* Notas */
.crm-table th:nth-child(13) { width: 96px; }  /* Seguimiento */
.crm-table th:nth-child(14) { width: 108px; } /* Actualizado */
.th-resizer { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; user-select: none; }
.th-resizer:hover { background: var(--green-soft); }

/* Botones de accion por fila del CRM */
.crm-wa-btn {
  width: 24px; height: 24px; border-radius: 50%; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  color: #fff; background: linear-gradient(160deg, #0ca678, #087a5c);
  box-shadow: 0 3px 8px rgba(12, 166, 120, 0.3);
}
.crm-wa-btn:hover { transform: scale(1.08); }
.crm-mini-btn {
  border: 1px solid var(--line); background: var(--panel-soft); color: var(--text-soft);
  border-radius: 7px; padding: 4px 9px; font-size: 11.5px; cursor: pointer;
}
.crm-mini-btn:hover { border-color: var(--green); color: var(--green-strong); }
.crm-mini-btn.primary { background: linear-gradient(160deg, #0ca678, #087a5c); color: #fff; border-color: transparent; }

/* Embudo de contactos: una columna por etapa con tarjetas */
.crm-funnel { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 8px; overflow-x: auto; }
.crm-funnel-col { background: var(--panel-deep); border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 90px; }
.crm-funnel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; font-size: 12.5px; }
.crm-funnel-head span { background: var(--green-soft); color: var(--green-strong); border-radius: 999px; padding: 1px 8px; font-size: 11.5px; font-weight: 700; }
.crm-funnel-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; margin-bottom: 6px; }
.crm-funnel-card strong { font-size: 12px; }
.crm-funnel-card small { display: block; font-size: 11px; color: var(--muted); }
.crm-funnel-cat { color: var(--cyan); }
.crm-funnel-moves { display: flex; justify-content: space-between; margin-top: 5px; }
.crm-funnel-moves button {
  border: 1px solid var(--line); background: var(--panel-soft); color: var(--text-soft);
  border-radius: 6px; padding: 1px 9px; font-size: 12px; cursor: pointer;
}
.crm-funnel-moves button:hover:not(:disabled) { border-color: var(--green); color: var(--green-strong); }
.crm-funnel-moves button:disabled { opacity: 0.35; cursor: default; }
.crm-funnel-empty { font-size: 11.5px; color: var(--muted); text-align: center; margin: 14px 0; }
@media (max-width: 900px) {
  .crm-funnel { grid-template-columns: repeat(5, 150px); }
}

/* ==================== Vista de chats a pantalla completa (sin scroll de pagina) ====================
   .inbox-shell tenia height:680px fijo -> en ventanas cortas la PAGINA hacia scroll.
   Con :has() limitamos SOLO la vista de chats al alto del viewport: la lista y los
   mensajes hacen scroll INTERNO y el cuadro de escribir queda siempre visible. Las
   demas vistas (dashboard, etc.) conservan su scroll de pagina normal. */
@media (min-width: 900px) {
  body:has(#chats.active) { height: 100vh; overflow: hidden; }
  body:has(#chats.active) > main { height: 100vh; display: flex; flex-direction: column; overflow: hidden; min-height: 0; padding-top: 10px; }
  body:has(#chats.active) > aside.sidebar { height: 100vh; overflow-y: auto; }
  body:has(#chats.active) .topbar { margin-bottom: 8px; }
  body:has(#chats.active) #globalStatus { display: none; }
  #chats.active { flex: 1 1 auto; min-height: 0; overflow: hidden; }
  #chats.active .inbox-panel { height: 100%; min-height: 0; overflow: hidden; }
  #chats.active .inbox-shell { height: 100%; }
  /* Encabezado y composer mas compactos para dar aire a los mensajes en pantallas cortas */
  #chats.active .inbox-thread-head { padding: 7px 12px; gap: 6px 8px; }
  #chats.active .inbox-thread-actions button,
  #chats.active .inbox-thread-actions select { padding: 4px 8px; font-size: 11.5px; min-height: 28px; }
  #chats.active .inbox-composer { padding: 8px 14px 10px; }
  #chats.active .inbox-composer-tabs { margin-bottom: 5px; }
  #chats.active .inbox-composer textarea { min-height: 42px; }
}

/* ==================== Lista de grupos de WhatsApp ==================== */
.wa-groups-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; max-height: 420px; overflow-y: auto; }
.wa-groups-count { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 2px 2px 4px; }
.wa-group-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.wa-group-row:hover { border-color: var(--green); }
.wa-group-ico { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft, #e7fff4); color: var(--green-strong, #0f8d66); font-weight: 900; }
.wa-group-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wa-group-main strong { font-size: 14.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-group-main span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-group-unread { flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--green); color: #04241a; font-size: 11px; font-weight: 900; display: grid; place-items: center; }

/* ============================================================
   SKIN WHATSAPP WEB para la vista de Chats (solo presentacion).
   Overrides al final del archivo: el CSS base queda intacto.
   Paleta clara = WhatsApp Web light, oscura = WhatsApp Web dark.
   ============================================================ */
:root {
  --wa-sidebar-bg: #ffffff;
  --wa-head-bg: #f0f2f5;
  --wa-search-bg: #f0f2f5;
  --wa-hover: #f5f6f6;
  --wa-row-active: #f0f2f5;
  --wa-border: #dde4e8;
  --wa-text: #111b21;
  --wa-text-2: #54656f;
  --wa-thread-bg: #efeae2;
  --wa-bubble-in: #ffffff;
  --wa-bubble-out: #d9fdd3;
  --wa-bubble-text: #111b21;
  --wa-bubble-meta: rgba(17, 27, 33, 0.68);
  --wa-accent: #00a884;
  --wa-accent-deep: #008069;
  --wa-badge-text: #ffffff;
  --wa-tab-active-bg: rgba(0, 168, 132, 0.14);
  --wa-tab-active-text: #008069;
  --wa-composer-bg: #f0f2f5;
  --wa-input-bg: #ffffff;
  --wa-quote-bg: rgba(17, 27, 33, 0.06);
  --wa-system-bg: #ffffff;
  --wa-system-text: #3b4a54;
  --wa-avatar-bg: #94a3ad;
  --wa-avatar-text: #ffffff;
}
html[data-theme="dark"] {
  --wa-sidebar-bg: #111b21;
  --wa-head-bg: #202c33;
  --wa-search-bg: #202c33;
  --wa-hover: #202c33;
  --wa-row-active: #2a3942;
  --wa-border: rgba(134, 150, 160, 0.15);
  --wa-text: #e9edef;
  --wa-text-2: #8696a0;
  --wa-thread-bg: #0b141a;
  --wa-bubble-in: #202c33;
  --wa-bubble-out: #005c4b;
  --wa-bubble-text: #e9edef;
  --wa-bubble-meta: rgba(233, 237, 239, 0.6);
  --wa-accent: #00a884;
  --wa-accent-deep: #06cf9c;
  --wa-badge-text: #111b21;
  --wa-tab-active-bg: #103529;
  --wa-tab-active-text: #00a884;
  --wa-composer-bg: #202c33;
  --wa-input-bg: #2a3942;
  --wa-quote-bg: rgba(0, 0, 0, 0.24);
  --wa-system-bg: #182229;
  --wa-system-text: #8696a0;
  --wa-avatar-bg: #6a7175;
  --wa-avatar-text: #cfd4d6;
}

body:has(#chats.active) {
  --shadow: none;
}

body:has(#chats.active) main {
  background: var(--wa-thread-bg);
}

body:has(#chats.active) .topbar {
  background: var(--wa-head-bg);
  border: 1px solid var(--wa-border);
  box-shadow: none;
}

body:has(#chats.active) .topbar-title h1,
body:has(#chats.active) .topbar-title p {
  color: var(--wa-text);
}

body:has(#chats.active) .topbar-title p {
  color: var(--wa-text-2);
}

body:has(#chats.active) .inbox-panel {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

/* --- Lista de conversaciones (columna izquierda) --- */
.inbox-shell { background: var(--wa-sidebar-bg); }
.inbox-list-pane { border-right: 1px solid var(--wa-border); background: var(--wa-sidebar-bg); }
.inbox-list-head { border-bottom: 0; padding: 12px 12px 8px; }
.inbox-list-head::before {
  content: "Chats";
  display: block;
  color: var(--wa-text);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
  margin: 4px 0 16px;
}
.inbox-list-head input {
  background: var(--wa-search-bg);
  background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238696a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px 50%;
  border: 0;
  border-radius: 8px;
  color: var(--wa-text);
  padding: 9px 12px 9px 38px;
}
.inbox-list-head input::placeholder { color: var(--wa-text-2); }
.inbox-tabs { gap: 6px; margin-bottom: 10px; }
.inbox-tab {
  background: var(--wa-search-bg);
  color: var(--wa-text-2);
  border: 0;
  padding: 6px 12px;
  font-weight: 500;
  font-size: 12.5px;
}
.inbox-tab.active { background: var(--wa-tab-active-bg); color: var(--wa-tab-active-text); border: 0; }
.inbox-dept-row select {
  background: var(--wa-search-bg);
  border: 0;
  border-radius: 8px;
  color: var(--wa-text-2);
}
.inbox-row { border-bottom: 1px solid var(--wa-border); padding: 11px 14px; background: transparent; }
.inbox-row:hover { background: var(--wa-hover); }
.inbox-row.active { background: var(--wa-row-active); }
.inbox-row-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  background: var(--wa-avatar-bg);
  color: var(--wa-avatar-text);
  font-size: 17px;
  font-weight: 600;
}
.inbox-row-top strong { color: var(--wa-text); font-size: 15px; font-weight: 500; }
.inbox-row-time { color: var(--wa-text-2); font-size: 11.5px; }
.inbox-row.unread .inbox-row-time { color: var(--wa-accent); font-weight: 600; }
.inbox-row-preview { color: var(--wa-text-2); font-size: 13px; }
.inbox-row.unread .inbox-row-preview { color: var(--wa-text-2); font-weight: 400; }
.inbox-row.unread .inbox-row-top strong { color: var(--wa-text); font-weight: 600; }
.inbox-unread-badge { background: var(--wa-accent); color: var(--wa-badge-text); font-weight: 700; min-width: 20px; height: 20px; align-self: center; }
.inbox-empty-list { color: var(--wa-text-2); }

/* --- Cabecera del hilo --- */
.inbox-thread-pane { background: var(--wa-thread-bg); }
.inbox-empty { color: var(--wa-text-2); background: var(--wa-sidebar-bg); }
.inbox-empty strong { color: var(--wa-text); }
.inbox-thread-head { background: var(--wa-head-bg); border-bottom: 1px solid var(--wa-border); padding: 10px 16px; }
.inbox-thread-avatar {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--wa-avatar-bg);
  color: var(--wa-avatar-text);
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 600;
}
.inbox-thread-contact strong { color: var(--wa-text); font-size: 15.5px; font-weight: 500; }
.inbox-thread-contact .muted { color: var(--wa-text-2); }
.inbox-thread-head .ghost-btn { color: var(--wa-text-2); }
.inbox-thread-actions { position: relative; flex-wrap: nowrap; }
.inbox-tools-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
}
.inbox-thread-tools {
  display: none;
}
.inbox-thread-tools.open {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 240px;
  padding: 10px;
  border-radius: 8px;
  background: var(--wa-head-bg);
  border: 1px solid var(--wa-border);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  z-index: 60;
}
.inbox-thread-tools.open button,
.inbox-thread-tools.open select {
  width: 100%;
  min-height: 34px;
  margin-top: 0;
  text-align: left;
  background: var(--wa-input-bg);
  border: 1px solid var(--wa-border);
  color: var(--wa-text);
}

/* --- Hilo de mensajes --- */
.inbox-messages {
  background-color: var(--wa-thread-bg);
  background-image: var(--chat-doodle);
  padding: 14px 7% 12px;
  gap: 3px;
}
.inbox-bubble {
  position: relative;
  max-width: 65%;
  padding: 6px 9px 8px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  margin-bottom: 6px;
}
.inbox-bubble.in {
  background: var(--wa-bubble-in);
  color: var(--wa-bubble-text);
  border: 0;
  border-radius: 8px;
  border-top-left-radius: 0;
}
.inbox-bubble.out,
.inbox-bubble.out.ai,
.inbox-bubble.out.from-phone {
  background: var(--wa-bubble-out);
  color: var(--wa-bubble-text);
  border-radius: 8px;
  border-top-right-radius: 0;
}
.inbox-bubble.in::before,
.inbox-bubble.out::before {
  content: "";
  position: absolute;
  top: 0;
  width: 8px;
  height: 13px;
}
.inbox-bubble.in::before {
  left: -8px;
  background: var(--wa-bubble-in);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}
.inbox-bubble.out::before {
  right: -8px;
  background: var(--wa-bubble-out);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
/* Notas internas conservan su identidad (amarillo) pero sin cola verde */
.inbox-bubble.out.note { border-top-right-radius: 8px; }
.inbox-bubble.out.note::before { display: none; }
.inbox-bubble-meta {
  justify-content: flex-end;
  margin-top: 2px;
  margin-bottom: -3px;
  font-size: 11px;
  color: var(--wa-bubble-meta);
  opacity: 1;
  float: none;
}
.inbox-bubble .msg-quote {
  background: var(--wa-quote-bg);
  border-left: 4px solid var(--wa-accent);
  border-radius: 6px;
  padding: 6px 10px;
  margin: 0 0 5px;
  font-size: 12.5px;
  color: var(--wa-text-2);
}
.wa-sender { font-size: 12.8px; font-weight: 600; margin-bottom: 2px; }
.msg-system span { background: var(--wa-system-bg); color: var(--wa-system-text); box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13); font-size: 12.5px; }
.msg-transcript { color: var(--wa-bubble-meta); }
.receipt-tick.read { color: #53bdeb; }
.inbox-bubble-media-image, .inbox-bubble-media-video { border-radius: 6px; }

/* --- Composer --- */
.inbox-composer { background: var(--wa-composer-bg); border-top: 1px solid var(--wa-border); padding: 8px 14px 10px; }
#inboxComposerText.wa-composer-input {
  background: var(--wa-input-bg);
  border: 0;
  color: var(--wa-text);
  border-radius: 22px;
  font-size: 14px;
  padding: 10px 16px;
}
#inboxComposerText.wa-composer-input::placeholder { color: var(--wa-text-2); }
.inbox-composer .icon-btn { color: var(--wa-text-2); }
.inbox-composer .icon-btn:hover { background: var(--wa-hover); color: var(--wa-text); }
.wa-action-btn.wa-send-btn { background: var(--wa-accent); color: #ffffff; }
.wa-action-btn.wa-send-btn:hover { background: var(--wa-accent-deep); }
.inbox-composer-tab { background: transparent; color: var(--wa-text-2); border: 0; font-weight: 500; }
.inbox-composer-tab.active { background: var(--wa-tab-active-bg); color: var(--wa-tab-active-text); border: 0; }
.inbox-attachment-preview { background: var(--wa-input-bg); border: 0; color: var(--wa-text); }

/* Altura estilo app en escritorio (el movil conserva sus reglas) */
@media (min-width: 921px) {
  .inbox-shell { height: clamp(560px, calc(100vh - 150px), 940px); }
  body:has(#chats.active) > main { padding: 10px 10px 10px 12px; }
  body:has(#chats.active) .topbar {
    min-height: 54px;
    padding: 8px 12px;
    margin-bottom: 0;
    border-radius: 0;
  }
  body:has(#chats.active) .topbar-title p { display: none; }
  body:has(#chats.active) .inbox-shell {
    grid-template-columns: minmax(330px, 34%) 1fr;
    border: 1px solid var(--wa-border);
  }
  body:has(#chats.active) #chats.active .inbox-panel {
    border-radius: 0;
  }
}

/* Menu principal ocultable en escritorio. En movil se conserva el menu desplegable existente. */
@media (min-width: 921px) {
  body.sidebar-hidden {
    grid-template-columns: 1fr;
  }
  body.sidebar-hidden > .sidebar {
    display: none;
  }
  body.sidebar-hidden .main-menu-toggle {
    display: inline-grid;
  }
}

@media (max-width: 920px) {
  .main-menu-toggle {
    display: none !important;
  }
  body.sidebar-hidden > .sidebar {
    display: block;
  }
}

/* ============================================================
   MODO INMERSIVO de Chats (body.wa-chats-full, la pone showView).
   En escritorio la vista de Chats llena todo el alto del viewport
   como WhatsApp Web: sin scroll de pagina, el inbox crece y solo
   scrollean la lista y el hilo. El resto de vistas no cambia.
   ============================================================ */
@media (min-width: 921px) {
  body.wa-chats-full main {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 12px 18px 14px;
  }
  body.wa-chats-full .topbar { flex: none; margin-bottom: 10px; }
  body.wa-chats-full .status-line,
  body.wa-chats-full .suspended-banner,
  body.wa-chats-full .announce-banner { flex: none; }
  body.wa-chats-full #chats.view.active {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  body.wa-chats-full #chats .inbox-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  body.wa-chats-full #chats .inbox-shell {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
  }
}


/* ============================================================
   INMERSION TOTAL en Chats -- OVERRIDES FINALES.
   Misma especificidad que las reglas :has(#chats.active) previas
   y al final del archivo: esta es la palabra definitiva.
   Objetivo: WhatsApp de borde a borde, sin chrome de wenko.
   El banner de suspension por pago (#suspendedBanner) NUNCA se oculta.
   ============================================================ */
@media (min-width: 900px) {
  body:has(#chats.active) > main { padding: 0; }
  body:has(#chats.active) .topbar {
    min-height: 42px;
    padding: 4px 14px;
    margin-bottom: 0;
    background: var(--wa-sidebar-bg);
    border: 0;
    border-bottom: 1px solid var(--wa-border);
    border-radius: 0;
    box-shadow: none;
  }
  body:has(#chats.active) .topbar-title h1 { font-size: 15px; }
  body:has(#chats.active) .trial-pill { display: none; }
  body:has(#chats.active) .verify-banner,
  body:has(#chats.active) .announce-banner { display: none; }
  body:has(#chats.active) .topbar-actions .ghost-btn,
  body:has(#chats.active) .topbar-actions .logout-btn { padding: 5px 10px; font-size: 12px; }
  body:has(#chats.active) .user-badge { transform: scale(0.85); }
  body:has(#chats.active) .inbox-shell { border: 0; border-radius: 0; }
  body:has(#chats.active) .inbox-panel { margin: 0; background: var(--wa-sidebar-bg); }

  /* Sidebar integrada a la paleta WhatsApp solo en tema oscuro (en claro
     se conserva el navy de marca de wenko). */
  html[data-theme="dark"] body:has(#chats.active) .sidebar {
    background: var(--wa-sidebar-bg);
    border-right: 1px solid var(--wa-border);
  }
  html[data-theme="dark"] body:has(#chats.active) .sidebar nav button { color: var(--wa-text-2); }
  html[data-theme="dark"] body:has(#chats.active) .sidebar nav button.active {
    background: var(--wa-row-active);
    color: var(--wa-text);
  }
  html[data-theme="dark"] body:has(#chats.active) .brand span { color: var(--wa-text-2); }
}

/* Tema CLARO: mas contraste en la lista de chats. Los tonos de WhatsApp real
   quedaban demasiado palidos aqui (horas, previews, etiquetas y avatares casi
   invisibles). Etiquetas con el verde del skin y texto oscuro legible. */
html:not([data-theme="dark"]) #chats .inbox-row-tag {
  background: rgba(0, 168, 132, 0.14);
  color: #067a60;
  font-weight: 600;
}
html:not([data-theme="dark"]) #chats .inbox-row-tag.agent {
  background: rgba(11, 147, 183, 0.14);
  color: #0b7391;
}
html:not([data-theme="dark"]) #chats .inbox-unread-badge { background: #008069; color: #ffffff; }

/* Identificacion visual de GRUPOS de WhatsApp en el inbox. */
.inbox-row-tag.group { background: rgba(0, 168, 132, 0.16); color: #067a60; font-weight: 700; }
html[data-theme="dark"] .inbox-row-tag.group { background: rgba(27, 227, 154, 0.16); color: #5df1b6; }
.inbox-row-avatar.group, .inbox-thread-avatar.group { font-size: 17px; }
