:root {
  --navy-950: #0a0e1a;
  --navy-900: #0d1220;
  --navy-850: #111729;
  --navy-800: #151d33;
  --navy-700: #1c2640;
  --navy-600: #263352;
  --border: #223055;
  --text-main: #e6ebf5;
  --text-dim: #8b9bc0;
  --text-faint: #5c6b8f;
  --accent: #3ea6ff;
  --accent-glow: #3ea6ff55;
  --green: #35d68a;
  --yellow: #f5c04b;
  --red: #ff6b6b;
  --score-low: #ff6b6b;
  --score-mid: #f5c04b;
  --score-high: #35d68a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--navy-950);
  color: var(--text-main);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 32px 32px;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(13,18,32,0.85);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(6px);
}

.topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.topbar-company-name {
  font-family: "Playfair Display", "Georgia", serif;
  font-style: italic;
  font-weight: 600;
  font-size: 26px;
  letter-spacing: 0.01em;
  background: linear-gradient(90deg, #ffffff 0%, var(--accent) 55%, #b98cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-shadow: 0 0 30px rgba(62,166,255,0.25);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-nav { display: flex; gap: 6px; }
.topbar-nav a {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.topbar-nav a.active, .topbar-nav a:hover {
  color: var(--text-main);
  background: var(--navy-700);
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--green);
  text-transform: uppercase;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 var(--green);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(53,214,138,0.6); }
  70% { box-shadow: 0 0 0 8px rgba(53,214,138,0); }
  100% { box-shadow: 0 0 0 0 rgba(53,214,138,0); }
}

.agent-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 6px;
  border-radius: 999px;
  background: var(--navy-700);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.agent-btn:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.agent-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  border: 2px solid var(--accent);
  flex-shrink: 0;
  background: var(--navy-800);
}

.agent-btn-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}
.agent-btn-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
}
.agent-btn-role {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 6px;
}
.agent-btn-247 {
  background: rgba(53,214,138,0.15);
  color: var(--green);
  border: 1px solid rgba(53,214,138,0.4);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--navy-800);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04101f; }
.btn.primary:hover { opacity: 0.9; color: #04101f; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: rgba(255,107,107,0.1); }

/* ---------- Pipeline ---------- */
.pipeline-header {
  padding: 20px 24px 4px;
}

/* Fila de subtítulo superior: "EN PROCESO" como pequeño texto encima de la
   columna CUALIFICANDO únicamente, en el mismo grid de 4 columnas que el
   board de abajo. No agrupa columnas, no cambia el orden ni el estilo general. */
.subtitle-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 2px;
}
.column-subtitle {
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Mismo grid de 4 columnas que .board, para que cada KPI quede exactamente
   encima de su columna correspondiente (Conversaciones/Entrando,
   Cualificadas/Cualificando+Cualificado, Citas/Cita Agendada). */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 16px;
}
.kpi-slot { display: flex; justify-content: center; }
.kpi { text-align: center; }
.kpi-value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.kpi-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 16px;
  padding: 16px 24px 32px;
  align-items: start;
}

.column {
  background: var(--navy-900);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 200px;
  padding: 10px;
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.column-badge {
  background: var(--navy-700);
  color: var(--text-main);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
}

.cards { display: flex; flex-direction: column; gap: 10px; min-height: 40px; }

.card {
  background: var(--navy-800);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card.card-enter {
  animation: cardIn 0.5s ease;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-title-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.card-code { color: var(--text-faint); font-size: 12px; font-weight: 700; }
.card-name { font-weight: 700; font-size: 14px; }
.card-tag {
  font-size: 10px; font-weight: 800; letter-spacing: 0.04em;
  background: rgba(245,192,75,0.15); color: var(--yellow);
  border-radius: 5px; padding: 1px 6px;
}

.score-pill {
  font-size: 12px; font-weight: 800; border-radius: 999px; padding: 2px 9px;
  flex-shrink: 0;
}
.score-low { background: rgba(255,107,107,0.15); color: var(--score-low); }
.score-mid { background: rgba(245,192,75,0.15); color: var(--score-mid); }
.score-high { background: rgba(53,214,138,0.15); color: var(--score-high); }

.card-line {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 6px;
}
.card-line strong { color: var(--text-main); }

.empty-column {
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  padding: 24px 8px;
}

/* ---------- Modal ficha ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,8,16,0.7);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--navy-850);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 420px;
  max-width: 92vw;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; color: var(--text-dim);
  font-size: 20px; cursor: pointer;
}
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; position: relative; }
.modal-name { font-size: 22px; font-weight: 800; }
.modal-subtitle { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

.modal-badge-appt {
  margin-top: 14px;
  background: rgba(53,214,138,0.12);
  border: 1px solid rgba(53,214,138,0.3);
  color: var(--green);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.fields { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.field-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--navy-700); }
.field-label { color: var(--text-faint); font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; font-size: 11px; }
.field-value { color: var(--text-main); font-weight: 600; text-align: right; }

.modal-actions { display: flex; gap: 8px; margin-top: 18px; }

/* ---------- Chat WhatsApp ---------- */
.wa-shell { display: flex; height: calc(100vh - 60px); }
.wa-list {
  width: 300px; border-right: 1px solid var(--border);
  overflow-y: auto; background: var(--navy-900);
}
.wa-list-item {
  padding: 12px 16px; border-bottom: 1px solid var(--navy-800);
  cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.wa-list-item:hover, .wa-list-item.active { background: var(--navy-800); }
.wa-list-name { font-weight: 700; font-size: 13.5px; }
.wa-list-preview { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wa-chat { flex: 1; display: flex; flex-direction: column; background: #0b141a; }
.wa-chat-header {
  background: var(--navy-850); padding: 12px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.wa-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: #04101f;
}
.wa-chat-title { font-weight: 700; font-size: 14.5px; }
.wa-chat-status { font-size: 12px; color: var(--green); }

.wa-messages {
  flex: 1; overflow-y: auto; padding: 20px;
  background-image: radial-gradient(circle at 20px 20px, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 24px 24px;
  display: flex; flex-direction: column; gap: 6px;
}
.bubble {
  max-width: 62%;
  padding: 8px 10px 6px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.4;
  position: relative;
}
.bubble.in { align-self: flex-start; background: #1f2c34; color: #e9edef; border-top-left-radius: 2px; }
.bubble.out { align-self: flex-end; background: #005c4b; color: #e9edef; border-top-right-radius: 2px; }
.bubble-meta { font-size: 10.5px; color: rgba(255,255,255,0.55); text-align: right; margin-top: 3px; display: flex; justify-content: flex-end; gap: 4px; align-items: center; }
.check { color: #53bdeb; }

.wa-composer {
  display: flex; gap: 10px; padding: 12px 16px; background: var(--navy-850); border-top: 1px solid var(--border);
}
.wa-composer input {
  flex: 1; border-radius: 20px; border: 1px solid var(--border);
  background: var(--navy-800); color: var(--text-main); padding: 10px 16px; font-size: 13.5px;
}
.wa-composer input:focus { outline: none; border-color: var(--accent); }

/* ---------- Calendario ---------- */
.cal-header { padding: 20px 24px 8px; display: flex; align-items: center; justify-content: space-between; }
.cal-title { font-size: 24px; font-weight: 800; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px;
  padding: 16px 24px 32px;
}
.cal-dow { text-align: center; font-size: 11px; font-weight: 800; color: var(--text-faint); text-transform: uppercase; padding-bottom: 6px; }
.cal-day {
  background: var(--navy-900); border: 1px solid var(--border); border-radius: 10px;
  min-height: 92px; padding: 8px; position: relative;
}
.cal-day.empty { background: transparent; border: none; }
.cal-day-num { font-size: 12px; font-weight: 700; color: var(--text-dim); }
.cal-day.today .cal-day-num { color: var(--accent); }
.cal-day.today { border-color: var(--accent); }
.cal-appt {
  margin-top: 6px; font-size: 11px; background: rgba(62,166,255,0.15); color: var(--accent);
  border-radius: 6px; padding: 3px 6px; font-weight: 700;
}

/* ---------- Agentes (gestor) ---------- */
.agents-shell { padding: 24px; display: flex; gap: 24px; align-items: flex-start; }
.agents-list { width: 300px; display: flex; flex-direction: column; gap: 10px; }
.agent-card {
  background: var(--navy-800); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; cursor: pointer;
}
.agent-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow); }
.agent-card-name { font-weight: 800; }
.agent-card-empresa { font-size: 12px; color: var(--text-dim); }
.agent-card-active-badge { font-size: 10px; color: var(--green); font-weight: 800; text-transform: uppercase; margin-top: 4px; }

.editor {
  flex: 1; background: var(--navy-900); border: 1px solid var(--border); border-radius: 14px; padding: 24px;
}
.editor h2 { margin-top: 0; }
.form-row { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 12px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.form-row input, .form-row textarea {
  background: var(--navy-800); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; color: var(--text-main); font-size: 13.5px; font-family: inherit;
}
.form-row textarea { min-height: 200px; resize: vertical; line-height: 1.5; }
.form-row input:focus, .form-row textarea:focus { outline: none; border-color: var(--accent); }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }

.custom-fields-list { display: flex; flex-direction: column; gap: 8px; }
.custom-field-row { display: flex; gap: 8px; }
.custom-field-row input { flex: 1; }

.ficha-hint { font-size: 11px; color: var(--text-faint); text-transform: none; letter-spacing: 0; font-weight: 500; margin-top: -2px; }
.ficha-fields-list { display: flex; flex-direction: column; gap: 6px; }
.ficha-field-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--navy-800); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 8px;
}
.ficha-field-row.hidden-field { opacity: 0.5; }
.ficha-field-order { display: flex; flex-direction: column; gap: 2px; }
.icon-btn { padding: 2px 8px; font-size: 11px; line-height: 1; }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.ficha-field-row input[type="text"], .ficha-field-row input:not([type]) { flex: 1; background: var(--navy-900); }
.ficha-field-tag {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-faint); border: 1px solid var(--border); border-radius: 5px; padding: 3px 7px;
  flex-shrink: 0;
}
.ficha-field-visible {
  display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-dim);
  white-space: nowrap; flex-shrink: 0;
}

/* ---------- QR ---------- */
.qr-wrap {
  max-width: 480px; margin: 48px auto; padding: 32px;
  background: var(--navy-900); border: 1px solid var(--border); border-radius: 16px;
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.qr-title { margin: 0; font-size: 22px; }
/* Texto de presentación de María sobre el QR: párrafo largo, se lee mejor a
   menor tamaño y con más interlineado que un titular. */
.qr-pitch {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.6;
  text-align: center;
  color: var(--text-main);
}
.qr-subtitle { margin: 0; color: var(--text-dim); font-size: 13.5px; }
.qr-image { width: 320px; height: 320px; border-radius: 12px; background: #fff; padding: 12px; }
.qr-number { font-size: 14px; font-weight: 700; color: var(--accent); }
.qr-link { margin-top: 4px; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--navy-700);
  border: 1px solid var(--accent); color: var(--text-main); padding: 12px 18px;
  border-radius: 10px; font-size: 13px; font-weight: 600; z-index: 200;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.maria-status { display: inline-flex; align-items: center; gap: 8px; }
.maria-dot { width: 9px; height: 9px; border-radius: 50%; background: #e5484d; box-shadow: 0 0 0 3px rgba(229,72,77,.18); }
.maria-status.on .maria-dot { background: #30a46c; box-shadow: 0 0 0 3px rgba(48,164,108,.2); }
.maria-status.busy { opacity: .6; pointer-events: none; }

/* ---------- Panel web (VPS): estado, Preparar demo, Probar María, login ---------- */
.estado-bar { display: flex; gap: 6px; align-items: center; }
.estado-pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.estado-pill.bien { color: var(--green); border-color: #35d68a66; }
.estado-pill.mal { color: #ff6b6b; border-color: #ff6b6b66; }
.estado-pill.neutro { color: var(--text-dim); }
.btn.big { padding: 12px 20px; font-size: 15px; }
.prep-modal { width: 480px; display: flex; flex-direction: column; gap: 10px; max-height: 90vh; overflow: auto; }
.prep-modal h2 { margin: 0; }
.prep-modal .input, .login-card input { background: var(--navy-900); color: var(--text-main); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 15px; width: 100%; box-sizing: border-box; }
.prep-acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.prep-paso { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.prep-paso.ko { color: #ff8b8b; }
.prep-listo { font-size: 22px; font-weight: 800; color: var(--green); text-align: center; padding: 12px; }
.prep-falla { font-size: 16px; font-weight: 700; color: #ff8b8b; text-align: center; padding: 10px; }
.muted { color: var(--text-dim); font-size: 13px; }
.probar { display: grid; grid-template-columns: 280px 1fr; gap: 16px; padding: 16px; height: calc(100vh - 90px); box-sizing: border-box; }
.probar-lista { display: flex; flex-direction: column; gap: 8px; overflow: auto; }
.probar-item { padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--navy-850); }
.probar-item.active { border-color: var(--accent); }
.probar-item.viejo { opacity: .55; }
.probar-item-nombre { font-weight: 700; }
.probar-chat { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 16px; background: var(--navy-900); min-height: 0; }
.probar-cab { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); gap: 8px; }
.probar-msgs { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.probar-burbuja { max-width: 75%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; line-height: 1.4; font-size: 15px; }
.probar-burbuja.in { align-self: flex-end; background: #1f5f46; }
.probar-burbuja.out { align-self: flex-start; background: var(--navy-700); }
.probar-burbuja.escribiendo { opacity: .6; font-style: italic; }
.probar-burbuja.aviso { align-self: center; background: #5a2a2a; color: #ffd0d0; font-size: 13px; }
.probar-escribir { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.probar-input { flex: 1; resize: none; background: var(--navy-850); color: var(--text-main); border: 1px solid var(--border); border-radius: 12px; padding: 10px; font-size: 16px; font-family: inherit; }
.probar-vacio { margin: auto; max-width: 420px; text-align: center; padding: 24px; }
.acciones { padding: 16px; overflow: auto; }
.acciones-tabla { border-collapse: collapse; width: 100%; font-size: 13px; }
.acciones-tabla td, .acciones-tabla th { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 360px; max-width: 100%; background: var(--navy-850); border: 1px solid var(--border); border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.login-card img { width: 72px; height: 72px; border-radius: 50%; align-self: center; }
.login-error { color: #ff8b8b; font-size: 14px; min-height: 18px; }
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; gap: 8px; height: auto; padding: 8px; }
  .topbar-center, .live-indicator { display: none; }
  .topbar-nav { overflow-x: auto; white-space: nowrap; }
  .topbar-right { flex-wrap: wrap; gap: 6px; }
  .probar { grid-template-columns: 1fr; height: auto; }
  .probar-lista { flex-direction: row; overflow-x: auto; }
  .probar-item { min-width: 160px; }
  .probar-chat { height: 70vh; }
  .probar-burbuja { max-width: 88%; }
}
