/* ═══════════════════════════════════════════════════════════════
   GOOD CALL AI — CRM PANEL
   Brand system aligned with app.goodcallai.net
═══════════════════════════════════════════════════════════════ */
:root {
  --bg-page: #f0f4ff;
  --bg-card: #ffffff;
  --bg-soft: #f8fafc;
  --bg-muted: #f1f5f9;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;

  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-deep: #1d4ed8;
  --primary-glow: rgba(59, 130, 246, 0.28);
  --primary-light: rgba(59, 130, 246, 0.1);
  --indigo: #6366f1;
  --sky: #38bdf8;

  --green: #10b981;
  --green-light: rgba(16, 185, 129, 0.12);
  --red: #ef4444;
  --red-light: rgba(239, 68, 68, 0.1);
  --amber: #f59e0b;
  --amber-light: rgba(245, 158, 11, 0.12);
  --purple: #8b5cf6;
  --purple-light: rgba(139, 92, 246, 0.12);

  --text-100: #0f172a;
  --text-200: #1e293b;
  --text-400: #64748b;
  --text-600: #94a3b8;

  --status-activo: #10b981;
  --status-inactivo: #f59e0b;
  --status-bloqueado: #ef4444;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.1);
  --transition: 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text-200);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; cursor: pointer; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; outline: none; }
li { list-style: none; }
.hidden { display: none !important; }
.font-mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

::selection { background: rgba(59, 130, 246, 0.2); color: var(--text-100); }

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  50% { opacity: 0.85; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.animate-in { animation: fadeInUp 0.45s ease both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Brand ─────────────────────────────────────────────────── */
.brand-logo {
  width: 42px; height: 42px;
  object-fit: contain;
  border-radius: 10px;
  flex-shrink: 0;
}
.brand-logo.sm { width: 34px; height: 34px; border-radius: 8px; }
.brand-text {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-100);
  letter-spacing: -0.02em;
}
.brand-text strong {
  background: linear-gradient(135deg, var(--sky), var(--primary-dark));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

/* ─── LOGIN ─────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(59, 130, 246, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(245, 158, 11, 0.08) 0%, transparent 50%),
    #f0f4ff;
  padding: 1.5rem;
}

.login-bg { position: absolute; inset: 0; pointer-events: none; }
.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}
.orb1 {
  width: 480px; height: 480px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.28), transparent 70%);
  top: -120px; right: -80px;
}
.orb2 {
  width: 360px; height: 360px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.2), transparent 70%);
  bottom: -80px; left: -60px;
}
.orb3 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.16), transparent 70%);
  top: 40%; left: 35%;
}

.login-card {
  position: relative;
  z-index: 2;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-xl);
  padding: 2.75rem 2.5rem;
  width: min(420px, 100%);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.login-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-100);
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}
.login-sub { color: var(--text-400); margin-bottom: 1.75rem; }

.login-form { display: flex; flex-direction: column; gap: 1.1rem; }

.form-field { display: flex; flex-direction: column; gap: 0.45rem; }
.form-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-400);
  letter-spacing: 0.02em;
}
.form-field.full { grid-column: 1 / -1; }

.input-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.input-wrap > i.fa-solid:first-child,
.input-wrap > i.fa-regular:first-child,
.input-wrap > i:first-of-type {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-600);
  font-size: 0.85rem;
  width: 1em;
  text-align: center;
  pointer-events: none;
  z-index: 1;
  line-height: 1;
}
.input-wrap input {
  display: block;
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  /* Sin icono a la izquierda: el texto empieza donde empieza el campo.
     Solo el de contrasena (.con-ojo) reserva sitio a la derecha para el ojo. */
  padding: 0.85rem 1rem;
  color: var(--text-100);
  transition: var(--transition);
  position: relative;
  z-index: 0;
}
.input-wrap.con-ojo input { padding-right: 2.75rem; }
.input-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.input-wrap input::placeholder { color: var(--text-600); }
.eye-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-600);
  padding: 0.35rem;
  z-index: 2;
  background: transparent;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.eye-btn:hover { color: var(--text-200); }
.eye-btn i { pointer-events: none; }

.login-error {
  background: var(--red-light);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--red);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.btn-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  font-weight: 600;
  font-size: 0.98rem;
  padding: 0.9rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  box-shadow: 0 6px 18px var(--primary-glow);
  margin-top: 0.25rem;
}
.btn-login:hover {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.4);
}
.btn-login:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }

.login-hint {
  text-align: center;
  color: var(--text-600);
  font-size: 0.8rem;
  margin-top: 1.35rem;
}

/* ─── APP SHELL ─────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(59, 130, 246, 0.06) 0%, transparent 45%),
    radial-gradient(ellipse at 100% 100%, rgba(245, 158, 11, 0.04) 0%, transparent 45%),
    var(--bg-page);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 150;
  backdrop-filter: blur(2px);
}

.sidebar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  z-index: 160;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.sidebar-toggle {
  display: none;
  width: 34px; height: 34px;
  border-radius: 8px;
  color: var(--text-400);
  align-items: center;
  justify-content: center;
}
.sidebar-toggle:hover { background: var(--bg-muted); color: var(--text-100); }

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.nav-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-600);
  padding: 0.85rem 0.85rem 0.4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.72rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text-400);
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}
.nav-item i { width: 18px; text-align: center; font-size: 0.95rem; }
.nav-item:hover {
  color: var(--primary-dark);
  background: var(--primary-light);
}
.nav-item.active {
  color: var(--primary-dark);
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.14), rgba(99, 102, 241, 0.06));
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary);
}

.sidebar-footer {
  padding: 0.85rem;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
}
.user-avatar.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 0.7rem; }
.user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-100);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: 0.72rem; color: var(--text-600); }
.logout-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  color: var(--text-600);
  display: flex;
  align-items: center;
  justify-content: center;
}
.logout-btn:hover { color: var(--red); background: var(--red-light); }

/* ─── MAIN + TOPBAR ─────────────────────────────────────────── */
.main-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 16px rgba(15, 23, 42, 0.04);
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.mobile-menu-btn {
  display: none;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-200);
  align-items: center;
  justify-content: center;
}
.breadcrumb {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-100);
  letter-spacing: -0.02em;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.55rem 0.3rem 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-200);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--green);
  background: var(--green-light);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s ease infinite;
}

.views-wrap { flex: 1; }
.view {
  display: none;
  padding: 1.5rem 1.75rem 2rem;
  animation: fadeIn 0.25s ease;
}
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
}
.view-header h2 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-100);
  letter-spacing: -0.03em;
}
.view-header p { color: var(--text-400); margin-top: 0.2rem; font-size: 0.9rem; }

/* ─── BUTTONS ───────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}
.btn-secondary {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-200);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--bg-soft); }
.btn-ghost { color: var(--text-400); padding: 0.65rem 0.85rem; }
.btn-ghost:hover { color: var(--text-100); background: var(--bg-muted); }
.btn-danger {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--red);
}
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* ─── KPI ───────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.25);
}
.kpi-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.kpi-blue .kpi-icon { background: var(--primary-light); color: var(--primary); }
.kpi-green .kpi-icon { background: var(--green-light); color: var(--green); }
.kpi-purple .kpi-icon { background: var(--purple-light); color: var(--purple); }
.kpi-orange .kpi-icon { background: var(--amber-light); color: var(--amber); }
.kpi-data { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.kpi-val {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-100);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.kpi-lbl { font-size: 0.8rem; color: var(--text-400); font-weight: 500; }

/* skeleton */
.skeleton {
  background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 50%, #eef2f7 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
  border-radius: 6px;
  color: transparent !important;
}

/* ─── CHARTS / CARDS ────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.chart-card, .table-card, .side-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.chart-card.wide { min-width: 0; }
.chart-header, .table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.75rem;
}
.chart-header h3, .table-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-100);
}
.chart-badge {
  font-size: 0.72rem;
  color: var(--primary-dark);
  background: var(--primary-light);
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-weight: 600;
}
.chart-wrap { position: relative; height: 230px; }

.bottom-row {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 1rem;
}
.view-all-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.view-all-link:hover { text-decoration: underline; }

/* ─── TABLES ────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.data-table thead th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-600);
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table td {
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: var(--text-200);
}
.data-table tbody tr { transition: background 0.12s ease; }
.data-table tbody tr:hover td { background: #f8fafc; }

.customer-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.mini-avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}

.action-btns { display: flex; gap: 0.35rem; }
.action-btns button {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.edit-btn { color: var(--primary); background: var(--primary-light); }
.edit-btn:hover { background: rgba(59, 130, 246, 0.2); }
.del-btn { color: var(--red); background: var(--red-light); }
.del-btn:hover { background: rgba(239, 68, 68, 0.18); }

/* ─── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-ganado, .badge-activo {
  background: var(--green-light);
  color: #047857;
}
.badge-calificado, .badge-inactivo {
  background: var(--amber-light);
  color: #b45309;
}
.badge-perdido, .badge-bloqueado {
  background: var(--red-light);
  color: #b91c1c;
}
.badge-admin { background: var(--primary-light); color: var(--primary-dark); }
.badge-supervisor { background: var(--purple-light); color: #6d28d9; }
.badge-agent { background: var(--bg-muted); color: var(--text-400); }

.badge-ganado::before, .badge-activo::before,
.badge-calificado::before, .badge-inactivo::before,
.badge-perdido::before, .badge-bloqueado::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ─── FILTERS / PAGINATION ──────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}
.search-wrap > i {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-600);
}
.search-wrap input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem 0.7rem 2.4rem;
  transition: var(--transition);
}
.search-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.filters-bar select {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  color: var(--text-200);
  min-width: 160px;
}
.filters-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.pagination {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
  padding-top: 1rem;
  flex-wrap: wrap;
}
.pagination button {
  min-width: 34px;
  height: 34px;
  padding: 0 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-400);
  font-weight: 600;
  font-size: 0.82rem;
}
.pagination button:hover:not(:disabled) {
  border-color: var(--border-hover);
  background: var(--bg-soft);
}
.pagination button.active {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-color: transparent;
  color: #fff;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── KANBAN ────────────────────────────────────────────────── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 0.85rem;
  width: 100%;
  align-items: stretch;
  padding-bottom: 0.25rem;
}
/* 3 cols (estado bots) and 4 cols (quejas) fill full width */
#kanban-board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#ticket-kanban,
.ticket-kanban { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.kanban-col {
  min-width: 0;
  width: 100%;
  max-width: none;
  flex: unset;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  padding: 0 0.15rem;
}
.kanban-col-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  color: var(--text-100);
  font-size: 0.9rem;
}
.kanban-dot { width: 9px; height: 9px; border-radius: 50%; }
.kanban-count {
  background: var(--bg-muted);
  color: var(--text-400);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.kanban-col-cards {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
  min-height: 120px;
}
.kanban-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}
.kanban-card:hover {
  border-color: rgba(59, 130, 246, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}
.kanban-card-customer {
  font-weight: 700;
  color: var(--text-100);
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}
.kanban-card-product {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 0.55rem;
}
.kanban-card-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-600);
}
.kanban-card-amount {
  font-family: ui-monospace, monospace;
  color: var(--text-400);
  font-weight: 600;
}
.kanban-empty {
  text-align: center;
  color: var(--text-600);
  padding: 1.5rem 0.5rem;
  font-size: 0.85rem;
}

/* ─── PLAN / USER CARDS ─────────────────────────────────────── */
.customers-grid, .users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.customer-card, .user-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.customer-card:hover, .user-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.25);
}
.customer-card-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.cust-avatar {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.customer-card h4, .user-card h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-100);
}
.customer-card-detail {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-400);
}
.customer-card-detail span {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.user-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}
.user-card-avatar {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}
.user-card-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.65rem;
  width: 100%;
  justify-content: center;
}
.user-inactive { opacity: 0.55; }

/* ─── TOP PLANS LIST ────────────────────────────────────────── */
.agent-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.25rem;
  border-bottom: 1px solid #f1f5f9;
}
.agent-item:last-child { border-bottom: none; }
.agent-rank {
  font-weight: 800;
  color: var(--text-600);
  font-size: 0.8rem;
  width: 28px;
}
.agent-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.agent-info strong {
  font-size: 0.88rem;
  color: var(--text-100);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-info span { font-size: 0.75rem; color: var(--text-600); }
.agent-revenue {
  font-weight: 700;
  color: var(--green);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ─── MODALS ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1rem;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.15s ease; }
.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  width: min(520px, 100%);
  max-height: min(90vh, 860px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-hover);
  animation: slideIn 0.22s ease;
}
.modal-box.wide { width: min(720px, 100%); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 {
  font-size: 1.05rem;
  font-weight: 750;
  color: var(--text-100);
}
.modal-close {
  width: 34px; height: 34px;
  border-radius: 8px;
  color: var(--text-600);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--red-light); color: var(--red); }
.modal-body {
  padding: 1.25rem 1.35rem;
  overflow-y: auto;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.35rem;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1rem;
}
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  color: var(--text-100);
  transition: var(--transition);
}
.form-field textarea { resize: vertical; min-height: 80px; }
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ─── TOAST / EMPTY ─────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 400;
  background: #0f172a;
  color: #fff;
  padding: 0.85rem 1.15rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.88rem;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.25);
  animation: slideIn 0.25s ease;
  max-width: min(360px, calc(100vw - 2rem));
}
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-600);
}
.empty-state i {
  font-size: 1.6rem;
  margin-bottom: 0.6rem;
  color: var(--text-600);
  display: block;
}
.empty-state p { font-size: 0.9rem; }

/* ─── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row, .bottom-row { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 270px;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: 8px 0 30px rgba(15, 23, 42, 0.12);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open ~ .sidebar-backdrop,
  .sidebar-backdrop.open { display: block; }
  .sidebar-toggle { display: flex; }
  .mobile-menu-btn { display: flex; }
  .view { padding: 1.15rem; }
  .view-header { flex-direction: column; align-items: stretch; }
  .view-header .btn-primary { width: 100%; }
  .live-pill { display: none; }
}

@media (max-width: 1100px) {
  #kanban-board { grid-template-columns: repeat(3, minmax(220px, 1fr)); overflow-x: auto; }
  #ticket-kanban,
  .ticket-kanban { grid-template-columns: repeat(4, minmax(220px, 1fr)); overflow-x: auto; }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filters-bar select { width: 100%; }
  #kanban-board,
  #ticket-kanban,
  .ticket-kanban,
  .kanban-board {
    grid-template-columns: 1fr;
    overflow-x: visible;
  }
  .kanban-col { min-width: 0; max-width: none; width: 100%; }
  .login-card { padding: 2rem 1.35rem; }
  .data-table { min-width: 640px; }
}

/* ─── TICKETS / QUEJAS ───────────────────────────────────────── */
.nav-badge {
  margin-left: auto;
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.nav-item .nav-badge { flex-shrink: 0; }

.ticket-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.ticket-stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  box-shadow: var(--shadow);
}
.ticket-stat .ts-val {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-100);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.ticket-stat .ts-lbl { font-size: 0.75rem; color: var(--text-400); font-weight: 500; }
.ticket-stat.ts-inbox .ts-val { color: var(--primary); }
.ticket-stat.ts-warn .ts-val { color: var(--amber); }
.ticket-stat.ts-info .ts-val { color: var(--purple); }
.ticket-stat.ts-ok .ts-val { color: var(--green); }

.ticket-kanban { align-items: stretch; width: 100%; }
.ticket-col { min-width: 0; max-width: none; width: 100%; }
.col-hint {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-600);
  margin-top: 0.1rem;
}

.ticket-card { position: relative; cursor: grab; }
.ticket-card:active { cursor: grabbing; }
.ticket-card.dragging { opacity: 0.45; transform: scale(0.98); }
.ticket-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}
.ticket-code-sm {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.02em;
}
.ticket-preview {
  font-size: 0.78rem;
  color: var(--text-400);
  line-height: 1.4;
  margin: 0.35rem 0 0.55rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ticket-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.72rem;
  color: var(--text-600);
  margin-bottom: 0.45rem;
}
.ticket-meta span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticket-meta i { width: 12px; text-align: center; opacity: 0.8; }

.ticket-move-btns {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}
.ticket-move {
  flex: 1;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-400);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: var(--transition);
}
.ticket-move:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.prio-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.prio-critica { background: #fee2e2; color: #b91c1c; }
.prio-alta { background: #ffedd5; color: #c2410c; }
.prio-media { background: #e0e7ff; color: #3730a3; }
.prio-baja { background: #f1f5f9; color: #64748b; }

.ticket-code-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.ticket-code {
  font-weight: 800;
  font-size: 1rem;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  letter-spacing: 0.03em;
}

.badge-estado-recibidor { background: var(--primary-light); color: var(--primary-dark); }
.badge-estado-en_revision { background: var(--amber-light); color: #b45309; }
.badge-estado-en_proceso { background: var(--purple-light); color: #6d28d9; }
.badge-estado-resuelto { background: var(--green-light); color: #047857; }

.ticket-activity-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.activity-header h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-100);
  margin-bottom: 0.65rem;
}
.activity-log {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}
.activity-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}
.activity-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-600);
  margin-bottom: 0.2rem;
}
.activity-meta strong { color: var(--text-200); }
.activity-note { font-size: 0.85rem; color: var(--text-200); }
.add-note-wrap {
  display: flex;
  gap: 0.5rem;
}
.add-note-wrap input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}
.add-note-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

@media (max-width: 900px) {
  .ticket-stats { grid-template-columns: repeat(2, 1fr); }
  .ticket-col { min-width: 0; max-width: none; }
}
@media (max-width: 600px) {
  .ticket-stats { grid-template-columns: 1fr 1fr; }
}

/* Full-width content areas — kill dead right space */
.view,
.views-wrap,
.table-card,
.filters-bar,
.ticket-stats {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.table-card .table-scroll { width: 100%; }

/* Vendedor — discreet */
.vendedor-tag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-400);
  background: var(--bg-muted);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-subtle {
  opacity: 0.92;
  min-width: 150px;
  font-size: 0.85rem;
  color: var(--text-400);
}
.badge-vendedor { background: #ecfdf5; color: #047857; }

/* Inversión ads */
.inv-layout {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 280px);
  gap: 1rem;
  width: 100%;
  align-items: start;
}
.inv-main { min-width: 0; display: flex; flex-direction: column; gap: 0.85rem; }
.inv-breakdown { position: sticky; top: calc(var(--topbar-h) + 1rem); }
.inv-cat-row { padding: 0.65rem 0; border-bottom: 1px solid #f1f5f9; }
.inv-cat-row:last-child { border-bottom: none; }
.inv-cat-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}
.inv-cat-head strong { color: var(--text-100); font-weight: 650; }
.inv-cat-head span { font-weight: 700; color: var(--text-200); font-variant-numeric: tabular-nums; }
.inv-bar {
  height: 6px;
  background: var(--bg-muted);
  border-radius: 99px;
  overflow: hidden;
}
.inv-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  border-radius: 99px;
}
.inv-cat-meta { font-size: 0.72rem; color: var(--text-600); margin-top: 0.25rem; }
input[type="month"], input[type="date"] {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  color: var(--text-200);
}
@media (max-width: 1000px) {
  .inv-layout { grid-template-columns: 1fr; }
  .inv-breakdown { position: static; }
}

/* Comparativa gasto vs ingresos */
.card-block {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  width: 100%;
}
.inv-compare-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.inv-compare-head h3 {
  font-size: 1rem;
  font-weight: 750;
  color: var(--text-100);
  letter-spacing: -0.02em;
}
.inv-compare-sub {
  font-size: 0.8rem;
  color: var(--text-600);
  margin-top: 0.2rem;
  max-width: 520px;
  line-height: 1.4;
}
.inv-compare-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}
.inv-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--text-400);
}
.inv-pill-gasto {
  background: var(--primary-light);
  color: var(--primary-dark);
}
.inv-bars { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.inv-bar-row { display: flex; flex-direction: column; gap: 0.3rem; }
.inv-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-400);
}
.inv-bar-label strong {
  color: var(--text-100);
  font-variant-numeric: tabular-nums;
}
.inv-bar-track {
  height: 12px;
  background: #f1f5f9;
  border-radius: 99px;
  overflow: hidden;
}
.inv-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.35s ease;
  min-width: 0;
}
.inv-fill-gasto { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.inv-fill-ing { background: linear-gradient(90deg, #10b981, #059669); }
.inv-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}
.inv-mini {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.inv-mini .im-lbl { font-size: 0.72rem; color: var(--text-600); }
.inv-mini strong {
  font-size: 0.95rem;
  color: var(--text-100);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 800px) {
  .inv-mini-grid { grid-template-columns: 1fr 1fr; }
}

/* Global search */
.global-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.global-search-wrap > i {
  position: absolute;
  left: 0.7rem;
  color: var(--text-600);
  font-size: 0.8rem;
  pointer-events: none;
}
.global-search-wrap input {
  width: min(240px, 28vw);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 0.75rem 0.45rem 2rem;
  background: #fff;
  font-size: 0.82rem;
  transition: var(--transition);
}
.global-search-wrap input:focus {
  width: min(320px, 40vw);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.global-search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(360px, 90vw);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 360px;
  overflow-y: auto;
  padding: 0.35rem;
}
.gs-item {
  width: 100%;
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  color: var(--text-200);
  background: transparent;
}
.gs-item:hover { background: var(--bg-soft); }
.gs-item i { color: var(--primary); margin-top: 0.15rem; }
.gs-item strong { display: block; font-size: 0.85rem; }
.gs-item span { font-size: 0.75rem; color: var(--text-600); }
.gs-empty { padding: 1rem; text-align: center; color: var(--text-600); font-size: 0.85rem; }

.topbar-btn {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-400);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.topbar-btn:hover { color: var(--primary); border-color: var(--border-hover); }
.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  min-width: 8px;
  padding: 0;
  border-radius: 50%;
  background: #ef4444;
  border: 1.5px solid #fff;
  color: transparent;
  font-size: 0;
  line-height: 0;
  pointer-events: none;
}

.alerts-panel {
  position: absolute;
  right: 1.5rem;
  top: calc(var(--topbar-h) + 4px);
  width: min(360px, calc(100vw - 2rem));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 180;
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.5rem;
}
.main-content { position: relative; }
.alerts-panel-head, .alerts-empty {
  padding: 0.5rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-400);
}
.alert-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-align: left;
  padding: 0.6rem 0.65rem;
  border-radius: 8px;
  border-left: 3px solid var(--border);
  margin-bottom: 0.25rem;
  background: var(--bg-soft);
}
.alert-row strong { font-size: 0.85rem; color: var(--text-100); }
.alert-row span { font-size: 0.75rem; color: var(--text-600); }
.alert-row.sev-critical { border-left-color: #ef4444; }
.alert-row.sev-high { border-left-color: #f59e0b; }
.alert-row.sev-medium { border-left-color: #3b82f6; }
.alert-row.sev-low { border-left-color: #94a3b8; }

.dash-alerts {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.dash-alerts-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.alert-item {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.5rem 0;
  border-top: 1px solid #f1f5f9;
  cursor: pointer;
}
.alert-item:hover { background: #f8fafc; }
.alert-sev {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-600);
  min-width: 52px;
}
.alert-detail { font-size: 0.78rem; color: var(--text-600); }

.pago-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}
.pago-ok { background: #ecfdf5; color: #047857; }
.pago-mora { background: #fef2f2; color: #b91c1c; }
.pago-trial { background: #eff6ff; color: #1d4ed8; }
.pago-soft { background: #f1f5f9; color: #64748b; }
.pago-bad { background: #fff7ed; color: #c2410c; }

/* 360 */
.c360-box { width: min(900px, 100%); }
.c360-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 1.25rem;
}
.c360-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.9rem; }
.c360-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1rem;
}
.c360-meta span { display: block; font-size: 0.72rem; color: var(--text-600); }
.c360-meta strong { font-size: 0.88rem; color: var(--text-100); }
.c360-notes-box {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
}
.c360-section { margin-top: 0.85rem; }
.c360-section h4 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-100);
}
.c360-timeline {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.c360-tl-item {
  border-left: 2px solid var(--primary-light);
  padding: 0.35rem 0 0.35rem 0.75rem;
  font-size: 0.85rem;
}
.c360-tl-meta { font-size: 0.72rem; color: var(--text-600); margin-bottom: 0.15rem; }
.c360-side { display: flex; flex-direction: column; gap: 0.55rem; }
.c360-stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
}
.c360-stat span { color: var(--text-600); }
.c360-ticket {
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.4rem;
  cursor: pointer;
  font-size: 0.82rem;
}
.c360-ticket:hover { border-color: var(--primary); background: var(--primary-light); }
@media (max-width: 800px) {
  .c360-grid { grid-template-columns: 1fr; }
  .global-search-wrap input { width: 120px; }
  .global-search-wrap input:focus { width: 160px; }
}


/* Alerts: only topbar pip — no invasive panels */
.alerts-panel,
.dash-alerts { display: none !important; }

/* Sección operación solo en edición de cliente */
.sale-ops-section {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}
.sale-ops-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-600);
  margin-bottom: 0.75rem;
}

/* ─── ANALYTICS ───────────────────────────────────────────────────────────── */
.an-acciones { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.an-check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--text-600); cursor: pointer; }
.an-check input { width: 16px; height: 16px; cursor: pointer; }

.an-aviso {
  display: flex; gap: 0.75rem; align-items: flex-start;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius-sm);
  padding: 0.9rem 1rem; margin-bottom: 1.25rem; font-size: 0.85rem; line-height: 1.5; color: #1e3a5f;
}
.an-aviso i { color: #3b82f6; margin-top: 2px; }

.an-bloque { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1.25rem; margin-bottom: 1.25rem; }
.an-bloque-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.an-bloque-head h3 { margin: 0; font-size: 1rem; }
.an-bloque-acciones { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.an-bloque-acciones select { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; background: #fff; }
.an-sub { font-size: 0.78rem; color: var(--text-600); }

/* Embudo. Barra plana de un solo color: aqui lo que se compara es el LARGO,
   y un degradado solo estorba para leerlo. */
.an-embudo { display: flex; flex-direction: column; gap: 0.6rem; }
.an-fila { display: grid; grid-template-columns: minmax(140px, 200px) 1fr 56px; align-items: center; gap: 0.85rem; }
.an-lbl { font-size: 0.85rem; color: var(--text-100); }
.an-barra-wrap { position: relative; background: #f1f5f9; border-radius: 4px; height: 30px; display: flex; align-items: center; }
.an-barra { background: #4f46e5; height: 30px; border-radius: 4px; min-width: 4px; }
.an-conv { position: absolute; left: 0.7rem; font-size: 0.75rem; font-weight: 600; color: #fff; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.an-conv.mal { color: #fecaca; }
.an-num { text-align: right; font-weight: 700; font-size: 0.95rem; }
.an-fila-vacia .an-lbl { color: var(--text-600); }
.an-sindatos { font-size: 0.78rem; color: var(--text-600); padding-left: 0.7rem; font-style: italic; }

.an-chip { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px; color: #fff; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.an-mail { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.82rem; }
.an-baja { display: inline-block; margin-left: 0.4rem; padding: 0.1rem 0.4rem; border-radius: 3px; background: #fee2e2; color: #991b1b; font-size: 0.68rem; font-weight: 600; }
.an-nulo { color: var(--text-600); font-style: italic; font-size: 0.8rem; }
.an-vacio { text-align: center; padding: 2rem; color: var(--text-600); }
.an-pie { margin: 0.85rem 0 0; font-size: 0.8rem; color: var(--text-600); line-height: 1.5; }
.data-table th.num, .data-table td.num { text-align: right; }

@media (max-width: 720px) {
  .an-fila { grid-template-columns: 1fr 48px; }
  .an-lbl { grid-column: 1 / -1; margin-bottom: -0.3rem; }
}

/* ═══ CONVERSACIONES DE LOS WIDGETS ══════════════════════════════════════════
   La forma de cualquier mensajeria: la lista a la izquierda, el chat a la
   derecha. En el movil no caben los dos, asi que se ve la lista, tocas y se ve
   el chat — con flecha para volver. Es lo mismo que hace el Studio. */
.wc-wrap { display: grid; grid-template-columns: 320px 1fr; gap: 16px;
  height: calc(100dvh - 210px); min-height: 420px; }

.wc-lista { background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow-y: auto; }
.wc-vacio { padding: 24px 16px; color: var(--text-600); font-size: .85rem; text-align: center; }

.wc-hilo { display: flex; gap: 10px; align-items: center; width: 100%;
  padding: 11px 13px; border: none; background: none; cursor: pointer;
  border-bottom: 1px solid var(--border); text-align: left; transition: background var(--transition); }
.wc-hilo:hover { background: var(--bg-soft); }
.wc-hilo.activo { background: var(--primary-light); }

/* EL AVATAR DICE DE QUE WIDGET VIENE.
   Son dos burbujas distintas en el Studio y hacen cosas distintas: una guia por
   el panel, la otra entrena al bot. Cada una se pinta con SU circulo — el mismo
   que ve el cliente — para saber de un vistazo con quien esta hablando. */
.wc-avatar { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-size: .95rem; }
.wc-avatar.guia { background: #4f46e5; }
.wc-avatar.entrenamiento { background: var(--purple); }

.wc-hilo-main { flex: 1; min-width: 0; }
.wc-hilo-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.wc-hilo-nom { font-weight: 600; font-size: .84rem; color: var(--text-100);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-hilo-hora { font-size: .68rem; color: var(--text-600); flex-shrink: 0; }
.wc-hilo-prev { font-size: .75rem; color: var(--text-400); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-tomado { display: inline-block; font-size: .62rem; font-weight: 700; margin-top: 3px;
  padding: 1px 7px; border-radius: 999px; background: var(--amber-light); color: #92400e; }

.wc-chat { background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; }
.wc-sinhilo { margin: auto; text-align: center; color: var(--text-600); }
.wc-sinhilo i { font-size: 2.2rem; opacity: .5; display: block; margin-bottom: 10px; }
.wc-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.wc-cab { display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); flex-shrink: 0; }
.wc-cab-info { flex: 1; min-width: 0; }
.wc-cab-info strong { display: block; font-size: .88rem; color: var(--text-100); }
.wc-cab-info small { font-size: .7rem; color: var(--text-400); }
.wc-volver { display: none; background: none; border: none; color: var(--text-400);
  cursor: pointer; font-size: .95rem; padding: 4px 6px; }
.wc-soltar { background: var(--bg-muted); border: 1px solid var(--border); cursor: pointer;
  border-radius: 999px; padding: 5px 12px; font-size: .72rem; font-weight: 600;
  color: var(--text-200); white-space: nowrap; }
.wc-soltar:hover { background: var(--green-light); color: #047857; }

.wc-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex;
  flex-direction: column; gap: 9px; background: var(--bg-page); }

/* TRES VOCES, TRES SITIOS.
   El cliente a la izquierda; Rainy y el equipo a la derecha, porque los dos
   contestan — pero distintos, o no se sabe quien dijo que. */
.wc-msg { max-width: 74%; padding: 8px 12px; border-radius: 13px;
  font-size: .82rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.wc-msg.user  { align-self: flex-start; background: var(--bg-card);
  border: 1px solid var(--border); border-bottom-left-radius: 4px; color: var(--text-100); }
.wc-msg.rainy { align-self: flex-end; background: #4f46e5; color: #fff; border-bottom-right-radius: 4px; }
.wc-msg.humano{ align-self: flex-end; background: var(--green); color: #fff; border-bottom-right-radius: 4px; }
.wc-quien { display: block; font-size: .62rem; opacity: .75; margin-bottom: 2px; font-weight: 700;
  letter-spacing: .3px; text-transform: uppercase; }

.wc-aviso { flex-shrink: 0; padding: 8px 14px; font-size: .74rem;
  background: var(--amber-light); color: #92400e; border-top: 1px solid var(--border); }

.wc-escribir { display: flex; gap: 8px; align-items: flex-end; padding: 11px 13px;
  border-top: 1px solid var(--border); flex-shrink: 0; }
.wc-escribir textarea { flex: 1; resize: none; font: inherit; font-size: .82rem;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-soft); color: var(--text-100); max-height: 110px; }
.wc-escribir textarea:focus { outline: none; border-color: var(--primary); }
.wc-enviar { flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; cursor: pointer; }
.wc-enviar:hover { background: var(--primary-dark); }

@media (max-width: 820px) {
  .wc-wrap { grid-template-columns: 1fr; height: calc(100dvh - 190px); }
  .wc-wrap.viendo-chat .wc-lista { display: none; }
  .wc-wrap:not(.viendo-chat) .wc-chat { display: none; }
  .wc-volver { display: block; }
  .wc-msg { max-width: 86%; }
}

.an-fila-clicable{cursor:pointer}.an-fila-clicable:hover td,.an-fila-clicable:focus td{background:#f5f7ff}.an-fila-clicable:focus{outline:2px solid #6366f1;outline-offset:-2px}.an-modal-backdrop{position:fixed;inset:0;z-index:2000;background:rgba(15,23,42,.52);display:grid;place-items:center;padding:1rem}.an-modal{position:relative;width:min(100%,560px);max-height:calc(100vh - 2rem);overflow:auto;border-radius:12px;background:#fff;padding:1.5rem;box-shadow:0 24px 64px rgba(15,23,42,.28)}.an-modal-kicker{margin:0 0 .2rem;color:#6366f1;font-size:.75rem;font-weight:700;letter-spacing:.07em;text-transform:uppercase}.an-modal h3{margin:0 2rem .5rem 0;overflow-wrap:anywhere}.an-modal-resumen{margin:0 0 1.25rem;color:var(--text-600)}.an-modal-cerrar{position:absolute;right:.85rem;top:.75rem;border:0;background:transparent;color:var(--text-600);font-size:1.8rem;line-height:1;cursor:pointer}.an-timeline{display:grid;gap:0}.an-paso{display:grid;grid-template-columns:30px 1fr;gap:.75rem;min-height:59px;color:var(--text-600)}.an-paso-icono{width:24px;height:24px;display:grid;place-items:center;border-radius:50%;background:#e2e8f0;color:#64748b;font-size:.7rem;position:relative}.an-paso:not(:last-child) .an-paso-icono::after{content:'';position:absolute;top:26px;width:2px;height:33px;background:#e2e8f0}.an-paso.completo{color:var(--text-100)}.an-paso.completo .an-paso-icono{background:#10b981;color:#fff}.an-paso.completo:not(:last-child) .an-paso-icono::after{background:#a7f3d0}.an-paso strong,.an-paso small{display:block}.an-paso small{margin-top:.15rem;color:var(--text-600);font-size:.78rem}.an-modal-meta{display:flex;flex-wrap:wrap;gap:.65rem 1.25rem;margin-top:.8rem;padding-top:.9rem;border-top:1px solid var(--border);font-size:.8rem;color:var(--text-600)}


/* ═══ EL MENÚ SE PLIEGA ══════════════════════════════════════════════════════
   La flecha de plegar vive en la cabecera del menú, donde se está mirando
   cuando uno decide que estorba. La de desplegar es una pestaña pegada al borde
   izquierdo, siempre presente pero invisible: aparece al acercar el ratón. Un
   menú que se esconde sin manera visible de recuperarlo es una trampa, y un
   botón flotando encima del contenido todo el rato es ruido.

   OJO CON EL GRID, que aquí me equivoqué una vez: al ocultar el menú con
   `display:none` deja de ser una celda, y entonces el contenido principal se
   coloca solo en la PRIMERA columna. Si esa columna se hubiera dejado en 0 -que
   es lo que parece natural al pensar "el menú mide cero"- el panel entero se
   aplasta contra el borde izquierdo. Plegado hay UNA columna, no dos.

   Todo esto es de escritorio: por debajo de 900 px el menú ya es un cajón con
   su propio botón, y plegar lo que ya está oculto no significa nada. */
.menu-plegar {
  display: none;
  width: 30px; height: 30px;
  border: none; background: none; cursor: pointer;
  border-radius: 8px;
  color: var(--text-600);
  align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.menu-plegar:hover { background: var(--bg-muted); color: var(--text-100); }

.menu-desplegar {
  display: none;
  position: fixed;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 26px; height: 76px;
  border: 1px solid var(--border); border-left: none;
  border-radius: 0 10px 10px 0;
  background: var(--bg-card);
  color: var(--text-400);
  cursor: pointer;
  z-index: 170;
  /* Invisible, pero presente: con opacidad 0 el botón sigue recibiendo el
     ratón, así que basta acercarse para que aparezca. */
  opacity: 0;
  transition: opacity 0.18s ease, color 0.18s ease;
  align-items: center; justify-content: center;
}
.menu-desplegar:hover,
.menu-desplegar:focus-visible { opacity: 1; color: var(--primary-dark); }

@media (min-width: 901px) {
  .menu-plegar { display: flex; }
  /* UNA sola columna: el menú ya no ocupa celda. */
  .app-shell.menu-plegado { grid-template-columns: 1fr; }
  .app-shell.menu-plegado .sidebar { display: none; }
  .app-shell.menu-plegado .menu-desplegar { display: flex; }
}
