/* ==========================================================================
   ESTILOS INSTITUCIONALES - SISTEMA S&OP Y MÉTODOS CUANTITATIVOS
   Desarrollado por: Rodrigo Andrés Gómez Montoya Ph.D | Politécnico Colombiano Jaime Isaza Cadavid
   Paleta Institucional: Verde Bosque (#006837), Verde Colab (#4CAF50), Azul (#2196F3)
   ========================================================================== */

:root {
  --politecnico-primary: #006837;
  --politecnico-hover: #004d29;
  --colab-header-green: #4caf50;
  --colab-header-blue: #2196f3;
  --bg-main: #f4f6f9;
  --bg-card: #ffffff;
  --border-color: #d1d5db;
  --border-light: #e5e7eb;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --text-white: #ffffff;
  --warning-bg: #fff3cd;
  --warning-border: #ffeeba;
  --warning-text: #856404;
  --danger-red: #d32f2f;
  --success-green: #2e7d32;
  --info-blue: #0288d1;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  padding: 16px;
}

.container {
  max-width: 1440px;
  margin: 0 auto;
}

/* ==========================================================================
   Header Institucional
   ========================================================================== */
.institutional-header {
  background: linear-gradient(135deg, #00562e 0%, #007a41 100%);
  color: var(--text-white);
  padding: 24px 28px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  border-bottom: 4px solid #f9b233; /* Acento dorado institucional */
}

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

.header-title-group h1 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.header-subtitle {
  font-size: 0.95rem;
  color: #e2f4ea;
  font-weight: 500;
}

.header-badges {
  display: flex;
  gap: 10px;
  align-items: center;
}

.badge-inst {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-port {
  background: #ffffff;
  color: #006837;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

/* ==========================================================================
   Sección de Pasos de Configuración
   ========================================================================== */
.steps-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 24px;
}

@media (min-width: 1024px) {
  .steps-container {
    grid-template-columns: 1.1fr 1fr 1.3fr;
  }
}

.step-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid #edf2f7;
}

.step-number {
  background: var(--politecnico-primary);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.step-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
}

/* Controles de Formulario */
.form-group {
  margin-bottom: 12px;
}

.form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.form-col {
  flex: 1;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}

select, input[type="number"], input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.88rem;
  color: var(--text-main);
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

select:focus, input:focus {
  outline: none;
  border-color: var(--politecnico-primary);
  box-shadow: 0 0 0 3px rgba(0, 104, 55, 0.15);
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

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

.btn-success {
  background-color: #2e7d32;
  color: white;
}

.btn-success:hover {
  background-color: #1b5e20;
}

.btn-info {
  background-color: #0288d1;
  color: white;
}

.btn-info:hover {
  background-color: #01579b;
}

.btn-secondary {
  background-color: #f3f4f6;
  color: #374151;
  border-color: #d1d5db;
}

.btn-secondary:hover {
  background-color: #e5e7eb;
}

.btn-block {
  width: 100%;
}

.btn-group-sync {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.btn-sync {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-sync:hover {
  background-color: #e2e8f0;
  border-color: #94a3b8;
}

.btn-sync.loaded {
  border-left: 4px solid var(--politecnico-primary);
  background-color: #f0fdf4;
}

.sync-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #94a3b8;
}

.btn-sync.loaded .sync-status-dot {
  background-color: #16a34a;
}

/* Parámetros del Método */
.method-params-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 8px;
  margin-bottom: 12px;
}

/* ==========================================================================
   Pestañas de Resultados (Tabs)
   ========================================================================== */
.results-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 30px;
}

.tabs-nav {
  display: flex;
  background: #f1f5f9;
  border-bottom: 2px solid #cbd5e1;
  overflow-x: auto;
}

.tab-btn {
  padding: 14px 20px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #475569;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--politecnico-primary);
  background: #e2e8f0;
}

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

.tab-content {
  display: none;
  padding: 22px;
}

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

/* Subpestañas (Almacén y Transporte) */
.subtabs-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 8px;
}

.subtab-btn {
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.subtab-btn.active {
  background: #2196f3;
  color: white;
  border-color: #2196f3;
}

/* ==========================================================================
   Tablas Estilo Colab (#4CAF50 y #2196F3)
   ========================================================================== */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-note {
  font-size: 0.85rem;
  color: var(--danger-red);
  font-weight: 700;
  margin-bottom: 12px;
  background: #fef2f2;
  padding: 8px 12px;
  border-left: 4px solid var(--danger-red);
  border-radius: var(--radius-sm);
}

.table-scroll-container {
  overflow-x: auto;
  max-height: 520px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.05);
  background: white;
}

table.colab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  text-align: center;
}

table.colab-table th {
  background-color: var(--colab-header-green);
  color: var(--text-white);
  padding: 10px 8px;
  font-weight: 600;
  border: 1px solid #388e3c;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: pre-line;
  line-height: 1.25;
}

table.colab-table-blue th {
  background-color: var(--colab-header-blue);
  border-color: #1976d2;
}

table.colab-table td {
  padding: 7px 8px;
  border: 1px solid #e2e8f0;
  vertical-align: middle;
  white-space: nowrap;
}

table.colab-table tbody tr:nth-child(even) {
  background-color: #f9fafb;
}

table.colab-table tbody tr:hover {
  background-color: #f1f5f9;
}

/* Inputs dentro de tablas editables */
table.colab-table input[type="number"],
table.colab-table input[type="text"],
table.colab-table select {
  width: 100%;
  min-width: 95px;
  padding: 4px 6px;
  font-size: 0.82rem;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  text-align: center;
  background-color: #ffffff;
}

table.colab-table input[readonly],
table.colab-table input[disabled] {
  background-color: #f1f5f9;
  color: #1e293b;
  font-weight: 600;
  border-color: #e2e8f0;
  cursor: not-allowed;
}

/* Totales y filas destacadas */
.tr-total {
  background-color: #dcfce7 !important;
  font-weight: 700;
  color: #14532d;
}

/* ==========================================================================
   Gráficos
   ========================================================================== */
.chart-container {
  position: relative;
  height: 380px;
  width: 100%;
  margin-bottom: 20px;
  background: white;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Notificaciones Toast & Spinners
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease forwards;
}

.toast-success { background-color: #16a34a; }
.toast-error { background-color: #dc2626; }
.toast-info { background-color: #0284c7; }

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

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Footer Institucional
   ========================================================================== */
.institutional-footer {
  text-align: center;
  padding: 20px 0;
  margin-top: 30px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   Módulo de Ingesta Multicanal (Paso 1)
   ========================================================================== */
.ingestion-module-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.ingestion-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: all 0.2s ease;
}

.ingestion-card:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.ingestion-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ingestion-card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #475569;
}

.status-pill.pill-green {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.status-pill.pill-amber {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.status-pill.pill-red {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.ingestion-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.btn-tpl {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.btn-tpl:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.btn-upload-file {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.btn-upload-file:hover {
  background: #1d4ed8;
}

.btn-sync-supa {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #006837;
  background: #ffffff;
  color: #006837;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.btn-sync-supa:hover {
  background: #006837;
  color: #ffffff;
}

/* ==========================================================================
   Semáforo de Integridad Estricta S&OP
   ========================================================================== */
.semaphore-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
}

.semaphore-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.semaphore-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 6px;
}

.semaphore-global-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}

.semaphore-global-badge.ready {
  background: #dcfce7;
  color: #15803d;
}

.semaphore-global-badge.blocked {
  background: #fee2e2;
  color: #b91c1c;
}

.semaphore-lights {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.semaphore-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #334155;
}

.led-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 2px rgba(0,0,0,0.2);
  transition: all 0.3s;
}

.led-light.green {
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

.led-light.yellow {
  background: #eab308;
  box-shadow: 0 0 8px #eab308;
}

.led-light.red {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

.forecast-btn-hint {
  font-size: 0.75rem;
  margin-top: 6px;
  text-align: center;
  color: #64748b;
}

.btn-primary:disabled {
  background-color: #94a3b8 !important;
  border-color: #94a3b8 !important;
  cursor: not-allowed;
  opacity: 0.7;
}

/* ==========================================================================
   Centro de Edición Directa de Datos (Data Grid Editable)
   ========================================================================== */
.datagrid-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.datagrid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: white;
  cursor: pointer;
  user-select: none;
}

.datagrid-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.datagrid-icon {
  font-size: 1.5rem;
}

.datagrid-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.datagrid-subtitle {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin: 0;
}

.datagrid-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.grid-dirty-pill {
  background: #f59e0b;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.btn-toggle-grid {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle-grid:hover {
  background: rgba(255, 255, 255, 0.25);
}

.datagrid-body {
  padding: 16px 20px;
}

.grid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.grid-table-selector-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.grid-tab-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.grid-tab-btn.active {
  background: #006837;
  border-color: #006837;
  color: white;
}

.grid-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.grid-search-input {
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  width: 200px;
}

.spreadsheet-container {
  overflow-x: auto;
  max-height: 480px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  background: white;
}

.spreadsheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
}

.spreadsheet-table th {
  background: #f8fafc;
  color: #334155;
  padding: 8px 10px;
  font-weight: 700;
  border-bottom: 2px solid #cbd5e1;
  border-right: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

.spreadsheet-table td {
  padding: 4px 6px;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #f1f5f9;
  white-space: nowrap;
}

.spreadsheet-table tr:hover td {
  background-color: #f8fafc;
}

.grid-cell-input {
  width: 100%;
  min-width: 75px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 3px;
  font-size: 0.82rem;
  font-family: inherit;
  background: transparent;
  transition: all 0.15s;
}

.grid-cell-input:focus {
  border-color: #2563eb;
  background: #ffffff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.grid-cell-input.cell-modified {
  background-color: #fef9c3 !important;
  border-color: #f59e0b !important;
  font-weight: 600;
  color: #92400e;
}

.grid-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 0.82rem;
  color: #64748b;
  flex-wrap: wrap;
  gap: 10px;
}

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

/* ==========================================================================
   Catálogo Maestro de Artículos y Logística Integral
   ========================================================================== */

.btn-maestro-open {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #38bdf8;
  border: 1px solid #38bdf8;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-maestro-open:hover {
  background: #0284c7;
  color: white;
  border-color: #0284c7;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.modal-container {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.25s ease-out;
}

.modal-container.modal-lg {
  max-width: 1280px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.modal-header {
  padding: 16px 24px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #334155;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-icon {
  font-size: 1.75rem;
}

.modal-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
}

.modal-subtitle {
  margin: 2px 0 0 0;
  font-size: 0.8rem;
  color: #94a3b8;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.2s;
}

.modal-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  background: #f8fafc;
}

/* Toolbar del Maestro */
.maestro-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
  background: white;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
}

.maestro-search-box {
  flex: 1;
  min-width: 260px;
}

.maestro-search-box input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.maestro-filter-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
}

.maestro-filter-box select {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.maestro-actions-box {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-upload-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

/* Form Drawer de Producto */
.maestro-form-drawer {
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  animation: slideDown 0.2s ease-out;
}

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

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 10px;
  margin-bottom: 16px;
}

.drawer-header h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #1e293b;
}

.drawer-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #64748b;
  cursor: pointer;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.form-card-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 16px;
}

.form-card-section h4 {
  margin: 0 0 14px 0;
  font-size: 0.92rem;
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 6px;
}

.form-field {
  margin-bottom: 12px;
}

.form-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 4px;
}

.form-field input,
.form-field select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  background: white;
}

.form-field input:focus,
.form-field select:focus {
  border-color: #0284c7;
  outline: none;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

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

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

.field-hint {
  display: block;
  font-size: 0.7rem;
  color: #64748b;
  margin-top: 3px;
}

.btn-text-action {
  background: none;
  border: none;
  color: #0284c7;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.btn-text-action:hover {
  text-decoration: underline;
}

.image-preview-container {
  margin-top: 10px;
}

.preview-box {
  width: 100%;
  height: 110px;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-top: 4px;
}

.preview-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
}

.form-actions-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

/* Tabla del Maestro */
.maestro-table-container {
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  max-height: 520px;
}

.maestro-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  text-align: left;
}

.maestro-table th {
  background: #0f172a;
  color: #f8fafc;
  padding: 10px 12px;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 5;
  white-space: nowrap;
}

.maestro-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  vertical-align: middle;
}

.maestro-table tr:hover td {
  background-color: #f1f5f9;
}

.product-thumb {
  width: 38px;
  height: 38px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid #cbd5e1;
  background: #e2e8f0;
  display: block;
}

.uom-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-status-activo {
  background: #dcfce7;
  color: #15803d;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-status-inactivo {
  background: #fee2e2;
  color: #b91c1c;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
}

.btn-action-icon {
  background: none;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.78rem;
  transition: all 0.15s;
}

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

.maestro-footer-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  margin-top: 14px;
  font-size: 0.85rem;
}

/* Animación de celda calculada en Data Grid */
.cell-highlight-calc {
  animation: highlightGlow 1.2s ease-out;
  background-color: #e0f2fe !important;
  color: #0369a1 !important;
  font-weight: 700 !important;
}

@keyframes highlightGlow {
  0% { background-color: #38bdf8; color: white; }
  100% { background-color: #e0f2fe; color: #0369a1; }
}

/* ==========================================================================
   Estilos Operaciones por Lote y Mejoras Visuales S&OP
   ========================================================================== */
.grid-row-selected td {
  background-color: #e0f2fe !important;
}

.btn-grid-row-delete,
.btn-delete-product {
  background: none;
  border: 1px solid #fca5a5;
  color: #dc2626;
  border-radius: 4px;
  padding: 3px 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s ease;
  line-height: 1;
}

.btn-grid-row-delete:hover,
.btn-delete-product:hover {
  background: #fee2e2;
  border-color: #ef4444;
  transform: scale(1.05);
}

.winner-metrics-card {
  transition: all 0.3s ease;
}

.winner-metrics-card:hover {
  box-shadow: 0 4px 12px rgba(0, 104, 55, 0.12);
}

.param-row {
  padding: 4px 0;
  border-bottom: 1px dashed #e2e8f0;
}

.param-row:last-child {
  border-bottom: none;
}

/* ==========================================================================
   HEADER INSTITUCIONAL DE 2 NIVELES & RIBBON SCM / DDMRP
   ========================================================================== */
.inst-header-industrial {
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 26, 51, 0.25);
  font-family: var(--font-main, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
}

/* NIVEL 1: BARRA INSTITUCIONAL (#002244) */
.header-top-bar {
  height: 56px;
  min-height: 56px;
  background-color: #002244;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  box-sizing: border-box;
}

.header-brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-sq {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  font-weight: 800;
  font-size: 15px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  user-select: none;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.brand-text-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-main-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: #ffffff;
  margin: 0 0 2px 0;
  text-transform: uppercase;
}

.brand-subtitle {
  font-size: 11px;
  color: #cbd5e1;
  margin: 0;
}

.header-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-status-port {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 4px;
  background-color: #0284c7;
  color: #ffffff;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.btn-top-item {
  height: 30px;
  padding: 0 12px;
  font-size: 11.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #ffffff;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-top-item:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: #ffffff;
  color: #ffffff;
}

.btn-top-item.btn-switcher-doe {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.45);
}

.btn-top-item.btn-switcher-doe:hover {
  background: rgba(16, 185, 129, 0.35);
  border-color: #10b981;
}

.btn-top-item.btn-switcher-sigma {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.45);
}

.btn-top-item.btn-switcher-sigma:hover {
  background: rgba(245, 158, 11, 0.35);
  border-color: #f59e0b;
}

/* NIVEL 2: RIBBON DE TRABAJO (#003366) */
.header-toolbar-ribbon {
  height: 48px;
  min-height: 48px;
  background-color: #003366;
  border-bottom: 2px solid #001a33;
  display: flex;
  align-items: center;
  padding: 0 18px;
  box-sizing: border-box;
}

.toolbar-block-project {
  display: flex;
  align-items: center;
}

.btn-ribbon-project {
  height: 32px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #ffffff;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.btn-ribbon-project:hover,
.btn-ribbon-project.active {
  background: rgba(255, 255, 255, 0.26);
  border-color: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.25);
}

.toolbar-ribbon-divider {
  border-right: 1px solid rgba(148, 163, 184, 0.4);
  height: 24px;
  margin: 0 14px;
  flex-shrink: 0;
}

.toolbar-block-scm {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.toolbar-label-scm {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  user-select: none;
}

.toolbar-select-scm {
  max-width: 440px;
  font-size: 12px;
}

.toolbar-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* MENÚ DESPLEGABLE INSTITUCIONAL [📁 ARCHIVO ▾] */
.menu-dropdown {
  position: relative;
  display: inline-block;
}

.menu-dropdown-content {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #ffffff;
  min-width: 270px;
  box-shadow: 0 10px 25px rgba(0, 31, 63, 0.25);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 0;
  z-index: 3000;
  animation: fadeInDown 0.15s ease-out;
}

.menu-dropdown-content.show {
  display: block;
}

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

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 12.5px;
  font-weight: 500;
  color: #1e293b;
  cursor: pointer;
  transition: background 0.12s ease;
  gap: 10px;
  box-sizing: border-box;
}

.menu-item:hover {
  background-color: #f1f5f9;
  color: #003366;
}

.menu-item.menu-item-danger {
  color: #dc2626;
}

.menu-item.menu-item-danger:hover {
  background-color: #fee2e2;
  color: #b91c1c;
}

.menu-separator {
  height: 1px;
  background-color: #e2e8f0;
  margin: 4px 0;
}

.menu-submenu-wrapper {
  position: relative;
}

.menu-item-has-sub {
  display: flex;
  justify-content: space-between;
}

.menu-submenu-content {
  display: none;
  position: absolute;
  top: 0;
  left: 100%;
  background: #ffffff;
  min-width: 240px;
  box-shadow: 0 10px 25px rgba(0, 31, 63, 0.25);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 0;
  z-index: 3010;
}

.menu-submenu-wrapper:hover .menu-submenu-content {
  display: block;
}

.menu-empty-recent {
  padding: 8px 16px;
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
}

/* MODALES INSTITUCIONALES (NEW, SAVE AS, EXIT, SCM CASE) */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog-box {
  background-color: #fff;
  border-radius: 6px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 580px;
  overflow: hidden;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header-bar {
  background-color: #002244;
  color: #fff;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #004c99;
}

.modal-header-bar h3 {
  font-size: 14.5px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
}

.btn-close-modal {
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.btn-close-modal:hover {
  color: #fff;
}

.modal-body-content {
  padding: 18px;
}

.modal-footer-bar {
  background-color: #f8fafc;
  padding: 12px 18px;
  border-top: 1px solid #cbd5e1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-minitab-dialog-ok {
  background-color: #003366;
  color: #ffffff;
  border: 1px solid #002244;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-minitab-dialog-ok:hover {
  background-color: #002244;
}

.btn-minitab-dialog-cancel {
  background-color: #e2e8f0;
  color: #334155;
  border: 1px solid #cbd5e1;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-minitab-dialog-cancel:hover {
  background-color: #cbd5e1;
}

/* =========================================================================
   ESTILOS INSTITUCIONALES PESTAÑA BUFFERS DDMRP & FLUJO NETO
   ========================================================================= */
.badge-ddmrp-rojo {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}

.badge-ddmrp-amarillo {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}

.badge-ddmrp-verde {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}

.badge-ddmrp-azul {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}

.btn-ddmrp-action-sm {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #003366;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.15s ease;
}

.btn-ddmrp-action-sm:hover {
  background: #003366;
  color: #ffffff;
  border-color: #002244;
}

#table-ddmrp-matrix tr:hover {
  background-color: #f8fafc;
}


