/* ============================================
   RE/MAX Vision Intranet - Global Styles
   Diseño Minimalista Claro
   ============================================ */

:root {
  --red: #E82525;
  --blue: #003DA5;
  --bg: #F4F6F9;
  --white: #FFFFFF;
  --text-primary: #1A1A2E;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --sidebar-w: 240px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --radius: 10px;
  --radius-sm: 6px;

  /* Activity colors - 13 tipos */
  --llamada-color: #0EA5E9;    --llamada-bg: #E0F2FE;
  --cita-color: #06B6D4;       --cita-bg: #ECFEFF;
  --captacion-color: #14B8A6;  --captacion-bg: #CCFBF1;
  --visita-color: #3B82F6;     --visita-bg: #EFF6FF;
  --reserva-color: #F59E0B;    --reserva-bg: #FFFBEB;
  --cierre-color: #10B981;     --cierre-bg: #ECFDF5;
  --busqueda-color: #6366F1;   --busqueda-bg: #EEF2FF;
  --oferta-color: #8B5CF6;     --oferta-bg: #F5F3FF;
  --reporte-color: #EC4899;    --reporte-bg: #FCE7F3;
  --lead-color: #EF4444;       --lead-bg: #FEF2F2;
  --lead_cartel-color: #F97316;    --lead_cartel-bg: #FFF7ED;
  --lead_portal-color: #A855F7;    --lead_portal-bg: #FAF5FF;
  --lead_campana-color: #D946EF;   --lead_campana-bg: #FAE8FF;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden; /* evita scroll horizontal de página completa */
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ============================================
   LAYOUT
   ============================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-mark {
  width: 36px;
  height: 36px;
  background: var(--red);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -1px;
  flex-shrink: 0;
}

.sidebar-logo .logo-img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--red);
}

/* Collapsible nav group */
.nav-group { margin: 2px 0; }
.nav-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  background: none;
  border: none;
  width: calc(100% - 16px);
  text-align: left;
  transition: all 0.15s;
}
.nav-group-header:hover {
  background: var(--bg);
  color: var(--text-primary);
}
.nav-group-header .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.8;
  flex-shrink: 0;
}
.nav-group-header > span {
  flex: 1;
}
.nav-group-caret {
  transition: transform 0.2s;
  opacity: 0.7;
  flex-shrink: 0;
}
.nav-group.open .nav-group-caret {
  transform: rotate(180deg);
}
.nav-group-body {
  display: none;
  padding-left: 14px;
}
.nav-group.open .nav-group-body {
  display: block;
}
.nav-group-body .nav-item {
  padding: 7px 14px;
  font-size: 13px;
}
.nav-group-body .nav-item .nav-icon {
  width: 14px;
  height: 14px;
  opacity: 0.55;
}

.sidebar-logo .logo-text {
  line-height: 1.2;
}

.sidebar-logo .logo-text strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-logo .logo-text span {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

/* === Etiquetas de sección como mini-cards con color === */
.nav-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  /* card de color: padding interno + fondo + radius + borde izquierdo color */
  margin: 14px 12px 6px;
  padding: 8px 12px 8px 14px;
  border-radius: 8px;
  background: #F1F5F9;
  border-left: 3px solid #94A3B8;
  transition: background .15s;
}
/* Colores específicos por sección. Aplicados con clase modificadora .nav-sec-<key> */
.nav-section-label.nav-sec-principal     { background:#EFF6FF; border-left-color:#3B82F6; color:#1E40AF; }
.nav-section-label.nav-sec-macro         { background:#F5F3FF; border-left-color:#8B5CF6; color:#5B21B6; }
.nav-section-label.nav-sec-team          { background:#FFF7ED; border-left-color:#F97316; color:#9A3412; }
.nav-section-label.nav-sec-recursos      { background:#ECFDF5; border-left-color:#10B981; color:#065F46; }
.nav-section-label.nav-sec-ia            { background:#FDF4FF; border-left-color:#D946EF; color:#86198F; }
.nav-section-label.nav-sec-marketing     { background:#FFF1F2; border-left-color:#F43F5E; color:#9F1239; }
.nav-section-label.nav-sec-formacion     { background:#FEF9C3; border-left-color:#EAB308; color:#854D0E; }
.nav-section-label.nav-sec-equipo-admin  { background:#FEF3C7; border-left-color:#F59E0B; color:#78350F; }
.nav-section-label.nav-sec-admin         { background:#F1F5F9; border-left-color:#0F172A; color:#0F172A; }
.nav-section-label.nav-sec-pruebas       { background:#CFFAFE; border-left-color:#06B6D4; color:#155E75; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-item:hover {
  background: var(--bg);
  color: var(--text-primary);
}

.nav-item.active {
  background: #FEF2F2;
  color: var(--red);
  font-weight: 600;
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.8;
  flex-shrink: 0;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-item .nav-ext {
  margin-left: auto;
  opacity: 0.4;
  flex-shrink: 0;
}
.nav-item:hover .nav-ext { opacity: 0.75; }

.sidebar-user {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--red);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-info span {
  font-size: 11px;
  color: var(--text-muted);
}

.logout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}
.logout-btn:hover { color: var(--red); }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0; /* permite a los hijos con overflow no estirar el contenedor */
}

.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.page-body {
  padding: 24px 28px;
  flex: 1;
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 20px; }

/* ============================================
   STAT CARDS
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* === Progreso vs meta (estilo Ruta de Éxito) === */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.goal-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 10px;
  background: #fff;
}
.goal-row.completo {
  background: #ECFDF5;
  border-color: #A7F3D0;
}
.goal-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #020641;
}
.goal-row-icon { font-size: 18px; }
.goal-row-label { flex: 1; }
.goal-row-pct {
  font-size: 14px;
  font-weight: 800;
  color: #AA1120;
  min-width: 50px;
  text-align: right;
}
.goal-row-pct.ok { color: #047857; }
.goal-progress-track {
  width: 100%;
  height: 14px;
  background: #F3F4F6;
  border-radius: 7px;
  overflow: hidden;
}
.goal-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #AA1120 0%, #DC2626 50%, #F59E0B 100%);
  border-radius: 7px;
  transition: width 0.6s cubic-bezier(.22,.61,.36,1);
  box-shadow: inset 0 1px 2px rgba(255,255,255,.3);
  min-width: 2px;
}
.goal-progress-fill.completo {
  background: linear-gradient(90deg, #047857 0%, #10B981 100%);
}
.goal-row-foot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #6B7280;
}
.goal-row-foot strong {
  color: #020641;
  font-weight: 800;
  font-size: 13px;
}

/* === Promedio semanal del equipo === */
.weekly-avg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.weekly-card {
  background: #fff;
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.weekly-card-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700;
  color: #020641;
}
.weekly-card-icon { font-size: 18px; }
.weekly-card-label { flex: 1; }
.weekly-card-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 90px;
  padding-bottom: 4px;
}
.wkbar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
}
.wkbar-track {
  flex: 1;
  background: #F1F5F9;
  border-radius: 4px;
  display: flex;
  align-items: flex-end;
  min-height: 30px;
}
.wkbar-fill {
  width: 100%;
  border-radius: 4px;
  min-height: 2px;
  transition: height .25s ease;
}
.wkbar-label {
  font-size: 10px;
  font-weight: 700;
  color: #6B7280;
  text-align: center;
}
.wkbar-val {
  font-size: 11px;
  font-weight: 700;
  color: #020641;
  text-align: center;
}
.weekly-card-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #F1F5F9;
  font-size: 11px;
  color: #6B7280;
}
.weekly-card-footer div {
  display: flex; flex-direction: column; gap: 1px;
}
.weekly-card-footer span { font-size: 10px; }
.weekly-card-footer strong {
  font-size: 14px;
  color: #020641;
  font-weight: 800;
}

.stat-card .stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-card .stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.stat-card.visita .stat-icon { background: var(--visita-bg); color: var(--visita-color); }
.stat-card.reserva .stat-icon { background: var(--reserva-bg); color: var(--reserva-color); }
.stat-card.oferta .stat-icon { background: var(--oferta-bg); color: var(--oferta-color); }
.stat-card.cierre .stat-icon { background: var(--cierre-bg); color: var(--cierre-color); }

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge.visita { background: var(--visita-bg); color: var(--visita-color); }
.badge.reserva { background: var(--reserva-bg); color: var(--reserva-color); }
.badge.oferta { background: var(--oferta-bg); color: var(--oferta-color); }
.badge.cierre { background: var(--cierre-bg); color: var(--cierre-color); }
.badge.admin { background: #FEF2F2; color: var(--red); }
.badge.agent { background: var(--bg); color: var(--text-secondary); }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--red);
  color: white;
}
.btn-primary:hover { background: #C91E1E; }

.btn-secondary {
  background: var(--bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border-light); }

.btn-ghost {
  background: none;
  color: var(--text-secondary);
  border: none;
  padding: 6px 10px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }

.btn-danger {
  background: #FEF2F2;
  color: var(--red);
  border: 1px solid #FECACA;
}
.btn-danger:hover { background: #FEE2E2; }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-control:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(232, 37, 37, 0.08);
}

select.form-control { appearance: none; cursor: pointer; }

.form-row {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
}

/* ============================================
   TABLE
   ============================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
}

thead tr {
  border-bottom: 1px solid var(--border);
}

thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #FAFAFA; }

tbody td {
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--text-primary);
}

.td-muted { color: var(--text-muted); font-size: 12.5px; }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.3;
  margin-bottom: 12px;
}

.empty-state p { font-size: 13.5px; margin-top: 4px; }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg); color: var(--text-primary); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid;
}
.alert-error { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }
.alert-success { background: var(--cierre-bg); color: #065F46; border-color: #A7F3D0; }

/* ============================================
   FILTERS BAR
   ============================================ */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.filter-chip:hover { border-color: var(--text-muted); }
.filter-chip.active {
  background: var(--red);
  border-color: var(--red);
  color: white;
}

/* ============================================
   TIMELINE (Dashboard activity feed)
   ============================================ */
.timeline { display: flex; flex-direction: column; gap: 0; }

.timeline-item {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  align-items: flex-start;
}
.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.timeline-dot.visita { background: var(--visita-bg); color: var(--visita-color); }
.timeline-dot.reserva { background: var(--reserva-bg); color: var(--reserva-color); }
.timeline-dot.oferta { background: var(--oferta-bg); color: var(--oferta-color); }
.timeline-dot.cierre { background: var(--cierre-bg); color: var(--cierre-color); }

.timeline-content { flex: 1; }
.timeline-content strong {
  font-size: 13.5px;
  font-weight: 600;
  display: block;
}
.timeline-content span {
  font-size: 12px;
  color: var(--text-muted);
}

.timeline-meta {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 400px;
  padding: 40px 36px 36px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-logo .logo-mark {
  width: 44px;
  height: 44px;
  background: var(--red);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -1px;
}

.login-logo .logo-img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--red);
}

/* ============================================
   GPT / Asistentes de Marketing — landing card
   ============================================ */
.gpt-card {
  padding: 40px 28px;
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
}
.gpt-card .gpt-icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 16px;
}
.gpt-card h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.gpt-card .gpt-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}
.btn-lg {
  padding: 12px 22px;
  font-size: 14.5px;
  font-weight: 600;
}

.login-logo .logo-text strong {
  display: block;
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
}
.login-logo .logo-text span {
  font-size: 12px;
  color: var(--text-muted);
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}
.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.login-btn {
  width: 100%;
  padding: 11px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}
.login-btn:hover { background: #C91E1E; }

.login-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.progress-label {
  width: 70px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}
.progress-bar-bg {
  flex: 1;
  height: 7px;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.4s ease;
}
.progress-row .progress-count {
  width: 30px;
  text-align: right;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ============================================
   MATERIALS PAGE
   ============================================ */
.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.material-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow 0.15s, border-color 0.15s;
  cursor: pointer;
}
.material-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--text-muted);
}

.material-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.material-card h3 { font-size: 14px; font-weight: 600; }
.material-card p { font-size: 12.5px; color: var(--text-muted); }

/* ============================================
   AGENT CARDS (Admin)
   ============================================ */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.agent-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agent-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-card .user-avatar {
  width: 44px;
  height: 44px;
  font-size: 16px;
}

.agent-card-info { flex: 1; min-width: 0; }
.agent-card-info strong { display: block; font-size: 14px; font-weight: 600; }
.agent-card-info span { font-size: 12px; color: var(--text-muted); }

.agent-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.agent-stat {
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.agent-stat .val { font-size: 16px; font-weight: 700; }
.agent-stat .lbl { font-size: 10px; color: var(--text-muted); }

/* ============================================
   UTILITIES
   ============================================ */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12.5px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ============================================
   EXTENDED ACTIVITY STYLES (13 tipos)
   ============================================ */
.badge.llamada { background: var(--llamada-bg); color: var(--llamada-color); }
.badge.cita { background: var(--cita-bg); color: var(--cita-color); }
.badge.captacion { background: var(--captacion-bg); color: var(--captacion-color); }
.badge.busqueda { background: var(--busqueda-bg); color: var(--busqueda-color); }
.badge.reporte { background: var(--reporte-bg); color: var(--reporte-color); }
.badge.lead { background: var(--lead-bg); color: var(--lead-color); }
.badge.lead_cartel { background: var(--lead_cartel-bg); color: var(--lead_cartel-color); }
.badge.lead_portal { background: var(--lead_portal-bg); color: var(--lead_portal-color); }
.badge.lead_campana { background: var(--lead_campana-bg); color: var(--lead_campana-color); }

.timeline-dot.llamada { background: var(--llamada-bg); color: var(--llamada-color); }
.timeline-dot.cita { background: var(--cita-bg); color: var(--cita-color); }
.timeline-dot.captacion { background: var(--captacion-bg); color: var(--captacion-color); }
.timeline-dot.busqueda { background: var(--busqueda-bg); color: var(--busqueda-color); }
.timeline-dot.reporte { background: var(--reporte-bg); color: var(--reporte-color); }
.timeline-dot.lead { background: var(--lead-bg); color: var(--lead-color); }
.timeline-dot.lead_cartel { background: var(--lead_cartel-bg); color: var(--lead_cartel-color); }
.timeline-dot.lead_portal { background: var(--lead_portal-bg); color: var(--lead_portal-color); }
.timeline-dot.lead_campana { background: var(--lead_campana-bg); color: var(--lead_campana-color); }

/* Stats grid para 13 tipos: responsive */
.stats-grid.grid-13 {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.stat-card .stat-bar {
  height: 4px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}
.stat-card .stat-bar-fill {
  height: 100%;
  border-radius: 4px;
}

.stat-card.llamada .stat-icon { background: var(--llamada-bg); color: var(--llamada-color); }
.stat-card.cita .stat-icon { background: var(--cita-bg); color: var(--cita-color); }
.stat-card.captacion .stat-icon { background: var(--captacion-bg); color: var(--captacion-color); }
.stat-card.busqueda .stat-icon { background: var(--busqueda-bg); color: var(--busqueda-color); }
.stat-card.reporte .stat-icon { background: var(--reporte-bg); color: var(--reporte-color); }
.stat-card.lead .stat-icon { background: var(--lead-bg); color: var(--lead-color); }
.stat-card.lead_cartel .stat-icon { background: var(--lead_cartel-bg); color: var(--lead_cartel-color); }
.stat-card.lead_portal .stat-icon { background: var(--lead_portal-bg); color: var(--lead_portal-color); }
.stat-card.lead_campana .stat-icon { background: var(--lead_campana-bg); color: var(--lead_campana-color); }

/* Google Drive iframe */
.drive-embed {
  width: 100%;
  height: calc(100vh - 220px);
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
}

/* Loading states */
.loader {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loader-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 48px; color: var(--text-muted);
}

/* Compact form row for 3 cols */
.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* Login error */
.login-error {
  margin-bottom: 14px; padding: 9px 12px;
  background: #FEF2F2; color: #B91C1C;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  display: none;
}
.login-error.show { display: block; }

/* ============================================
   MOBILE NAV (hamburger + backdrop)
   ============================================ */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 120;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s;
}
.mobile-nav-toggle.hidden { opacity: 0; pointer-events: none; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.45);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.2s;
}
.sidebar-backdrop.open { opacity: 1; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
    box-shadow: 2px 0 16px rgba(0,0,0,0.12);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }

  .mobile-nav-toggle { display: flex; }
  .sidebar-backdrop.open { display: block; }

  /* Deja espacio a la izquierda del título para que no tape el botón */
  .page-header {
    padding: 14px 16px 14px 64px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .page-header h1 { font-size: 17px; }
  .page-header > *:first-child { padding-right: 0; }
  .page-header .btn,
  .page-header button,
  .page-header .page-actions { width: 100%; justify-content: center; }
  .page-body { padding: 16px; max-width: 100%; overflow-x: hidden; }

  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-13 { grid-template-columns: repeat(2, 1fr) !important; }

  /* Tablas con scroll horizontal en vez de romperse */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrapper table { min-width: 560px; }

  /* Modal ocupa casi toda la pantalla */
  .modal { width: 94vw; max-width: 94vw; margin: 20px auto; }

  /* Tabs del admin con scroll horizontal */
  .tabs { overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; }
  .tab { flex: 0 0 auto; }

  /* Chips de filtro con scroll */
  .filters-bar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .filter-chip { flex: 0 0 auto; }
}

@media (max-width: 420px) {
  .stats-grid, .grid-13 { grid-template-columns: 1fr !important; }
}
