/* ===== Reset & base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* Utilidad genérica para ocultar cualquier elemento, sin importar sus otras clases de display. */
.hidden { display: none !important; }

:root {
  --sidebar-bg: #ffffff;
  --sidebar-bg-active: #eef0ff;
  --sidebar-text: #6b6d85;
  --sidebar-text-active: #4f46e5;
  --sidebar-border: #eceef5;
  --login-bg: #171933;

  --bg: #f5f6fb;
  --card-bg: #ffffff;
  --border: #e9eaf2;

  --text-primary: #14162b;
  --text-secondary: #6b6d85;
  --text-muted: #9698ab;

  --accent: #4f46e5;
  --accent-light: #eef0ff;

  --green: #16a34a;
  --green-light: #e7f8ee;
  --pink: #db2777;
  --pink-light: #fce7f3;
  --orange: #ea580c;
  --orange-light: #fff1e6;
  --blue: #2563eb;
  --blue-light: #e8f0fe;
  --red: #dc2626;
  --red-light: #fdecec;
  --teal: #0d9488;
  --teal-light: #e6f7f5;
  --purple: #7c3aed;
  --purple-light: #f2ebfe;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(20, 22, 43, .03), 0 6px 18px rgba(20, 22, 43, .04);
}

html, body { height: 100%; }
html { overflow-x: hidden; }

.admin-body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ===== Shell layout ===== */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
  transition: width .2s ease;
}
/* En escritorio, "oculta" ya no esconde el menú por completo — lo reduce a una barra angosta de
   solo íconos (como el riel izquierdo de WhatsApp Web), con el nombre de cada sección disponible
   como tooltip nativo (atributo title en cada botón). En celular no aplica nada de esto: ahí la
   visibilidad de .sidebar la controla la clase .abierto con position:fixed, no este ancho. */
@media (min-width: 801px) {
  .sidebar.oculta { width: 68px; }
  .sidebar.oculta .sidebar-logo { justify-content: center; padding: 22px 0; gap: 0; }
  .sidebar.oculta .sidebar-logo-title,
  .sidebar.oculta .sidebar-logo-sub,
  .sidebar.oculta .nav-item-texto,
  .sidebar.oculta .sidebar-plan,
  .sidebar.oculta .sidebar-footer { display: none; }
  .sidebar.oculta .nav-item { justify-content: center; padding: 12px 0; gap: 0; }
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-logo-title { color: var(--accent); font-weight: 700; font-size: 15px; }
.sidebar-logo-sub { font-size: 10.5px; color: var(--sidebar-text); margin-top: 2px; text-transform: uppercase; letter-spacing: .06em; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item svg { flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: var(--bg); color: var(--text-primary); }
.nav-item.active {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-active);
}
.nav-item.active svg { opacity: 1; }

.sidebar-footer { padding: 8px 20px 16px; text-align: center; }
.sidebar-footer-logo { max-width: 92px; width: 100%; height: auto; display: block; margin: 0 auto; opacity: .92; }
.sidebar-footer-credito {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--sidebar-text);
  text-decoration: none;
  letter-spacing: .01em;
}
.sidebar-footer-credito:hover { color: var(--text-primary); text-decoration: underline; }

.sidebar-plan {
  margin: 12px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-md);
}
.sidebar-plan-label { font-size: 11px; color: var(--sidebar-text); text-transform: uppercase; letter-spacing: .04em; }
.sidebar-plan-nombre { color: var(--text-primary); font-weight: 600; font-size: 15px; margin: 3px 0 2px; }
.sidebar-plan-vence { font-size: 11.5px; color: var(--sidebar-text); margin-bottom: 8px; }
.sidebar-plan-barra { height: 6px; background: var(--border); }

/* Espaciado amplio fijo en todas las pantallas — si en alguna pantalla muy corta de altura no
   alcanza a caber toda la lista de opciones, el menú (.sidebar-nav) ya tiene su propio scroll
   interno para deslizar hasta las últimas, en vez de apretar el diseño. */

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.btn-outline {
  background: var(--card-bg);
  border-color: var(--border);
  color: var(--text-primary);
}
.btn-outline:hover { background: #fafafd; }
.btn-outline.peligro { color: #dc2626; border-color: #fecaca; }
.btn-outline.peligro:hover { background: #fee2e2; }
.btn-sm { padding: 6px 11px; font-size: 12px; white-space: nowrap; }
.btn-ghost {
  background: rgba(255,255,255,.08);
  color: #fff;
  border-color: rgba(255,255,255,.12);
}
.btn-ghost:hover { background: rgba(255,255,255,.14); }
.btn-block { width: 100%; justify-content: center; }
.btn-link {
  background: transparent;
  color: var(--accent);
  padding: 6px 0;
  font-weight: 600;
}
.btn-link:hover { text-decoration: underline; }
.btn-link-sm { font-size: 12.5px; padding: 0; }

.icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
}
.icon-btn:hover { background: #fafafd; }
.icon-btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 30px; height: 30px;
}
.icon-btn-ghost:disabled { opacity: .35; cursor: not-allowed; }
.badge-count {
  position: absolute;
  top: -5px; right: -5px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}

/* ===== Pills ===== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
}
.pill-success { background: var(--green-light); color: var(--green); }
.pill-sm { padding: 3px 10px; font-size: 11px; margin-left: auto; }
.pill-etiqueta { padding: 3px 10px; font-size: 11px; font-weight: 600; }

.celda-etiquetas { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; max-width: 220px; }
.celda-etiquetas-vacio { color: var(--text-muted); font-size: 12px; }

.lista-checks { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; }
.lista-checks label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }

.card-uso-ia { margin-bottom: 20px; }
.uso-ia-barra-wrap { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.uso-ia-barra { flex: 1; height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.uso-ia-barra-relleno { height: 100%; border-radius: 999px; background: var(--accent); transition: width .3s; }
.uso-ia-barra-relleno.uso-ia-aviso { background: #d97706; }
.uso-ia-barra-relleno.uso-ia-limite { background: #dc2626; }
.uso-ia-barra-texto { font-size: 12px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.uso-ia-costo { margin-top: 10px; font-size: 12.5px; color: var(--text-secondary); }
.uso-ia-costo strong { color: var(--text-primary); }

.filtros-contactos { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin: 14px 0; }
.filtros-contactos .form-label { gap: 4px; }
.filtros-contactos .form-input { min-width: 160px; }

.campo-instrucciones-destacado {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid #fbd9a8;
  background: #fffaf2;
  border-radius: var(--radius-sm);
}
.campo-instrucciones-titulo { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.editor-toolbar { display: flex; gap: 6px; }
.editor-toolbar-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}
.editor-toolbar-btn:hover { background: var(--bg); color: var(--text-primary); }
.lista-instrucciones { display: flex; flex-direction: column; gap: 8px; }
.instruccion-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.instruccion-card:hover { border-color: var(--accent); }
.instruccion-card.inactiva { opacity: .55; }
.instruccion-card-info { flex: 1; min-width: 0; }
.instruccion-card-titulo { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.instruccion-card-preview { display: block; font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }

.instrucciones-preview {
  margin-top: 4px;
  padding: 10px 12px;
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-primary);
  min-height: 20px;
  white-space: pre-wrap;
}

/* ===== Topbar ===== */
.main { flex: 1; min-width: 0; padding: 32px 36px 48px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

/* Ancho típico de portátil (más angosto que un monitor de escritorio, pero mucho más ancho que un
   celular) — sin esto, el bloque de la derecha (estado conectado, número, botón, notificaciones,
   perfil) no cabía junto al título y saltaba a una segunda línea, dejando un espacio vacío grande
   a la derecha del título en la primera línea. Se angosta ese bloque para que quepa en una sola línea. */
@media (max-width: 1400px) {
  .topbar-acciones { gap: 8px; }
  .topbar-perfil-info { display: none; }
  .topbar-wa-manager-texto { display: none; }
  .topbar-acciones .btn-outline { padding: 8px 10px; }
}
.topbar-izquierda { display: flex; align-items: center; gap: 14px; }
.topbar-titulo { font-size: 22px; font-weight: 700; }
.topbar-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.topbar-acciones { display: flex; align-items: center; gap: 10px; }
.topbar-numero-wa {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}
.topbar-numero-wa:empty { display: none; }

.topbar-perfil-wrap { position: relative; }
.topbar-perfil {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px 5px 5px;
}
.topbar-perfil-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  min-width: 170px;
  overflow: hidden;
  z-index: 20;
}
.topbar-perfil-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  font-size: 13px;
  color: var(--text-primary);
  text-decoration: none;
}
.topbar-perfil-menu-item:hover { background: var(--bg); }
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}
.topbar-perfil-info { display: flex; flex-direction: column; text-align: left; }
.topbar-perfil-nombre { font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.topbar-perfil-email { font-size: 11px; color: var(--text-muted); line-height: 1.2; }

/* ===== Notificaciones ===== */
.notif-menu { width: 340px; max-width: 90vw; }
.notif-menu-titulo {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.notif-lista { list-style: none; max-height: 340px; overflow-y: auto; }
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); cursor: pointer; }
.notif-item-icono {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.notif-item-icono-pedido { background: #fef3e2; color: #d97706; }
.notif-item-icono-error { background: #fee2e2; color: #dc2626; }
.notif-item-icono-derivada { background: var(--accent-light); color: var(--accent); }
.notif-item-icono-recordatorio { background: var(--teal-light); color: var(--teal); }
.notif-item-icono-consumo { background: #fef3c7; color: #b45309; }
.notif-item-texto { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-item-desc { font-size: 12.5px; color: var(--text-primary); line-height: 1.4; }
.notif-item-hora { font-size: 11px; color: var(--text-muted); }
.notif-vacio { padding: 24px 14px; text-align: center; font-size: 12.5px; color: var(--text-muted); }

/* ===== Layout: content + preview ===== */
.contenido-con-preview {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}
.contenido-principal { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* ===== Stats grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.stat-card-desplegable {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  width: 100%;
  transition: box-shadow .15s ease;
}
.stat-card-desplegable:hover { box-shadow: 0 1px 2px rgba(20,22,43,.04), 0 6px 18px rgba(20,22,43,.08); }
.stat-card-chevron {
  position: absolute;
  top: 18px;
  right: 18px;
  color: var(--text-muted);
  transition: transform .15s ease;
}
.stat-card-desplegable.abierto .stat-card-chevron { transform: rotate(90deg); }
.stat-icono {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.stat-icono-morado { background: var(--accent-light); color: var(--accent); }
.stat-icono-verde { background: var(--green-light); color: var(--green); }
.stat-icono-azul { background: var(--blue-light); color: var(--blue); }
.stat-icono-naranja { background: var(--orange-light); color: var(--orange); }
.stat-numero { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.stat-delta { font-size: 11.5px; color: var(--green); font-weight: 600; margin-top: 8px; }

/* ===== Cards ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.card-titulo { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--text-secondary); margin-top: 3px; margin-bottom: 14px; }
.card-head-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head-row .card-titulo { margin: 0; }

.cards-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cards-grid-2 { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; }
.cards-grid-3 > .card, .cards-grid-2 > .card { min-width: 0; }

.info-list { display: flex; flex-direction: column; gap: 13px; margin-bottom: 14px; }
.info-list li { display: flex; align-items: center; gap: 10px; }
.info-list-icono {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.info-list-icono-ok { background: var(--green-light); color: var(--green); }
.info-list-texto { display: flex; flex-direction: column; min-width: 0; }
.info-list-texto strong { font-size: 13px; font-weight: 500; }
.info-list-texto small { font-size: 11.5px; color: var(--text-muted); }

.select-sm {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
  background: var(--card-bg);
  font-family: inherit;
}

/* ===== Logo de la empresa ===== */
.logo-actual-wrap { display: flex; align-items: center; gap: 14px; }
.logo-actual {
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.logo-actual img { width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 4px; box-sizing: border-box; }
.logo-actual span { font-size: 10.5px; color: var(--text-muted); text-align: center; padding: 4px; }

/* ===== Buscador ===== */
.buscador-wrap { position: relative; display: flex; align-items: center; }
.buscador-wrap svg { position: absolute; left: 11px; color: var(--text-muted); pointer-events: none; }
.buscador-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px 9px 32px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  width: 260px;
  max-width: 100%;
}
.buscador-input:focus { outline: none; border-color: var(--accent); }

.buscador-wrap-sutil { margin: 0 14px 8px; }
.buscador-wrap-sutil .buscador-input {
  width: 100%;
  border: none;
  background: var(--bg);
  padding: 7px 10px 7px 30px;
  font-size: 12.5px;
  border-radius: 999px;
}
.buscador-wrap-sutil .buscador-input:focus { box-shadow: 0 0 0 1.5px var(--accent); }
.buscador-wrap-sutil svg { left: 12px; }
.filtro-conv-etiqueta { margin: 0 14px 8px; width: calc(100% - 28px); }

/* ===== Pestañas ===== */
.tabs-pedidos {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
  width: fit-content;
  margin-bottom: 18px;
}
.tab-btn {
  border: none;
  background: transparent;
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 7px;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { background: var(--card-bg); color: var(--accent); box-shadow: var(--shadow-card); }

.tab-contador {
  display: inline-block;
  min-width: 17px;
  padding: 1px 6px;
  margin-left: 5px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  transition: background .15s ease, color .15s ease;
}
.tab-btn.active .tab-contador { background: var(--accent); color: #fff; }

/* ===== Pedidos: contadores por estado ===== */
.pedidos-stats { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.pedido-stat {
  flex: 1;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border-left: 4px solid transparent;
}
.pedido-stat-num { font-size: 22px; font-weight: 700; }
.pedido-stat-label { font-size: 12px; font-weight: 600; }
.pedido-stat-cotizacion { background: var(--purple-light); border-left-color: var(--purple); }
.pedido-stat-cotizacion .pedido-stat-num { color: var(--purple); }
.pedido-stat-cotizacion .pedido-stat-label { color: var(--purple); }
.pedido-stat-nuevo { background: var(--blue-light); border-left-color: var(--blue); }
.pedido-stat-nuevo .pedido-stat-num { color: var(--blue); }
.pedido-stat-nuevo .pedido-stat-label { color: var(--blue); }
.pedido-stat-contactado { background: var(--orange-light); border-left-color: var(--orange); }
.pedido-stat-contactado .pedido-stat-num { color: var(--orange); }
.pedido-stat-contactado .pedido-stat-label { color: var(--orange); }
.pedido-stat-pendiente_pago { background: var(--teal-light); border-left-color: var(--teal); }
.pedido-stat-pendiente_pago .pedido-stat-num { color: var(--teal); }
.pedido-stat-pendiente_pago .pedido-stat-label { color: var(--teal); }
.pedido-stat-completado { background: var(--green-light); border-left-color: var(--green); }
.pedido-stat-completado .pedido-stat-num { color: var(--green); }
.pedido-stat-completado .pedido-stat-label { color: var(--green); }
.pedido-stat-cancelado { background: var(--red-light); border-left-color: var(--red); }
.pedido-stat-cancelado .pedido-stat-num { color: var(--red); }
.pedido-stat-cancelado .pedido-stat-label { color: var(--red); }

/* ===== Select de estado del pedido, coloreado ===== */
.select-estado { font-weight: 600; border-width: 1.5px; }
.select-estado-cotizacion { background: var(--purple-light); color: var(--purple); border-color: var(--purple-light); }
.select-estado-nuevo { background: var(--blue-light); color: var(--blue); border-color: var(--blue-light); }
.select-estado-contactado { background: var(--orange-light); color: var(--orange); border-color: var(--orange-light); }
.select-estado-completado { background: var(--green-light); color: var(--green); border-color: var(--green-light); }
.select-estado-cancelado { background: var(--red-light); color: var(--red); border-color: var(--red-light); }
.select-estado-historico { background: var(--bg); color: var(--text-secondary); border-color: var(--border); }
.select-estado-pendiente_pago { background: var(--teal-light); color: var(--teal); border-color: var(--teal-light); }

/* ===== Detalle expandible de un pedido (datos de facturación y envío) ===== */
.btn-detalle-pedido {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-primary);
  font: inherit;
  text-align: left;
}
.btn-detalle-pedido .icono-chevron { flex-shrink: 0; color: var(--text-muted); transition: transform .15s ease; }
.btn-detalle-pedido.abierto .icono-chevron { transform: rotate(90deg); }
.fila-detalle-pedido td { background: var(--bg); padding: 14px 16px; }
.detalle-pedido-bloque { display: inline-block; vertical-align: top; min-width: 220px; margin: 0 28px 8px 0; }
.detalle-pedido-bloque h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 8px; }
.detalle-pedido-fila { display: flex; gap: 8px; font-size: 13px; padding: 2px 0; }
.detalle-pedido-etiqueta { color: var(--text-muted); min-width: 90px; flex-shrink: 0; }
.detalle-pedido-vacio { font-size: 13px; color: var(--text-muted); font-style: italic; }
.detalle-pedido-bloque-ancho { display: block; min-width: 0; width: 100%; }
.detalle-pedido-nota { display: flex; gap: 10px; font-size: 13px; padding: 4px 0; align-items: baseline; }
.detalle-pedido-nota-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; background: var(--accent-light); color: var(--accent);
  font-size: 10.5px; font-weight: 700; flex-shrink: 0;
}
.detalle-pedido-nota-fecha { color: var(--text-muted); font-size: 11px; white-space: nowrap; flex-shrink: 0; }
.detalle-pedido-nota-estado { font-weight: 600; color: var(--accent); }

/* ===== Toast de confirmación ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--text-primary);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast svg { flex-shrink: 0; color: var(--green); }
@media (max-width: 760px) {
  .toast-container { bottom: 96px; }
}

.inbox-pedido-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.inbox-menu-wrap { position: relative; margin-left: auto; flex-shrink: 0; }
.inbox-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  min-width: 200px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 6px;
}
.inbox-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
}
.inbox-menu-item:hover { background: var(--bg); }

.chart-wrap { height: 220px; }
.chart-leyenda { display: flex; gap: 18px; margin-top: 12px; font-size: 12px; color: var(--text-secondary); }
.chart-leyenda span { display: flex; align-items: center; gap: 6px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-morado { background: var(--accent); }
.dot-verde { background: var(--green); }

/* ===== Conversaciones recientes ===== */
.conv-lista { display: flex; flex-direction: column; gap: 4px; }
.conv-lista li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 6px;
  border-radius: var(--radius-sm);
}
.conv-lista li:hover { background: var(--bg); }
.conv-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12.5px;
  color: #fff;
  flex-shrink: 0;
}
.conv-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.conv-nombre { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-msg { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.conv-badge { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.conv-badge-ia { background: var(--accent-light); color: var(--accent); }
.conv-badge-humano { background: var(--pink-light); color: var(--pink); }
.conv-badge-pedido { background: var(--teal-light); color: var(--teal); }
.conv-badge-derivacion { background: var(--orange-light); color: var(--orange); }
.conv-badge-cotizacion { background: var(--purple-light); color: var(--purple); }
.conv-hora { font-size: 11px; color: var(--text-muted); }

/* ===== Indicador de mensajes nuevos sin leer (como WhatsApp) ===== */
.conv-avatar-wrap { position: relative; flex-shrink: 0; }
.conv-punto-nuevo {
  position: absolute; top: -2px; right: -2px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
  animation: parpadeoNoLeido 1.3s ease-in-out infinite;
}
.conv-contador-no-leidos {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: #22c55e;
  color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.conv-lista li.tiene-no-leidos { background: #22c55e14; }
.conv-lista li.tiene-no-leidos .conv-nombre,
.conv-lista li.tiene-no-leidos .conv-msg { font-weight: 700; color: var(--text); }
@keyframes parpadeoNoLeido {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* ===== Preview chat (WhatsApp) ===== */
.preview-chat { position: sticky; top: 24px; }
.preview-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; margin-bottom: 10px;
}
.preview-chat-live { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 500; color: var(--green); }

.wa-panel {
  position: relative;
  background: #e5ddd5;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  height: 560px;
}
.wa-header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card-bg);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.wa-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; flex-shrink: 0;
  overflow: hidden;
}
.wa-avatar-img { width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 3px; box-sizing: border-box; }
.wa-header-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.wa-header-info strong { font-size: 13px; }
.wa-header-info small { font-size: 11px; color: var(--text-muted); }
.wa-header-acciones { display: flex; align-items: center; gap: 12px; color: var(--text-secondary); }

.wa-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: #e5ddd5;
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIiB2aWV3Qm94PSIwIDAgMjAwIDIwMCI+CiAgPGcgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjYjdhZGEwIiBzdHJva2Utd2lkdGg9IjEuNCIgb3BhY2l0eT0iMC41NSI+CiAgICA8cGF0aCBkPSJNMjAgMzBjNi0xMCAxOC0xMCAyMiAwcy00IDE4LTExIDE4LTE3LTgtMTEtMThaIi8+CiAgICA8Y2lyY2xlIGN4PSI5MCIgY3k9IjIwIiByPSI3Ii8+CiAgICA8cGF0aCBkPSJNODUgMjBoMTBNOTAgMTV2MTAiLz4KICAgIDxwYXRoIGQ9Ik0xNTAgNDBjNC04IDE0LTggMTcgMSAzIDktNiAxNS0xMyAxMi03LTMtOC05LTQtMTNaIi8+CiAgICA8cGF0aCBkPSJNMzAgMTAwYzgtNiA4LTE2LTEtMjAtOS00LTE2IDUtMTMgMTMgMyA4IDkgMTAgMTQgN1oiLz4KICAgIDxjaXJjbGUgY3g9IjExMCIgY3k9Ijk1IiByPSI2Ii8+CiAgICA8cGF0aCBkPSJNMTA0IDk1aDEyTTExMCA4OXYxMiIvPgogICAgPHBhdGggZD0iTTE3MCAxMTBjLTIgOS0xMiAxMi0xOCA1LTYtNy0xLTE3IDgtMTggOS0xIDEyIDUgMTAgMTNaIi8+CiAgICA8cGF0aCBkPSJNNTUgMTYwYzctNSA3LTE1LTEtMTktOC00LTE1IDQtMTIgMTIgMyA4IDggMTAgMTMgN1oiLz4KICAgIDxjaXJjbGUgY3g9IjE0MCIgY3k9IjE2NSIgcj0iNyIvPgogICAgPHBhdGggZD0iTTEzNCAxNjVoMTJNMTQwIDE1OXYxMiIvPgogICAgPHBhdGggZD0iTTE1IDE3NWM1LTkgMTYtOCAxOSAxIDMgOS01IDE2LTEyIDEzLTctMy0xMC04LTctMTRaIi8+CiAgPC9nPgo8L3N2Zz4K");
  background-size: 200px 200px;
}
.wa-fecha { display: flex; justify-content: center; margin: 4px 0 8px; }
.wa-fecha span {
  background: rgba(255,255,255,.8);
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 8px;
}
.wa-burbuja {
  max-width: 82%;
  padding: 8px 10px 6px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.45;
  position: relative;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.wa-burbuja-responder-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  opacity: 0;
  transition: opacity .15s;
  background: rgba(255,255,255,.7);
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
}
.wa-burbuja-responder-btn:hover { background: #fff; color: var(--accent); }
.wa-burbuja:hover .wa-burbuja-responder-btn { opacity: 1; }
.wa-cita {
  display: block;
  border-left: 3px solid var(--accent);
  background: rgba(0,0,0,.06);
  padding: 4px 8px;
  margin-bottom: 6px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.wa-respondiendo {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}
.wa-respondiendo-linea { width: 3px; align-self: stretch; background: var(--accent); border-radius: 2px; flex-shrink: 0; }
.wa-respondiendo-texto { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.wa-respondiendo-etiqueta { font-size: 11px; font-weight: 600; color: var(--accent); }
.wa-respondiendo-contenido {
  font-size: 12.5px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wa-burbuja a { color: #0a6cff; text-decoration: underline; }
.wa-burbuja a:visited { color: #6b3fa0; }
.wa-imagen-adjunta {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 4px 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  cursor: pointer;
  transition: opacity .15s;
}
.wa-imagen-adjunta:hover { opacity: .92; }
.wa-audio-adjunto {
  display: block;
  width: 260px;
  max-width: 100%;
  height: 36px;
  margin: 4px 0;
}
.wa-link-preview:empty { display: none; }
.wa-burbuja a.wa-link-preview-card {
  display: flex;
  flex-direction: column;
  width: 260px;
  max-width: 100%;
  margin: 6px 0 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  text-decoration: none;
  color: inherit;
}
.wa-link-preview-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: var(--border);
}
.wa-link-preview-texto {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
}
.wa-link-preview-dominio {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
}
.wa-link-preview-titulo {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}
.wa-link-preview-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.wa-in { align-self: flex-start; background: #fff; border-top-left-radius: 2px; }
.wa-out { align-self: flex-end; background: #d9fdd3; border-top-right-radius: 2px; }
.wa-hora {
  display: flex; align-items: center; justify-content: flex-end; gap: 3px;
  font-size: 10px; color: var(--text-muted); margin-top: 3px;
}
.wa-check { vertical-align: middle; }
.wa-check-gris { color: #8696a0; }
.wa-check-leido { color: #53bdeb; }
.wa-check-fallido { color: #e65a5a; }

.inbox-ventana-expirada {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fff3e0;
  color: #9a5b00;
  border-top: 1px solid #ffe0b0;
  padding: 10px 14px;
  font-size: 11.5px;
  line-height: 1.4;
}
.inbox-ventana-expirada svg { flex-shrink: 0; margin-top: 1px; }

.wa-footer {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--card-bg);
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
}
.wa-footer input, .wa-footer textarea {
  flex: 1;
  border: none;
  background: var(--bg);
  border-radius: 18px;
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--text-primary);
}
.wa-footer textarea {
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
}
.wa-footer input:disabled, .wa-footer textarea:disabled { opacity: .7; }
.wa-footer .icon-btn-ghost { flex-shrink: 0; }

/* ===== Selector de emojis (bandeja de mensajes) ===== */
.emoji-picker {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 62px;
  z-index: 20;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
}
.emoji-picker-btn {
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
}
.emoji-picker-btn:hover { background: var(--bg); }
@media (max-width: 480px) {
  .emoji-picker { grid-template-columns: repeat(6, 1fr); }
}

.respuestas-picker {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 62px;
  z-index: 20;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 10px;
  max-height: 260px;
  display: flex;
  flex-direction: column;
}
.respuestas-picker-titulo {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
}
.respuestas-picker-lista { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.respuestas-picker-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.respuestas-picker-item:hover { background: var(--bg); }
.respuestas-picker-item-titulo { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.respuestas-picker-item-contenido {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Modal genérico ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 43, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px 22px;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-header .card-titulo { margin: 0; }

/* ===== Inbox (Conversaciones) ===== */
.inbox-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
  align-items: start;
}
/* Modo "agrandar el chat": oculta la lista de conversaciones y deja el chat a todo el ancho. */
.inbox-shell.expandido { grid-template-columns: 1fr; }
.inbox-shell.expandido .inbox-lista-card { display: none; }
#btnInboxMaximizar.activo { background: var(--accent-light); color: var(--accent); border-color: var(--accent-light); }
.inbox-lista-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  height: calc(100vh - 132px);
  display: flex;
  flex-direction: column;
}
.inbox-lista-header { padding: 16px 18px 10px; }
.inbox-lista-header .tabs-pedidos { margin: 10px 0 0; }
.inbox-lista { list-style: none; overflow-y: auto; flex: 1; padding: 0 8px 8px; }
.inbox-lista li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.conv-fijar-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  opacity: 0;
  transition: opacity .15s;
  background: none;
  border: none;
  padding: 3px;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
}
.inbox-lista li:hover .conv-fijar-btn,
.conv-fijar-btn.fijada { opacity: 1; }
.conv-fijar-btn.fijada { color: var(--accent); }
.conv-fijar-btn:hover { background: rgba(0,0,0,.08); }
.inbox-lista li:hover { background: var(--bg); }
.inbox-lista li.activa { background: var(--accent-light); }
.inbox-lista li.necesita-humano,
.inbox-lista li.necesita-humano-pedido,
.inbox-lista li.necesita-humano-cotizacion,
.inbox-lista li.necesita-humano-derivacion {
  border-left: 3px solid transparent;
  padding-left: 5px;
}
.inbox-lista li.necesita-humano { background: var(--pink-light); border-left-color: var(--pink); }
.inbox-lista li.necesita-humano-pedido { background: var(--teal-light); border-left-color: var(--teal); }
.inbox-lista li.necesita-humano-cotizacion { background: var(--purple-light); border-left-color: var(--purple); }
.inbox-lista li.necesita-humano-derivacion { background: var(--orange-light); border-left-color: var(--orange); }
.inbox-lista li.necesita-humano.activa,
.inbox-lista li.necesita-humano-pedido.activa,
.inbox-lista li.necesita-humano-cotizacion.activa,
.inbox-lista li.necesita-humano-derivacion.activa { background: var(--accent-light); border-left-color: var(--accent); }

.inbox-chat-card { height: calc(100vh - 132px); }
.inbox-wa-panel { height: 100%; }
.inbox-chat-vacio {
  height: calc(100vh - 132px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.inbox-toggle-ia {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.wa-humano { align-self: flex-end; background: #cfe8ff; border-top-right-radius: 2px; }
.wa-origen-tag { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; opacity: .6; display: block; margin-bottom: 2px; }

.aviso-inline {
  font-size: 11.5px;
  color: var(--orange);
  padding: 6px 14px;
  background: var(--orange-light);
  border-top: 1px solid var(--border);
}

.inbox-back-btn { display: none; }

@media (max-width: 980px) {
  .inbox-shell { grid-template-columns: 1fr; }
  .inbox-lista-card, .inbox-chat-card, .inbox-chat-vacio { height: 420px; }
}

/* En pantallas de celular, el inbox se comporta como una app de mensajería:
   se ve la lista O el chat a pantalla completa, nunca los dos apilados. */
@media (max-width: 760px) {
  .main { padding: 12px; }
  .inbox-shell { gap: 0; }
  .inbox-lista-card,
  .inbox-chat-card,
  .inbox-chat-vacio,
  .inbox-wa-panel {
    height: calc(100dvh - 130px);
    border-radius: var(--radius-md);
  }
  .inbox-shell:not(.mostrando-chat) .inbox-chat-card { display: none; }
  .inbox-shell.mostrando-chat .inbox-lista-card { display: none; }
  #btnInboxMaximizar { display: none; }
  .inbox-back-btn { display: inline-flex; }

  .topbar { gap: 10px; }
  .topbar-titulo { font-size: 18px; }
  .topbar-perfil-info { display: none; }
  .buscador-input { width: 100%; }
  .card-head-row { gap: 10px; }
  .pedidos-stats { gap: 8px; }
  .pedido-stat { min-width: 100px; padding: 10px 12px; }
}

/* ===== Placeholder sections ===== */
.seccion-placeholder { display: flex; }
.seccion-placeholder[hidden] { display: none; }

/* ===== Guía de pasos (Integraciones) ===== */
.guia-pasos {
  list-style: none;
  counter-reset: paso;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 18px;
}
.guia-pasos li {
  counter-increment: paso;
  position: relative;
  padding-left: 38px;
}
.guia-pasos li::before {
  content: counter(paso);
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.guia-pasos li strong { display: block; font-size: 13.5px; margin-bottom: 4px; }
.guia-pasos li p { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 4px; line-height: 1.5; }
.guia-pasos li a { color: var(--accent); }
.guia-pasos li code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.placeholder-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px;
  max-width: 560px;
  margin: 20px auto 0;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.placeholder-card h2 { font-size: 19px; margin-bottom: 10px; }
.placeholder-card p { color: var(--text-secondary); font-size: 13.5px; margin-bottom: 16px; }
.placeholder-tag {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
}

/* ===== Scrollbars personalizados ===== */
* { scrollbar-width: thin; }

.sidebar-nav {
  scrollbar-color: rgba(0,0,0,.14) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius: 999px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.22); }

html {
  scrollbar-color: #d5d7e4 transparent;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d5d7e4; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #b9bcd1; }

/* ===== Responsive ===== */
@media (max-width: 1180px) {
  .contenido-con-preview { grid-template-columns: 1fr; }
  .preview-chat { position: static; }
  .wa-panel { height: 460px; }
}
@media (max-width: 980px) {
  .cards-grid-3 { grid-template-columns: 1fr; }
  .cards-grid-2 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  .sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.abierto { transform: translateX(0); }
  .main { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ===== Overlay oscuro detrás del menú lateral en celular ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 33, .45);
  z-index: 35;
  opacity: 0;
  transition: opacity .2s ease;
}
@media (max-width: 800px) {
  .sidebar-overlay.visible { display: block; opacity: 1; }
}

/* ===== Barra de navegación inferior estilo app (solo celular) ===== */
.tabbar-movil {
  display: none;
}
@media (max-width: 760px) {
  body.admin-body { padding-bottom: env(safe-area-inset-bottom, 0); }
  .tabbar-movil {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 12px rgba(15, 17, 33, .06);
  }
  .tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    padding: 6px 2px;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
  }
  .tabbar-item.active { color: var(--accent); }
  .main { padding-bottom: 84px; }
  /* Con la barra inferior ya cubriendo la navegación principal, el menú lateral pasa a ser el
     panel de "Más" — se abre a pantalla completa desde abajo, como un menú de app. */
  .sidebar {
    top: auto;
    bottom: 0;
    height: 85dvh;
    width: 100%;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    transition: transform .25s ease;
  }
  .sidebar.abierto { transform: translateY(0); }
}

/* ===== Ajustes de la vista de chat en celular: botones más grandes para el dedo,
   y espacio para la barra inferior de gestos del iPhone ===== */
@media (max-width: 760px) {
  .inbox-back-btn {
    width: 40px; height: 40px;
    margin-right: 2px;
  }
  .wa-header { padding: 12px 14px; }
}

/* ===== Login ===== */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--login-bg);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-logo-title { font-weight: 700; font-size: 16px; color: var(--accent); }
.login-logo-sub { font-size: 10.5px; color: var(--text-secondary); margin-top: 2px; text-transform: uppercase; letter-spacing: .06em; }
.login-restringido {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-muted);
  margin-bottom: 18px;
}
.login-error {
  background: #fef2f2; color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 12.5px;
  margin-bottom: 14px;
}
.login-label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.login-input-wrap { position: relative; margin-bottom: 18px; }
.login-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 40px 11px 13px;
  font-size: 14px;
  color: var(--text-primary);
}
.login-input:focus { outline: none; border-color: var(--accent); }
.login-toggle-pass {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
}
.login-toggle-pass.activo { color: var(--accent); }
.login-toggle-pass-barra { opacity: 0; transition: opacity .1s; }
.login-toggle-pass.activo .login-toggle-pass-barra { opacity: 1; }
.login-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
}
.login-btn:hover { background: #4338ca; }
.login-btn:disabled { opacity: .5; cursor: not-allowed; }
.login-input:disabled { opacity: .6; }

/* ===== Botón primario ===== */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: #4338ca; }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

/* ===== Card angosta (formularios centrados) ===== */
.card-angosta { max-width: 560px; }

/* ===== Formularios de configuración ===== */
.form-config { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.form-label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.form-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-primary);
  font-weight: 400;
  resize: vertical;
}
.form-input:focus { outline: none; border-color: var(--accent); }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 500; }
.form-acciones { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.form-guardado { font-size: 12.5px; color: var(--green); font-weight: 600; }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: -8px; }

.form-foto-producto { display: flex; align-items: center; gap: 12px; }
.producto-foto-preview { width: 56px; height: 56px; object-fit: contain; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; padding: 4px; box-sizing: border-box; }
.producto-foto-vacio { width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--border); border-radius: var(--radius-sm); font-size: 10.5px; color: var(--text-muted); text-align: center; }

/* ===== Tablas de datos ===== */
.tabla-wrap { overflow-x: auto; margin-top: 4px; }
.tabla-datos { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla-datos th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tabla-datos td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.tabla-datos tr:last-child td { border-bottom: none; }
.tabla-datos td.celda-truncada { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabla-acciones { display: flex; gap: 8px; white-space: nowrap; }
.tabla-accion-btn {
  background: none; border: none; color: var(--text-muted); padding: 2px;
  display: inline-flex; align-items: center; justify-content: center;
}
.tabla-accion-btn:hover { color: var(--accent); }
.telefono-celda { display: inline-flex; align-items: center; gap: 4px; }
.telefono-texto { font-variant-numeric: tabular-nums; white-space: nowrap; }
.icon-btn-mini { width: 22px; height: 22px; color: var(--text-muted); }
.icon-btn-mini:hover { color: var(--accent); }
.paginacion { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.paginacion-btn {
  min-width: 30px; height: 30px; padding: 0 6px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--card-bg); color: var(--text-secondary);
  font-size: 12.5px; font-variant-numeric: tabular-nums; cursor: pointer;
}
.paginacion-btn:hover { border-color: var(--accent); color: var(--accent); }
.paginacion-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabla-accion-btn.peligro:hover { color: #dc2626; }
.tabla-vacio { text-align: center; color: var(--text-muted); font-size: 13px; padding: 26px 0; }

/* ===== Página de enlaces ===== */
.pagina-publica-url {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 16px;
  color: var(--text-secondary);
  font-size: 13px;
}
.pagina-publica-url svg { flex-shrink: 0; color: var(--text-muted); }
.pagina-publica-url span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pagina-publica-url .btn { flex-shrink: 0; }

.icono-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.icono-picker-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.icono-picker-btn svg { display: block; width: 100%; height: 100%; }
.icono-picker-btn:hover { transform: scale(1.06); }
.icono-picker-btn.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.icono-picker-btn-vacio {
  background: var(--bg);
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 600;
}
.icono-picker-btn-vacio.selected { border-style: solid; }

/* ===== Vista previa en vivo de la página pública ===== */
.pagina-publica-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.pagina-publica-columna { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pagina-publica-preview-wrap { position: sticky; top: 24px; }
.preview-pagina-etiqueta { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 10px; text-align: center; }

.telefono-frame {
  background: #0d0e1c;
  border-radius: 34px;
  padding: 12px;
  box-shadow: var(--shadow-card);
}
.telefono-pantalla {
  position: relative;
  height: 560px;
  overflow-y: auto;
  border-radius: 24px;
  background:
    radial-gradient(circle at 20% -10%, #2c2a6b 0%, transparent 45%),
    radial-gradient(circle at 90% 10%, #1f5a52 0%, transparent 40%),
    #12142b;
  padding: 28px 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: #f4f4fb;
  font-family: 'Poppins', system-ui, sans-serif;
}
.preview-pagina-avatar {
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  margin: 0 auto;
  border-radius: 50%;
  background: linear-gradient(145deg, #6d63f0, #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}
.preview-pagina-avatar.con-logo {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  border-radius: 50%;
  background: #ffffff;
}
.preview-pagina-avatar img { width: 100%; height: 100%; object-fit: cover; }
.preview-pagina-avatar.con-logo img { display: block; width: 46px; height: 32px; }
.preview-pagina-nombre { margin-top: 12px; font-size: 14px; font-weight: 700; }
.preview-pagina-bio { margin-top: 5px; font-size: 11px; line-height: 1.4; color: #a6a8c9; max-width: 220px; }
.preview-pagina-wa {
  margin-top: 16px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: linear-gradient(135deg, #25d366, #1da851);
  color: #08240f;
  font-weight: 700;
  font-size: 11px;
  padding: 10px 12px;
  border-radius: 11px;
}
.preview-pagina-catalogo {
  margin-top: 8px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, #6d63f0, #4f46e5);
  color: #fff;
  font-weight: 700;
  font-size: 10.5px;
  padding: 9px 12px;
  border-radius: 11px;
}
.preview-pagina-enlaces { margin-top: 10px; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.preview-pagina-enlace {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  color: #f4f4fb;
  padding: 9px 12px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 500;
}
.preview-pagina-enlace svg { flex-shrink: 0; }
.preview-pagina-enlace span { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-pagina-enlace.oculto { opacity: .4; }
.preview-pagina-vacio { margin-top: 40px; font-size: 11px; color: #a6a8c9; }
.preview-pagina-inactiva {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 30px;
  font-size: 12px;
  color: #a6a8c9;
  background: #12142b;
  border-radius: 24px;
}

@media (max-width: 980px) {
  .pagina-publica-layout { grid-template-columns: 1fr; }
  .pagina-publica-preview-wrap { position: static; max-width: 320px; margin: 0 auto; }
}
