@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Paleta Oficial Procables */
  --procables-blue: #231F83;
  --procables-blue-dark: #191660;
  --procables-blue-subtle: #eef2ff;
  --procables-red: #EE140F;
  --procables-red-hover: #c90e0a;
  --procables-red-light: #fef2f2;

  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-glass: rgba(241, 245, 249, 0.85);
  --border-color: #e2e8f0;
  --border-hover: #231F83;
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --text-light: #cbd5e1;
  
  /* Sidebar Procables Azul Corporativo */
  --sidebar-bg: #191660;
  --sidebar-header-bg: #110e42;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: #cbd5e1;
  --sidebar-text-hover: #ffffff;
  --sidebar-item-hover: rgba(255, 255, 255, 0.12);
  
  /* Acentos */
  --accent-primary: #231F83;
  --accent-hover: #191660;
  --accent-gradient: linear-gradient(135deg, #231F83 0%, #191660 100%);
  --accent-purple: #231F83;
  --accent-cyan: #0284c7;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-rose: #EE140F;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 4px 12px 0 rgba(35, 31, 131, 0.25);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius: 12px;
  --radius-lg: 16px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, .brand-text h1, .kpi-title {
  font-family: 'Poppins', sans-serif;
}

/* ==========================================================================
   TOP NAVBAR (ESTÁNDAR HOMOLOGADO PROCABLES)
   ========================================================================== */
.top-navbar {
  background: #ffffff;
  border-top: 4px solid var(--procables-red, #EE140F);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  padding: 0.65rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
}

.dashboard-container {
  display: flex;
  min-height: calc(100vh - 65px);
}

/* ==========================================================================
   SIDEBAR NAVIGATION (TEMA COMISIONES SLATE 900)
   ========================================================================== */
.sidebar {
  width: 255px;
  min-width: 255px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 20;
  position: sticky;
  top: 65px;
  height: calc(100vh - 65px);
  overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
  width: 5px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.brand-text h1 {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
}

.brand-text p {
  font-size: 11px;
  color: var(--sidebar-text);
  font-weight: 500;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-grow: 1;
  gap: 16px;
}

.nav-section-top {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-user-footer {
  padding-top: 14px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-session-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #020617;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

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

.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-email {
  font-size: 11px;
  color: var(--sidebar-text);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.nav-logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  color: #f87171;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.nav-logout-btn:hover {
  background: rgba(220, 38, 38, 0.15);
  border-color: #ef4444;
  color: #fca5a5;
}

.nav-item-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}

.nav-item-btn:hover {
  background: var(--sidebar-item-hover);
  color: var(--sidebar-text-hover);
}

.nav-category {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}

.nav-category:hover {
  background: var(--sidebar-item-hover);
  color: var(--sidebar-text-hover);
}

.nav-submenu {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-left: 10px;
  margin-top: 2px;
}

.nav-subitem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}

.nav-subitem.active {
  background: var(--procables-red);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(238, 20, 15, 0.35);
}

.nav-subitem:hover:not(.active) {
  background: var(--sidebar-item-hover);
  color: var(--sidebar-text-hover);
}

/* ==========================================================================
   MAIN CONTENT & TOP FILTER BAR (IMAGE 2 & 4)
   ========================================================================== */
.main-content {
  flex: 1;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

/* Horizontal Filter Bar Card */
.filter-card-top {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-card);
}

.filter-grid-horizontal {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 130px;
  min-width: 120px;
}

.filter-item label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  white-space: nowrap;
}

.form-control {
  width: 100%;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  background: #ffffff;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.filter-action,
.filter-btn-container {
  display: flex;
  align-items: flex-end;
  flex: 0 0 auto;
}

.btn-filtrar,
.btn-filter-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 22px;
  background: var(--accent-primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-glow);
  transition: var(--transition);
  white-space: nowrap;
}

.btn-filtrar:hover,
.btn-filter-action:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

/* Top Bar Summary */
.top-bar-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.active-filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--accent-primary);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* ==========================================================================
   KPI CARDS GRID
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

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

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.kpi-icon.blue { background: #eff6ff; color: var(--accent-primary); }
.kpi-icon.emerald { background: #f0fdf4; color: var(--accent-emerald); }
.kpi-icon.amber { background: #fff7ed; color: var(--accent-amber); }
.kpi-icon.purple { background: #faf5ff; color: var(--accent-purple); }
.kpi-icon.rose { background: #fef2f2; color: var(--accent-rose); }

/* ==========================================================================
   CARD DE EXPORTACIÓN EN GRID DE KPIS
   ========================================================================== */
.kpi-card-export {
  grid-column: span 3;
  background: linear-gradient(135deg, #f8fafc 0%, #f0fdf4 100%);
  border: 1.5px dashed #86efac;
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.kpi-card-export:hover {
  border-color: #10b981;
  background: linear-gradient(135deg, #f8fafc 0%, #dcfce7 100%);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.export-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.export-title {
  font-size: 13px;
  font-weight: 700;
  color: #166534;
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-desc {
  font-size: 11.5px;
  color: #4b5563;
  line-height: 1.4;
}

.export-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-export-excel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: #10b981;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
  transition: var(--transition);
}

.btn-export-excel:hover {
  background: #059669;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-export-csv {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: #ffffff;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-export-csv:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

/* ==========================================================================
   CARD DE LEYENDA INFORMATIVA DE RANGOS (SEGUNDA FILA DE KPIS)
   ========================================================================== */
.kpi-card-legend {
  grid-column: span 3;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.kpi-card-legend:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg);
}

.legend-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 4px;
}

.legend-main-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-columns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.legend-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend-block-title {
  font-size: 11px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
}

.legend-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.legend-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  line-height: 1.3;
}

.legend-color-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.legend-color-indicator.dot-low { background: #ef4444; }
.legend-color-indicator.dot-mid { background: #f59e0b; }
.legend-color-indicator.dot-high { background: #10b981; }

.legend-name {
  font-weight: 700;
  color: #334155;
  min-width: 44px;
}

.legend-val {
  color: #475569;
  font-weight: 500;
  background: #f8fafc;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid #f1f5f9;
  font-size: 10.5px;
  white-space: nowrap;
}

@media (max-width: 1200px) {
  .kpi-card-export,
  .kpi-card-legend {
    grid-column: 1 / -1;
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ==========================================================================
   BARRA DE CONFIGURACIÓN PERSONALIZADA DEL SEMÁFORO
   ========================================================================== */
.config-semaphore-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: var(--transition);
}

.config-semaphore-card:hover {
  border-color: var(--border-hover);
}

.config-semaphore-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
}

.config-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.config-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-config-apply {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-glow);
  transition: var(--transition);
}

.btn-config-apply:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.btn-config-reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-config-reset:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.config-semaphore-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.config-group {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.config-group-title {
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.config-inputs-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.config-field label {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 5px;
}

.config-input {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  padding: 7px 10px;
  background: #ffffff;
}

.config-readonly-badge {
  padding: 7px 10px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  color: #166534;
  white-space: nowrap;
  display: flex;
  align-items: center;
  min-height: 35px;
}

.field-hint {
  font-size: 10px;
  color: #64748b;
  font-weight: 500;
}

@media (max-width: 1000px) {
  .config-semaphore-grid {
    grid-template-columns: 1fr;
  }
  .config-inputs-row {
    grid-template-columns: 1fr;
  }
}

.kpi-value {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.4px;
}

.kpi-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================================================
   CARD CONTAINER & CHARTS
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.card-title .badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  background: #eff6ff;
  color: var(--accent-primary);
}

.segmented-control {
  display: inline-flex;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  padding: 3px;
  border-radius: var(--radius-sm);
  gap: 2px;
}

.segment-btn {
  border: none;
  background: transparent;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.segment-btn.active {
  background: #ffffff;
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

.analytics-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
}

@media (max-width: 1200px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

.heatmap-wrapper {
  width: 100%;
  overflow-x: auto;
}

/* Semáforo Interactivo del Mapa de Calor */
.heatmap-legend-interactive {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.legend-filter-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-right: 4px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-main);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.legend-chip:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.legend-chip.active {
  background: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
  color: #0f172a;
  font-weight: 700;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-all {
  background: conic-gradient(#ef4444 0deg 90deg, #f59e0b 90deg 180deg, #10b981 180deg 270deg, #8b5cf6 270deg 360deg);
}

.dot-none {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
}

.dot-low {
  background: #ef4444; /* Rojo */
  box-shadow: 0 0 5px rgba(239, 68, 68, 0.5);
}

.dot-mid {
  background: #f59e0b; /* Amarillo */
  box-shadow: 0 0 5px rgba(245, 158, 11, 0.5);
}

.dot-high {
  background: #10b981; /* Verde */
  box-shadow: 0 0 5px rgba(16, 185, 129, 0.5);
}

.dot-peak {
  background: #8b5cf6; /* Morado */
  box-shadow: 0 0 5px rgba(139, 92, 246, 0.5);
}

/* Data Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 10px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-btn {
  padding: 5px 10px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
  background: #eff6ff;
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 12px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3.5px solid #e2e8f0;
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile Navbar Header */
.mobile-navbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.btn-mobile-menu {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 16px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-mobile-menu:hover {
  background: #e2e8f0;
}

.mobile-brand {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 90;
}

/* App Views */
.app-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.app-view:not(.active) {
  display: none !important;
}

/* Responsive Media Queries */
@media (max-width: 992px) {
  .mobile-navbar {
    display: flex;
  }

  .dashboard-container {
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -290px;
    width: 270px;
    min-width: 270px;
    height: 100vh;
    z-index: 100;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

  .sidebar.mobile-open {
    left: 0;
  }

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

  .main-content {
    padding: 16px;
    max-height: none;
    overflow-y: visible;
  }
}

@media (max-width: 768px) {
  .filter-grid-horizontal {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-item {
    width: 100%;
    min-width: 100%;
  }

  .filter-action,
  .filter-btn-container {
    width: 100%;
  }

  .btn-filtrar,
  .btn-filter-action {
    width: 100%;
    height: 42px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi-card-export,
  .kpi-card-legend {
    grid-column: 1 / -1;
  }

  .legend-columns-grid {
    grid-template-columns: 1fr !important;
  }

  .config-semaphore-grid {
    grid-template-columns: 1fr;
  }

  .config-inputs-row {
    grid-template-columns: 1fr;
  }

  .config-two-columns {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 24px 18px;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 12px;
  }

  .config-semaphore-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .config-buttons {
    width: 100%;
    justify-content: space-between;
  }

  .btn-config-apply,
  .btn-config-reset {
    flex: 1;
    justify-content: center;
  }
}

/* ==========================================================================
   AUTENTICACIÓN Y CONTROL DE ACCESO (LOGIN, CAPTCHA, 2FA OTP)
   ========================================================================== */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #0b1329;
  background: radial-gradient(circle at 50% 35%, #1e293b 0%, #0b1329 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 16px;
}

.auth-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 440px;
  padding: 32px;
  animation: fadeInDown 0.3s ease;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-header {
  margin-bottom: 24px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.auth-field label {
  font-size: 11.5px;
  font-weight: 700;
  color: #334155;
}

.btn-auth-primary {
  width: 100%;
  padding: 11px;
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-auth-primary:hover:not(:disabled) {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.btn-auth-secondary {
  padding: 11px 18px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-auth-secondary:hover {
  background: #e2e8f0;
}

.auth-alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-alert-success {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 14px;
}

.auth-alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 14px;
}

.captcha-wrapper {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.captcha-display {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px dashed #93c5fd;
  text-align: center;
}

.btn-refresh-captcha {
  width: 38px;
  height: 38px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: var(--transition);
}

.btn-refresh-captcha:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  transform: rotate(180deg);
}

/* User Session Badge & Logout */
.user-session-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #f1f5f9;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name {
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 10.5px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.nav-logout-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* ==========================================================================
   VISTAS DE CONFIGURACIÓN (USUARIOS, PERMISOS, CORREO)
   ========================================================================== */
.config-view-header {
  margin-bottom: 24px;
}

.config-view-header h2 {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 4px 0;
  font-family: 'Outfit', sans-serif;
}

.config-view-header p {
  font-size: 13px;
  color: #64748b;
  margin: 0;
}

.config-two-columns {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1100px) {
  .config-two-columns {
    grid-template-columns: 1fr;
  }
}

.config-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.config-card-title {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
}

.config-form .form-group {
  margin-bottom: 14px;
}

.config-form label {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: block;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.btn-config-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-glow);
  transition: var(--transition);
}

.btn-config-primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.btn-config-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-config-secondary:hover {
  background: #e2e8f0;
}

.btn-config-link {
  background: none;
  border: none;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.btn-config-link:hover {
  color: #1e293b;
}

.user-badge-admin {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

.user-badge-custom {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.btn-action-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 14px;
  border-radius: 4px;
  transition: var(--transition);
}

.btn-action-icon:hover {
  background: #f1f5f9;
}

.perm-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

/* ==========================================================================
   VISTAS EN CONSTRUCCIÓN (RENTABILIDAD DÍA / PERIODO)
   ========================================================================== */
.under-construction-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  background: #ffffff;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  max-width: 900px;
  margin: 20px auto;
  width: 100%;
}

.under-construction-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 20px;
}

.under-construction-container h2 {
  font-size: 24px;
  font-weight: 800;
  color: #1e293b;
  margin: 0 0 10px 0;
}

.under-construction-desc {
  font-size: 14px;
  color: #64748b;
  max-width: 580px;
  line-height: 1.6;
  margin: 0 0 36px 0;
}

.under-construction-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  width: 100%;
}

.preview-metric-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 24px 18px;
  text-align: center;
  transition: all 0.2s ease;
}

.preview-metric-box:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  transform: translateY(-2px);
}

.preview-metric-box i {
  font-size: 28px;
  color: var(--accent-primary);
  margin-bottom: 12px;
}

.preview-metric-box h4 {
  font-size: 14.5px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 6px 0;
}

.preview-metric-box p {
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
  margin: 0;
}

/* ==========================================================================
   ESTILOS MÓDULO INVENTARIO EN TRÁNSITO
   ========================================================================== */
.badge-folio {
  display: inline-block;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-family: monospace;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.badge-status-transito {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-status-transito i {
  font-size: 11px;
  color: #d97706;
}

/* ==========================================================================
   ESTÁNDAR CORPORATIVO PROCABLES: BARRAS DE DESPLAZAMIENTO DE ALTO CONTRASTE
   Y NAVEGACIÓN CONTROLADA TÁCTIL / ESCRITORIO
   ========================================================================== */
.table-responsive {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: auto;
  scrollbar-color: #231F83 #e2e8f0;
  padding-bottom: 4px;
}

.table-responsive::-webkit-scrollbar {
  width: 12px;
  height: 12px;
  display: block;
}

.table-responsive::-webkit-scrollbar-track {
  background: #e2e8f0;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #231F83 0%, #2563eb 100%);
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  min-width: 44px;
  min-height: 44px;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:active {
  background: linear-gradient(135deg, #EE140F 0%, #b91c1c 100%);
}

.procables-scroll-helper {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin-bottom: 6px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
  user-select: none;
}

.procables-scroll-helper.is-scrollable {
  display: flex;
}

.procables-scroll-helper .scroll-btn {
  width: 30px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #231F83;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.procables-scroll-helper .scroll-btn:hover,
.procables-scroll-helper .scroll-btn:active {
  background: #231F83;
  color: #ffffff;
  border-color: #231F83;
}

.procables-scroll-helper .scroll-label {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.procables-scroll-helper .scroll-range {
  flex: 1;
  height: 8px;
  accent-color: #231F83;
  cursor: pointer;
  margin: 0;
}

.procables-scroll-helper .scroll-pct {
  font-size: 11px;
  font-weight: 800;
  color: #231F83;
  min-width: 36px;
  text-align: right;
}




/* ==========================================================================
   OPTIMIZACIÓN RESPONSIVA INTEGRAL (MÓVIL, TABLET Y ESCRITORIO)
   CONTENCIÓN DE VIEWPORT, DISTRIBUCIÓN DE FILTROS Y BARRAS DE SCROLL
   ========================================================================== */

/* 1. Contención estricta de ancho para evitar desbordamiento horizontal o zoom en móviles */
html,
body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.dashboard-container,
.main-content,
.app-view,
.card,
.table-card,
.table-card-container,
.config-card,
.filters-bar,
.view-header,
.view-header-row {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box;
}

/* Soporte para colapsar sidebar en escritorio (> 1024px) */
@media (min-width: 1025px) {
  body.sidebar-collapsed .sidebar {
    margin-left: -255px;
    transition: margin-left 0.25s ease;
  }
  .sidebar {
    transition: margin-left 0.25s ease;
  }
}

/* Asegurar scroll vertical y horizontal con barras visibles en todas las tablas */
.table-responsive {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: auto;
  scrollbar-color: #231F83 #e2e8f0;
}

.table-responsive::-webkit-scrollbar-corner {
  background: #e2e8f0;
}

/* ==========================================================================
   BREAKPOINT 1: TABLETS Y PANTALLAS MEDIANAS (<= 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  .top-navbar {
    padding: 0.55rem 1rem !important;
    gap: 0.5rem;
  }

  .dashboard-container {
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
  }

  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -290px !important;
    width: 270px !important;
    min-width: 270px !important;
    height: 100vh !important;
    z-index: 1000 !important;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  }

  .sidebar.mobile-open {
    left: 0 !important;
  }

  .sidebar-backdrop.mobile-open {
    display: block !important;
    z-index: 990 !important;
  }

  .main-content {
    padding: 16px !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
}

/* ==========================================================================
   BREAKPOINT 2: DISPOSITIVOS MÓVILES (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
  /* 1. Barra Superior (.top-navbar) compacta sin desbordar jamás el viewport móvil */
  .top-navbar {
    padding: 0.45rem 0.65rem !important;
    gap: 0.4rem !important;
    flex-wrap: nowrap !important;
  }

  .top-navbar > div:first-child {
    gap: 0.45rem !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
  }

  .top-navbar .btn-mobile-menu {
    padding: 6px 10px !important;
    font-size: 15px !important;
    margin-right: 0 !important;
    flex-shrink: 0 !important;
  }

  .top-navbar img {
    height: 28px !important;
    flex-shrink: 0 !important;
  }

  /* Ocultar línea divisoria vertical en móvil */
  .top-navbar > div:first-child > div:nth-child(3) {
    display: none !important;
  }

  .top-navbar > div:first-child > div:last-child {
    min-width: 0 !important;
    overflow: hidden !important;
  }

  .top-navbar > div:first-child > div:last-child > span:first-child {
    font-size: 0.84rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
  }

  /* Ocultar subtítulo largo en la barra superior móvil */
  .top-navbar > div:first-child > div:last-child > span:last-child {
    display: none !important;
  }

  .top-navbar > div:last-child {
    gap: 6px !important;
    flex-shrink: 0 !important;
  }

  /* El nombre de usuario ya está en el menú lateral; ocultarlo arriba en móvil libera espacio */
  #top-user-info {
    display: none !important;
  }

  #btn-top-logout {
    padding: 5px 10px !important;
    font-size: 0.74rem !important;
    white-space: nowrap !important;
  }

  /* 2. Contenedor principal y Portada Ejecutiva (#view-ejecutivos) */
  .main-content {
    padding: 10px !important;
    gap: 14px !important;
  }

  .app-view {
    gap: 14px !important;
  }

  .executive-welcome-banner {
    padding: 16px !important;
    border-radius: 12px !important;
  }

  .executive-welcome-banner h2 {
    font-size: 17px !important;
    line-height: 1.25 !important;
  }

  .executive-welcome-banner p {
    font-size: 12px !important;
  }

  /* Evitar que minmax(300px, 1fr) o minmax(230px, 1fr) inline desborden pantallas de 320px-375px */
  #view-ejecutivos > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  #view-ejecutivos .card {
    padding: 16px !important;
  }

  /* 3. Encabezados de vistas y botones de acción (Exportar Excel, CSV, Actualizar) */
  .view-header,
  .view-header-row,
  #view-inventario-resurtido > div:first-child,
  #view-zonas-sucursales .config-view-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .view-header h1,
  .view-header-row h2,
  #view-inventario-resurtido > div:first-child h2,
  .config-view-header h2 {
    font-size: 17px !important;
    line-height: 1.25 !important;
  }

  .view-header > div:last-child,
  .view-header-row > div:last-child,
  #view-inventario-resurtido > div:first-child > div:last-child,
  #view-zonas-sucursales .config-view-header > div:last-child {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .view-header > div:last-child > button,
  .view-header-row > div:last-child > button,
  #view-inventario-resurtido > div:first-child > div:last-child > button,
  #view-zonas-sucursales .config-view-header > div:last-child > button {
    flex: 1 1 auto !important;
    justify-content: center !important;
    padding: 7px 10px !important;
    font-size: 12px !important;
  }

  /* 4. Tarjetas KPI en cuadrícula compacta de 2 columnas en móvil */
  .kpi-grid,
  section.kpi-grid[style],
  div.kpi-grid[style] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .kpi-card {
    padding: 12px 14px !important;
    gap: 6px !important;
  }

  .kpi-value,
  #kpi-compras-ordenes,
  #kpi-compras-ordenadas,
  #kpi-compras-recibidas,
  #kpi-compras-faltantes,
  #kpi-compras-importe {
    font-size: 18px !important;
    word-break: break-word;
  }

  .kpi-card-export {
    grid-column: 1 / -1 !important;
    padding: 12px 14px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .kpi-card-export .export-actions {
    width: 100% !important;
    display: flex !important;
    gap: 8px !important;
  }

  .kpi-card-export .export-actions button {
    flex: 1 1 50% !important;
    justify-content: center !important;
  }

  /* 5. DISTRIBUCIÓN RESPONSIVA DE FILTROS EN TODOS LOS REPORTES DE INVENTARIOS */
  /* Neutralizar cualquier min-width inline en contenedores de filtros y selects */
  #view-inventario-transito section.card:first-of-type div[style*="min-width"],
  #view-inventario-resurtido section.card div[style*="min-width"],
  #view-compras-ordenes section div[style*="min-width"],
  #view-inventario-menos-vendidos .filters-bar div[style*="min-width"],
  #view-inventario-sin-rotacion .filters-bar div[style*="min-width"],
  #view-zonas-sucursales .config-card div[style*="min-width"] {
    min-width: 0 !important;
    width: 100% !important;
    flex: 1 1 100% !important;
  }

  #view-inventario-transito select.form-control,
  #view-inventario-resurtido select.form-control,
  #view-compras-ordenes select.form-control,
  #view-inventario-menos-vendidos select.form-control,
  #view-inventario-sin-rotacion select.form-control,
  #view-zonas-sucursales select.form-control {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    font-size: 12px !important;
  }

  /* 5A. Filtros de Productos en Tránsito (#view-inventario-transito) */
  #view-inventario-transito > section.card:first-of-type {
    padding: 12px !important;
  }

  #view-inventario-transito > section.card:first-of-type > div {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  /* Contenedor de selects de Tránsito en cuadrícula de 2 columnas */
  #view-inventario-transito > section.card:first-of-type > div > div:nth-child(2) {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
  }

  #view-inventario-transito > section.card:first-of-type > div > div:nth-child(2) > button[onclick*="abrirModalOrganizadorZonas"] {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    justify-content: center !important;
  }

  #view-inventario-transito #btn-filtrar-transito,
  #view-inventario-transito #btn-reset-transito {
    width: 100% !important;
    justify-content: center !important;
  }

  /* 5B. Filtros de Reporte de Resurtido (#view-inventario-resurtido) */
  #view-inventario-resurtido > section.card:nth-of-type(2) {
    padding: 12px !important;
  }

  #view-inventario-resurtido > section.card:nth-of-type(2) > div:first-child {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
  }

  /* Buscador, Rango de fechas personalizado y botones largos ocupan las 2 columnas */
  #view-inventario-resurtido > section.card:nth-of-type(2) > div:first-child > div:first-child,
  #resurtido-custom-date-wrap,
  #view-inventario-resurtido button[onclick*="abrirModalOrganizadorZonas"],
  #btn-toggle-glosario-resurtido,
  #view-inventario-resurtido > section.card:nth-of-type(2) > div:first-child > div:last-child {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    justify-content: center !important;
  }

  /* 5C. Filtros de Compras (#view-compras-ordenes) */
  #view-compras-ordenes > section:nth-of-type(2) {
    padding: 12px !important;
    gap: 10px !important;
  }

  #view-compras-ordenes > section:nth-of-type(2) > div:first-child {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
  }

  #view-compras-ordenes > section:nth-of-type(2) > div:first-child > div:first-child,
  #compras-mes-select,
  #compras-estatus-select,
  #compras-custom-date-wrap {
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }

  #view-compras-ordenes > section:nth-of-type(2) > div:last-child > div:first-child {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
  }

  #compras-proveedor-select {
    grid-column: 1 / -1 !important;
  }

  #view-compras-ordenes > section:nth-of-type(2) > div:last-child > div:last-child {
    width: 100% !important;
    justify-content: space-between !important;
  }

  #view-compras-ordenes > section:nth-of-type(2) > div:last-child > div:last-child > div:first-child {
    display: flex !important;
    width: 100% !important;
  }

  #btn-compras-mode-productos,
  #btn-compras-mode-ordenes {
    flex: 1 1 50% !important;
    text-align: center !important;
    justify-content: center !important;
    padding: 7px 6px !important;
    font-size: 11px !important;
  }

  /* Rango de fechas manual en Resurtido y Compras */
  #resurtido-custom-date-wrap,
  #compras-custom-date-wrap {
    padding: 8px !important;
    gap: 6px !important;
  }

  #resurtido-fecha-inicio,
  #resurtido-fecha-fin,
  #compras-fecha-inicio,
  #compras-fecha-fin {
    flex: 1 1 115px !important;
    width: auto !important;
    min-width: 110px !important;
  }

  #btn-resurtido-apply-dates,
  #btn-compras-apply-dates {
    width: 100% !important;
    justify-content: center !important;
  }

  /* 5D. Filtros de Productos Menos Vendidos y Sin Rotación */
  #view-inventario-menos-vendidos .filters-bar,
  #view-inventario-sin-rotacion .filters-bar {
    padding: 12px !important;
  }

  #view-inventario-menos-vendidos .filters-bar > div:first-child,
  #view-inventario-sin-rotacion .filters-bar > div:first-child,
  #view-inventario-menos-vendidos .filters-bar > div:last-child > div:first-child,
  #view-inventario-sin-rotacion .filters-bar > div:last-child > div:first-child {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
  }

  #view-inventario-menos-vendidos .filters-bar > div:first-child > div:first-child,
  #view-inventario-sin-rotacion .filters-bar > div:first-child > div:first-child,
  #view-inventario-menos-vendidos .filters-bar button[onclick*="openSucursalesOrganizerModal"],
  #view-inventario-sin-rotacion .filters-bar button[onclick*="openSucursalesOrganizerModal"] {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    justify-content: center !important;
  }

  /* 6. Tablas y barras de desplazamiento en móvil */
  .table-responsive {
    max-height: 65vh !important;
  }

  .table-responsive::-webkit-scrollbar {
    width: 9px !important;
    height: 9px !important;
  }

  .procables-scroll-helper {
    padding: 6px 10px !important;
    gap: 6px !important;
  }

  .table-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .table-toolbar > div:last-child {
    display: flex !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .table-toolbar > div:last-child > button {
    flex: 1 1 50% !important;
    justify-content: center !important;
  }

  /* Glosarios desplegables en móvil */
  #panel-glosario-resurtido > div[style*="grid-template-columns"],
  #panel-glosario-compras > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* Modales adaptables en móvil */
  #modalFiltroSucursalesZonas > div,
  #modal-zona-crud > div {
    width: 96vw !important;
    max-width: 96vw !important;
    max-height: 92vh !important;
    padding: 14px !important;
  }

  #modalFiltroSucursalesZonas > div > div {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

/* ==========================================================================
   BREAKPOINT 3: PANTALLAS MÓVILES ESTRECHAS (<= 480px)
   ========================================================================== */
@media (max-width: 480px) {
  .procables-scroll-helper .scroll-label-text {
    display: none !important;
  }

  .kpi-grid,
  section.kpi-grid[style],
  div.kpi-grid[style] {
    grid-template-columns: 1fr !important;
  }

  #view-inventario-transito > section.card:first-of-type > div > div:nth-child(2),
  #view-inventario-resurtido > section.card:nth-of-type(2) > div:first-child,
  #view-compras-ordenes > section:nth-of-type(2) > div:first-child,
  #view-compras-ordenes > section:nth-of-type(2) > div:last-child > div:first-child,
  #view-inventario-menos-vendidos .filters-bar > div:first-child,
  #view-inventario-sin-rotacion .filters-bar > div:first-child,
  #view-inventario-menos-vendidos .filters-bar > div:last-child > div:first-child,
  #view-inventario-sin-rotacion .filters-bar > div:last-child > div:first-child {
    grid-template-columns: 1fr !important;
  }

  .captcha-box > div {
    flex-wrap: wrap !important;
  }

  #login-captcha-answer {
    flex: 1 1 100px !important;
  }
}
