/* SISTEMA DE DISEÑO PREMIUM - MARBACON */
/* Estilo Moderno, Minimalista y Corporativo (Inspiración: Canva) */

:root {
  /* Paleta de Colores Corporativa */
  --primary: #6e1414;        /* Vino Tinto / Burdeos */
  --primary-hover: #500e0e;  /* Vino Tinto Oscuro */
  --accent: #a2222f;         /* Rojo Carmesí */
  --accent-light: #fbecee;   /* Fondo Rosa Suave */
  --success: #10b981;        /* Verde Éxito */
  --success-light: #ecfdf5;  /* Verde Éxito Fondo */
  --warning: #f59e0b;        /* Amarillo Advertencia */
  --warning-light: #fefbeb;  /* Amarillo Advertencia Fondo */
  --danger: #ef4444;         /* Rojo Peligro */
  --danger-light: #fef2f2;   /* Rojo Peligro Fondo */
  
  /* Tonos Neutros */
  --bg-app: #f4f6f8;         /* Fondo Gris Azulado muy Suave */
  --card-bg: rgba(255, 255, 255, 0.9); /* Tarjetas con Glassmorphism */
  --text-main: #2d3748;      /* Texto Oscuro Principal */
  --text-muted: #718096;     /* Texto Atenuado */
  --border-color: #e2e8f0;   /* Bordes Finos */
  --border-hover: #cbd5e1;   /* Bordes al hacer Hover */
  
  /* Fuentes */
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Sombras y Radios */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(110, 20, 20, 0.06);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.08);
  
  /* Transiciones */
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 1. RESET Y ESTILOS BASE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Scrollbar Personalizada */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* 2. DISEÑO DE CONTENEDOR GENERAL */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 3. APP HEADER (ESTILO PREMIUM) */
.app-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.header-logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.brand-text {
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 1px;
}

.main-nav {
  display: flex;
  gap: 0.5rem;
}

.nav-btn {
  background: transparent;
  border: none;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.nav-btn svg {
  transition: var(--transition);
}

.nav-btn:hover {
  color: var(--primary);
  background-color: var(--bg-app);
}

.nav-btn.active {
  color: var(--primary);
  background-color: var(--accent-light);
  font-weight: 600;
}

.nav-btn.active svg {
  stroke: var(--primary);
}

.user-profile-container {
  display: flex;
  align-items: center;
}

.user-badge {
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.4rem 1rem;
  border-radius: 50px;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}

/* 4. CONTENT WRAPPER & SECTIONS */
.app-content {
  flex: 1;
  padding: 2rem;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.screen-section {
  display: none;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.screen-section.active {
  display: block;
}

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

/* 5. DISEÑO DE PANTALLA 1: PORTADA HERO */
.hero-container {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 3rem;
  align-items: center;
  padding: 1.5rem 0;
}

.hero-visual {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 3rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.hero-visual::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(110, 20, 20, 0.03) 0%, transparent 60%);
  pointer-events: none;
}

.hero-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform 0.5s ease;
}

.hero-image:hover {
  transform: scale(1.02);
}

.hero-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hero-logo {
  height: 48px;
  width: auto;
}

.hero-brand-name {
  font-family: var(--font-title);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
}

.hero-title {
  font-family: var(--font-title);
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.15;
  color: #1a202c;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Tarjeta de Autorización */
.card {
  background-color: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.auth-card {
  border-left: 5px solid var(--primary);
  background-color: rgba(255, 255, 255, 0.95);
  margin-top: 1rem;
}

.auth-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.auth-header h3 {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
}

.auth-icon {
  color: var(--primary);
}

.auth-body {
  padding: 1.5rem;
  font-size: 0.95rem;
  color: var(--text-main);
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-body p {
  line-height: 1.55;
}

.auth-footer {
  padding: 1.25rem 1.5rem;
  background-color: var(--bg-app);
  display: flex;
  justify-content: flex-end;
}

/* 6. BOTONES */
.btn {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

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

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(110, 20, 20, 0.2);
}

.btn-secondary {
  background-color: var(--accent);
  color: #ffffff;
}

.btn-secondary:hover {
  background-color: #8c1c27;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(162, 34, 47, 0.2);
}

.btn-outline-secondary {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline-secondary:hover {
  background-color: var(--bg-app);
  border-color: var(--text-muted);
}

.btn-outline-primary {
  background-color: transparent;
  border-color: var(--primary);
  color: var(--primary);
}

.btn-outline-primary:hover {
  background-color: var(--accent-light);
  color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-outline-danger {
  background-color: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-outline-danger:hover {
  background-color: var(--danger-light);
  color: #b91c1c;
  border-color: #b91c1c;
}

.ciiu-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background-color: var(--accent-light);
  color: var(--primary);
  padding: 0.3rem 0.65rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid rgba(110, 20, 20, 0.15);
  transition: all var(--transition-fast);
}

.ciiu-tag:hover {
  background-color: #fbe0e3;
}

.ciiu-tag-close {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
  margin-left: 0.15rem;
}

.ciiu-tag-close:hover {
  color: var(--primary-hover);
}

.btn-lg {
  padding: 0.85rem 1.8rem;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* 7. ENCABEZADOS DE SECCIÓN */
.section-header {
  margin-bottom: 2rem;
}

.section-title {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 700;
  color: #1a202c;
  margin-bottom: 0.25rem;
}

.section-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
}

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

.flex-wrap {
  flex-wrap: wrap;
}

.gap-md {
  gap: 1.5rem;
}

/* 8. FORMULARIOS (DATOS EMPRESA) */
.grid-2-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.form-card {
  border: 1px solid var(--border-color);
}

.card-header {
  padding: 1.25rem 1.5rem;
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-num {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--primary);
  background-color: var(--accent-light);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-header h3 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 700;
  color: #2d3748;
}

.card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #4a5568;
}

.required {
  color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(110, 20, 20, 0.1);
}

.readonly-input {
  background-color: var(--bg-app) !important;
  color: var(--text-muted) !important;
  cursor: not-allowed;
}

.input-help {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-actions-bar {
  margin-top: 2rem;
  display: flex;
  justify-content: flex-end;
}

/* 9. PANTALLA 3: CARGA MASIVA */
.grid-layout-sidebar {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 2rem;
  align-items: start;
}

.tabs-container {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background-color: #ffffff;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 1rem 0.5rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: var(--transition);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
  padding: 1.5rem;
}

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

/* Drop Zone */
.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  background-color: #f8fafc;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background-color: var(--accent-light);
}

.drop-icon {
  color: var(--text-muted);
  transition: var(--transition);
}

.drop-zone:hover .drop-icon,
.drop-zone.dragover .drop-icon {
  color: var(--primary);
  transform: translateY(-4px);
}

.drop-text-primary {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.95rem;
}

.drop-text-secondary {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.file-input {
  display: none;
}

/* Zona de Pegar */
.paste-zone {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.paste-instructions {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

#paste-textarea {
  width: 100%;
  height: 175px;
  resize: vertical;
  font-family: monospace;
  font-size: 0.8rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background-color: #f8fafc;
}

.mapping-help-box {
  padding: 1.25rem 1.5rem;
  background-color: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.help-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
}

.help-header h4 {
  font-size: 0.9rem;
  font-weight: 700;
}

.mapping-help-box p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Vista Previa y Mapeo */
.preview-mapping-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.empty-preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6rem 2rem;
  text-align: center;
  gap: 1rem;
  border: 1px solid var(--border-color);
}

.empty-icon {
  color: #94a3b8;
}

.empty-preview-card h3 {
  font-family: var(--font-title);
  font-size: 1.3rem;
  font-weight: 700;
  color: #475569;
}

.empty-preview-card p {
  max-width: 420px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Mapeador de Columnas Activo */
.mapping-panel-card {
  border-left: 5px solid var(--warning);
}

.border-bottom {
  border-bottom: 1px solid var(--border-color);
}

.mapping-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.mapping-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background-color: #f8fafc;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.mapping-item label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
}

.mapping-item select {
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

/* Tabla de Previsualización */
.preview-table-card {
  border-left: 5px solid var(--primary);
}

.preview-stats {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.no-padding {
  padding: 0 !important;
}

.scrollable-table-container {
  max-height: 480px;
  overflow: auto;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  position: relative;
}

.preview-table,
.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.preview-table th,
.admin-table th {
  background-color: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

.preview-table td,
.admin-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.preview-table tbody tr:hover,
.admin-table tbody tr:hover {
  background-color: #f8fafc;
}

/* Estados de Fila de Validación */
.row-valid {
  border-left: 3px solid var(--success);
}

.row-warning {
  border-left: 3px solid var(--warning);
  background-color: var(--warning-light);
}

.row-error {
  border-left: 3px solid var(--danger);
  background-color: var(--danger-light);
}

.row-duplicate {
  border-left: 3px solid #8b5cf6; /* Púrpura */
  background-color: #f5f3ff;
}

/* Indicadores Visuales de Célula de Error */
.cell-error-marker {
  color: var(--danger);
  font-weight: bold;
  border-bottom: 1px dashed var(--danger);
}

.tooltip {
  position: relative;
  display: inline-block;
  cursor: help;
}

.validation-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 50px;
}

.badge-success { background-color: var(--success-light); color: var(--success); }
.badge-warning { background-color: var(--warning-light); color: var(--warning); }
.badge-danger { background-color: var(--danger-light); color: var(--danger); }
.badge-duplicate { background-color: #f5f3ff; color: #8b5cf6; }

/* 10. PANTALLA 4: PANEL DE ADMINISTRACIÓN */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.kpi-card {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.kpi-icon-container {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background-color: var(--accent-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(110, 20, 20, 0.05);
}

.kpi-icon-container.bg-blue {
  background-color: #e0f2fe;
  color: #0284c7;
}

.kpi-icon-container.bg-green {
  background-color: #dcfce7;
  color: #16a34a;
}

.kpi-info {
  display: flex;
  flex-direction: column;
}

.kpi-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-value {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 800;
  color: #1a202c;
  line-height: 1.2;
}

.kpi-formula-ref {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.1rem;
}

.margin-top {
  margin-top: 2rem;
}

/* Gráficos de Barras CSS */
.chart-card {
  min-height: 300px;
}

.chart-bar-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chart-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chart-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
}

.chart-bar-track {
  height: 12px;
  background-color: var(--bg-app);
  border-radius: 6px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  background-color: var(--primary);
  border-radius: 6px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  width: 0; /* Animado vía JS */
}

.chart-empty,
.log-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 3rem 1.5rem;
  font-size: 0.9rem;
  font-style: italic;
}

/* Historial de Cambios (Logs) */
.log-card {
  max-height: 380px;
}

.scrollable-list-container {
  max-height: 300px;
  overflow-y: auto;
  padding: 0;
}

.logs-list {
  list-style: none;
}

.log-item {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 1rem;
  align-items: start;
  font-size: 0.85rem;
}

.log-item:last-child {
  border-bottom: none;
}

.log-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--primary);
  margin-top: 0.25rem;
  flex-shrink: 0;
}

.log-item-content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.log-item-title {
  font-weight: 700;
  color: var(--text-main);
}

.log-item-desc {
  color: var(--text-muted);
}

.log-item-time {
  font-size: 0.75rem;
  color: #94a3b8;
  align-self: flex-start;
  white-space: nowrap;
}

/* Tabla de Gestión Administrativa */
.table-management-card {
  border-top: 4px solid var(--primary);
}

.table-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--text-muted);
}

.search-input-wrapper input {
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem 0.5rem 2.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  width: 250px;
  transition: var(--transition);
}

.search-input-wrapper input:focus {
  border-color: var(--primary);
  width: 320px;
}

.table-controls select {
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: #ffffff;
}

.table-pagination-footer {
  padding: 0.75rem 1.5rem;
  background-color: #f8fafc;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pagination-buttons {
  display: flex;
  gap: 0.5rem;
}

/* Botones de acción en tabla */
.row-actions {
  display: flex;
  gap: 0.4rem;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border-color);
  padding: 0.35rem;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
}

.btn-icon:hover {
  background-color: var(--bg-app);
  color: var(--text-main);
  border-color: var(--text-muted);
}

.btn-icon-danger:hover {
  background-color: var(--danger-light);
  color: var(--danger);
  border-color: #fca5a5;
}

.btn-icon-primary:hover {
  background-color: var(--accent-light);
  color: var(--primary);
  border-color: #f87171;
}

/* 11. MODALES */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  font-weight: 300;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--danger);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  background-color: var(--bg-app);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* 12. TOAST NOTIFICATIONS */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background-color: #ffffff;
  color: var(--text-main);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  max-width: 400px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideIn {
  from {
    transform: translateX(100%) translateY(-10px);
    opacity: 0;
  }
  to {
    transform: translateX(0) translateY(0);
    opacity: 1;
  }
}

.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.danger { border-left-color: var(--danger); }

/* 13. RESPONSIVE DESIGN */
@media (max-width: 1024px) {
  .hero-container {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .hero-visual {
    order: -1;
    padding: 1.5rem;
  }
  
  .grid-2-cols {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .grid-layout-sidebar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }
  
  .main-nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }
  
  .nav-btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.85rem;
  }
  
  .app-content {
    padding: 1rem;
  }
  
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* 14. PESTAÑAS ADMINISTRATIVAS & PROCESAMIENTO ETL */

.admin-tabs-nav {
  display: flex;
  background-color: #ffffff;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  gap: 0.25rem;
}

.admin-tab-btn {
  background: transparent;
  border: none;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.admin-tab-btn:hover {
  color: var(--primary);
  background-color: var(--bg-app);
}

.admin-tab-btn.active {
  color: #ffffff;
  background-color: var(--primary);
}

.admin-tab-btn svg {
  transition: var(--transition);
}

.admin-tab-pane {
  display: none;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.admin-tab-pane.active {
  display: block;
}

/* Bordes de tarjetas de KPIs del ETL */
.border-success {
  border-left: 5px solid var(--success) !important;
}

.border-purple {
  border-left: 5px solid #8b5cf6 !important; /* Púrpura de duplicados */
}

.border-danger {
  border-left: 5px solid var(--danger) !important;
}

.bg-purple {
  background-color: #f3e8ff !important;
  color: #8b5cf6 !important;
}

.bg-red {
  background-color: #fee2e2 !important;
  color: #ef4444 !important;
}

.text-danger {
  color: var(--danger);
}

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

.gap-xs {
  gap: 0.5rem;
}

/* Alertas de Calidad de Datos ETL */
.etl-alerts-card {
  border-top: 4px solid var(--danger);
}

.etl-alerts-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 1.25rem 1.5rem !important;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background-color: var(--danger-light);
}

.etl-alert-item {
  display: flex;
  align-items: start;
  gap: 0.75rem;
  background-color: #ffffff;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  border: 1px solid #fca5a5;
  box-shadow: var(--shadow-sm);
  font-size: 0.85rem;
}

.etl-alert-icon {
  color: var(--danger);
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.etl-alert-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.etl-alert-row {
  font-weight: 700;
  color: var(--text-main);
}

.etl-alert-msg {
  color: var(--text-muted);
}

.etl-alert-sug {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 600;
  margin-top: 0.15rem;
}

/* Column sorting styling */
.etl-table th[data-sort] {
  cursor: pointer;
  position: relative;
  padding-right: 1.75rem;
}

.etl-table th[data-sort]::after {
  content: '↕';
  position: absolute;
  right: 0.5rem;
  color: #94a3b8;
  font-size: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
}

.etl-table th[data-sort].sort-asc::after {
  content: '▲';
  color: var(--primary);
}

.etl-table th[data-sort].sort-desc::after {
  content: '▼';
  color: var(--primary);
}

/* --- ESTILOS ADICIONALES PARA MOTOR ETL AVANZADO --- */
.sheet-selector-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.sheet-selector-title {
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.sheet-selector-help {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.35;
}

.sheet-checkboxes-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sheet-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  background-color: var(--bg-app);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}

.sheet-checkbox-item:hover {
  border-color: var(--primary-light);
  background-color: rgba(110, 20, 20, 0.03);
}

.sheet-checkbox-item input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.sheet-checkbox-label-text {
  font-size: 0.9rem;
  color: var(--text-main);
  font-weight: 600;
}

.sheet-checkbox-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* Badges de Confianza de Mapeo */
.badge-alta {
  background-color: #d1fae5 !important;
  color: #065f46 !important;
  border: 1px solid #10b981;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-block;
  text-align: center;
}

.badge-media {
  background-color: #fef3c7 !important;
  color: #92400e !important;
  border: 1px solid #f59e0b;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-block;
  text-align: center;
}

.badge-baja {
  background-color: #fee2e2 !important;
  color: #991b1b !important;
  border: 1px solid #ef4444;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-block;
  text-align: center;
}

.audit-table th, .audit-table td {
  padding: 10px 12px;
  font-size: 0.85rem;
  vertical-align: middle;
}

.audit-table td strong {
  color: var(--primary);
}

.audit-justification {
  font-size: 0.8rem;
  color: #4b5563;
  line-height: 1.3;
}

/* Searchable Dropdown Options */
.searchable-dropdown-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  max-height: 250px;
  overflow-y: auto;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  margin-top: 4px;
}

.searchable-dropdown-options.hidden {
  display: none !important;
}

.searchable-dropdown-option {
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-main);
  transition: background-color 0.15s ease;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
}

.searchable-dropdown-option:last-child {
  border-bottom: none;
}

.searchable-dropdown-option:hover {
  background-color: var(--bg-app);
  color: var(--primary);
}

.searchable-dropdown-option.selected {
  background-color: rgba(110, 20, 20, 0.08);
  color: var(--primary);
  font-weight: 600;
}

.searchable-dropdown-option-empty {
  padding: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9rem;
}

/* Portal Mode Navigation Hiding */
body.portal-mode #nav-admin {
  display: none !important;
}

/* Modal styling for Audit Report */
#audit-report-modal .modal-card {
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  animation: modalFadeIn 0.3s ease-out;
}

#audit-report-modal table th {
  background-color: var(--bg-app);
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 10px;
}

#audit-report-modal table td {
  padding: 8px 10px;
  font-size: 0.85rem;
  color: var(--text-main);
  border-bottom: 1px solid #f1f5f9;
}

#audit-report-modal ul {
  padding-left: 1.2rem;
  margin: 0;
}

#audit-report-modal li {
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

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

/* FASE 5: Estilo Canva para Tarjetas KPI de Empresas */
.companies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
  width: 100%;
}

.company-kpi-card {
  background: #ffffff;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 20px rgba(110, 20, 20, 0.03);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
}

.company-kpi-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 30px rgba(110, 20, 20, 0.09);
}

.company-kpi-card-header {
  background: linear-gradient(135deg, #fdf2f3, #f7e1e3);
  padding: 1.75rem 1.5rem 1.5rem 1.5rem;
  border-bottom: 1px solid #f1f5f9;
  position: relative;
}

.company-kpi-card-title {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 800;
  color: #1e293b;
  margin: 0 0 0.35rem 0;
  line-height: 1.3;
  word-break: break-word;
}

.company-kpi-card-nit {
  font-family: var(--font-body);
  font-size: 14px;
  color: #475569;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.company-kpi-card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
}

.company-kpi-stat {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background-color: #fdf8f8;
  border: 1px solid #faebed;
  padding: 1rem 1.25rem;
  border-radius: 16px;
  margin-bottom: 0.25rem;
}

.company-kpi-stat-value {
  font-family: var(--font-title);
  font-size: 36px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.company-kpi-stat-label {
  font-size: 13px;
  color: #475569;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  display: block;
}

.company-kpi-info-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.company-kpi-info-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  line-height: 1.5;
}

.company-kpi-info-item .info-label {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}

.company-kpi-info-item .info-value {
  font-size: 15px;
  color: #1e293b;
  font-weight: 600;
  word-break: break-all;
}

.company-kpi-info-icon {
  color: var(--primary);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  margin-top: 3px;
  background: #fdf2f3;
  padding: 6px;
  border-radius: 8px;
}

.company-kpi-card-footer {
  padding: 1.25rem 1.5rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.company-kpi-card-footer .btn {
  font-size: 13px;
  font-weight: 700;
  padding: 0.65rem 0.5rem;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  text-align: center;
  white-space: nowrap;
}

.company-kpi-badge {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  box-shadow: 0 2px 8px rgba(110, 20, 20, 0.08);
}

.company-kpi-badge.active {
  background-color: #d1fae5;
  color: #065f46;
}

.company-kpi-badge.inactive {
  background-color: #fee2e2;
  color: #991b1b;
}

/* ==========================================
   ESTILOS ADICIONALES REGISTROEMPRESA 3.0
   ========================================== */

/* Animación de números al cargar */
@keyframes countUp {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-num {
  animation: countUp 0.5s ease-out forwards;
}

/* Grid de Empresas del CRM */
.companies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

/* Checklist de Progreso */
.checklist-item-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
}

.checklist-item-box:hover {
  border-color: var(--primary);
  background: #fff;
}

.checklist-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.checklist-item-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-main);
}

.checklist-item-status {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-completed { color: var(--success); }
.status-pending { color: var(--warning); }
.status-na { color: var(--text-muted); }

/* Alertas de Inactividad y Calidad */
.alert {
  padding: 12px 15px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
}

.alert-danger {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.alert-warning {
  background-color: #fefbeb;
  color: #92400e;
  border: 1px solid #fde047;
}

.alert-info {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
}

.alert:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.alert .badge {
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

/* Listado de Recordatorios */
.reminder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
}

.reminder-item.completed {
  background: #f1f5f9;
  text-decoration: line-through;
  opacity: 0.7;
}

.reminder-item-desc {
  font-weight: 500;
  color: var(--text-main);
}

.reminder-item-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Bitácora de Cambios */
.logs-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.logs-list li {
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 6px;
  border-left: 3px solid var(--primary);
  font-size: 12px;
  line-height: 1.4;
}

.logs-list li .log-time {
  font-size: 10px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
  font-weight: 600;
}

/* Estilos de Mapa */
#map-container {
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

/* Ajustes de Gráficos */
canvas {
  max-width: 100%;
}

