/* =============================================
   1. FUNDACIÃ“N Y VARIABLES GLOBALES
   ============================================= */
:root {
  --primary: #007bff;
  --primary-dark: #0056b3;
  --primary-light: #e6f2ff;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #17a2b8;
  --dark: #212529;
  --muted: #6c757d;
  --light: #f8f9fa;
  --white: #ffffff;
  --line: #dee2e6;
  --bg: #f8f9fa;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --transition: all 0.3s ease;
  --radius: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  color: var(--dark);
  background-color: var(--light);
  font-size: 15px;
}

body.login-active {
  background-color: var(--light);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* =============================================
   2. LAYOUT PRINCIPAL (APP Y SIDEBAR) - DISEÃ‘O MODERNO
   ============================================= */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.3s ease;
}

.app-layout.collapsed {
  grid-template-columns: 80px 1fr;
}

.sidebar {
  /* Nuevo fondo mÃ¡s oscuro y profesional */
  background-color: #111827;
  color: var(--light);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  position: fixed;
  height: 100%;
  width: 260px;
  z-index: 1000;
  transition: all 0.3s ease;
  overflow-x: hidden;
}

.sidebar.collapsed {
  width: 80px;
  padding: 1rem 0.5rem;
}

/* Header del Sidebar */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
  margin: 0;
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: center;
}

.sidebar-logo {
  max-width: 160px;
  width: 100%;
  height: auto;
  transition: opacity 0.2s ease;
}

.sidebar-logo-mini {
  width: 32px;
  height: auto;
}

.sidebar.collapsed .sidebar-header {
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 1rem;
}

.sidebar.collapsed .sidebar-logo {
  display: none;
}

.sidebar.collapsed .sidebar-logo-mini {
  display: block !important;
}

.sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2rem;
  transition: var(--transition);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle:hover {
  color: var(--white);
  transform: scale(1.1);
}

.sidebar.collapsed .sidebar-toggle i {
  transform: rotate(180deg);
  transition: transform 0.3s ease;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  color: #9ca3af;
  transition: var(--transition);
  position: relative;
  font-weight: 500;
}

/* Hover sutil */
.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--white);
}

/* Estilo del link activo (sin fondo azul) */
.nav-link.active {
  background-color: transparent;
  color: var(--white);
  /* Texto mÃ¡s brillante */
  font-weight: 600;
}

/* El nuevo indicador visual para el link activo */
.nav-link.active::before {
  content: '';
  position: absolute;
  left: -1rem;
  /* Se posiciona fuera del padding */
  top: 50%;
  transform: translateY(-50%);
  height: 60%;
  width: 4px;
  background-color: var(--primary);
  border-radius: 0 4px 4px 0;
}

/* Estilos de Nav Link cuando el menÃº estÃ¡ colapsado */
.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 0.65rem 0;
}

.sidebar.collapsed .nav-link span {
  display: none;
}

.sidebar.collapsed .nav-link i {
  font-size: 1.3rem;
  margin: 0;
}

.sidebar.collapsed .nav-link.active::before {
  left: -0.5rem;
  /* Ajuste del indicador porque el padding cambia */
}

/* El nuevo indicador visual para el link activo */
.nav-link.active::before {
  content: '';
  position: absolute;
  left: -1rem;
  /* Se posiciona fuera del padding */
  top: 50%;
  transform: translateY(-50%);
  height: 60%;
  width: 4px;
  background-color: var(--primary);
  border-radius: 0 4px 4px 0;
}



.main-content {
  grid-column: 2 / 3;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* ocupa toda la altura de la ventana */
  overflow-y: auto;
}


.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.5s ease-out;
}

/* =============================================
   ESTILOS PARA LA BARRA SUPERIOR DE USUARIO
   ============================================= */

.top-user-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0 0 1rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
  gap: 1.5rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info i {
  font-size: 1.5rem;
  color: var(--primary);
  /* Cambiar a un color visible sobre fondo claro */
}

.logout-btn {
  color: var(--muted);
  color: var(--muted);
  text-decoration: none;
  font-size: 1.2rem;
  padding: 0.4rem;
  border-radius: 8px;
  transition: all 0.3s ease;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-btn:hover {
  background-color: rgba(220, 53, 69, 0.1);
  /* Fondo rojo muy claro */
  color: var(--danger);
  /* El Ã­cono se vuelve rojo intenso */
  transform: scale(1.1);
  /* AnimaciÃ³n: crece un poco */
}

.sidebar.collapsed .logout-btn {
  width: 100%;
}

/* =============================================
   3. COMPONENTES REUTILIZABLES
   ============================================= */

/* Estilo especÃ­fico para el botÃ³n de WhatsApp */
.btn-whatsapp {
  background-color: #25D366;
  /* Color verde oficial de WhatsApp */
  color: var(--white);
  border-color: #25D366;
}

.btn-whatsapp:hover {
  background-color: #1DA851;
  /* Un verde un poco mÃ¡s oscuro al pasar el mouse */
  border-color: #1DA851;
  transform: translateY(-2px);
}

/* Botón tipo enlace (Link Button) */
.btn-link {
  background: none !important;
  border: none !important;
  padding: 0 !important;
  color: var(--primary) !important;
  text-decoration: none !important;
  cursor: pointer !important;
  font-weight: 600 !important;
  font-family: inherit !important;
  transition: var(--transition) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  font-size: inherit;
}
.btn-link:hover {
  color: var(--primary-dark) !important;
  text-decoration: underline !important;
}

/* --- BOTONES --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 15px;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn.primary {
  background-color: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.btn.primary:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-2px);
}

.btn.secondary {
  background-color: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-light);
}

.btn.secondary:hover {
  background-color: #d1e5ff;
}

.btn.ghost {
  background-color: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.btn.ghost:hover {
  background-color: var(--light);
  color: var(--dark);
}

.btn.danger {
  background-color: var(--danger);
  color: var(--white);
  border-color: var(--danger);
}

.btn.danger:hover {
  background-color: #c82333;
  border-color: #c82333;
}

.btn.success {
  background-color: var(--success);
  color: var(--white);
  border-color: var(--success);
}

.btn-sm {
  padding: 6px 16px;
  font-size: 14px;
}

.btn-icon {
  padding: 0;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 999px;
}

.table-actions .btn-icon {
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
}

.btn-icon i {
  font-size: 1rem;
}

.btn-group {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 50px;
  overflow: hidden;
}

.btn-group .btn {
  border-radius: 0;
  border: none;
  background-color: var(--white);
  color: var(--muted);
}

.btn-group .btn.active {
  background-color: var(--primary);
  color: var(--white);
}

/* --- TARJETAS (CARDS) --- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 2rem;
  position: relative;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background-color: var(--primary);
  border-radius: var(--radius) var(--radius) 0 0;
}

/* --- FORMULARIOS --- */
label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  transition: var(--transition);
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

fieldset:disabled {
  opacity: 0.6;
  pointer-events: none;
  background-color: #fafafa;
}

/* --- TABLAS --- */
table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

thead {
  background-color: var(--light);
}

th {
  font-weight: 600;
  font-size: 14px;
}

.right {
  text-align: right;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}

/* --- INSIGNIAS (BADGES) --- */
.badge {
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success {
  background-color: #e9f7ef;
  color: #28a745;
}

.badge-info {
  background-color: #e8f7fa;
  color: #17a2b8;
}

.badge-danger {
  background-color: #fceeee;
  color: #dc3545;
}

.badge-warning {
  background-color: #fff8e9;
  color: #b45309;
}

.badge-muted {
  background-color: #f1f3f5;
  color: #6c757d;
}

/* --- NOTIFICACIONES (TOASTS) --- */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 1rem;
  background-color: var(--white);
  color: var(--dark);
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
  border-left: 5px solid;
  min-width: 300px;
  animation: slideIn 0.4s ease-out;
}

.toast.hiding {
  animation: slideOut 0.4s ease-in forwards;
}

.toast-icon {
  font-size: 1.5rem;
}

.toast.success {
  border-color: var(--success);
}

.toast.success .toast-icon {
  color: var(--success);
}

.toast.error {
  border-color: var(--danger);
}

.toast.error .toast-icon {
  color: var(--danger);
}

.toast.warning {
  border-color: var(--warning);
}

.toast.warning .toast-icon {
  color: var(--warning);
}

.toast.info {
  border-color: var(--info);
}

.toast.info .toast-icon {
  color: var(--info);
}

.toast p {
  margin: 0;
}

.toast-close {
  margin-left: auto;
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--muted);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }

  to {
    transform: translateX(100%);
    opacity: 0;
  }
}


/* =============================================
   4. ESTILOS DE PÃGINAS Y COMPONENTES ESPECÃFICOS
   ============================================= */


/* --- DASHBOARD --- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.page-header h2 {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 2rem;
  margin: 0;
}

.toolbar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* --- Dashboard layout --- */
.page-header--dashboard {
  margin-bottom: 1.25rem;
}

.page-header--dashboard h2 {
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.dashboard-filters {
  margin-bottom: 0.25rem;
  padding: 1.15rem 1.35rem !important;
}

.premium-limit-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 55vh;
  padding: 20px;
}

.premium-limit-card {
  width: 100%;
  max-width: 640px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.98));
  border: 1px solid rgba(96, 165, 250, 0.18);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
  border-radius: 24px;
  padding: 42px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.premium-limit-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.18), transparent 28%),
              radial-gradient(circle at left center, rgba(14, 165, 233, 0.08), transparent 24%);
  pointer-events: none;
}

.premium-limit-card > * {
  position: relative;
  z-index: 1;
}

.premium-limit-badge {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.28);
  font-size: 1.9rem;
}

#limitacion-titulo {
  color: #f8fafc;
  font-size: clamp(1.8rem, 2.3vw, 2.4rem);
  margin-bottom: 14px;
}

#limitacion-mensaje {
  color: #cbd5e1;
  font-size: 1rem;
  line-height: 1.8;
  margin: 0 auto 28px;
  max-width: 520px;
}

.premium-limit-features {
  display: grid;
  gap: 12px;
  margin-bottom: 30px;
}

.premium-feature {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  justify-content: center;
  padding: 14px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-size: 0.98rem;
}

.premium-feature i {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
}

.premium-action {
  width: 100%;
  padding: 14px 0;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.premium-action i {
  margin-right: 0.35rem;
}


.dashboard-filters__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 1.5rem;
}

.dashboard-filters__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 200px));
  gap: 0.85rem 1rem;
  flex: 1;
  min-width: 0;
}

.dashboard-filter-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dashboard-date-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.9rem;
  background: var(--light);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.dashboard-date-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.12);
  background: var(--white);
}

.dashboard-filters__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dashboard-filters__actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
}

.stat-card {
  display: block;
  container-type: inline-size;
  text-align: left;
  position: relative;
  overflow: visible;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 1.15rem 1.25rem;
  min-height: 104px;
  border-left: 4px solid transparent;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.stat-card .card::before {
  display: none;
}

.stat-card__body {
  width: 100%;
  z-index: 1;
}

.stat-card--highlight {
  background: linear-gradient(135deg, var(--primary-light) 0%, #fff 100%);
  border-left-color: var(--primary);
}

.stat-card--accent-green { border-left-color: #22c55e; }
.stat-card--accent-red { border-left-color: #ef4444; }
.stat-card--accent-blue { border-left-color: #3b82f6; }
.stat-card--accent-purple { border-left-color: #a855f7; }

.stat-value {
  font-size: clamp(0.9rem, 11.5cqw, 1.45rem);
  font-weight: 800;
  line-height: 1.2;
  margin: 0.35rem 0 0;
  z-index: 1;
  white-space: nowrap;
  text-overflow: clip;
  overflow: visible;
  word-break: normal;
  overflow-wrap: normal;
}

.stat-value--profit {
  color: var(--primary-dark);
}

.stat-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0;
  z-index: 1;
  line-height: 1.3;
  padding-right: 42px;
}

.stat-icon {
  position: absolute !important;
  top: 1.15rem !important;
  right: 1.25rem !important;
  flex-shrink: 0;
  width: 40px !important;
  height: 40px !important;
  border-radius: 10px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 1.1rem !important;
  opacity: 1 !important;
  z-index: 2 !important;
}

.stat-icon.green {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
}

.stat-icon.red {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.stat-icon.blue {
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
}

.stat-icon.purple {
  background: rgba(168, 85, 247, 0.15);
  color: #9333ea;
}

/* --- TABS --- */
.config-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--line);
  margin-bottom: 2rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  /* Superponer sobre la lÃ­nea del contenedor */
  transition: all 0.2s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab-btn:hover {
  color: var(--primary);
  background: rgba(0, 0, 0, 0.02);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
  display: block;
}

/* --- TOGGLE SWITCH (Factura de Contingencia) --- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--primary);
}

input:checked+.slider:before {
  transform: translateX(22px);
}

/* --- OTROS COMPONENTES --- */
.hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1.5rem 0;
}

.client-selector,
.product-adder-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.product-adder-grid {
  grid-template-columns: 1fr 80px auto;
}

.total-box {
  background: var(--light);
  padding: 1rem;
  border-radius: 8px;
}

.search-box {
  position: relative;
}

.search-box input {
  padding-left: 40px;
}

.search-box svg {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.responsibilities-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 5px;
  min-height: 40px;
}

.responsibility-tag {
  background-color: var(--primary-light);
  color: var(--primary-dark);
  padding: 5px 10px;
  border-radius: 50px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.responsibility-tag span {
  cursor: pointer;
}

/* =============================================
   PAGINACIÃ“N â€“ ESTILO MODERNO
   ============================================= */
.pagination-controls {
  margin-top: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background-color: var(--white);
  border: 1px solid rgba(148, 163, 184, 0.4);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

/* Contenedor centrado dentro de la card */
.card .pagination-controls {
  display: inline-flex;
}

/* Botones de la paginaciÃ³n */
.pagination-controls .btn {
  margin: 0;
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0 0.7rem;
  border-radius: 999px;
  border: none;
  font-size: 0.8rem;
  font-weight: 500;
  background-color: transparent;
  color: var(--muted);
  box-shadow: none;
}

/* Desactivamos el "salto" vertical de los btn en hover solo aquÃ­ */
.pagination-controls .btn:hover {
  background-color: #EEF2FF;
  color: var(--primary);
  transform: none;
}

/* PÃ¡gina activa */
.pagination-controls .btn.active {
  background-color: var(--primary);
  color: var(--white);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
}

/* Prev / Next (primer y Ãºltimo botÃ³n) un poco mÃ¡s anchos */
.pagination-controls .btn:first-child,
.pagination-controls .btn:last-child {
  padding-inline: 0.9rem;
  font-weight: 600;
}

/* BotÃ³n deshabilitado (cuando no hay pÃ¡gina anterior/siguiente) */
.pagination-controls .btn[disabled],
.pagination-controls .btn:disabled {
  opacity: 0.45;
  cursor: default;
  background-color: transparent;
  box-shadow: none;
  color: rgba(148, 163, 184, 0.9);
}

/* Responsive: si hay muchas pÃ¡ginas, que se acomode mejor */
@media (max-width: 576px) {
  .pagination-controls {
    flex-wrap: wrap;
    row-gap: 0.25rem;
    padding-inline: 0.5rem;
  }

  .pagination-controls .btn {
    min-width: 2rem;
    height: 2rem;
    font-size: 0.75rem;
  }
}

/* Modo oscuro (si usas dark-mode) */
body.dark-mode .pagination-controls {
  background-color: #020617;
  border-color: rgba(148, 163, 184, 0.35);
  box-shadow: 0 10px 35px rgba(15, 23, 42, 0.9);
}

body.dark-mode .pagination-controls .btn {
  color: #e5e7eb;
}

body.dark-mode .pagination-controls .btn:hover {
  background-color: rgba(37, 99, 235, 0.1);
  color: var(--primary-light);
}

body.dark-mode .pagination-controls .btn.active {
  background-color: var(--primary);
  color: #f9fafb;
}


/* =============================================
   Estilos para Banner Global (DiseÃ±o Moderno)
   ============================================= */

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

#global-banner {
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  color: var(--white);
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 1500;
  animation: slideDown 0.5s ease-out;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.banner-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.banner-icon {
  font-size: 1.25rem;
}

.banner-close {
  background: none;
  border: none;
  color: var(--white);
  opacity: 0.7;
  font-size: 1.5rem;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.banner-close:hover {
  opacity: 1;
}

/* Colores especÃ­ficos */
#global-banner.info {
  background-color: var(--info);
}

#global-banner.success {
  background-color: var(--success);
}

#global-banner.warning {
  background-color: var(--warning);
  color: var(--dark);
}

#global-banner.warning .banner-close {
  color: var(--dark);
}

/* Para que el botÃ³n de cierre sea visible */
#global-banner.danger {
  background-color: var(--danger);
}

/* =============================================
   MODALES - CÃ“DIGO ACTUALIZADO
   ============================================= */

/* Contenedor general del modal (Overlay) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  /* Prioridad base para modales principales */
}

/* Caja del modal (Contenido) */
.modal-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2rem;
  width: 90%;
  max-width: 650px;
  /* Ancho mÃ¡ximo para modales de formulario (Producto, Cliente, etc.) */
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
  animation: fadeIn 0.3s ease-out;
}

/* --- AJUSTES DE TAMAÃ‘O ESPECÃFICOS --- */
/* El modal de Estado de Cuenta necesita ser mÃ¡s ancho */
#modalEstadoCuenta .modal-box {
  max-width: 850px;
}

/* Los modales de selecciÃ³n pueden ser mÃ¡s angostos */
.modal-selection .modal-box {
  max-width: 500px;
}

/* --- CORRECCIÃ“N DE ORDEN (Z-INDEX) --- */
/* Los modales que se abren encima de otros necesitan una prioridad mayor */
#modalSeleccionCliente,
#modalSeleccionProducto,
#modalSeleccionFactura,
#modalSeleccionResponsabilidad {
  z-index: 5000;
  /* Prioridad mÃ¡s alta para que siempre aparezcan delante */
}


/* --- Estilos internos del modal (sin cambios) --- */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
}

.items-container {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px;
}

.item-card {
  padding: 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.item-card:hover,
.item-card.selected {
  background-color: var(--primary-light);
}

.item-card h4 {
  margin: 0 0 5px;
}

.item-card p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.no-results {
  text-align: center;
  padding: 1rem;
  color: var(--muted);
}

/* --- FOOTER DE LA APP --- */
footer {
  grid-column: 2 / 3;
  background: var(--white);
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

footer a {
  color: var(--primary);
  text-decoration: none;
}

/* =============================================
   5. ESTILOS ADICIONALES Y CORRECCIONES
   ============================================= */

.logo-preview {
  max-width: 140px;
  height: 80px;
  object-fit: contain;
  /* Asegura que la imagen se ajuste sin deformarse */
  border: 1px dashed var(--line);
  border-radius: 8px;
  background-color: var(--light);
}

/* CorrecciÃ³n para el tamaÃ±o de los Ã­conos del menÃº */
.nav-link svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  /* Evita que el Ã­cono se encoja si el texto es largo */
}

/* Iconos Font Awesome en el sidebar */
.nav-link i {
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.05);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.nav-link:hover i,
.nav-link.active i {
  background-color: rgba(255, 255, 255, 0.15);
  transform: scale(1.1);
}

/* Que el texto no se pegue demasiado al icono */
.sidebar-nav .nav-link span {
  font-size: 0.9rem;
  font-weight: 500;
}


/* CorrecciÃ³n para Ã­conos en TÃ­tulos de PÃ¡gina y Login */

/* Para los tÃ­tulos de secciÃ³n (ej: "Dashboard", "Clientes") */
.page-header h2 svg {
  width: 32px;
  height: 32px;
}

/* Para los Ã­conos dentro de los campos de Login */
.input-group svg {
  width: 20px;
  height: 20px;
}

/* =============================================
   6. MODAL DE SUSCRIPCIÃ“N VENCIDA
   ============================================= */

/* =============================================
   6. MODAL DE SUSCRIPCIÓN VENCIDA (PREMIUM DESIGN)
   ============================================= */

.suscripcion-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.99));
  backdrop-filter: blur(16px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 2rem 1.5rem;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  opacity: 0;
  transition: opacity 0.4s ease;
  overflow-y: auto; /* Habilitar scroll si el contenido supera la pantalla */
}

.suscripcion-overlay.active {
  display: flex;
  opacity: 1;
}

.suscripcion-card {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 40px;
  max-width: 580px;
  width: 100%;
  text-align: center;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5);
  animation: suscripcionSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  color: #f1f5f9;
  margin: auto; /* Mantener centrado dinámico */
  position: relative;
  overflow: hidden;
}

/* Efecto de luz ambiental roja suave detrás del candado */
.suscripcion-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(239, 68, 68, 0.07) 0%, rgba(239, 68, 68, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

/* Badge de Conexión SSL Segura */
.secure-ssl-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 99px;
  margin-bottom: 24px;
  color: #4ade80;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.05);
  animation: securePulse 3s infinite;
  z-index: 1;
  position: relative;
}

@keyframes securePulse {
  0% { border-color: rgba(34, 197, 94, 0.2); box-shadow: 0 4px 12px rgba(34, 197, 94, 0.05); }
  50% { border-color: rgba(34, 197, 94, 0.45); box-shadow: 0 4px 20px rgba(34, 197, 94, 0.2); }
  100% { border-color: rgba(34, 197, 94, 0.2); box-shadow: 0 4px 12px rgba(34, 197, 94, 0.05); }
}

/* Panel de Detalles de Empresa Vencida (Dinámico & XSS Sanitized) */
.suscripcion-meta-panel {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 26px;
  text-align: center;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
  z-index: 1;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-item:not(:last-child) {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.meta-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.meta-label i {
  font-size: 0.8rem;
  opacity: 0.8;
}

.meta-val {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) or (max-height: 745px) {
  .suscripcion-overlay {
    align-items: flex-start; /* Evitar corte superior en pantallas pequeñas */
    padding: 1.5rem 1rem;
  }
  
  .suscripcion-card {
    padding: 24px 20px;
    border-radius: 20px;
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
  }
  
  .suscripcion-icon-wrapper {
    width: 60px !important;
    height: 60px !important;
    font-size: 1.6rem !important;
    margin-bottom: 16px !important;
  }
  
  .suscripcion-card h2 {
    font-size: 1.6rem !important;
  }
  
  .suscripcion-card p {
    font-size: 0.88rem !important;
    margin-bottom: 20px !important;
  }

  .secure-ssl-badge {
    font-size: 0.72rem !important;
    padding: 6px 12px !important;
    margin-bottom: 18px !important;
  }

  /* Adaptación Premium Móvil para el Panel de Detalles */
  .suscripcion-meta-panel {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    padding: 12px !important;
    text-align: left !important;
    margin-bottom: 20px !important;
  }
  
  .meta-item {
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
  }
  
  .meta-item:not(:last-child) {
    border-right: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    padding-bottom: 8px !important;
  }
  
  .meta-label {
    justify-content: flex-start !important;
    font-size: 0.68rem !important;
  }
  
  .meta-val {
    white-space: normal !important;
    text-align: right !important;
    font-size: 0.82rem !important;
    max-width: 65% !important;
  }
  
  .plan-card {
    padding: 14px 16px !important;
  }
  
  .suscripcion-support-row {
    grid-template-columns: 1fr !important; /* Una sola columna para que los botones de soporte no se rompan */
    gap: 8px !important;
  }
  
  .badge-save {
    position: relative !important;
    top: -1px !important;
    right: auto !important;
    font-size: 0.6rem !important;
    padding: 2px 6px !important;
    margin-left: 6px !important;
  }
}

@keyframes suscripcionSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.suscripcion-icon-wrapper {
  width: 72px;
  height: 72px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  color: #ef4444;
  font-size: 2rem;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
  animation: pulseLock 2s infinite;
}

@keyframes pulseLock {
  0% { transform: scale(1); box-shadow: 0 0 20px rgba(239, 68, 68, 0.2); }
  50% { transform: scale(1.05); box-shadow: 0 0 35px rgba(239, 68, 68, 0.4); }
  100% { transform: scale(1); box-shadow: 0 0 20px rgba(239, 68, 68, 0.2); }
}

.suscripcion-card h2 {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: -0.5px;
  color: #f8fafc;
}

.suscripcion-card p {
  color: #94a3b8;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0 auto 30px;
  max-width: 440px;
}

/* Selector de Planes Premium */
.plan-selector-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 30px;
  text-align: left;
}

.plan-card {
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

/* --- CONTEXTO CLARO (Pestaña Facturación) --- */
#page_facturacion .plan-card {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
}

#page_facturacion .plan-card:hover {
  background: #f1f5f9;
  border-color: rgba(0, 123, 255, 0.3);
}

#page_facturacion .plan-card.active {
  background: rgba(0, 123, 255, 0.06);
  border-color: #007bff;
  box-shadow: 0 8px 24px rgba(0, 123, 255, 0.1);
}

#page_facturacion .plan-title {
  color: #1e293b;
  font-weight: 700;
  font-size: 1.05rem;
}

#page_facturacion .plan-desc {
  color: #64748b;
  font-size: 0.8rem;
  margin-top: 2px;
}

#page_facturacion .plan-card.active .plan-desc {
  color: #2563eb;
}

#page_facturacion .price-amount {
  color: #0f172a;
  font-size: 1.25rem;
  font-weight: 800;
}

#page_facturacion .price-period {
  color: #64748b;
  font-size: 0.75rem;
}

#page_facturacion .plan-card.active .price-period {
  color: #2563eb;
}

/* --- CONTEXTO OSCURO (Overlay Suscripción Expirada) --- */
#suscripcion-vencida-overlay .plan-card {
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid rgba(255, 255, 255, 0.08);
}

#suscripcion-vencida-overlay .plan-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(0, 123, 255, 0.3);
}

#suscripcion-vencida-overlay .plan-card.active {
  background: rgba(0, 123, 255, 0.15);
  border-color: #007bff;
  box-shadow: 0 8px 24px rgba(0, 123, 255, 0.25);
}

#suscripcion-vencida-overlay .plan-title {
  color: #f8fafc;
  font-weight: 700;
  font-size: 1.05rem;
}

#suscripcion-vencida-overlay .plan-desc {
  color: #94a3b8;
  font-size: 0.8rem;
  margin-top: 2px;
}

#suscripcion-vencida-overlay .plan-card.active .plan-desc {
  color: #93c5fd;
}

#suscripcion-vencida-overlay .price-amount {
  color: #f8fafc;
  font-size: 1.25rem;
  font-weight: 800;
}

#suscripcion-vencida-overlay .price-period {
  color: #94a3b8;
  font-size: 0.75rem;
}

#suscripcion-vencida-overlay .plan-card.active .price-period {
  color: #93c5fd;
}

.plan-card-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.plan-radio {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(148, 163, 184, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.plan-card.active .plan-radio {
  border-color: #007bff;
}

.plan-radio::after {
  content: '';
  width: 10px;
  height: 10px;
  background-color: #007bff;
  border-radius: 50%;
  transform: scale(0);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.plan-card.active .plan-radio::after {
  transform: scale(1);
}

.plan-info {
  display: flex;
  flex-direction: column;
}

.plan-price {
  text-align: right;
  display: flex;
  flex-direction: column;
}

.badge-save {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  font-weight: 800;
  font-size: 0.65rem;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
  position: relative;
  top: -1px;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2);
  white-space: nowrap;
}

/* Acciones */
.suscripcion-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.btn-epayco-pay {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white !important;
  font-weight: 700;
  font-size: 1rem;
  padding: 14px 28px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s ease;
  box-shadow: 0 8px 20px rgba(249, 115, 22, 0.25);
}

.btn-epayco-pay:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(249, 115, 22, 0.4);
  background: linear-gradient(135deg, #ea580c, #c2410c);
}

.btn-epayco-pay:active {
  transform: translateY(0);
}

.suscripcion-support-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-sub-action {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0 !important;
  padding: 11px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-sub-action:hover {
  transform: translateY(-1px);
}

.btn-sub-action.whatsapp-btn:hover {
  background: rgba(34, 197, 94, 0.1) !important;
  border-color: rgba(34, 197, 94, 0.45) !important;
  color: #4ade80 !important;
  box-shadow: 0 4px 15px rgba(34, 197, 94, 0.15);
}

.btn-sub-action.email-btn:hover {
  background: rgba(59, 130, 246, 0.1) !important;
  border-color: rgba(59, 130, 246, 0.45) !important;
  color: #60a5fa !important;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.15);
}

.suscripcion-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 20px;
  margin-top: 20px;
}

.btn-sub-logout {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s ease;
}

.btn-sub-logout:hover {
  color: #ef4444;
}

/* =============================================
   7. SISTEMA DE REJILLA Y CORRECCIONES ADICIONALES
   ============================================= */

/* Sistema de rejilla para organizar formularios */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}


/* CorrecciÃ³n para los Ã­conos de lupa en los modales */
.search-box svg {
  width: 20px;
  height: 20px;
}

/* =============================================
   8. CORRECCIONES FINALES DE LAYOUT Y VISIBILIDAD
   ============================================= */

/* 1. Ocultar el menÃº de hamburguesa en escritorio y mostrarlo en mÃ³vil */
.mobile-menu-btn {
  display: none;
  background: var(--white);
  border: 1px solid var(--line);
  padding: 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: var(--dark);
  align-items: center;
  justify-content: center;
  height: 2.5rem;
  width: 2.5rem;
  box-sizing: border-box;
}

/* 11. ESTILOS PARA LA BARRA DE SCROLL DEL MENÚ */
.sidebar-nav::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background-color: #4b5563; border-radius: 20px; border: 2px solid #111827; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background-color: #6b7280; }
.sidebar-nav { scrollbar-width: thin; scrollbar-color: #4b5563 #111827; }

/* 12. CORRECCIÓN VISUAL PARA RESPONSABILIDADES FISCALES */
.responsibilities-container { border: 1px solid var(--line); background-color: var(--light); border-radius: 8px; padding: 8px; min-height: 45px; display: flex; flex-wrap: wrap; gap: 8px; }

/* 13. TRANSICIÓN SUAVE PARA MODAL DE PRODUCTO */
.collapsible-section { max-height: 0; opacity: 0; overflow: hidden; margin-top: 0 !important; padding-top: 0; padding-bottom: 0; transition: all 0.4s ease-in-out; }
.collapsible-section.visible { max-height: 150px; opacity: 1; margin-top: 16px !important; }

/* 14. MEJORAS PARA MODALES ALTOS (CON SCROLL) */
.modal-box { display: flex; flex-direction: column; max-height: 90vh; }
.modal-body { overflow-y: auto; flex-grow: 1; padding: 1rem 0; }
.modal-header, .modal-box .toolbar { flex-shrink: 0; }

/* 15. ESTILOS PARA EL MENÚ MÓVIL (HAMBURGUESA) */
.sidebar-overlay { position: fixed; inset: 0; background-color: rgba(0, 0, 0, 0.5); z-index: 1999; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.sidebar-overlay.active { opacity: 1; visibility: visible; }
/* 2. Informacion del usuario en sesion */
.current-user-info {
  font-size: 13px;
  color: var(--light);
  opacity: 0.8;
  margin-bottom: 0.5rem;
  word-break: break-all;
}

/* 3. Items en modal de Responsabilidades */
#responsabilidadesList .item-card { display: block; }

/* 4. Footer dentro del contenido principal */
.main-content footer {
  background: var(--white);
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 0.75rem 2rem;
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.main-content footer a { color: var(--primary); text-decoration: none; }

/* 9. Toggle views y config grid */
.toggle-view { display: none; }
.toggle-view.active { display: block; animation: fadeIn 0.4s ease-out; }
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 1.5rem; }

/* 10. FAQ, Tickets y Soporte */
fieldset { border: none; padding: 0; margin: 0; }
.faq-item, .ticket-item { margin-bottom: 1rem; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background-color: var(--white); }
.faq-item summary, .ticket-item summary { font-weight: 600; padding: 1rem 1.5rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: var(--transition); }
.faq-item details[open] summary, .ticket-item details[open] summary { background-color: var(--light); color: var(--primary); }
.faq-item p, .ticket-item .ticket-content { color: var(--muted); padding: 0 1.5rem 1.5rem; }
.ticket-summary-info { display: flex; flex-direction: column; }
.ticket-summary-info small { font-size: 0.8rem; color: var(--muted); }
.ticket-content strong { color: var(--dark); }
.ticket-response { margin-top: 1rem; padding: 1rem; background-color: #f0f0f0; border-radius: 8px; }
.ticket-response small { display: block; margin-top: 0.5rem; font-size: 0.8rem; color: var(--muted); }

/* Estado de Cuenta */
.summary-gastos { margin-bottom: 1.5rem; background-color: var(--primary-light); text-align: center; }
.ec-filters { justify-content: space-between; align-items: flex-end; margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
#modalEstadoCuenta .items-container { width: 97%; box-sizing: border-box; }

/* Boton de ayuda contextual */
.help-button { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background-color: transparent; border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: 1rem; font-weight: bold; transition: all 0.3s ease; flex-shrink: 0; }
.help-button:hover { background-color: var(--primary); color: var(--white); border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3); }

/* Status cell y dropdown menu */
.status-cell { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; justify-content: flex-end; }
.status-menu-container { position: relative; display: inline-block; }
.status-menu-trigger { background-color: transparent; border: 1px solid var(--line); color: var(--muted); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; }
.status-menu-trigger:hover { background-color: var(--light); color: var(--dark); }
.status-dropdown-menu { display: none; position: absolute; right: 0; top: calc(100% + 5px); z-index: 10; background-color: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; width: 220px; animation: fadeIn 0.2s ease-out; }
.status-dropdown-menu.active { display: block; position: fixed !important; z-index: 9999 !important; }
.status-dropdown-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.85rem; border: none; background: none; width: 100%; text-align: left; cursor: pointer; font-size: 0.82rem; }
.status-dropdown-item:hover { background-color: var(--primary-light); color: var(--primary); }
.status-dropdown-item i { width: 16px; }

/* Tooltip informativo */
.tooltip-container { position: relative; display: inline-flex; align-items: center; gap: 0.5rem; }
.tooltip-container .tooltip-text { visibility: hidden; width: 280px; background-color: var(--dark); color: var(--white); border-radius: 8px; padding: 1rem; position: absolute; z-index: 1; bottom: 125%; left: 50%; margin-left: -140px; opacity: 0; transition: opacity 0.3s; font-size: 0.9rem; line-height: 1.5; }
.tooltip-container .tooltip-text::after { content: ""; position: absolute; top: 100%; left: 50%; border-width: 5px; border-style: solid; border-color: var(--dark) transparent transparent transparent; }
.tooltip-container:hover .tooltip-text { visibility: visible; opacity: 1; }
.info-icon { cursor: help; color: var(--muted); }

/* Validador de contrasena */
.password-rules { list-style: none; padding: 0; margin: 0.75rem 0 0 0.5rem; max-height: 0; opacity: 0; overflow: hidden; transition: all 0.4s ease-in-out; }
.password-rules.visible { max-height: 200px; opacity: 1; }
.password-rules li { color: var(--muted); transition: all 0.3s ease; padding-left: 1.5rem; position: relative; margin-bottom: 0.25rem; }
.password-rules li::before { content: 'x'; position: absolute; left: 0; font-weight: bold; }
.password-rules li.valid { color: var(--success); }
.password-rules li.valid::before { content: 'v'; color: var(--success); }

/* Onboarding wizard */
.onboarding-step { animation: fadeIn 0.5s ease-out; }

/* Truncar texto de usuario */
.user-info { flex: 1; min-width: 0; }
#currentUserDisplay { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }

/* Cuadro de totales dark mode */
body.dark-mode .total-box { background-color: #2a2a2a; color: #e5e5e5; }
body.dark-mode .total-box span[style*="border-top"] { border-color: #444 !important; }

/* Opciones de impuestos */
.tax-options-box { display: flex; flex-direction: column; gap: 10px; background-color: var(--light); padding: 12px; border-radius: var(--radius); }
body.dark-mode .tax-options-box { background-color: #2a2a2a; }

/* (Login compacto legacy removido — ver AUTH WALL más abajo) */

/* =============================================
   DARK MODE COMPLETO
   ============================================= */
body.dark-mode { 
  background-color: #121212; 
  color: #e5e5e5; 
  --light: #121212;
  --bg: #121212;
  --white: #1e1e1e;
  --line: #333333;
  --dark: #f5f5f5;
  --ink: #f5f5f5;
  --muted: #888888;
}

body.dark-mode .form-section {
  background-color: #1e1e1e !important;
  color: #f5f5f5 !important;
  border: 1px solid #333 !important;
}

body.dark-mode .form-section-title {
  color: #4da3ff !important;
  border-bottom: 1px solid #333 !important;
}
body.dark-mode .card { background-color: #1e1e1e; color: #f5f5f5; border: 1px solid #333; }
body.dark-mode .sidebar { background-color: #0d1117; }
body.dark-mode .nav-link.active::before { background-color: var(--primary-light); }
body.dark-mode input, body.dark-mode select, body.dark-mode textarea { background-color: #1e1e1e; color: #f5f5f5; border: 1px solid #444; }
body.dark-mode input::placeholder, body.dark-mode textarea::placeholder { color: #888; }
body.dark-mode fieldset:disabled { background-color: #2a2a2a; opacity: 0.7; }
body.dark-mode table { color: #e5e5e5; background-color: #1e1e1e; }
body.dark-mode thead { background-color: #2a2a2a; color: #ffffff; }
body.dark-mode th, body.dark-mode td { border-color: #444; }
body.dark-mode footer, body.dark-mode .footer { background-color: #0d1117; color: #aaa; }
body.dark-mode footer a, body.dark-mode .footer a { color: var(--primary); }
body.dark-mode label { color: #ddd; }
body.dark-mode .btn.primary { background-color: var(--primary); border-color: var(--primary-dark); color: #fff; }
body.dark-mode .btn.primary:hover { background-color: var(--primary-dark); }
body.dark-mode .faq-item, body.dark-mode .faq-answer { background-color: #1e1e1e; color: #e5e5e5; border: 1px solid #333; }
body.dark-mode .faq-question { color: #4da3ff; }
body.dark-mode .faq-answer strong { color: #fff; }
body.dark-mode input[type="date"] { background-color: #1e1e1e; color: #f5f5f5; border: 1px solid #444; }
body.dark-mode input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); }
body.dark-mode .login-container { background-color: #121212; color: #f5f5f5; }
body.dark-mode .login-card { background-color: #1e1e1e; border: 1px solid #333; color: #e5e5e5; }
body.dark-mode .login-card h2, body.dark-mode .login-card h3 { color: #fff; }
body.dark-mode .login-card input { background-color: #222; color: #eee; border: 1px solid #444; }
body.dark-mode .login-card input::placeholder { color: #aaa; }
body.dark-mode .ticket-item { background-color: #1e1e1e; border: 1px solid #333; color: #eee; }
body.dark-mode .ticket-item .ticket-header { color: #4da3ff; }
body.dark-mode .ticket-message { background-color: #2a2a2a; color: #ddd; border: 1px solid #444; }
body.dark-mode fieldset:disabled { opacity: 0.5; }
body.dark-mode .item-card { background-color: #1e1e1e; color: #eee; border: 1px solid #333; }
body.dark-mode .item-card:hover { background-color: #2a2a2a; color: #4da3ff; }
body.dark-mode .item-card.selected { background-color: #333 !important; color: #4da3ff !important; border-color: #555; }
body.dark-mode #toggle-theme-btn:hover { background-color: rgba(255,255,255,0.1); color: #4da3ff; border-radius: 8px; }
body.dark-mode #em_fecha_vencimiento { background-color: #1e1e1e !important; color: #f5f5f5 !important; border: 1px dashed #555 !important; }

/* =============================================
   GOLD MODE COMPLETO (Tema de Lujo)
   ============================================= */
body.gold-mode {
  background-color: #111111;
  color: #f5f5f5;
  --primary: #d4af37;
  --primary-dark: #aa8410;
  --primary-light: rgba(212, 175, 55, 0.15);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --dark: #f5f5f5;
  --light: #111111;
  --bg: #111111;
  --white: #1c1917;
  --line: rgba(212, 175, 55, 0.25);
  --ink: #f5f5f5;
  --muted: #a8a29e;
}

body.gold-mode .card,
body.gold-mode .form-section,
body.gold-mode .dashboard-panel {
  background-color: #1c1917 !important;
  color: #f5f5f5 !important;
  border: 1px solid rgba(212, 175, 55, 0.25) !important;
  box-shadow: 0 8px 32px rgba(212, 175, 55, 0.05) !important;
}

body.gold-mode .sidebar {
  background-color: #0c0a09 !important;
  border-right: 1px solid rgba(212, 175, 55, 0.15) !important;
}

body.gold-mode input, 
body.gold-mode select, 
body.gold-mode textarea {
  background-color: #292524 !important;
  color: #f5f5f5 !important;
  border: 1px solid rgba(212, 175, 55, 0.3) !important;
}

body.gold-mode input:focus, 
body.gold-mode select:focus, 
body.gold-mode textarea:focus {
  border-color: #d4af37 !important;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.25) !important;
}

body.gold-mode .nav-link.active {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(212, 175, 55, 0.05)) !important;
  color: #d4af37 !important;
  border-left: 3px solid #d4af37 !important;
}

body.gold-mode .nav-link.active i {
  color: #d4af37 !important;
}

body.gold-mode .btn.primary {
  background: linear-gradient(135deg, #f59e0b, #d4af37) !important;
  border-color: #aa8410 !important;
  color: #000 !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.2) !important;
}

body.gold-mode .btn.primary:hover {
  background: linear-gradient(135deg, #d4af37, #f59e0b) !important;
  transform: translateY(-1px) !important;
}

body.gold-mode label {
  color: #e7e5e4 !important;
}

body.gold-mode .form-section-title {
  color: #d4af37 !important;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2) !important;
}

body.gold-mode .total-box {
  background-color: #292524 !important;
  color: #f5f5f5 !important;
  border: 1px solid rgba(212, 175, 55, 0.2) !important;
}

body.gold-mode .faq-item, 
body.gold-mode .faq-answer {
  background-color: #1c1917 !important;
  color: #f5f5f5 !important;
  border: 1px solid rgba(212, 175, 55, 0.2) !important;
}

body.gold-mode .faq-question {
  color: #d4af37 !important;
}

body.gold-mode #toggle-theme-btn:hover {
  background-color: rgba(212, 175, 55, 0.15) !important;
  color: #d4af37 !important;
  border-radius: 8px !important;
}

/* Corrección de la tarjeta destacada en Modo Gold (Utilidad Neta) */
body.gold-mode .stat-card--highlight {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.15) 0%, #1c1917 100%) !important;
  border-left-color: #d4af37 !important;
}

body.gold-mode .stat-card {
  border: 1px solid rgba(212, 175, 55, 0.25) !important;
}

/* Modo Gold — Inicio de Sesión y Registro */
body.gold-mode .login-container {
  background-color: #111111 !important;
  color: #f5f5f5 !important;
}

body.gold-mode .auth-card {
  background: #1c1917 !important;
  border: 1px solid rgba(212, 175, 55, 0.25) !important;
  box-shadow: 0 8px 32px rgba(212, 175, 55, 0.08) !important;
  color: #f5f5f5 !important;
}

body.gold-mode .auth-card h2,
body.gold-mode .auth-card h3 {
  color: #d4af37 !important;
}

body.gold-mode .auth-tagline,
body.gold-mode .auth-reset-desc {
  color: #a8a29e !important;
}

body.gold-mode .auth-tabs {
  background: #0c0a09 !important;
  border: 1px solid rgba(212, 175, 55, 0.2) !important;
}

body.gold-mode .auth-tab {
  color: #a8a29e !important;
}

body.gold-mode .auth-tab.active {
  background: rgba(212, 175, 55, 0.2) !important;
  color: #d4af37 !important;
}

body.gold-mode .auth-field label {
  color: #e7e5e4 !important;
}

body.gold-mode .auth-input {
  background: #292524 !important;
  color: #f5f5f5 !important;
  border-color: rgba(212, 175, 55, 0.3) !important;
}

body.gold-mode .auth-input:focus {
  border-color: #d4af37 !important;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2) !important;
  background: #292524 !important;
}

body.gold-mode .auth-btn {
  background: linear-gradient(135deg, #f59e0b, #d4af37) !important;
  color: #000 !important;
  font-weight: 700 !important;
}

body.gold-mode .auth-btn:hover {
  background: linear-gradient(135deg, #d4af37, #f59e0b) !important;
}

body.gold-mode .auth-link {
  color: #d4af37 !important;
}

/* =============================================
   CORRECCIONES CLARO/OSCURO PARA SELECTOR DE PLANES (Evitar oscuros invisibles)
   ============================================= */
body.dark-mode #page_facturacion .plan-card,
body.gold-mode #page_facturacion .plan-card {
  background: #1e1e1e !important;
  border-color: #333333 !important;
}

body.dark-mode #page_facturacion .plan-card:hover,
body.gold-mode #page_facturacion .plan-card:hover {
  background: #2a2a2a !important;
  border-color: rgba(0, 123, 255, 0.4) !important;
}

body.dark-mode #page_facturacion .plan-card.active {
  background: rgba(0, 123, 255, 0.15) !important;
  border-color: #007bff !important;
  box-shadow: 0 8px 24px rgba(0, 123, 255, 0.25) !important;
}

body.gold-mode #page_facturacion .plan-card.active {
  background: rgba(212, 175, 55, 0.15) !important;
  border-color: #d4af37 !important;
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.25) !important;
}

body.dark-mode #page_facturacion .plan-title,
body.gold-mode #page_facturacion .plan-title {
  color: #f8fafc !important;
}

body.dark-mode #page_facturacion .plan-desc,
body.gold-mode #page_facturacion .plan-desc {
  color: #94a3b8 !important;
}

body.dark-mode #page_facturacion .plan-card.active .plan-desc {
  color: #93c5fd !important;
}

body.gold-mode #page_facturacion .plan-card.active .plan-desc {
  color: #fef08a !important;
}

body.dark-mode #page_facturacion .price-amount,
body.gold-mode #page_facturacion .price-amount {
  color: #f8fafc !important;
}

body.dark-mode #page_facturacion .price-period,
body.gold-mode #page_facturacion .price-period {
  color: #94a3b8 !important;
}

body.dark-mode #page_facturacion .plan-card.active .price-period {
  color: #93c5fd !important;
}

body.gold-mode #page_facturacion .plan-card.active .price-period {
  color: #fef08a !important;
}

/* Toggle de tema */
#toggle-theme-btn { transition: background-color 0.3s ease, color 0.3s ease; }
#toggle-theme-btn svg { width: 26px; height: 26px; transition: transform 0.4s ease, opacity 0.3s ease; }
#toggle-theme-btn:hover svg { transform: rotate(25deg) scale(1.1); }
body:not(.dark-mode) #toggle-theme-btn:hover { background-color: rgba(0,0,0,0.08); color: var(--primary); border-radius: 8px; }

/* Animacion nav links */
.sidebar-nav .nav-link { position: relative; transition: all 0.3s ease; }
.sidebar-nav .nav-link:hover { background-color: var(--primary-light); color: #3c4fe2; border-radius: 8px; }

/* Fecha de vencimiento */
#em_fecha_vencimiento { color: var(--dark); }

/* Item-card en modales (modo claro) */
.item-card { background-color: #f9f9f9; color: #222; padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 0.5rem; cursor: pointer; transition: all 0.3s ease; }
.item-card:hover { background-color: #e6f0ff; color: #000; }
.item-card.selected { background-color: #007bff; color: #fff; }

/* Tablas optimizacion tablet */
@media (max-width: 1024px) {
  .historial-card { overflow-x: auto; }
  .card table { display: block; width: 100%; overflow-x: auto; white-space: nowrap; }
  .card table td .btn { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
  .card table td .btn svg { width: 18px; height: 18px; }
}

/* Secciones de formulario */
.form-section { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 2px 10px rgba(0,0,0,0.02); }
.form-section-title { font-size: 1.1rem; font-weight: 600; color: var(--ink); margin-bottom: 1.25rem; display: flex; align-items: center; gap: 0.5rem; border-bottom: 1px solid var(--line); padding-bottom: 0.75rem; }

/* Tablas responsivas */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 1rem; border-radius: 8px; border: 1px solid var(--line); }
.table-responsive table { margin-top: 0 !important; min-width: 800px; }

/* Iconos de accion en tablas */
.table-actions .btn-icon i.fa-pen-to-square { color: var(--primary); }
.table-actions .btn-icon i.fa-clock-rotate-left { color: #7c3aed; }

/* Graficos de reportes */
.report-chart-container { position: relative; height: 300px; width: 100%; }

/* Dashboard panels y gráficas */
.dashboard-panel {
  padding: 1.35rem 1.5rem !important;
}

.dashboard-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.dashboard-panel__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--dark);
}

.dashboard-panel__subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.dashboard-segmented {
  flex-shrink: 0;
  max-width: 100%;
}

.dashboard-segmented .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.dashboard-chart-wrap {
  position: relative;
  width: 100%;
  height: clamp(220px, 42vw, 320px);
  min-height: 200px;
}

.dashboard-chart-wrap--main {
  height: clamp(240px, 50vw, 340px);
}

.dashboard-table-wrap {
  margin: 0 -0.25rem;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.dashboard-empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem !important;
}

.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.dashboard-chart-card {
  padding: 1.25rem 1.35rem !important;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dashboard-chart-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.dashboard-chart-card__head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.dashboard-chart-card__badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.dashboard-chart-card .dashboard-chart-wrap {
  flex: 1;
  height: clamp(200px, 35vw, 260px);
}

/* Tablet & Laptop: dashboard */
@media (max-width: 1366px) {
  .dashboard-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 850px) {
  .dashboard-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-charts {
    grid-template-columns: 1fr;
  }

  .dashboard-filters__fields {
    grid-template-columns: 1fr 1fr;
    width: 100%;
    max-width: none;
  }

  .dashboard-filters__actions {
    width: 100%;
  }

  .dashboard-filters__actions .btn {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .dashboard-panel__head {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-segmented {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    border-radius: 12px;
  }

  .dashboard-segmented .btn {
    justify-content: center;
    padding: 0.65rem 0.5rem;
  }

  .dashboard-segmented .btn span {
    font-size: 0.8rem;
  }

  .dashboard-filters__inner {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-filters__fields {
    grid-template-columns: 1fr;
  }


}

@media (max-width: 520px) {
  .dashboard-kpis {
    grid-template-columns: 1fr !important;
  }

  .dashboard-segmented .btn i {
    display: none;
  }
}

body.dark-mode .dashboard-panel__title,
body.dark-mode .dashboard-chart-card__head h3 {
  color: #f1f5f9;
}

body.dark-mode .stat-card--highlight {
  background: linear-gradient(135deg, rgba(0, 123, 255, 0.15) 0%, #1e293b 100%);
}

body.dark-mode .dashboard-date-input {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

body.dark-mode .dashboard-table-wrap {
  border-color: #334155;
}

body.dark-mode .dashboard-chart-card__badge {
  background: rgba(0, 123, 255, 0.2);
  color: #93c5fd;
}


/* =============================================
   RESPONSIVE MOVIL - SIDEBAR Y LAYOUT
   ============================================= */

/* TABLET (1024px): sidebar contraida, solo iconos */
@media (max-width: 1024px) {
  .app-layout { grid-template-columns: 70px 1fr; }
  .sidebar { width: 70px; padding: 0.5rem; }
  .sidebar h1 img { width: 45px; height: auto; }
  .sidebar-nav .nav-link span { display: none; }
}

/* MOVIL (992px): sidebar fuera de pantalla, menu hamburguesa */
@media (max-width: 992px) {
  .mobile-menu-btn { display: flex !important; align-items: center; justify-content: center; }
  .app-layout { grid-template-columns: 1fr !important; }
  .sidebar {
    position: fixed;
    top: 4.5rem !important; /* Sale debajo del menú de cabecera desplegado */
    left: 0; bottom: 0;
    height: calc(100vh - 4.5rem) !important;
    transform: translateX(-100%);
    width: 260px !important;
    z-index: 2000;
    transition: transform 0.4s ease, width 0.3s ease;
    box-shadow: 10px 0 30px rgba(0,0,0,0.2);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-toggle { display: flex !important; }
  .main-content { grid-column: 1 / -1; padding-top: 4.5rem; }
  #currentUserDisplay { display: none !important; }
  .sidebar-overlay { top: 4.5rem !important; height: calc(100vh - 4.5rem) !important; }

  /* Cuando el sidebar esta ABIERTO y NO colapsado: mostrar icono + texto */
  .sidebar.mobile-open:not(.collapsed) .nav-link span {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    overflow: visible !important;
    white-space: nowrap;
  }

  /* Cuando esta COLAPSADO (solo iconos): ocultar texto siempre */
  .sidebar.collapsed .nav-link span { display: none !important; }
  .sidebar.collapsed { width: 70px !important; }
  .sidebar.collapsed .nav-link { justify-content: center; padding: 0.65rem 0; }
}

/* MOVIL PEQUENO (768px): cards, dashboard y formularios */
@media (max-width: 768px) {
  .main-content {
    padding: 1rem !important;
    padding-top: 5rem !important;
  }

  .dashboard-grid {
    gap: 1rem;
  }

  .dashboard-filters {
    padding: 1rem !important;
  }

  .stat-card {
    padding: 1rem 1.1rem !important;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4 {
    grid-template-columns: 1fr !important;
  }

  .form-section { padding: 1rem; }

  .main-content footer {
    flex-direction: column;
    text-align: center;
    padding: 0.75rem 1rem;
  }

  .toolbar { flex-wrap: wrap; }

  #toast-container {
    left: 1rem;
    right: 1rem;
    top: auto;
    bottom: 1rem;
  }

  .toast { min-width: unset; width: 100%; }
}

/* =============================================
   AUTH WALL — Login / Registro moderno
   ============================================= */
.auth-wall,
#login-wall {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 1.25rem;
  overflow-y: auto;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(0, 123, 255, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 90%, rgba(99, 102, 241, 0.12), transparent 50%),
    linear-gradient(160deg, #0f172a 0%, #1e293b 45%, #0f172a 100%);
}

.auth-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(340px, 440px);
  width: min(960px, 100%);
  max-height: min(720px, calc(100dvh - 2.5rem));
  border-radius: 20px;
  overflow: hidden;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  animation: fadeIn 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-brand {
  position: relative;
  padding: 2.5rem 2rem;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    linear-gradient(165deg, rgba(15, 23, 42, 0.88) 0%, rgba(0, 123, 255, 0.35) 50%, rgba(15, 23, 42, 0.95) 100%),
    url('../img/loginnubifica.jpg') center / cover no-repeat;
}

.auth-brand-logo {
  max-width: 160px;
  height: auto;
  margin-bottom: 1.75rem;
  filter: brightness(0) invert(1);
}

.auth-brand-title {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.auth-brand-text {
  font-size: 0.95rem;
  color: #cbd5e1;
  line-height: 1.55;
  max-width: 320px;
  margin-bottom: 1.75rem;
}

.auth-brand-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  font-size: 0.88rem;
  color: #e2e8f0;
}

.auth-brand-features li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.auth-brand-features i {
  color: #60a5fa;
  width: 1.1rem;
}

.auth-card {
  position: relative;
  background: #ffffff;
  padding: 1.75rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.auth-card-header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.auth-logo {
  max-width: 130px;
  height: auto;
  margin-bottom: 0.35rem;
}

.auth-tagline {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0;
}

.auth-legacy-title {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.35rem;
  background: #f1f5f9;
  border-radius: 12px;
  margin-bottom: 1.25rem;
}

.auth-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 0.75rem;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.auth-tab:hover {
  color: var(--dark);
}

.auth-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.auth-panel {
  display: none;
  flex-direction: column;
  animation: authPanelIn 0.3s ease;
}

.auth-panel.auth-panel--active {
  display: flex;
}

.auth-panel--signup {
  max-height: min(52vh, 420px);
  overflow-y: auto;
  padding-right: 0.25rem;
  scrollbar-width: thin;
}

@keyframes authPanelIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.auth-field--full {
  grid-column: 1 / -1;
}

.auth-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 0.85rem;
  color: #94a3b8;
  font-size: 0.9rem;
  pointer-events: none;
}

.auth-input-wrap .auth-input {
  padding-left: 2.5rem;
  padding-right: 2.75rem;
}

.auth-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--dark);
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.auth-input:hover {
  border-color: #cbd5e1;
}

.auth-input:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.auth-input[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fff5f5;
}

.auth-field--valid .auth-input:not(:focus) {
  border-color: #86efac;
}

.auth-pwd-toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
  line-height: 1;
}

.auth-pwd-toggle:hover {
  color: var(--primary);
}

.auth-field-hint {
  font-size: 0.75rem;
  color: var(--danger);
  min-height: 1rem;
}

.auth-password-rules {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

.auth-alert,
.login-error-message,
#login-error,
#login-signup-error,
#reset-error {
  font-size: 0.82rem;
  font-weight: 500;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  text-align: center;
  margin: 0;
}

.auth-alert[hidden],
#login-error[hidden],
#login-signup-error[hidden],
#reset-error[hidden] {
  display: none !important;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.85rem 1.25rem;
  border: none;
  border-radius: 11px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}

.auth-btn--primary,
#login-button,
#fs-register-button,
#send-reset-link-button {
  background: linear-gradient(135deg, var(--primary) 0%, #0056b3 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 123, 255, 0.35);
}

.auth-btn--primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 123, 255, 0.4);
}

.auth-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.auth-link,
#recover-password-link {
  display: block;
  text-align: center;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--primary) !important;
  text-decoration: none;
  font-weight: 500;
}

.auth-link:hover,
#recover-password-link:hover {
  text-decoration: underline;
}

.auth-captcha {
  padding: 0.85rem;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
}

.auth-captcha-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.auth-captcha-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.auth-captcha-equation {
  flex-shrink: 0;
  padding: 0.5rem 0.85rem;
  background: rgba(0, 123, 255, 0.08);
  border: 1px dashed rgba(0, 123, 255, 0.25);
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
  min-width: 5.5rem;
  text-align: center;
}

.auth-captcha-input {
  max-width: 5.5rem;
  text-align: center;
}

.auth-captcha-refresh {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.auth-captcha-refresh:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.auth-reset {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.75rem;
  background: rgba(255, 255, 255, 0.98);
  text-align: center;
}

.auth-reset[hidden] {
  display: none !important;
}

.auth-reset-back {
  align-self: flex-start;
  margin-bottom: 1rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: inherit;
}

.auth-reset-back:hover {
  color: var(--primary);
}

.auth-reset-logo {
  max-width: 110px;
  margin-bottom: 1rem;
}

.auth-reset h3 {
  font-size: 1.25rem;
  margin-bottom: 0.35rem;
  color: var(--dark);
}

.auth-reset-desc {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  max-width: 280px;
}

.auth-reset .auth-form {
  width: 100%;
  max-width: 320px;
}

/* Dark mode — auth */
body.dark-mode .auth-card {
  background: #1e293b;
}
body.dark-mode .auth-tagline,
body.dark-mode .auth-reset-desc {
  color: #94a3b8;
}
body.dark-mode .auth-tabs {
  background: #0f172a;
}
body.dark-mode .auth-tab.active {
  background: #334155;
  color: #93c5fd;
}
body.dark-mode .auth-field label {
  color: #e2e8f0;
}
body.dark-mode .auth-input {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}
body.dark-mode .auth-input:focus {
  background: #1e293b;
}
body.dark-mode .auth-captcha {
  background: #0f172a;
  border-color: #475569;
}
body.dark-mode .auth-reset {
  background: rgba(30, 41, 59, 0.98);
}
body.dark-mode .auth-reset h3 {
  color: #f1f5f9;
}

@media (max-width: 768px) {
  .auth-shell {
    grid-template-columns: 1fr;
    max-height: none;
  }
  .auth-brand {
    display: none;
  }
  .auth-card {
    padding: 1.5rem 1.25rem 1.75rem;
  }
  .auth-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .auth-wall,
  #login-wall {
    padding: 0.75rem;
    align-items: flex-start;
    padding-top: 1.25rem;
  }
  .auth-shell {
    border-radius: 16px;
  }
  .auth-tab {
    font-size: 0.8rem;
    padding: 0.55rem 0.4rem;
  }
  .auth-tab i {
    display: none;
  }
}

/* Notificaciones (Campana) */
.notif-wrapper {
    position: relative;
    display: inline-block;
}

.notif-panel {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: -10px;
    width: 320px;
    background-color: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 1000;
    border: 1px solid var(--line);
    overflow: hidden;
    transform-origin: top right;
    animation: fadeInScale 0.2s ease-out forwards;
}

.notif-panel.open {
    display: flex;
    flex-direction: column;
}

.notif-panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg);
}

.notif-panel-header span {
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.notif-panel-header button {
    font-size: 0.8rem;
    padding: 4px 8px;
    color: var(--primary);
}

.notif-lista {
    max-height: 350px;
    overflow-y: auto;
}

.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-item:hover {
    background-color: var(--light);
}

.notif-item.unread {
    background-color: rgba(37, 99, 235, 0.05);
    border-left: 3px solid var(--primary);
}

.notif-item-title {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
}

.notif-item-body {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.4;
}

.notif-item-time {
    font-size: 0.75rem;
    color: var(--muted);
    align-self: flex-end;
}

.notif-empty {
    padding: 30px;
    text-align: center;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.notif-empty i {
    font-size: 2rem;
    opacity: 0.5;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* =============================================
   ONBOARDING WIZARD STYLES (MODERN & RESPONSIVE)
   ============================================= */
#onboarding-wizard {
    background: rgba(15, 23, 42, 0.5) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    transition: all 0.3s ease-in-out;
    align-items: flex-start !important;
    overflow-y: auto !important;
    padding: 3rem 1rem !important;
}

#onboarding-wizard .modal-box {
    background: #ffffff !important;
    border: 1px solid rgba(226, 232, 240, 0.8) !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15) !important;
    border-radius: 24px !important;
    padding: 2.5rem !important;
    max-width: 680px !important;
    width: calc(100% - 3rem) !important;
    margin: 2rem auto !important;
    border-top: 6px solid var(--primary) !important;
    max-height: none !important;
    display: block !important;
    height: auto !important;
}

.onboarding-stepper {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 3rem !important;
    position: relative !important;
    padding: 0 1.5rem !important;
}

.onboarding-stepper::before {
    content: '' !important;
    position: absolute !important;
    top: 22px !important;
    left: 15% !important;
    right: 15% !important;
    height: 3px !important;
    background: #e2e8f0 !important;
    z-index: 1 !important;
    border-radius: 2px !important;
}

.step-indicator {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 0.75rem !important;
    position: relative !important;
    z-index: 2 !important;
    flex: 1 !important;
    text-align: center !important;
}

.step-dot {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    border: 3px solid #e2e8f0 !important;
    color: #64748b !important;
    font-weight: 700 !important;
    font-size: 1.05rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05) !important;
}

.step-label {
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    color: #64748b !important;
    transition: all 0.3s ease !important;
}

/* Active Step */
.step-indicator.active .step-dot {
    border-color: var(--primary) !important;
    background: var(--primary) !important;
    color: #ffffff !important;
    transform: scale(1.15) !important;
    box-shadow: 0 8px 16px -4px rgba(0, 123, 255, 0.35) !important;
}

.step-indicator.active .step-label {
    color: var(--primary) !important;
    font-weight: 700 !important;
}

/* Completed Step */
.step-indicator.completed .step-dot {
    border-color: #10b981 !important;
    background: #10b981 !important;
    color: #ffffff !important;
}

.step-indicator.completed .step-label {
    color: #10b981 !important;
}

/* Steps and Transitions */
.onboarding-step {
    display: none !important;
    opacity: 0 !important;
}

.onboarding-step.active {
    display: block !important;
    opacity: 1 !important;
    animation: fadeInStep 0.4s ease-out forwards !important;
}

@keyframes fadeInStep {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header inside Onboarding */
.onboarding-header {
    text-align: center !important;
    margin-bottom: 2.25rem !important;
}

.onboarding-header i {
    font-size: 2.5rem !important;
    color: var(--primary) !important;
    margin-bottom: 0.85rem !important;
    display: inline-block !important;
    background: var(--primary-light) !important;
    padding: 1.1rem !important;
    border-radius: 20px !important;
    box-shadow: 0 6px 12px -3px rgba(0, 123, 255, 0.15) !important;
}

.onboarding-header h3 {
    font-size: 1.45rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    margin-bottom: 0.4rem !important;
    letter-spacing: -0.02em !important;
}

.onboarding-header p.mini {
    font-size: 0.92rem !important;
    color: #64748b !important;
}

/* Grid within Form */
.grid.cols-2 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1.25rem !important;
}

.form-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.45rem !important;
}

.form-group label {
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    color: #475569 !important;
    margin-bottom: 0.1rem !important;
}

.form-group input, .form-group select {
    border-radius: 12px !important;
    border: 1px solid #cbd5e1 !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.95rem !important;
    color: #0f172a !important;
    background: #ffffff !important;
    transition: all 0.2s ease !important;
    outline: none !important;
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.1) !important;
}

/* Special logo picker styles */
.logo-upload-container {
    border: 2px dashed #cbd5e1 !important;
    padding: 2rem !important;
    border-radius: 20px !important;
    background: #f8fafc !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    width: 100% !important;
    max-width: 240px !important;
}

.logo-upload-container:hover {
    border-color: var(--primary) !important;
    background: #eff6ff !important;
}

.logo-preview {
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.08) !important;
    transition: transform 0.3s ease !important;
}

.logo-preview:hover {
    transform: scale(1.04) !important;
}

/* Responsiveness for Onboarding */
@media (max-width: 640px) {
    #onboarding-wizard .modal-box {
        padding: 1.5rem !important;
        margin: 1rem auto !important;
        width: calc(100% - 2rem) !important;
        border-radius: 20px !important;
        max-height: none !important;
        display: block !important;
        height: auto !important;
    }

    .onboarding-stepper {
        margin-bottom: 2rem !important;
        padding: 0 0.5rem !important;
    }

    .onboarding-stepper::before {
        top: 16px !important;
        left: 10% !important;
        right: 10% !important;
    }

    .step-dot {
        width: 34px !important;
        height: 34px !important;
        font-size: 0.9rem !important;
        border-width: 2px !important;
    }

    .step-indicator {
        gap: 0.45rem !important;
    }

    .step-label {
        font-size: 0.72rem !important;
    }

    .grid.cols-2 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        width: 100% !important;
    }

    .onboarding-header h3 {
        font-size: 1.25rem !important;
    }

    .onboarding-header i {
        font-size: 2.2rem !important;
        padding: 0.9rem !important;
    }
}

/* ==========================================================================
   Nubifica Premium Responsiveness & Mobile-First Enhancements
   ========================================================================== */

/* Tablet & Smaller Screens General Layout */
@media (max-width: 992px) {
  /* 1. Fixed, Glassmorphic Top User Header Bar */
  .top-user-bar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 4.5rem !important;
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8) !important;
    z-index: 1500 !important;
    padding: 0 1.5rem !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05) !important;
  }
  
  body.dark-mode .top-user-bar {
    background: rgba(17, 24, 39, 0.85) !important;
    border-bottom: 1px solid rgba(55, 65, 81, 0.8) !important;
  }

  /* 2. Hamburger Menu: part of flex flow inside top user bar on mobile */
  .mobile-menu-btn {
    position: static !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 2.5rem !important;
    width: 2.5rem !important;
    border-radius: 8px !important;
    background: var(--white) !important;
    border: 1px solid var(--line) !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05) !important;
    color: var(--ink) !important;
  }
  
  body.dark-mode .mobile-menu-btn {
    background: #1f2937 !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
  }

  /* 3. Push user info display next to hamburger to look organic */
  .user-info {
    display: flex !important;
    margin-left: 0 !important;
    font-size: 0.85rem !important;
    cursor: pointer !important;
    transition: transform 0.2s ease, opacity 0.2s ease !important;
  }
  .user-info:hover {
    transform: scale(1.05) !important;
    opacity: 0.95 !important;
  }

  /* 4. Pad main content to fit the fixed header bar */
  .main-content {
    padding-top: 6.5rem !important;
  }

  #global-banner {
    position: fixed !important;
    top: 4.5rem !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1400 !important;
  }
  body.has-global-banner .main-content {
    padding-top: 10.5rem !important;
  }
  /* 5. Restore full-size logo when sidebar is open on mobile
     (overrides the 1024px rule that shrinks .sidebar h1 img to 45px) */
  .sidebar.mobile-open h1 img,
  .sidebar.mobile-open .sidebar-logo {
    width: 100% !important;
    max-width: 160px !important;
    height: auto !important;
    display: block !important;
    opacity: 1 !important;
  }
  .sidebar.mobile-open .sidebar-logo-mini {
    display: none !important;
  }
  .sidebar.mobile-open .sidebar-header {
    flex-direction: row !important;
    padding: 0.75rem 1rem !important;
  }
  .sidebar.mobile-open .sidebar-header h1 {
    width: auto !important;
    justify-content: flex-start !important;
    flex: 1 !important;
  }
}

/* Tablet Only Layout: 2-column Grid Adaptation */
@media (min-width: 577px) and (max-width: 992px) {
  .grid.cols-3,
  .grid.cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1.25rem !important;
  }
}

/* Mobile-First Table Cards Transformation */
@media (max-width: 768px) {
  .table-responsive {
    border: none !important;
    overflow-x: visible !important;
  }
  .table-responsive table {
    min-width: 100% !important;
    display: block !important;
    width: 100% !important;
  }
  .table-responsive thead {
    display: none !important; /* Hide original headers */
  }
  .table-responsive tbody {
    display: block !important;
    width: 100% !important;
  }
  .table-responsive tr {
    display: block !important;
    background: var(--white) !important;
    border: 1px solid var(--line) !important;
    border-radius: 12px !important;
    margin-bottom: 1.25rem !important;
    padding: 1rem !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
  }
  body.dark-mode .table-responsive tr {
    background: #1e1e1e !important;
  }
  .table-responsive tr:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04) !important;
  }
  .table-responsive td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0.6rem 0 !important;
    border-bottom: 1px dashed var(--line) !important;
    font-size: 0.9rem !important;
    text-align: right !important;
  }
  .table-responsive td:last-child {
    border-bottom: none !important;
  }
  .table-responsive td::before {
    content: attr(data-label) !important;
    font-weight: 600 !important;
    color: var(--muted) !important;
    text-align: left !important;
    margin-right: 1.5rem !important;
    font-size: 0.75rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
  }
  .table-responsive td.right {
    text-align: right !important;
  }
  .table-responsive .table-actions {
    justify-content: flex-end !important;
    width: 100% !important;
    margin-top: 0.25rem !important;
  }
  .table-responsive .table-actions .btn {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.85rem !important;
  }

  /* Asegurar que el menú desplegable en móviles se posicione absolute relativo a su contenedor parent */
  .status-dropdown-menu.active {
    position: absolute !important;
    top: calc(100% + 5px) !important;
    right: 0 !important;
    left: auto !important;
    bottom: auto !important;
    z-index: 100 !important;
  }
}

/* Smartphone Specific Optimization */
@media (max-width: 576px) {
  /* Hide the long email/name string on mobile to keep fixed bar clean */
  #currentUserDisplay {
    display: none !important;
  }
  .user-info {
    margin-left: 0 !important;
    position: relative !important;
  }
  
  /* Tooltip de usuario conectado en hover/activo */
  .user-info::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%;
    left: 0;
    transform: translateY(8px) scale(0.9);
    background: #0f172a;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    z-index: 9999;
  }

  .user-info::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 10px;
    transform: translateY(4px);
    border-width: 4px;
    border-style: solid;
    border-color: transparent transparent #0f172a transparent;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
  }

  .user-info:hover::after,
  .user-info:active::after {
    opacity: 1;
    transform: translateY(8px) scale(1);
  }

  .user-info:hover::before,
  .user-info:active::before {
    opacity: 1;
  }

  body.dark-mode .user-info::after {
    background: #f1f5f9;
    color: #0f172a;
  }
  body.dark-mode .user-info::before {
    border-color: transparent transparent #f1f5f9 transparent;
  }

  /* Compact Modal boxes to utilize every pixel of screen space */
  .modal-box {
    padding: 1.25rem !important;
    width: 95% !important;
    margin: 1rem auto !important;
    max-height: 94vh !important;
    border-radius: 16px !important;
  }

  /* Make sure fields in modals stack properly and have a clear focus layout */
  .modal-box .grid.cols-2,
  .modal-box .grid.cols-3,
  .modal-box .grid.cols-4 {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }

  /* Product adder responsive grid adaptation */
  .product-adder-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }
  .product-adder-grid input,
  .product-adder-grid .btn {
    width: 100% !important;
    height: 48px !important;
  }
}

/* --- TOUR GUIADO DE ONBOARDING --- */
.tour-spotlight {
  position: fixed;
  z-index: 9998;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.65);
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  border: 2px solid var(--primary);
  box-sizing: border-box;
  opacity: 0;
}

.tour-spotlight.visible {
  opacity: 1;
}

.tour-popover {
  position: fixed;
  z-index: 9999;
  width: 330px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
  color: var(--ink);
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  transform: scale(0.95);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tour-popover.active {
  opacity: 1;
  transform: scale(1);
}

.tour-popover__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tour-popover__step {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tour-popover__skip {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.25rem;
  font-weight: 600;
  transition: color 0.2s;
}

.tour-popover__skip:hover {
  color: var(--danger);
}

.tour-popover__title {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0;
  line-height: 1.2;
}

.tour-popover__body {
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--ink);
  opacity: 0.9;
  margin: 0;
}

.tour-popover__progress-container {
  width: 100%;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.25rem;
}

.tour-popover__progress-bar {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
}

.tour-popover__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}

.tour-popover__footer-btns {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.tour-btn {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tour-btn--prev {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.tour-btn--prev:hover {
  background: var(--bg-hover);
  color: var(--ink);
}

.tour-btn--next {
  background: var(--primary);
  color: var(--white);
}

.tour-btn--next:hover {
  background: var(--primary-dark);
}

/* Modal centrado especial para Inicio y Fin del Tour */
.tour-popover--modal {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) scale(0.95) !important;
  width: 90% !important;
  max-width: 420px !important;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3) !important;
}

.tour-popover--modal.active {
  transform: translate(-50%, -50%) scale(1) !important;
}

/* Estilos adaptativos en Móvil (<= 768px): Se ancla como Bottom Sheet */
@media (max-width: 768px) {
  .tour-popover {
    position: fixed !important;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)) !important;
    left: 1rem !important;
    right: 1rem !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    max-height: 55vh !important;
    overflow-y: auto !important;
    margin: 0 !important;
    transform: translateY(120%) !important;
    opacity: 0 !important;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s !important;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.25) !important;
  }

  .tour-popover.active {
    transform: translateY(0) !important;
    opacity: 1 !important;
  }

  /* Modal centrado en móvil: pantalla de bienvenida y final */
  .tour-popover--modal {
    bottom: auto !important;
    top: 50% !important;
    left: 1rem !important;
    right: 1rem !important;
    transform: translateY(-50%) scale(0.92) !important;
    opacity: 0 !important;
    max-height: 90vh !important;
  }

  .tour-popover--modal.active {
    transform: translateY(-50%) scale(1) !important;
    opacity: 1 !important;
  }
}

/* Modo oscuro nativo */
body.dark-mode .tour-popover {
  background: rgba(15, 23, 42, 0.85) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4) !important;
  color: #f1f5f9 !important;
}

body.dark-mode .tour-popover__title {
  color: #fff !important;
}

body.dark-mode .tour-popover__body {
  color: #cbd5e1 !important;
}

body.dark-mode .tour-btn--prev {
  border-color: rgba(255, 255, 255, 0.15) !important;
  color: #94a3b8 !important;
}

body.dark-mode .tour-btn--prev:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  color: #fff !important;
}

/* =============================================
   MODAL DETALLE DE PLAN (PREMIUM & RESPONSIVE)
   ============================================= */
#modalPlanDetalle {
  display: none;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 5500;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 16px;
}

#modalPlanDetalle .modal-box {
  width: 90%;
  max-width: 500px;
  padding: 24px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
  position: relative;
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Decoración superior con gradiente */
#modalPlanDetalle .modal-decor {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, #10b981, #3b82f6, #6366f1);
}

#modalPlanDetalle .modal-header {
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

#modalPlanDetalle .modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

#modalPlanDetalle .modal-header p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 500;
}

#modalPlanDetalle .modal-body {
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
  margin-bottom: 16px;
}

/* Custom scrollbar para la lista de características */
#modalPlanDetalle .modal-body::-webkit-scrollbar {
  width: 5px;
}
#modalPlanDetalle .modal-body::-webkit-scrollbar-track {
  background: transparent;
}
#modalPlanDetalle .modal-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 99px;
}

#modalPlanDetalle .price-box {
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  border: 1px solid #e2e8f0;
}

#modalPlanDetalle .price-amount {
  font-size: 2rem;
  font-weight: 900;
  color: #0f172a;
  line-height: 1;
}

#modalPlanDetalle .price-period {
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 600;
  margin-left: 4px;
}

#modalPlanDetalle .price-label {
  display: block;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

#modalPlanDetalle .features-title {
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 8px;
}

#modalPlanDetalle .features-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#modalPlanDetalle .features-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.85rem;
  color: #475569;
  font-weight: 500;
  line-height: 1.4;
}

#modalPlanDetalle .features-list li i {
  color: #10b981;
  font-size: 0.95rem;
  margin-top: 2px;
  flex-shrink: 0;
}

#modalPlanDetalle .trust-box {
  margin-top: 20px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.04);
  border: 1px solid rgba(16, 185, 129, 0.12);
  display: flex;
  align-items: center;
  gap: 10px;
}

#modalPlanDetalle .trust-box i.shield-icon {
  color: #10b981;
  font-size: 1.2rem;
  flex-shrink: 0;
}

#modalPlanDetalle .trust-box-content {
  flex: 1;
}

#modalPlanDetalle .trust-box-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

#modalPlanDetalle .trust-box-desc {
  margin: 2px 0 0;
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 500;
  line-height: 1.2;
}

#modalPlanDetalle .modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid #f1f5f9;
  padding-top: 16px;
  margin-top: auto;
}

/* Animaciones */
@keyframes modalSlideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Adaptación responsiva para móviles */
@media (max-width: 576px) {
  #modalPlanDetalle {
    padding: 10px;
  }
  #modalPlanDetalle .modal-box {
    padding: 20px 16px 16px;
    border-radius: 16px;
    max-height: 95vh;
  }
  #modalPlanDetalle .modal-header h3 {
    font-size: 1.3rem;
  }
  #modalPlanDetalle .price-box {
    padding: 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 16px;
  }
  #modalPlanDetalle .price-box div:last-child {
    text-align: left;
    width: 100%;
  }
  #modalPlanDetalle .price-amount {
    font-size: 1.8rem;
  }
  #modalPlanDetalle .trust-box {
    padding: 10px;
    margin-top: 16px;
  }
  #modalPlanDetalle .modal-footer {
    padding-top: 12px;
  }
  #modalPlanDetalle .modal-footer button {
    flex: 1;
    font-size: 0.85rem;
    padding: 10px 12px !important;
  }
}

/* Alerta de pago pendiente premium */
.pending-payment-alert {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: linear-gradient(135deg, rgba(0, 123, 255, 0.08) 0%, rgba(99, 102, 241, 0.08) 100%);
  border: 1px dashed rgba(0, 123, 255, 0.3);
  border-radius: 12px;
  margin-bottom: 1.25rem;
  animation: authPanelIn 0.4s ease;
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.05);
}
.pending-payment-alert .alert-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  color: #fff;
  border-radius: 10px;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 123, 255, 0.2);
}
.pending-payment-alert .alert-content {
  text-align: left;
}
.pending-payment-alert .alert-content h4 {
  margin: 0 0 0.25rem 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}
.pending-payment-alert .alert-content p {
  margin: 0;
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.4;
}

body.dark-mode .pending-payment-alert {
  background: linear-gradient(135deg, rgba(0, 123, 255, 0.15) 0%, rgba(99, 102, 241, 0.15) 100%);
  border-color: rgba(99, 102, 241, 0.4);
}
body.dark-mode .pending-payment-alert .alert-content p {
  color: #cbd5e1;
}

/* ==========================================================================
   Nubifica Premium Responsiveness & Custom Dynamic Additions
   ========================================================================== */

/* PC Tooltip Left Mitigation (prevents overflow on left side of screen) */
.tooltip-container .tooltip-text {
  visibility: hidden;
  width: 290px;
  background-color: var(--dark);
  color: var(--white);
  border-radius: 8px;
  padding: 1rem;
  position: absolute;
  z-index: 999;
  bottom: 125%;
  left: -20px !important; /* Starts slightly left of icon, shifts content right */
  margin-left: 0 !important;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.9rem;
  line-height: 1.5;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.tooltip-container .tooltip-text::after {
  content: "" !important;
  position: absolute;
  top: 100%;
  left: 25px !important; /* Points exactly to the info-icon on the left */
  right: auto !important;
  margin-left: 0 !important;
  border-width: 6px;
  border-style: solid;
  border-color: var(--dark) transparent transparent transparent;
}

/* Mobile KPI Card Tooltip Overrides */
@media (max-width: 768px) {
  .stat-card .tooltip-container {
    position: static !important;
  }
  .stat-card .tooltip-text {
    width: calc(100% - 2.5rem) !important;
    left: 1.25rem !important;
    right: 1.25rem !important;
    margin-left: 0 !important;
    bottom: 85px !important;
    font-size: 0.85rem !important;
    padding: 0.85rem !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15) !important;
  }
  .stat-card .tooltip-text::after {
    display: none !important; /* Hide arrow pointing down since it centers in card */
  }
}

/* Mobile Segmented Horizontal Scrollable Tabs */
@media (max-width: 768px) {
  .toggle-container-wrapper {
    display: block !important;
    width: 100% !important;
    overflow: visible !important;
  }
  
  #reportes-toggle, #ayuda-toggle {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-radius: 8px !important;
    border: 1px solid var(--line) !important;
    width: 100% !important;
    padding: 4px !important;
    background: var(--light) !important;
    gap: 4px !important;
    margin-bottom: 1.5rem !important;
  }
  
  body.dark-mode #reportes-toggle, body.dark-mode #ayuda-toggle {
    background: #111827 !important;
    border-color: #2a2a2a !important;
  }
  
  #reportes-toggle .btn, #ayuda-toggle .btn {
    flex: 0 0 auto !important;
    border-radius: 6px !important;
    border: none !important;
    margin: 0 !important;
    font-size: 0.82rem !important;
    padding: 8px 14px !important;
    box-shadow: none !important;
    height: auto !important;
    color: var(--muted) !important;
    background: transparent !important;
  }
  
  body.dark-mode #reportes-toggle .btn, body.dark-mode #ayuda-toggle .btn {
    color: #9ca3af !important;
  }
  
  #reportes-toggle .btn.active, #ayuda-toggle .btn.active {
    background: var(--white) !important;
    color: var(--primary) !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08) !important;
  }
  
  body.dark-mode #reportes-toggle .btn.active, body.dark-mode #ayuda-toggle .btn.active {
    background: #1f2937 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) !important;
  }
  
  /* Hide scrollbar for seamless native segmented UI appearance */
  #reportes-toggle::-webkit-scrollbar, #ayuda-toggle::-webkit-scrollbar {
    display: none !important;
  }
  #reportes-toggle, #ayuda-toggle {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
  }
}

/* Mobile Sidebar Viewport Constrains & Smooth Scrolling */
@media (max-width: 992px) {
  .sidebar {
    top: 4.5rem !important;
    bottom: 0 !important;
    height: auto !important; /* Constrains height auto to match dynamic device height */
    -webkit-overflow-scrolling: touch !important;
  }
  .sidebar-nav {
    -webkit-overflow-scrolling: touch !important;
  }
}

/* Unified Premium Microsoft Excel themed Export Buttons */
.btn-export-excel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px !important;
  font-size: 0.85rem !important;
  font-weight: 600;
  border-radius: 20px !important;
  background-color: rgba(16, 124, 65, 0.06) !important;
  border: 1px solid rgba(16, 124, 65, 0.2) !important;
  color: #107c41 !important;
  cursor: pointer;
  transition: all 0.2s ease-in-out !important;
  box-shadow: none !important;
  height: auto !important;
}

body.dark-mode .btn-export-excel {
  background-color: rgba(16, 124, 65, 0.12) !important;
  border-color: rgba(16, 124, 65, 0.4) !important;
  color: #1a9e58 !important; /* Brighter green for readability in dark mode */
}

.btn-export-excel:hover {
  background-color: #107c41 !important;
  border-color: #107c41 !important;
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(16, 124, 65, 0.2) !important;
}

body.dark-mode .btn-export-excel:hover {
  background-color: #107c41 !important;
  border-color: #107c41 !important;
  color: #ffffff !important;
}

.btn-export-excel i {
  font-size: 0.95rem !important;
}

/* Custom Premium Filters Card for Reports */
.reportes-filtro-card {
  padding: 1.5rem !important;
  border-radius: var(--radius);
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
  margin-bottom: 1.5rem;
}

body.dark-mode .reportes-filtro-card {
  background: #1e1e1e;
  border-color: #333;
}

.filter-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}

body.dark-mode .filter-panel-header {
  border-color: #333;
}

.filter-panel-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary-dark);
}

body.dark-mode .filter-panel-header h3 {
  color: #fff;
}

.quick-dates-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.quick-date-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.quick-dates-buttons {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.quick-date-btn {
  background: var(--light) !important;
  border: 1px solid var(--line) !important;
  color: var(--muted) !important;
  padding: 5px 12px !important;
  font-size: 0.78rem !important;
  border-radius: 20px !important;
  font-weight: 600 !important;
  cursor: pointer;
  transition: all 0.2s ease !important;
  height: auto !important;
  box-shadow: none !important;
}

body.dark-mode .quick-date-btn {
  background: #2a2a2a !important;
  border-color: #444 !important;
  color: #bbb !important;
}

.quick-date-btn:hover {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}

body.dark-mode .quick-date-btn:hover {
  background: rgba(59, 130, 246, 0.12) !important;
  border-color: var(--primary) !important;
  color: #4da3ff !important;
}

.quick-date-btn.active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: var(--white) !important;
  font-weight: 700 !important;
}

body.dark-mode .quick-date-btn.active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #ffffff !important;
}

.filter-grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  align-items: flex-end;
}

@media (min-width: 993px) {
  .filter-grid-layout {
    grid-template-columns: repeat(4, 1fr) auto;
  }
}

.filter-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.filter-field-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

body.dark-mode .filter-field-group label {
  color: #aaa;
}

.premium-input, .premium-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.88rem;
  background: var(--light);
  color: var(--dark);
  transition: all 0.2s ease;
}

body.dark-mode .premium-input, body.dark-mode .premium-select {
  background: #252525;
  border-color: #444;
  color: #eee;
}

.premium-input:focus, .premium-select:focus {
  border-color: var(--primary);
  background: var(--white);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.12);
}

body.dark-mode .premium-input:focus, body.dark-mode .premium-select:focus {
  background: #1e1e1e;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.15);
}

.filter-actions-group {
  display: flex;
  justify-content: flex-end;
}

.btn-generate-report {
  width: 100%;
  padding: 11px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  height: 42px !important;
}

.btn-generate-report:hover i {
  animation: spin 1s linear infinite;
}


/* ==========================================================================
   M�dulo IA - Chatbot y Modales M�gicos
   ========================================================================== */

.ai-chat-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 450px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    z-index: 10000;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

/* Boton flotante del Chatbot IA */
.ai-chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    z-index: 10001;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: aiPulse 2s infinite alternate;
}

.ai-chat-toggle-btn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.ai-chat-toggle-btn:active {
    transform: scale(0.95);
}

@keyframes aiPulse {
    0% {
        box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    }
    100% {
        box-shadow: 0 4px 24px rgba(99, 102, 241, 0.7), 0 0 0 6px rgba(99, 102, 241, 0.12);
    }
}

.ai-chat-header {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-body {
    height: 300px;
    padding: 15px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.ai-msg-system {
    background: #e2e8f0;
    color: #334155;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.ai-msg-user {
    background: #6366f1;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.ai-chat-footer {
    display: flex;
    padding: 10px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

.ai-chat-footer input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 8px 15px;
    outline: none;
}

.ai-chat-footer button {
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    margin-left: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.dark-mode .ai-chat-widget {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .ai-chat-body {
    background: #0f172a;
}

body.dark-mode .ai-chat-footer {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .ai-chat-footer input {
    background: #334155;
    color: white;
    border-color: #475569;
}

/* Responsive Fixes for AI Chatbot and Table Actions */
@media (max-width: 576px) {
    .ai-chat-widget {
        width: calc(100vw - 40px) !important;
        right: 20px !important;
        bottom: 80px !important;
        height: 60vh !important;
    }
    td.right, th.right, td {
        white-space: normal !important;
    }
    .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        justify-content: flex-end;
    }
    td .btn {
        margin-bottom: 5px;
    }
}

