:root {
  --bg: #0f1420;
  --panel: #182131;
  --panel-2: #1f2a3d;
  --borde: #2a3852;
  --texto: #e8edf5;
  --muted: #8b9bb4;
  --acento: #5b8cff;
  --acento-2: #7c5bff;
  --ok: #35c88a;
  --error: #ff6b6b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #1b2740 0%, var(--bg) 55%);
  color: var(--texto);
  min-height: 100vh;
}

.oculto { display: none !important; }

/* ── Auth ───────────────────────────────────────────── */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.logo {
  font-size: 30px;
  font-weight: 700;
  text-align: center;
  background: linear-gradient(90deg, var(--acento), var(--acento-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sub { text-align: center; color: var(--muted); margin: 6px 0 22px; }

.tabs { display: flex; gap: 6px; background: var(--panel-2); padding: 5px; border-radius: 12px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 9px; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--muted); font-weight: 600; font-size: 14px;
}
.tab.activa { background: var(--acento); color: #fff; }

.form { display: flex; flex-direction: column; gap: 12px; }

input, textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--borde);
  color: var(--texto);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--acento); }
textarea { resize: vertical; }

.btn {
  background: linear-gradient(90deg, var(--acento), var(--acento-2));
  color: #fff; border: 0; padding: 12px; border-radius: 10px;
  font-weight: 600; font-size: 15px; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn-link { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; }
.btn-link:hover { color: var(--texto); }

.error { color: var(--error); font-size: 13px; text-align: center; margin: 12px 0 0; }
.legal-links { text-align: center; margin: 18px 0 0; font-size: 12px; }
.legal-links a { color: var(--muted); text-decoration: none; }
.legal-links a:hover { color: var(--texto); }
.ok { color: var(--ok); font-size: 13px; font-weight: 600; }

/* ── App ────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--borde);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 20px; }
.nav { display: flex; gap: 6px; flex: 1; }
.nav-item {
  background: transparent; border: 0; color: var(--muted);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px;
}
.nav-item.activa { background: var(--panel-2); color: var(--texto); }
.user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }

.contenido { max-width: 780px; margin: 0 auto; padding: 30px 24px 60px; }
h2 { margin: 0 0 4px; }
.hint { color: var(--muted); margin: 0 0 20px; font-size: 14px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 16px;
  padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.panel label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.panel label input, .panel label textarea { color: var(--texto); font-weight: 400; }
.fila { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { flex-direction: row !important; align-items: center; gap: 10px !important; }
.check input { width: auto; }

.estado { margin-bottom: 16px; font-size: 14px; }
.estado.conectado { color: var(--ok); }
.estado.pendiente { color: var(--muted); }

/* ── Métricas ───────────────────────────────────────── */
.metricas {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.metrica {
  background: var(--panel); border: 1px solid var(--borde); border-radius: 12px;
  padding: 16px; display: flex; flex-direction: column; gap: 4px;
}
.m-valor { font-size: 24px; font-weight: 700; color: var(--texto); }
.m-label { font-size: 12px; color: var(--muted); }

/* ── Chats ──────────────────────────────────────────── */
.chats-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
.contactos { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--borde); border-radius: 14px; overflow: hidden; max-height: 60vh; overflow-y: auto; }
.contactos li { padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--borde); font-size: 14px; }
.contactos li:hover { background: var(--panel-2); }
.contactos li.activa { background: var(--panel-2); border-left: 3px solid var(--acento); }
.contactos .cnt { color: var(--muted); font-size: 12px; }

.detalle { background: var(--panel); border: 1px solid var(--borde); border-radius: 14px; padding: 18px; max-height: 60vh; overflow-y: auto; }
.msg { margin-bottom: 10px; display: flex; }
.msg .burbuja { padding: 8px 12px; border-radius: 12px; max-width: 75%; font-size: 14px; line-height: 1.4; }
.msg.user { justify-content: flex-start; }
.msg.user .burbuja { background: var(--panel-2); }
.msg.assistant { justify-content: flex-end; }
.msg.assistant .burbuja { background: linear-gradient(90deg, var(--acento), var(--acento-2)); color: #fff; }

/* ── Plan badge / candado ───────────────────────────── */
.plan-badge {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--borde); color: var(--muted);
}
.plan-badge.pro {
  background: linear-gradient(90deg, var(--acento), var(--acento-2));
  color: #fff; border-color: transparent;
}
.lock { font-size: 12px; color: var(--muted); margin-left: 6px; }
.check input:disabled + * , .check input:disabled { opacity: .6; }

/* ── Conexión WhatsApp ──────────────────────────────── */
.panel-details {
  background: var(--panel); border: 1px solid var(--borde); border-radius: 14px;
  padding: 0 18px; margin-top: 14px;
}
.panel-details > summary {
  cursor: pointer; padding: 14px 0; color: var(--muted); font-size: 14px; list-style: none;
}
.panel-details[open] > summary { border-bottom: 1px solid var(--borde); margin-bottom: 8px; }
.panel-details .panel { border: none; padding: 12px 0 18px; }

/* ── Planes ─────────────────────────────────────────── */
.planes-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px; margin-top: 16px;
}
.plan-card {
  background: var(--panel); border: 1px solid var(--borde); border-radius: 16px;
  padding: 22px; display: flex; flex-direction: column; gap: 10px;
}
.plan-card.actual { border-color: var(--acento); }
.plan-card.destacado { border-color: transparent; background: linear-gradient(160deg, #22304d, var(--panel)); }
.plan-card h3 { margin: 0; font-size: 18px; }
.plan-precio { font-size: 30px; font-weight: 800; }
.plan-precio small { font-size: 13px; font-weight: 500; color: var(--muted); }
.plan-feats { list-style: none; margin: 6px 0 0; padding: 0; font-size: 14px; color: var(--muted); }
.plan-feats li { padding: 4px 0; }
.plan-card .btn { margin-top: auto; }
.plan-estado { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

/* ── Wizard de onboarding ───────────────────────────── */
.wizard-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8, 11, 18, 0.72); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px;
}
.wizard-card {
  width: 100%; max-width: 540px; background: var(--panel);
  border: 1px solid var(--borde); border-radius: 18px; padding: 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.wizard-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.wizard-paso-label { font-size: 13px; color: var(--muted); }
.wizard-dots { display: flex; gap: 6px; }
.wizard-dots .dot { width: 26px; height: 5px; border-radius: 999px; background: var(--borde); transition: background .2s; }
.wizard-dots .dot.activa { background: linear-gradient(90deg, var(--acento), var(--acento-2)); }
.wizard-paso h3 { margin: 0 0 4px; font-size: 20px; }
.wizard-paso label { display: block; margin-top: 12px; font-size: 13px; color: var(--muted); }
.wizard-paso input, .wizard-paso textarea {
  width: 100%; margin-top: 5px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--borde); background: var(--panel-2); color: var(--texto);
  font-size: 14px; font-family: inherit;
}
.wizard-checklist { list-style: none; padding: 0; margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.wizard-checklist li { padding: 6px 0; }
.wizard-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; }
.wizard-nav { display: flex; gap: 10px; margin-left: auto; }
.btn.secundario { background: var(--panel-2); color: var(--texto); border: 1px solid var(--borde); }

@media (max-width: 640px) {
  .fila, .chats-layout { grid-template-columns: 1fr; }
  .nav { display: none; }
}
