:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --text: #e7ecf3;
  --muted: #93a1b5;
  --primary: #25d366;
  --primary-dark: #1da851;
  --danger: #ff6b6b;
  --success: #4ade80;
  --border: #2f3d52;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: #7dd3fc; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-stats-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1.1rem;
  padding: 0.55rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.78rem;
}

.admin-stats-bar .stat-item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  white-space: nowrap;
}

.admin-stats-bar .stat-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.68rem;
}

.admin-stats-bar strong {
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
}

.admin-stats-bar .stat-item.stat-warn strong {
  color: #fbbf24;
}

.admin-stats-bar .stat-item.stat-danger strong {
  color: var(--danger);
}

.admin-stats-bar .stat-bots strong {
  color: var(--primary);
}

.admin-stats-bar.admin-stats-error {
  border-color: rgba(255, 107, 107, 0.45);
}

.brand { font-weight: 700; color: var(--primary); }

.topbar nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.user { color: var(--muted); font-size: 0.9rem; }

.inline { display: inline; margin: 0; }

.btn-link {
  background: none;
  border: none;
  color: #7dd3fc;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.container {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 2rem clamp(1rem, 2.5vw, 2.5rem) 3rem;
}

.container.narrow,
.container.narrow-wide {
  max-width: none;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
/* Una tabla ancha dentro de la columna se desplaza; no estira la cuadrícula. */
.grid-2 > * { min-width: 0; }

.compact-grid label {
  margin-bottom: 0.75rem;
}

.section-block { margin-bottom: 1.5rem; }
.section-block h2 { margin-top: 0; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-row input { width: auto; margin: 0; }

.form select {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1017;
  color: var(--text);
  font: inherit;
}

.hidden { display: none !important; }

.tag-green {
  background: rgba(37, 211, 102, 0.15);
  border-color: var(--primary);
  color: #bbf7d0;
}

.tag-disabled {
  background: rgba(148, 163, 184, 0.12);
  border-color: #475569;
  color: #94a3b8;
}

.response-row-disabled td {
  opacity: 0.72;
}

.response-row-disabled strong {
  text-decoration: line-through;
  text-decoration-color: rgba(148, 163, 184, 0.5);
}

.tag-auto {
  background: #dc2626;
  color: #fff;
  font-weight: 600;
  border-color: #b91c1c;
}

.tag-system {
  background: #991b1b;
  color: #fff;
  font-weight: 600;
  border-color: #7f1d1d;
}

.tag-content {
  background: rgba(56, 189, 248, 0.15);
  border-color: #0ea5e9;
  color: #bae6fd;
}

.tag-ticket {
  background: rgba(251, 191, 36, 0.2);
  border-color: #f59e0b;
  color: #fde68a;
  margin-left: 0.25rem;
}

.ticket-toggle-row {
  margin-top: 0.75rem;
}

.hint-inline {
  color: var(--muted);
  font-size: 0.9rem;
}

.tag-inline {
  display: inline-block;
  vertical-align: middle;
}

.response-actions-cell {
  white-space: nowrap;
}

.response-actions-cell .inline {
  display: inline-block;
  margin-left: 0.35rem;
}

.pause-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1rem;
}

.pause-banner .inline-form {
  margin-left: 0.6rem;
}

.pause-pending {
  margin-bottom: 1.2rem;
}

.tag-pause {
  background: #dc2626;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.tag-warn {
  background: #fef3c7;
  color: #92400e;
  margin-bottom: 0.25rem;
}

.sort-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
  white-space: nowrap;
}

.sort-link:hover {
  color: #2563eb;
}

.tag-variants {
  background: #ede9fe;
  color: #5b21b6;
  border-color: #c4b5fd;
}

.variants-block {
  border-left: 3px solid #c4b5fd;
  padding-left: 0.85rem;
  margin: 0.25rem 0 0.75rem;
}

.button-name-form {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  min-width: 14rem;
}

.button-name-form input,
.button-name-form select {
  flex: 1;
  min-width: 0;
  padding: 0.3rem 0.45rem;
  font-size: 0.85rem;
}

.btn-danger {
  background: rgba(255, 107, 107, 0.2);
  color: #fecaca;
  border: 1px solid var(--danger);
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* «Guardar para todos» (superadmin) y «Sin cambios del admin» (cada bot). */
.btn-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
  border: 1px solid #f59e0b;
}

.save-scope-row { align-items: center; }

.admin-lock-toggle {
  padding: 0.45rem 0.75rem;
  border: 1px dashed #f59e0b;
  border-radius: 8px;
  color: #fde68a;
  font-weight: 600;
  cursor: pointer;
}

.tag-locked {
  background: rgba(245, 158, 11, 0.15);
  color: #fde68a;
  border-color: #f59e0b;
}

.limits-list {
  margin: 0.5rem 0 1rem;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.url-cell code { font-size: 0.75rem; word-break: break-all; }

.step-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.step-item {
  display: block;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.step-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}

.step-meta { flex: 1; min-width: 160px; }

.step-num {
  display: inline-flex;
  width: 1.5rem;
  height: 1.5rem;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-radius: 50%;
  margin-right: 0.5rem;
  font-size: 0.8rem;
}

.step-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .step-item { flex-direction: column; }
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.back { display: inline-block; margin-bottom: 0.5rem; color: var(--muted); }

h1 { margin: 0 0 0.5rem; font-size: 1.75rem; }

.muted { color: var(--muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.card, .box, .card-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat { font-size: 2rem; font-weight: 700; margin: 0.5rem 0 1rem; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font: inherit;
  cursor: pointer;
  text-align: center;
}

.btn-primary { background: var(--primary); color: #052e16; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-success {
  background: #15803d;
  color: #ecfdf5;
  border: 1px solid #22c55e;
  font-weight: 600;
}

.btn-success:hover {
  background: #166534;
  text-decoration: none;
}

.btn-small { padding: 0.35rem 0.75rem; font-size: 0.875rem; }

.form label {
  display: block;
  margin-bottom: 1rem;
}

.form input,
.form textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1017;
  color: var(--text);
  font: inherit;
}

.copy-box {
  width: 100%;
  margin: 0.5rem 0 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid #22c55e;
  background: #0b1017;
  color: var(--text);
  font: inherit;
  white-space: pre-wrap;
}

.form input[type="checkbox"],
.form input[type="radio"] {
  width: auto;
  margin-top: 0;
  padding: 0;
  flex-shrink: 0;
}

.form label.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.35;
}

.form label.checkbox-row:hover {
  border-color: var(--accent, #3b82f6);
}

.ai-catalog-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 42rem;
}

.ai-catalog-list .catalog-title {
  font-weight: 600;
}

.ai-catalog-list .catalog-key {
  display: block;
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.alert-error { background: rgba(255,107,107,0.15); border: 1px solid var(--danger); }
.alert-success { background: rgba(74,222,128,0.12); border: 1px solid var(--success); }
.alert-info { background: rgba(96,165,250,0.12); border: 1px solid rgba(96,165,250,0.6); }

/* Aviso de arriba repetido flotando cuando la página vuelve a la misma altura tras guardar. */
.alert.flash-toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: min(92vw, 640px);
  margin: 0;
  background-color: var(--surface);
  background-image: linear-gradient(rgba(74,222,128,0.12), rgba(74,222,128,0.12));
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  cursor: pointer;
  transition: opacity 0.5s ease;
}
.alert-error.flash-toast { background-image: linear-gradient(rgba(255,107,107,0.15), rgba(255,107,107,0.15)); }
.alert-info.flash-toast { background-image: linear-gradient(rgba(96,165,250,0.12), rgba(96,165,250,0.12)); }
.flash-toast-hide { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .alert.flash-toast { transition: none; }
}

/* Aviso de la barra superior en todas las páginas (iboplayer por vencer). */
.login-alert {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 1.1rem;
  border-radius: 10px;
  color: #fff;
  text-decoration: none;
  font-size: 1rem;
  line-height: 1.35;
}
.login-alert-aviso { background: #b45309; border: 2px solid #fbbf24; }
.login-alert-urgente {
  background: #b91c1c;
  border: 2px solid #fecaca;
  animation: login-alert-pulse 1.6s ease-in-out infinite;
}
.login-alert-icon { font-size: 1.8rem; }
.login-alert-body { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.login-alert-body strong { font-size: 1.15rem; text-transform: uppercase; letter-spacing: 0.02em; }
.login-alert-cta {
  background: #fff;
  color: #111;
  font-weight: 700;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  white-space: nowrap;
}
.login-alert:hover .login-alert-cta { background: #fde68a; }
@keyframes login-alert-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .login-alert-urgente { animation: none; }
}
@media (max-width: 640px) {
  .login-alert { flex-wrap: wrap; }
  .login-alert-cta { width: 100%; text-align: center; }
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Tabla más ancha que la pantalla (monitor chico, ventana angosta): se mueve
   de izquierda a derecha en vez de quedar cortada. */
.table-wrap,
.hscroll {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  color-scheme: dark;
}

/* Barra fija al pie mientras la parte de abajo de la tabla está fuera de la vista (panel.js). */
.hscroll-float {
  position: fixed;
  bottom: 0;
  z-index: 900;
  display: none;
  height: 18px;
  overflow-x: scroll;
  overflow-y: hidden;
  color-scheme: dark;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.35);
}
.hscroll-float.on { display: block; }
.hscroll-float > div { height: 1px; }

table { width: 100%; border-collapse: collapse; background: var(--surface); }

th, td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }

th { background: var(--surface-2); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.tag {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  margin: 0.15rem 0.25rem 0.15rem 0;
  font-size: 0.8rem;
}

.keywords-cell { max-width: none; }

code { background: #0b1017; padding: 0.1rem 0.35rem; border-radius: 4px; }

.hint { display: block; margin-top: 0.35rem; font-size: 0.85rem; color: var(--muted); }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.auth-card h1 { margin-top: 0; color: var(--primary); }

.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.form label.provider-card {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin: 0;
  padding: 0.9rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.form label.provider-card.on,
.form label.provider-card:has(input:checked) {
  border-color: var(--primary);
}

.provider-card input {
  margin-top: 0.25rem;
}

.provider-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.evo-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin-bottom: 1rem;
}

.evo-qr-box {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

.evo-qr {
  width: 264px;
  height: 264px;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  border: 1px solid var(--border);
}

.evo-pair-code {
  display: inline-block;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  padding: 0.5rem 1rem;
  margin: 0.25rem 0 0.5rem;
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
}

.pw-wrap {
  position: relative;
  display: block;
}

.pw-wrap input {
  padding-right: 2.8rem;
}

.pw-eye {
  position: absolute;
  right: 0.35rem;
  top: calc(50% + 0.175rem);
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  opacity: 0.65;
}

.pw-eye:hover,
.pw-eye.on {
  opacity: 1;
  background: rgba(127, 127, 127, 0.15);
}

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; }
}

/* Fase 3 — flujo visual */
.flow-visual { width: 100%; }

@media (max-width: 768px) {
  .flow-visual { overflow-x: auto; }
}

.flow-tree {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.flow-tree .flow-tree {
  margin-left: 1.25rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}

.flow-node { margin: 0.75rem 0; }

.flow-node-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.flow-node-title { font-weight: 600; }

.flow-node-key {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.flow-node-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

.flow-help {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.flow-help li { margin-bottom: 0.5rem; }

.flow-parent-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.flow-parent-form select {
  min-width: 220px;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.code-block {
  display: block;
  padding: 0.65rem 0.85rem;
  background: var(--surface-2);
  border-radius: 8px;
  word-break: break-all;
}

.details-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.details-block summary {
  cursor: pointer;
  color: #7dd3fc;
  margin-bottom: 0.5rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.inline-test-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.phone-input-light {
  max-width: 180px;
  background: #fff;
  color: #111827;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  font: inherit;
}

.phone-input-light::placeholder {
  color: #9ca3af;
  font-size: 0.8rem;
}

.phone-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.pagination-summary {
  margin-bottom: 0.75rem;
}

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.pagination-current {
  padding: 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.pagination-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.media-step-block {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.field-label-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.bot-text-media-current {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.add-step-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.media-source-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
}

.tab-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.media-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  max-height: 320px;
  overflow: auto;
  padding: 0.25rem;
}

.media-picker-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.5rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.media-picker-item:hover {
  border-color: #38bdf8;
}

.media-picker-item.selected {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 1px #0ea5e9;
}

.media-picker-item.hidden {
  display: none;
}

.media-picker-thumb {
  width: 100%;
  height: 88px;
  object-fit: cover;
  border-radius: 6px;
  background: #111827;
}

.media-picker-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 88px;
  border-radius: 6px;
  background: #111827;
  color: #7dd3fc;
  font-size: 1.6rem;
}

.media-picker-name,
.media-picker-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-picker-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.limits-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.cooldown-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.35rem;
}

.cooldown-row input[type='number'] {
  width: 100px;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.cooldown-row select {
  min-width: 120px;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.step-preview-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  background: #111827;
  flex-shrink: 0;
}

.step-preview-audio,
.response-preview-audio {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: #111827;
  color: #7dd3fc;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.step-edit-panel {
  margin-top: 0.75rem;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.fixed-qr-preview {
  display: block;
  width: 100%;
  max-width: 220px;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  border: 1px solid var(--border);
  margin: 0.5rem 0 1rem;
}

.step-edit-preview {
  max-width: 220px;
  max-height: 140px;
  border-radius: 8px;
  margin: 0.5rem 0 1rem;
  background: #111827;
}

.response-preview-cell {
  min-width: 72px;
}

.response-preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.response-preview-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: #111827;
}

.media-picker-thumb video {
  width: 100%;
  height: 88px;
  object-fit: cover;
  border-radius: 6px;
  background: #111827;
}

/* Utilidades que sustituyen los atributos style= inline (R3: CSP sin unsafe-inline). */
.text-small { font-size: 0.9em; }

.pre-line { white-space: pre-line; }

.table-wrap-spaced { margin-top: 1.5rem; }

.input-owner { max-width: 100px; }

.input-phone { max-width: 150px; }

.input-notes { max-width: 120px; }

/* Pagos y métricas */
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }

.filter-search { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }

.row-attention td { background: rgba(251, 191, 36, 0.06); }

.payment-actions { white-space: nowrap; }

.payment-actions .inline { display: inline-block; margin: 0 0.35rem 0.35rem 0; }

.stat-sub { margin: -0.5rem 0 1rem; color: var(--muted); font-size: 0.9rem; }

.health-list { list-style: none; padding: 0; margin: 0.5rem 0 1rem; }

.health-list li { margin: 0.35rem 0; }

/* App de botones */
.app-qr-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }

.app-qr { width: 190px; flex: 0 0 190px; background: #fff; border-radius: 8px; padding: 6px; }

.app-qr svg { display: block; width: 100%; height: auto; }

.app-qr-row > div:last-child { flex: 1 1 220px; min-width: 0; }

.app-qr-row input { width: 100%; }

.app-icon { font-size: 1.15em; }

.app-order { white-space: nowrap; }

.app-order .inline { display: inline-block; margin-right: 0.25rem; }

.row-muted td { opacity: 0.5; }

.app-matrix th, .app-matrix td { text-align: center; padding: 0.35rem; }

.app-matrix th:first-child, .app-matrix td:first-child { text-align: left; }

.app-matrix .btn { min-width: 2.2rem; }

.form .app-form-fields[hidden] { display: none; }

.app-options { font-family: ui-monospace, monospace; min-height: 8rem; }
.app-demo-text { min-height: 18rem; }

/* Inicio: luces de estado de cada bot */
.light { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.light-dot { width: 0.8rem; height: 0.8rem; border-radius: 50%; flex: none; background: #5b6778; }
.light-verde .light-dot { background: #22c55e; box-shadow: 0 0 6px rgba(34, 197, 94, 0.8); }
.light-amarillo .light-dot { background: #facc15; box-shadow: 0 0 6px rgba(250, 204, 21, 0.7); }
.light-rojo .light-dot { background: #ef4444; box-shadow: 0 0 6px rgba(239, 68, 68, 0.9); }
.light-gris { color: var(--muted); }
.light-detail { display: block; font-size: 0.78rem; color: var(--muted); white-space: normal; max-width: 16rem; }
.bots-table td { vertical-align: top; }
.bot-actions { display: flex; flex-direction: column; gap: 0.35rem; align-items: stretch; white-space: nowrap; }
.bot-actions form { display: flex; }
.bot-actions form .btn { flex: 1; }
/* Acciones siempre a la vista aunque la tabla de bots se desplace a lo ancho. */
td.sticky-actions, th.sticky-actions { position: sticky; right: 0; z-index: 1; box-shadow: -6px 0 8px -6px rgba(0, 0, 0, 0.6); }
td.sticky-actions { background: var(--surface); }
th.sticky-actions { background: var(--surface-2); }

/* «Entrar como usuario»: aviso fijo arriba en la pestaña del panel del usuario. */
.viewas-banner {
  position: sticky; top: 0; z-index: 50; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem;
  padding: 0.55rem 1rem; background: #7c2d12; color: #fff7ed; font-size: 0.9rem; border-bottom: 2px solid #fb923c;
}
.viewas-banner form { margin-left: auto; }
.ibo-clients-table td { vertical-align: top; }
.ibo-client-form { display: grid; grid-template-columns: repeat(2, minmax(9rem, 1fr)); gap: 0.3rem; max-width: 26rem; }
.ibo-client-form input { width: 100%; padding: 0.3rem 0.45rem; font-size: 0.85rem; }
.ibo-client-form .btn { justify-self: start; }
.ibo-macs { min-width: 18rem; }
.ibo-mac { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; padding: 0.3rem 0; border-bottom: 1px dashed var(--border, #ddd); }
.ibo-mac code { font-size: 0.85rem; }
.ibo-mac-note, .ibo-mac-add { display: inline-flex; gap: 0.25rem; align-items: center; }
.ibo-mac-note input { width: 8rem; padding: 0.2rem 0.4rem; font-size: 0.8rem; }
.ibo-mac-add { margin-top: 0.4rem; }
.ibo-mac-add input { width: 8.5rem; padding: 0.25rem 0.4rem; font-size: 0.8rem; }
.ibo-totals { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 1rem; }
.ibo-totals > div { display: flex; flex-direction: column; min-width: 9rem; }
.ibo-totals strong { font-size: 1.5rem; }
.ibo-toggles { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.4rem; white-space: nowrap; }
.ibo-toggles .btn { width: 100%; }
.limit-input { width: 5.5rem; padding: 0.25rem 0.4rem; font-size: 0.85rem; margin-bottom: 0.3rem; }
.ibo-toggles .limit-input { width: 100%; }
.bot-search { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-bottom: 0.75rem; }
.bot-search input { flex: 1 1 18rem; max-width: 32rem; padding: 0.6rem 0.75rem; border-radius: 8px; border: 1px solid var(--border); background: #0b1017; color: inherit; font-size: 1rem; }
.limit-default { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1rem; }
.limit-default .limit-input { margin: 0 0 0 0.4rem; }
.bots-table .light-detail { max-width: 11rem; }
.bots-table .wa-cell .light-detail { max-width: 9rem; overflow-wrap: anywhere; }
.bots-table .wa-id-cell code { display: inline-block; max-width: 8rem; overflow-wrap: anywhere; word-break: break-all; }
.bots-table .line2-block { margin-top: 0.45rem; padding-top: 0.45rem; border-top: 1px dashed var(--border); }
.limit-cell { min-width: 9.5rem; }
.limit-form { display: flex; align-items: center; gap: 0.3rem; margin: 0 0 0.3rem; }
.limit-form .limit-input { width: 4.8rem; margin: 0; flex: none; }
.limit-form .btn { flex: none; width: auto; }
.limit-note { display: block; white-space: normal; }
.msg-count { text-align: right; white-space: nowrap; }
.msg-count span { display: block; }
.light-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0.5rem 0 1rem; font-size: 0.85rem; }

/* PRECIOS */
.prices-scope { max-width: 26rem; margin-bottom: 1rem; }
.prices-section { margin-bottom: 1.25rem; }
.prices-section h2 .tag { vertical-align: middle; text-transform: none; letter-spacing: 0; }
.tag-ok { background: rgba(34, 197, 94, 0.15); border-color: #22c55e; }
.prices-grid th, .prices-grid td { padding: 0.5rem 0.75rem; vertical-align: middle; }
.prices-grid input { width: 7rem; margin: 0; }
.prices-grid small { display: block; margin-top: 0.2rem; }
.prices-reset { display: inline-block; margin-top: 0.75rem; }
.foreign-price { border-top: 1px solid var(--border, #333); padding-top: 1rem; margin-top: 1rem; }
.foreign-price h3,
.foreign-price h4 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.foreign-price .fixed-qr-preview { margin-bottom: 0.75rem; }
.foreign-group-title { margin: 2rem 0 0.25rem; padding-top: 1rem; border-top: 2px solid var(--border, #333); font-size: 1.15rem; }
.prices-section > .foreign-group-title:first-of-type { margin-top: 0.5rem; padding-top: 0; border-top: 0; font-size: 1rem; }
.ai-owner-switch { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.ai-owner-switch h2 { margin: 0 0 0.35rem; font-size: 1.15rem; }
.ai-owner-switch p { margin: 0; max-width: 60ch; }
.foreign-block { margin-top: 1.5rem; border: 1px solid var(--border, #333); border-radius: 8px; padding: 0.5rem 0.9rem; }
.foreign-block > summary { cursor: pointer; font-weight: 600; font-size: 1.05rem; padding: 0.35rem 0; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.foreign-block[open] > summary { margin-bottom: 0.5rem; }
.foreign-block .save-scope-row { margin-top: 1rem; }

/* Respuestas → Mensajes del bot */
.bot-texts { margin-top: 2rem; }
.bot-texts-group { border: 1px solid var(--border, #ddd); border-radius: 8px; margin-bottom: 0.75rem; padding: 0.5rem 0.75rem; }
.bot-texts-group > summary { cursor: pointer; padding: 0.25rem 0; }
.bot-texts-group[open] > summary { margin-bottom: 0.5rem; }
.bot-text-preview { max-width: 28rem; color: var(--muted); font-size: 0.9em; }
.bot-texts .small { font-size: 0.85em; }
.bot-text-vars { margin: 0.75rem 0; }
.bot-text-vars ul { margin: 0.4rem 0; padding-left: 1.2rem; }
.bot-text-vars li { margin-bottom: 0.25rem; }
.bot-text-sample { white-space: pre-wrap; word-break: break-word; background: var(--surface-2, #f6f6f6); padding: 0.75rem; border-radius: 6px; font-family: inherit; }

/* Inicio → API gratuita: avance de la actualización */
.evo-update-log { white-space: pre-wrap; word-break: break-word; max-height: 16rem; overflow-y: auto; font-size: 0.8rem; background: var(--surface-2, #f6f6f6); padding: 0.6rem 0.75rem; border-radius: 6px; }
.evo-update-light { white-space: normal; }

/* Historial: filas de envíos o botones que fallaron */
.row-failed td { background: rgba(239, 68, 68, 0.08); }
