:root {
  /* 60% lienzo / aire · 30% superficies · 10% acento azul Pendiente */
  --bg: #F4F5F7;
  --chat-bg: #ECEFF3;
  --surface: #FFFFFF;
  --surface-glass: rgba(255, 255, 255, 0.86);
  --surface-soft: #F7F8FA;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);

  --ink: #0F172A;
  --ink-2: #475569;
  --ink-3: #8391A5;

  --acento: #1F5696;
  --acento-hover: #17447A;
  --acento-soft: #EAF1FA;
  --acento-ink: #143B6B;

  --ok: #15803D;
  --ok-soft: #E8F6EE;
  --ok-ink: #115E2E;

  --alerta: #C2591A;
  --alerta-soft: #FEF1E7;
  --alerta-border: rgba(194, 89, 26, 0.24);
  --peligro: #C81E1E;
  --peligro-soft: #FDECEC;

  /* Sombras tintadas con el tono frío del fondo */
  --sombra-xs: 0 1px 2px rgba(15, 34, 62, 0.06);
  --sombra-sm: 0 2px 6px rgba(15, 34, 62, 0.05), 0 1px 2px rgba(15, 34, 62, 0.04);
  --sombra-md: 0 10px 30px rgba(15, 34, 62, 0.08), 0 2px 6px rgba(15, 34, 62, 0.04);

  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --app-h: 100dvh;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 15px;
  line-height: 1.45;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

[hidden] { display: none !important; }

/* Tipografía */
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
h3 { font-size: 15.5px; font-weight: 700; letter-spacing: -0.015em; }
.sub { color: var(--ink-2); font-size: 13.5px; margin-top: 4px; line-height: 1.45; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: var(--bg);
  color: var(--ink);
  padding: 3px 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
}

.stack-12 { display: flex; flex-direction: column; gap: 12px; }
.stack-16 { display: flex; flex-direction: column; gap: 16px; }
.stack-24 { display: flex; flex-direction: column; gap: 24px; }
.fila-entre { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fila-der { display: flex; justify-content: flex-end; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* Botones con respuesta en pointer-down */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  min-height: 40px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: manipulation;
  user-select: none;
  transition: transform 110ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.48; cursor: not-allowed; }
.btn.chico { padding: 7px 12px; min-height: 34px; font-size: 13px; border-radius: 10px; }
.btn.lg { min-height: 48px; font-size: 15.5px; border-radius: 14px; }
.btn.full { width: 100%; }

.btn.primario { background: var(--acento); color: #FFFFFF; box-shadow: 0 2px 8px rgba(31, 86, 150, 0.22); }
.btn.suave { background: var(--surface); color: var(--ink); border-color: var(--border); box-shadow: var(--sombra-xs); }
.btn.fantasma { background: transparent; color: var(--ink-2); }
.btn.alerta { background: var(--alerta-soft); color: var(--alerta); border-color: var(--alerta-border); }
.btn.ok { background: var(--ok-soft); color: var(--ok-ink); border-color: rgba(21, 128, 61, 0.22); }

.ico-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: transform 110ms var(--ease-out), background-color 140ms ease, color 140ms ease;
}
.ico-btn.chico { width: 32px; height: 32px; border-radius: 9px; }
.ico-btn:active { transform: scale(0.92); }
.ico-btn.peligro { border-color: transparent; background: transparent; color: var(--ink-3); }

@media (hover: hover) and (pointer: fine) {
  .btn.primario:hover:not(:disabled) { background: var(--acento-hover); }
  .btn.suave:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-soft); }
  .btn.fantasma:hover:not(:disabled) { background: rgba(15, 23, 42, 0.05); color: var(--ink); }
  .ico-btn:hover { background: var(--surface-soft); color: var(--ink); }
  .ico-btn.peligro:hover { background: var(--peligro-soft); color: var(--peligro); }
}

/* Campos: 16px mínimo garantizado para CERO auto-zoom en iOS Safari */
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.campo input, .campo textarea, .campo select {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  outline: none;
  appearance: none;
  touch-action: manipulation;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}
.campo textarea { resize: vertical; line-height: 1.5; }
.campo input:focus, .campo textarea:focus, .campo select:focus {
  background: var(--surface);
  border-color: var(--acento);
  box-shadow: 0 0 0 3px rgba(31, 86, 150, 0.14);
}
.clave-wrap { position: relative; display: flex; align-items: center; }
.clave-wrap input { padding-right: 44px; }
.ico-btn-in {
  position: absolute;
  right: 6px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ico-btn-in:active { transform: scale(0.92); color: var(--ink); }

/* Login */
.login-wrap {
  min-height: var(--app-h);
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, rgba(31, 86, 150, 0.08), transparent 55%), var(--bg);
}
.login-card {
  width: 100%;
  max-width: 396px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  box-shadow: var(--sombra-md);
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: entrar 240ms var(--ease-spring);
}
.login-brand { display: flex; align-items: center; gap: 16px; }
.login-ico { border-radius: 14px; box-shadow: var(--sombra-sm); flex-shrink: 0; }
.login-brand p { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }
.nota-suave { font-size: 12.5px; color: var(--ink-3); text-align: center; }
.msg-err { font-size: 13px; color: var(--peligro); font-weight: 600; }

/* App shell */
.app-shell {
  height: var(--app-h);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.topbar {
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  z-index: 15;
}
.topbar-izq, .topbar-der { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-ico { border-radius: 8px; flex-shrink: 0; box-shadow: var(--sombra-xs); }

.negocio-pick {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.negocio-pick select {
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.015em;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 11px;
  cursor: pointer;
  max-width: 170px;
  text-overflow: ellipsis;
  touch-action: manipulation;
}
.negocio-fijo {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.015em;
  color: var(--ink);
  padding: 4px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.pill-modo {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--alerta-soft);
  color: var(--alerta);
  white-space: nowrap;
}
.pill-modo.en_vivo { background: var(--ok-soft); color: var(--ok-ink); }
.pill-modo.pausado { background: var(--surface-soft); color: var(--ink-2); }

/* Tabs escritorio (píldora limpia centrada) */
.tabs-desk {
  display: inline-flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
}
.tab {
  appearance: none;
  background: transparent;
  border: none;
  border-radius: 9px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 110ms var(--ease-out);
}
.tab:active { transform: scale(0.96); }
.tab.activo {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--sombra-xs);
}

.badge-num {
  background: var(--alerta);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Botón push con estado */
.btn-push.activo {
  background: var(--ok-soft);
  color: var(--ok-ink);
  border-color: rgba(21, 128, 61, 0.22);
}

/* Bandeja */
.panel-bandeja {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 348px minmax(0, 1fr);
  position: relative;
}

.lista-col {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.lista-top {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}
.lista-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.buscar-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.buscar-wrap svg {
  position: absolute;
  left: 12px;
  color: var(--ink-3);
  pointer-events: none;
}
.buscar-wrap input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 8px 12px 8px 36px;
  outline: none;
  appearance: none;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.buscar-wrap input:focus {
  background: var(--surface);
  border-color: var(--acento);
}

.filtros-bar {
  display: flex;
  gap: 6px;
}
.filtro {
  appearance: none;
  border: 1px solid transparent;
  background: var(--bg);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  touch-action: manipulation;
  transition: background-color 140ms ease, color 140ms ease, transform 100ms var(--ease-out);
}
.filtro:active { transform: scale(0.95); }
.filtro.activo {
  background: var(--ink);
  color: #FFFFFF;
}
.f-cnt {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: var(--alerta);
  color: #FFFFFF;
  padding: 0 5px;
  border-radius: 999px;
  min-width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lista-chats {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Avatars */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  user-select: none;
}
.avatar.sm { width: 38px; height: 38px; font-size: 13.5px; }
.avatar-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  border: 2px solid var(--surface);
  background: var(--ok);
}
.avatar-dot.humano { background: var(--alerta); }
.avatar-dot.pausado { background: var(--ink-3); }

/* Fila de chat: regla 1-2-Resto */
.chat-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 11px 12px;
  cursor: pointer;
  font: inherit;
  display: flex;
  align-items: center;
  gap: 12px;
  touch-action: manipulation;
  transition: background-color 140ms ease, border-color 140ms ease, transform 110ms var(--ease-out);
}
.chat-item:active { transform: scale(0.985); background: var(--surface-soft); }
.chat-item.seleccionado { background: var(--acento-soft); border-color: rgba(31, 86, 150, 0.16); }
.chat-item.alerta { background: var(--alerta-soft); border-color: var(--alerta-border); }
@media (hover: hover) and (pointer: fine) {
  .chat-item:hover:not(.seleccionado):not(.alerta) { background: var(--surface-soft); }
}
.ci-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ci-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ci-nombre {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ci-hora {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  flex-shrink: 0;
}
.ci-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ci-prev {
  font-size: 13.5px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-2);
  flex-shrink: 0;
}
.tag.humano { background: var(--alerta); color: #FFFFFF; }
.tag.sim { background: rgba(15, 23, 42, 0.07); color: var(--ink-2); }
.unread-pill {
  background: var(--acento);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Estado vacío lista */
.lista-vacia {
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
}
.lista-vacia strong { color: var(--ink); font-size: 15px; }
.lista-vacia p { font-size: 13.5px; max-width: 240px; }

/* Columna Chat */
.chat-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--chat-bg);
}
.chat-vacio {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
}
.vacio-ico {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--surface);
  color: var(--acento);
  display: grid;
  place-items: center;
  box-shadow: var(--sombra-sm);
}
.vacio-tit { font-size: 17px; font-weight: 700; color: var(--ink); }
.vacio-sub { font-size: 14px; color: var(--ink-2); max-width: 320px; }

.chat-activo {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-head {
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
.chat-head-izq { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.chat-id-wrap { min-width: 0; }
.chat-id-wrap h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-der { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chat-meta {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-back {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--acento);
  width: 34px;
  height: 36px;
  margin-left: -6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-back:active { transform: scale(0.9); background: var(--acento-soft); }

.banner-humano {
  background: var(--alerta-soft);
  border-bottom: 1px solid var(--alerta-border);
  color: var(--alerta);
  padding: 9px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.banner-humano-txt { display: flex; gap: 6px; flex-wrap: wrap; line-height: 1.35; }

.chat-mensajes {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dia-sep {
  align-self: center;
  margin: 12px 0 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.07);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
}

/* Burbujas estilo iMessage / WhatsApp */
.burbuja {
  max-width: min(540px, 82%);
  padding: 9px 13px 7px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.42;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  box-shadow: var(--sombra-xs);
}
.burbuja.nueva { animation: popMsg 190ms var(--ease-spring); }
.burbuja.inicio-grupo { margin-top: 9px; }

.burbuja.cliente {
  align-self: flex-start;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}
.burbuja.bot {
  align-self: flex-end;
  background: var(--acento-soft);
  color: var(--ink);
  border: 1px solid rgba(31, 86, 150, 0.14);
  border-bottom-right-radius: 6px;
}
.burbuja.humano {
  align-self: flex-end;
  background: var(--acento);
  color: #FFFFFF;
  border-bottom-right-radius: 6px;
}
.burbuja.error { border-color: rgba(200, 30, 30, 0.4); }

.burbuja-pie {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 3px;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  opacity: 0.68;
}

/* Composer estilo iMessage */
.chat-composer {
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 4px 5px 4px 14px;
  box-shadow: var(--sombra-xs);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.composer-box:focus-within {
  border-color: var(--acento);
  box-shadow: 0 0 0 3px rgba(31, 86, 150, 0.12);
}
.composer-box textarea {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 16px;
  line-height: 1.38;
  color: var(--ink);
  padding: 7px 0;
  max-height: 112px;
  resize: none;
  outline: none;
  overflow-y: auto;
}
.btn-send {
  appearance: none;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: var(--acento);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 1px;
  transition: transform 110ms var(--ease-out), background-color 140ms ease, opacity 140ms ease;
}
.btn-send:active:not(:disabled) { transform: scale(0.9); }
.btn-send:disabled { opacity: 0.35; cursor: default; }

.btn-mic {
  appearance: none;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: var(--acento-soft);
  color: var(--acento);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 1px;
  touch-action: manipulation;
  transition: transform 110ms var(--ease-out), background-color 140ms ease, color 140ms ease;
}
.btn-mic:active:not(:disabled) { transform: scale(0.9); background: var(--acento); color: #FFFFFF; }
.btn-mic:disabled { opacity: 0.4; cursor: default; }

/* Barra de grabación activa estilo iMessage/WhatsApp */
.grabando-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid rgba(200, 30, 30, 0.24);
  border-radius: 22px;
  padding: 4px 5px 4px 6px;
  box-shadow: 0 0 0 3px rgba(200, 30, 30, 0.08);
  animation: popMsg 170ms var(--ease-spring);
}
.btn-rec-cancel {
  appearance: none;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: var(--peligro-soft);
  color: var(--peligro);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: transform 110ms var(--ease-out);
}
.btn-rec-cancel:active { transform: scale(0.9); }
.grabando-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--peligro);
  flex-shrink: 0;
  animation: recPulse 1.1s ease-in-out infinite;
}
.rec-tiempo {
  font-size: 14.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.rec-ondas {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 16px;
}
.rec-ondas i {
  display: block;
  width: 2.5px;
  height: 6px;
  border-radius: 999px;
  background: var(--peligro);
  opacity: 0.75;
  animation: recBar 0.9s ease-in-out infinite;
}
.rec-ondas i:nth-child(2) { animation-delay: 0.14s; }
.rec-ondas i:nth-child(3) { animation-delay: 0.28s; }
.rec-ondas i:nth-child(4) { animation-delay: 0.42s; }
.rec-ondas i:nth-child(5) { animation-delay: 0.56s; }
.rec-hint {
  font-size: 12.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@keyframes recPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}
@keyframes recBar {
  0%, 100% { height: 5px; }
  50% { height: 15px; }
}

/* Reproductor inline de notas de voz dentro de burbujas */
.audio-msg { display: flex; flex-direction: column; gap: 7px; min-width: 196px; }
.audio-player { display: flex; align-items: center; gap: 10px; }
.audio-play {
  appearance: none;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: var(--acento);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  touch-action: manipulation;
  transition: transform 110ms var(--ease-out), opacity 140ms ease;
}
.audio-play:active:not(:disabled) { transform: scale(0.9); }
.audio-play:disabled { opacity: 0.45; cursor: default; }
.audio-play::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  margin-left: 2px;
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent currentColor;
}
.audio-play.sonando::before {
  margin-left: 0;
  width: 10px;
  height: 11px;
  border: none;
  border-left: 3px solid currentColor;
  border-right: 3px solid currentColor;
}
.audio-play.cargando { opacity: 0.65; }
.burbuja.humano .audio-play { background: rgba(255, 255, 255, 0.22); color: #FFFFFF; }
.audio-track {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.14);
  overflow: hidden;
  min-width: 72px;
}
.burbuja.humano .audio-track { background: rgba(255, 255, 255, 0.28); }
.audio-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--acento);
  transition: width 120ms linear;
}
.burbuja.humano .audio-fill { background: #FFFFFF; }
.audio-dur {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  opacity: 0.78;
  flex-shrink: 0;
}
.audio-transcripcion {
  font-size: 14px;
  line-height: 1.42;
  padding-top: 6px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  color: inherit;
}

/* Paneles centrados (Simulador y Ajustes) */
.panel-centrado {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.card {
  width: 100%;
  max-width: 800px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--sombra-sm);
}

.chips-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 110ms var(--ease-out), border-color 140ms ease, color 140ms ease, background-color 140ms ease;
}
.chip:active { transform: scale(0.95); background: var(--acento-soft); color: var(--acento-ink); }
@media (hover: hover) and (pointer: fine) {
  .chip:hover { border-color: var(--acento); color: var(--acento-ink); background: var(--acento-soft); }
}

.sim-resultado {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: entrar 200ms var(--ease-spring);
}

.copy-box {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.copy-lbl { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.copy-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.copy-row code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; padding: 7px 9px; }
.copy-row .btn { flex-shrink: 0; }

.estado-secrets { display: flex; gap: 6px; flex-wrap: wrap; }
.clave-cli-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.clave-cli-inp {
  flex: 1 1 240px;
  min-width: 0;
}
.clave-cli-inp input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 44px 11px 14px;
  outline: none;
  appearance: none;
  touch-action: manipulation;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}
.clave-cli-inp input:focus {
  background: var(--surface);
  border-color: var(--acento);
  box-shadow: 0 0 0 3px rgba(31, 86, 150, 0.14);
}
.clave-cli-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.sec-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--ink-2);
}
.sec-pill.ok { background: var(--ok-soft); color: var(--ok-ink); border-color: rgba(21, 128, 61, 0.22); }
.sec-pill.falta { background: var(--alerta-soft); color: var(--alerta); border-color: var(--alerta-border); }

/* Control segmentado estilo iOS */
.seg-modo {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
}
.seg-modo button {
  appearance: none;
  border: none;
  background: transparent;
  padding: 7px 12px;
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 100ms var(--ease-out);
}
.seg-modo button:active { transform: scale(0.96); }
.seg-modo button.activo { background: var(--surface); color: var(--ink); box-shadow: var(--sombra-xs); }
.seg-modo button.activo[data-modo="en_vivo"] { background: var(--ok); color: #FFFFFF; }
.seg-modo button.activo[data-modo="lista_blanca"] { background: var(--alerta-soft); color: var(--alerta); }

/* Tab bar inferior (oculta en escritorio) */
.tabbar-movil { display: none; }

/* Modal / Sheet */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 40;
  animation: fadeIn 160ms ease;
}
.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border-radius: 20px;
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--sombra-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: entrar 220ms var(--ease-spring);
}
.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  align-self: center;
  margin-top: -8px;
  margin-bottom: 2px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #FFFFFF;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--sombra-md);
  transition: transform 220ms var(--ease-spring), opacity 180ms ease;
  z-index: 60;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0) scale(1); }

.solo-movil { display: none; }
.solo-desk { display: inline-flex; }

@keyframes entrar {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes popMsg {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ── EXPERIENCIA MÓVIL NATIVA (iPhone / Android PWA) ── */
@media (max-width: 820px) {
  .grid-2 { grid-template-columns: 1fr; }
  .solo-movil { display: inline-flex; }
  .solo-desk { display: none; }
  .tabs-desk { display: none; }

  .topbar {
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    gap: 8px;
  }
  .pill-modo { font-size: 11px; padding: 3px 8px; }
  .negocio-pick select { max-width: 132px; padding: 5px 10px; }
  .btn-push .push-lbl { display: none; }
  .btn-push { width: 36px; height: 36px; padding: 0; border-radius: 10px; }

  /* Ocultar topbar y tabbar cuando estamos dentro de un chat para 100% pantalla */
  .app-shell.en-chat .topbar { display: none; }
  .app-shell.en-chat .tabbar-movil { display: none; }
  .app-shell.en-chat .chat-head {
    padding-top: calc(10px + env(safe-area-inset-top));
  }

  /* Transición espacial slide derecha <-> izquierda */
  .panel-bandeja {
    display: block;
    position: relative;
    overflow: hidden;
  }
  .lista-col {
    position: absolute;
    inset: 0;
    border-right: none;
    transition: transform 280ms var(--ease-spring), opacity 240ms ease;
    will-change: transform;
  }
  .chat-col {
    position: absolute;
    inset: 0;
    transform: translate3d(100%, 0, 0);
    transition: transform 280ms var(--ease-spring);
    will-change: transform;
    z-index: 5;
  }
  .panel-bandeja.en-chat .lista-col {
    transform: translate3d(-24%, 0, 0);
    opacity: 0.6;
  }
  .panel-bandeja.en-chat .chat-col {
    transform: translate3d(0, 0, 0);
  }
  .panel-bandeja.dragging .lista-col,
  .panel-bandeja.dragging .chat-col {
    transition: none;
  }

  /* Bottom Tab Bar fija estilo iOS */
  .tabbar-movil {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: var(--surface-glass);
    backdrop-filter: saturate(180%) blur(22px);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    flex-shrink: 0;
    z-index: 20;
  }
  .tab-m {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--ink-3);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    touch-action: manipulation;
    transition: color 140ms ease, transform 100ms var(--ease-out);
  }
  .tab-m:active { transform: scale(0.92); }
  .tab-m.activo { color: var(--acento); }
  .tab-m-ico { position: relative; display: inline-flex; }
  .tab-m-ico .badge-num {
    position: absolute;
    top: -4px;
    right: -10px;
    min-width: 17px;
    height: 17px;
    font-size: 10px;
    border: 2px solid var(--surface);
  }

  .panel-centrado {
    padding: 16px 12px 28px;
    gap: 14px;
  }
  .card {
    padding: 18px 16px;
    border-radius: 16px;
  }
  .seg-modo { width: 100%; }
  .seg-modo button { flex: 1; padding: 8px 6px; font-size: 12.5px; }
  .full-movil { width: 100%; }

  /* Bottom Sheet para modal en móvil */
  .modal-bg {
    align-items: end;
    padding: 0;
  }
  .modal-card {
    max-width: none;
    border-radius: 22px 22px 0 0;
    border-bottom: none;
    padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
    animation: sheetUp 280ms var(--ease-spring);
  }

  .toast {
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
  .app-shell.en-chat ~ .toast {
    bottom: calc(74px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
