:root {
  --bg: #0a0a0f;
  --card: #14141c;
  --border: rgba(255,255,255,0.08);
  --purple: #8b5cf6;
  --blue: #6366f1;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --text: #e2e8f0;
  --muted: #94a3b8;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 28px 40px 60px;
}
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.topbar h1 { font-size: 22px; margin: 0; }
.accent { background: linear-gradient(135deg, #8b5cf6, #6366f1); -webkit-background-clip: text; background-clip: text; color: transparent; }

.btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13.5px;
}
.btn:hover { background: rgba(255,255,255,0.1); }
.btn-primary {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  border: none;
  font-weight: 600;
}
.btn-close { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  cursor: pointer;
  transition: border-color .15s;
}
.card:hover { border-color: rgba(139,92,246,0.4); }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card .nicho { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.badge {
  display: inline-block;
  font-size: 10.5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
}
.badge.conectado { background: rgba(16,185,129,0.15); color: var(--green); }
.badge.esperando_qr { background: rgba(245,158,11,0.15); color: var(--amber); }
.badge.sin_iniciar { background: rgba(148,163,184,0.15); color: var(--muted); }
.badge.desconectado, .badge.error { background: rgba(239,68,68,0.15); color: var(--red); }
.card .footer-card { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.card .footer-card .del { color: var(--muted); font-size: 12px; }
.card .footer-card .del:hover { color: var(--red); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 26px; width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto;
}
.modal-ancho { max-width: 560px; }
.modal h2 { margin: 0 0 18px; font-size: 18px; }
.modal label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; }
.modal input, .modal select, .modal textarea {
  width: 100%; background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 11px; color: var(--text); font-size: 13.5px;
}
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.seccion { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.seccion h3 { font-size: 13.5px; margin: 0 0 6px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0; }
.error { color: var(--red); font-size: 12.5px; margin-top: 10px; }
.hidden { display: none; }

.qr-box { margin-top: 14px; display: flex; justify-content: center; }
.qr-box img { border-radius: 10px; background: white; padding: 10px; }

.test-chat-box {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.test-msg { max-width: 80%; padding: 8px 12px; border-radius: 10px; font-size: 13px; }
.test-msg.user { align-self: flex-end; background: rgba(139,92,246,0.25); }
.test-msg.assistant { align-self: flex-start; background: rgba(255,255,255,0.08); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(30px);
  background: var(--card); border: 1px solid var(--purple); padding: 12px 18px;
  border-radius: 10px; font-size: 13px; opacity: 0; transition: .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
