/* ============================================
   NEXO - Sistema de Gestión
   Diseño Profesional
   ============================================ */

/* Variables de diseño */
:root {
  /* Colores principales */
  --primary: #4F46E5;
  --primary-dark: #4338CA;
  --primary-light: #818CF8;
  --primary-bg: #EEF2FF;
  
  /* Colores de estado */
  --success: #10B981;
  --success-bg: #D1FAE5;
  --warning: #F59E0B;
  --warning-bg: #FEF3C7;
  --danger: #EF4444;
  --danger-bg: #FEE2E2;
  --info: #3B82F6;
  --info-bg: #DBEAFE;
  
  /* Neutros */
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  
  /* Sidebar */
  --sidebar-bg: #0F172A;
  --sidebar-hover: #1E293B;
  --sidebar-active: #4F46E5;
  --sidebar-text: #94A3B8;
  --sidebar-text-active: #FFFFFF;
  
  /* Layout */
  --sidebar-width: 260px;
  --header-height: 64px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;
  
  /* Sombras */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  /* Transiciones */
  --transition: all 0.2s ease;
  --transition-slow: all 0.3s ease;
}

/* Reset y base */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--gray-700);
  background: var(--gray-50);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: var(--transition-slow);
}

.sidebar-logo {
  padding: 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: white;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.sidebar-logo small {
  display: block;
  color: var(--sidebar-text);
  font-size: 11px;
  font-weight: 400;
  margin-top: 4px;
  margin-left: 50px;
}

/* Navegación */
.sidebar nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-section {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  padding: 20px 16px 8px;
  margin-top: 8px;
}

.sidebar-section:first-child {
  margin-top: 0;
  padding-top: 8px;
}

/* Subsecciones del menú (Reportes, Configuración) */
.sidebar-subsection {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-600);
  padding: 12px 16px 4px;
  margin-top: 8px;
}

/* Items de subsección con indentación */
.sidebar nav a.sidebar-subitem {
  padding-left: 24px;
  font-size: 12px;
  opacity: 0.9;
}

.sidebar nav a.sidebar-subitem:hover {
  opacity: 1;
}

/* Color diferente para subitems activos */
.sidebar nav a.sidebar-subitem.active {
  background: rgba(139, 92, 246, 0.15); /* Violeta más suave */
  color: #C4B5FD; /* Violeta claro */
  border-left: 3px solid var(--primary-light);
  padding-left: 21px; /* Compensar el borde */
}

/* ============================================
   MENÚ COLAPSABLE
   ============================================ */

/* Header del módulo (clickeable) */
.sidebar-module-header {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 12px;
  transition: var(--transition);
  border-radius: var(--border-radius-sm);
  margin: 0 4px;
}

.sidebar-module-header:hover {
  background: rgba(255,255,255,0.03);
}

.sidebar-module-header .sidebar-section {
  flex: 1;
  margin: 0;
  padding: 16px 12px 8px;
}

.sidebar-module-header.expanded .sidebar-section {
  color: var(--primary-light);
}

/* Icono de toggle */
.module-toggle-icon {
  width: 16px;
  height: 16px;
  color: var(--sidebar-text);
  opacity: 0.5;
  transition: transform 0.2s ease, opacity 0.2s ease;
  transform: rotate(-90deg);
  flex-shrink: 0;
}

.sidebar-module-header:hover .module-toggle-icon {
  opacity: 0.8;
}

.sidebar-module-header.expanded .module-toggle-icon {
  opacity: 1;
  color: var(--primary-light);
}

/* Contenido del módulo */
.sidebar-module-content {
  overflow: hidden;
  transition: all 0.3s ease;
}

.sidebar-module-content a {
  animation: fadeInMenu 0.2s ease;
}

@keyframes fadeInMenu {
  from {
    opacity: 0;
    transform: translateX(-4px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: var(--border-radius-sm);
  font-weight: 500;
  font-size: 13px;
  transition: var(--transition);
  margin-bottom: 2px;
}

.sidebar nav a svg {
  width: 20px;
  height: 20px;
  opacity: 0.7;
}

.sidebar nav a:hover {
  background: var(--sidebar-hover);
  color: white;
}

.sidebar nav a:hover svg {
  opacity: 1;
}

.sidebar nav a.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  font-weight: 600;
}

.sidebar nav a.active svg {
  opacity: 1;
}

.sidebar nav a .badge {
  margin-left: auto;
  font-size: 10px;
  padding: 3px 8px;
  font-weight: 600;
  background: var(--danger);
  color: white;
  border-radius: 10px;
}

/* Badge de notificaciones en menú */
.menu-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 3px 8px;
  font-weight: 600;
  background: var(--danger);
  color: white;
  border-radius: 10px;
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.sidebar-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin: 16px 0;
}

/* ============================================
   CONTENIDO PRINCIPAL
   ============================================ */

.content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--gray-50);
}

.top-header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 32px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-header .page-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

.top-header .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--gray-600);
  font-size: 13px;
}

.avatar {
  width: 36px;
  height: 36px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}

.container-fluid {
  padding: 28px 32px;
}

/* ============================================
   CARDS
   ============================================ */

.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

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

.card-header h5 {
  margin: 0;
  font-weight: 600;
  color: var(--gray-900);
  font-size: 15px;
}

.card-body {
  padding: 20px;
}

/* ============================================
   KPI CARDS
   ============================================ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.kpi-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  padding: 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gray-200);
  transition: var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card:hover::before {
  background: var(--primary);
}

.kpi-card.primary::before { background: var(--primary); }
.kpi-card.success::before { background: var(--success); }
.kpi-card.warning::before { background: var(--warning); }
.kpi-card.danger::before { background: var(--danger); }

.kpi-value {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 6px;
  color: var(--gray-900);
}

.kpi-label {
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ============================================
   FILTROS
   ============================================ */

.filter-bar {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 20px;
}

.filter-bar .form-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

/* ============================================
   TABLAS
   ============================================ */

.table {
  margin: 0;
  font-size: 13px;
  width: 100%;
  border-collapse: collapse;
}

.table thead th {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  color: var(--gray-600);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 14px 16px;
  text-align: left;
  white-space: nowrap;
}

.table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  color: var(--gray-700);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--gray-50);
}

.table tbody tr.row-clickable {
  cursor: pointer;
}

.table tbody tr.row-clickable:hover {
  background: var(--primary-bg);
}

/* Fila con mensajes sin leer */
.table tbody tr.row-unread {
  background: #FEF3C7;
  border-left: 3px solid var(--warning);
}

.table tbody tr.row-unread:hover {
  background: #FDE68A;
}

.table tbody tr.row-unread td:first-child {
  padding-left: 13px;
}

/* ============================================
   FORMULARIOS
   ============================================ */

.form-label {
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
  font-size: 13px;
}

.form-control, .form-select {
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  transition: var(--transition);
  width: 100%;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
  outline: none;
}

.form-control::placeholder {
  color: var(--gray-400);
}

textarea.form-control {
  min-height: 120px;
  resize: vertical;
}

/* ============================================
   BOTONES
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

/* Normalizar botones <button> para que coincidan con <a> */
button.btn {
  font-family: inherit;
  line-height: inherit;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  color: white;
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #DC2626;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}

.btn-outline:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

/* ============================================
   BADGES
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-success { background: var(--success-bg); color: #047857; }
.badge-warning { background: var(--warning-bg); color: #B45309; }
.badge-danger { background: var(--danger-bg); color: #B91C1C; }
.badge-info { background: var(--info-bg); color: #1D4ED8; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-purple { background: rgba(139, 92, 246, 0.1); color: #7C3AED; }

/* Estados de reclamos */
.estado-activo { background: var(--success-bg); color: #047857; }
.estado-pendiente { background: var(--warning-bg); color: #B45309; }
.estado-finalizado { background: var(--gray-100); color: var(--gray-600); }
.estado-bloqueado { background: var(--danger-bg); color: #B91C1C; }
.estado-inactivo { background: var(--gray-100); color: var(--gray-600); }

/* Estados de documentos */
.estado-vigente { background: var(--success-bg); color: #047857; }
.estado-por_vencer { background: var(--warning-bg); color: #B45309; }
.estado-vencido { background: var(--danger-bg); color: #B91C1C; }

/* Estados de Tickets */
.estado-ticket-nuevo { background: var(--info-bg); color: #1D4ED8; }
.estado-ticket-en_proceso { background: var(--primary-bg); color: var(--primary); }
.estado-ticket-pendiente_cliente { background: var(--warning-bg); color: #B45309; }
.estado-ticket-resuelto { background: var(--success-bg); color: #047857; }
.estado-ticket-listo_facturar { background: #FEF3C7; color: #92400E; }
.estado-ticket-cerrado { background: var(--gray-100); color: var(--gray-600); }

/* Tipos de Ticket */
.tipo-remoto { background: #DBEAFE; color: #1D4ED8; }
.tipo-visita { background: #FEF3C7; color: #B45309; }
.tipo-mixto { background: #E0E7FF; color: #4338CA; }

/* Prioridades */
.prioridad-baja { background: var(--gray-100); color: var(--gray-600); }
.prioridad-media { background: var(--info-bg); color: #1D4ED8; }
.prioridad-alta { background: var(--warning-bg); color: #B45309; }
.prioridad-urgente { background: var(--danger-bg); color: #B91C1C; }

/* Estados de Propiedades (Real Estate) */
.estado-borrador { background: var(--gray-100); color: var(--gray-600); }
.estado-activa { background: var(--success-bg); color: #047857; }
.estado-reservada { background: var(--warning-bg); color: #B45309; }
.estado-vendida { background: var(--primary-bg); color: var(--primary); }
.estado-alquilada { background: var(--info-bg); color: #1D4ED8; }
.estado-suspendida { background: var(--danger-bg); color: #B91C1C; }
.estado-retirada { background: var(--gray-100); color: var(--gray-600); }

/* Tipos de Contacto (Real Estate) */
.tipo-comprador { background: var(--primary-bg); color: var(--primary); }
.tipo-vendedor { background: var(--success-bg); color: #047857; }
.tipo-propietario { background: var(--gray-100); color: var(--gray-600); }
.tipo-inquilino { background: var(--gray-100); color: var(--gray-600); }
.tipo-lead { background: var(--info-bg); color: #1D4ED8; }

/* Calificaciones de Contacto (Real Estate) */
.calificacion-frio { background: var(--gray-100); color: var(--gray-600); }
.calificacion-tibio { background: var(--info-bg); color: #1D4ED8; }
.calificacion-caliente { background: var(--warning-bg); color: #B45309; }
.calificacion-muy_caliente { background: var(--danger-bg); color: #B91C1C; }

/* Estados de Contacto (Real Estate) */
.estado-contacto-activo { background: var(--success-bg); color: #047857; }
.estado-contacto-inactivo { background: var(--gray-100); color: var(--gray-600); }
.estado-contacto-convertido { background: var(--primary-bg); color: var(--primary); }
.estado-contacto-perdido { background: var(--gray-100); color: var(--gray-600); }

/* Estados de Oportunidad (Real Estate) */
.estado-oportunidad-nueva { background: var(--info-bg); color: #1D4ED8; }
.estado-oportunidad-en_seguimiento { background: var(--primary-bg); color: var(--primary); }
.estado-oportunidad-negociacion { background: var(--warning-bg); color: #B45309; }
.estado-oportunidad-ganada { background: var(--success-bg); color: #047857; }
.estado-oportunidad-perdida { background: var(--danger-bg); color: #B91C1C; }

/* Estados de Muestra (Real Estate) */
.estado-muestra-agendada { background: var(--warning-bg); color: #B45309; }
.estado-muestra-confirmada { background: var(--success-bg); color: #047857; }
.estado-muestra-en_curso { background: var(--primary-bg); color: var(--primary); }
.estado-muestra-completada { background: var(--info-bg); color: #1D4ED8; }
.estado-muestra-cancelada { background: var(--danger-bg); color: #B91C1C; }
.estado-muestra-no_presentado { background: var(--gray-100); color: var(--gray-600); }
.estado-muestra-reagendada { background: var(--warning-bg); color: #B45309; }

/* ============================================
   ALERTAS
   ============================================ */

.alert {
  padding: 14px 18px;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-success { background: var(--success-bg); color: #047857; }
.alert-danger { background: var(--danger-bg); color: #B91C1C; }
.alert-warning { background: var(--warning-bg); color: #B45309; }
.alert-info { background: var(--info-bg); color: #1D4ED8; }

/* ============================================
   TIMELINE (Comentarios)
   ============================================ */

.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

.timeline-item {
  position: relative;
  padding: 16px 20px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  margin-bottom: 16px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -23px;
  top: 22px;
  width: 12px;
  height: 12px;
  background: white;
  border: 3px solid var(--primary);
  border-radius: 50%;
}

.timeline-item.interno {
  background: var(--gray-50);
  border-style: dashed;
}

.timeline-item.interno::before {
  border-color: var(--gray-400);
}

.timeline-item.sistema {
  background: var(--info-bg);
  border-color: var(--info);
}

.timeline-item.sistema::before {
  border-color: var(--info);
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--gray-300);
  margin-bottom: 20px;
}

.empty-state p {
  font-size: 15px;
  margin-bottom: 24px;
}

/* ============================================
   LOGIN
   ============================================ */

.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #1E293B 100%);
  padding: 20px;
}

.login-box {
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
}

.login-box h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
  text-align: center;
  margin-bottom: 8px;
}

.login-box .subtitle {
  text-align: center;
  color: var(--gray-500);
  margin-bottom: 32px;
}

.login-box .logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-box .logo-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.login-box .logo-icon svg {
  width: 32px;
  height: 32px;
  color: white;
}

/* ============================================
   UTILIDADES
   ============================================ */

.text-muted { color: var(--gray-500); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.actions-cell {
  white-space: nowrap;
  text-align: right;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Botón menú móvil - oculto en desktop */
.mobile-menu-btn {
  display: none !important;
  background: none;
  border: none;
  padding: 8px;
  margin-right: 12px;
  cursor: pointer;
  color: var(--gray-700);
  border-radius: var(--border-radius-sm);
  transition: var(--transition);
}

.mobile-menu-btn:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

/* Overlay para cerrar menú */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
  opacity: 1;
}

@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 100;
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .content {
    margin-left: 0;
  }

  .container-fluid {
    padding: 20px;
  }

  .top-header {
    padding: 0 20px;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  /* Mostrar botón menú en móvil */
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Mostrar overlay cuando está activo */
  .sidebar-overlay.show {
    display: block;
  }

  /* Ajustar header para incluir botón menú */
  .top-header {
    display: flex;
    align-items: center;
  }

  .page-title {
    flex: 1;
  }
}

/* ============================================
   TABS
   ============================================ */

.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  padding-left: 0;
  margin-bottom: 0;
  list-style: none;
  border-bottom: 2px solid var(--gray-200);
}

.nav-item {
  margin-bottom: -2px;
}

.nav-link {
  display: block;
  padding: 0.75rem 1.25rem;
  color: var(--gray-600);
  text-decoration: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
  font-weight: 500;
}

.nav-link:hover {
  color: var(--primary);
  border-bottom-color: var(--gray-300);
}

.nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============================================
   ANIMACIONES
   ============================================ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card, .kpi-card, .alert {
  animation: fadeIn 0.25s ease-out;
}

/* ============================================
   UTILIDADES DE LAYOUT
   ============================================ */

/* Anchos de columna */
.col-xs { width: 40px; }
.col-sm { width: 60px; }
.col-md { width: 100px; }
.col-lg { width: 150px; }
.col-xl { width: 200px; }
.col-actions { width: 80px; text-align: right; }

/* Alineación de texto */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Flexbox utilities */
.d-flex { display: flex; }
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.align-items-start { align-items: flex-start; }
.align-items-center { align-items: center; }
.align-items-end { align-items: flex-end; }
.justify-content-start { justify-content: flex-start; }
.justify-content-center { justify-content: center; }
.justify-content-end { justify-content: flex-end; }
.justify-content-between { justify-content: space-between; }

/* Gaps */
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }
.gap-6 { gap: 24px; }

/* Padding utilities */
.p-0 { padding: 0; }
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 16px; }
.p-4 { padding: 24px; }

.px-1 { padding-left: 4px; padding-right: 4px; }
.px-2 { padding-left: 8px; padding-right: 8px; }
.px-3 { padding-left: 16px; padding-right: 16px; }
.px-4 { padding-left: 24px; padding-right: 24px; }

.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 16px; padding-bottom: 16px; }
.py-4 { padding-top: 24px; padding-bottom: 24px; }

/* Margin utilities */
.m-0 { margin: 0; }
.m-1 { margin: 4px; }
.m-2 { margin: 8px; }
.m-3 { margin: 16px; }
.m-4 { margin: 24px; }

.mx-1 { margin-left: 4px; margin-right: 4px; }
.mx-2 { margin-left: 8px; margin-right: 8px; }
.mx-3 { margin-left: 16px; margin-right: 16px; }
.mx-4 { margin-left: 24px; margin-right: 24px; }

.my-1 { margin-top: 4px; margin-bottom: 4px; }
.my-2 { margin-top: 8px; margin-bottom: 8px; }
.my-3 { margin-top: 16px; margin-bottom: 16px; }
.my-4 { margin-top: 24px; margin-bottom: 24px; }

/* ============================================
   BREADCRUMBS
   ============================================ */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  padding: 0;
  margin: 0 0 8px 0;
  list-style: none;
  font-size: 13px;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
}

.breadcrumb-item + .breadcrumb-item {
  padding-left: 0;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "/";
  padding: 0 8px;
  color: var(--gray-400);
}

.breadcrumb-item a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb-item a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.breadcrumb-item.active {
  color: var(--gray-500);
}

/* ============================================
   GRID SYSTEM (Bootstrap-like)
   ============================================ */

.row {
  display: flex;
  flex-wrap: wrap;
  margin-right: -12px;
  margin-left: -12px;
}

.row > * {
  padding-right: 12px;
  padding-left: 12px;
}

.col { flex: 1 0 0%; }
.col-auto { flex: 0 0 auto; width: auto; }
.col-1 { flex: 0 0 auto; width: 8.333333%; }
.col-2 { flex: 0 0 auto; width: 16.666667%; }
.col-3 { flex: 0 0 auto; width: 25%; }
.col-4 { flex: 0 0 auto; width: 33.333333%; }
.col-5 { flex: 0 0 auto; width: 41.666667%; }
.col-6 { flex: 0 0 auto; width: 50%; }
.col-7 { flex: 0 0 auto; width: 58.333333%; }
.col-8 { flex: 0 0 auto; width: 66.666667%; }
.col-9 { flex: 0 0 auto; width: 75%; }
.col-10 { flex: 0 0 auto; width: 83.333333%; }
.col-11 { flex: 0 0 auto; width: 91.666667%; }
.col-12 { flex: 0 0 auto; width: 100%; }

/* Grid columns for larger screens */
@media (min-width: 768px) {
  .col-md-1 { flex: 0 0 auto; width: 8.333333%; }
  .col-md-2 { flex: 0 0 auto; width: 16.666667%; }
  .col-md-3 { flex: 0 0 auto; width: 25%; }
  .col-md-4 { flex: 0 0 auto; width: 33.333333%; }
  .col-md-5 { flex: 0 0 auto; width: 41.666667%; }
  .col-md-6 { flex: 0 0 auto; width: 50%; }
  .col-md-7 { flex: 0 0 auto; width: 58.333333%; }
  .col-md-8 { flex: 0 0 auto; width: 66.666667%; }
  .col-md-9 { flex: 0 0 auto; width: 75%; }
  .col-md-10 { flex: 0 0 auto; width: 83.333333%; }
  .col-md-11 { flex: 0 0 auto; width: 91.666667%; }
  .col-md-12 { flex: 0 0 auto; width: 100%; }
}

@media (min-width: 992px) {
  .col-lg-1 { flex: 0 0 auto; width: 8.333333%; }
  .col-lg-2 { flex: 0 0 auto; width: 16.666667%; }
  .col-lg-3 { flex: 0 0 auto; width: 25%; }
  .col-lg-4 { flex: 0 0 auto; width: 33.333333%; }
  .col-lg-5 { flex: 0 0 auto; width: 41.666667%; }
  .col-lg-6 { flex: 0 0 auto; width: 50%; }
  .col-lg-7 { flex: 0 0 auto; width: 58.333333%; }
  .col-lg-8 { flex: 0 0 auto; width: 66.666667%; }
  .col-lg-9 { flex: 0 0 auto; width: 75%; }
  .col-lg-10 { flex: 0 0 auto; width: 83.333333%; }
  .col-lg-11 { flex: 0 0 auto; width: 91.666667%; }
  .col-lg-12 { flex: 0 0 auto; width: 100%; }
}

/* Grid gap utilities */
.g-1 { gap: 4px; }
.g-2 { gap: 8px; }
.g-3 { gap: 16px; }
.g-4 { gap: 24px; }
.g-5 { gap: 32px; }

/* Display utilities */
.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-grid { display: grid; }

/* Width utilities */
.w-100 { width: 100%; }
.w-auto { width: auto; }

/* Form check (checkbox) */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.form-check-input {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

.form-check-label {
  cursor: pointer;
  font-size: 14px;
  color: var(--gray-700);
}

/* Table responsive */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Pagination */
.pagination {
  display: flex;
  padding-left: 0;
  list-style: none;
  gap: 4px;
}

.page-item .page-link {
  display: block;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--gray-700);
  text-decoration: none;
  background-color: white;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  transition: var(--transition);
}

.page-item .page-link:hover {
  background-color: var(--gray-100);
  border-color: var(--gray-400);
}

.page-item.active .page-link {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
}

.page-item.disabled .page-link {
  color: var(--gray-400);
  pointer-events: none;
  background-color: var(--gray-50);
}

.justify-content-center {
  justify-content: center;
}

/* Heading styles */
.h1, h1 { font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--gray-900); }
.h2, h2 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--gray-900); }
.h3, h3 { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--gray-900); }
.h4, h4 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--gray-900); }
.h5, h5 { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--gray-900); }
.h6, h6 { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--gray-900); }
