/* ============================================
   SGC - Sistema de Gestión de Contratos
   Estilos principales
   ============================================ */

:root {
  /* Paleta corporativa Gestión & Competencias Capacitación */
  --brand-navy: #1C435E;
  --brand-blue: #0F679C;
  --brand-blue-bright: #1A79B9;
  --brand-sky: #6BAFDF;
  --brand-gray: #687482;

  --primary: #0F679C;
  --primary-light: #1A79B9;
  --primary-dark: #1C435E;
  --accent: #6BAFDF;
  --accent-hover: #4a97cc;
  --success: #38a169;
  --danger: #e53e3e;
  --warning: #dd6b20;
  --info: #1A79B9;
  --bg: #f2f5f8;
  --bg-card: #ffffff;
  --text: #1c2a3a;
  --text-light: #687482;
  --border: #d9dfe5;
  --shadow: 0 2px 8px rgba(28,67,94,0.08);
  --shadow-lg: 0 4px 16px rgba(28,67,94,0.14);
  --radius: 8px;
  --radius-sm: 4px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* --- Header (sticky: brand + main nav + sub nav) --- */
.header {
  background: #ffffff;
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.app-logo {
  width: 38px;
  height: 38px;
  max-width: 38px;
  max-height: 38px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 3px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  flex-shrink: 0;
}

.app-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-info {
  font-size: 0.8rem;
  opacity: 0.95;
  display: flex;
  gap: 16px;
  align-items: center;
}

.header-info .badge-demo {
  background: var(--warning);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}

.user-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-selector label {
  font-size: 0.8rem;
  opacity: 0.9;
}

.user-selector select {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 0.8rem;
}

.user-selector select option {
  background: var(--primary);
  color: white;
}

.btn-cerrar-sesion {
  margin-left: 10px;
  padding: 5px 12px;
  font-size: 12px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-cerrar-sesion:hover { background: rgba(255,255,255,0.30); }

/* Paleta de pesta&ntilde;as: colores vivos por subsistema (segun modelo Instr. 5) */
:root {
  --tab-asignaciones: #2E86C1;   /* azul */
  --tab-propuestas:   #E67E22;   /* naranja */
  --tab-ejecucion:    #1E8449;   /* verde */
  --tab-calendario:   #7D3C98;   /* morado/lila */
  --tab-config:       #C0392B;   /* rojo (modulo CONFIGURACION / GENERAL) */
}

/* --- Men&uacute; principal (subsistemas): pestañas tipo carpeta --- */
.main-nav {
  display: flex;
  align-items: flex-end;
  background: #0f172a;  /* slate-900: contraste con las pestañas vivas */
  padding: 10px 14px 0;
  gap: 6px;
}

.main-tab {
  padding: 11px 30px 12px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  border: none;
  background: transparent;
  position: relative;
  font-family: inherit;
  /* Forma de pestaña de carpeta: lados superiores en diagonal hacia adentro */
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 100%, 0 100%);
  /* Instrucciones 7 · General item 1: border-radius en 5px */
  border-radius: 5px;
  /* Inactivas: hundidas (mas abajo), apagadas y "detras" */
  transform: translateY(7px);
  filter: brightness(0.62) saturate(0.85);
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
}

.main-tab:hover { filter: brightness(0.82); transform: translateY(4px); }

.main-tab[data-section="asignaciones"]   { background: var(--tab-asignaciones); }
.main-tab[data-section="propuestas"]     { background: var(--tab-propuestas); }
.main-tab[data-section="ejecucion"]      { background: var(--tab-ejecucion); }
.main-tab[data-section="calendario"]     { background: var(--tab-calendario); }
.main-tab[data-section="config-global"]  { background: var(--tab-config); }

/* Tab activa: al frente, color pleno, mas grande y "pegada" al contenido
   inferior — efecto de pestaña de archivador seleccionada. */
.main-tab.active {
  transform: translateY(0);
  filter: brightness(1.05) saturate(1.1);
  font-size: 0.9rem;
  padding: 14px 34px 14px;
  z-index: 3;
  box-shadow: 0 -5px 14px rgba(0, 0, 0, 0.40);
}
.main-tab.active::after {
  /* Tapa la union nav/contenido para que la pestaña activa se funda abajo */
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 6px;
  background: inherit;
}

/* --- Submen&uacute; --- */
.sub-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  background: var(--tab-asignaciones);   /* fallback: color del default */
  align-items: center;
  transition: background 0.2s;
}

.sub-tab {
  padding: 7px 16px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: #fff;
  background: rgba(255,255,255,0.0);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px 6px 0 0;
  transition: background 0.18s, border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transform: translateY(2px);
}

.sub-tab:hover {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.35);
  transform: translateY(1px);
}

.sub-tab.active {
  background: rgba(255,255,255,0.97);
  color: var(--brand-navy);
  border-color: rgba(255,255,255,0.97);
  transform: translateY(0);
  box-shadow: 0 -3px 8px rgba(0,0,0,0.22);
  font-weight: 700;
}

.sub-tab .tab-count {
  background: rgba(255,255,255,0.85);
  color: var(--brand-navy);
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

.sub-tab.active .tab-count { background: var(--brand-navy); color: #fff; }

/* Status indicators en la cinta del submenu */
.sub-nav-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.22);
  border-radius: 12px;
  white-space: nowrap;
}
.status-pill .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
}
.status-pill .dot.ok  { background: #16a34a; box-shadow: 0 0 0 2px rgba(22,163,74,0.30); }
.status-pill .dot.err { background: #dc2626; box-shadow: 0 0 0 2px rgba(220,38,38,0.30); }

/* El submen&uacute; toma el color del men&uacute; principal seleccionado */
.header[data-active-section="asignaciones"] .sub-nav[data-section="asignaciones"] { background: var(--tab-asignaciones); }
.header[data-active-section="asignaciones"] .sub-tab.active                        { color: var(--tab-asignaciones); }

.header[data-active-section="propuestas"] .sub-nav[data-section="propuestas"]      { background: var(--tab-propuestas); }
.header[data-active-section="propuestas"] .sub-tab.active                           { color: var(--tab-propuestas); }

/* EJECUCION: submenú verde, mismo diseño que los demás (Instrucciones 7) */
.header[data-active-section="ejecucion"] .sub-nav[data-section="ejecucion"]        { background: var(--tab-ejecucion); }
.header[data-active-section="ejecucion"] .sub-tab.active                            { color: var(--tab-ejecucion); }
/* secciones sin submen&uacute;: calendario / config-global */

/* Compatibilidad: estilos viejos de .tabs / .tab quedan inertes pero no rompen JS legacy */
.tabs { display: none; }

/* --- Main content --- */
.main-content {
  padding: 20px 24px;
  max-width: 1600px;
  margin: 0 auto;
}

.view { display: none; }
.view.active { display: block; }

/* Vistas reubicadas dentro de CONFIGURACION (reparenting JS, Instr. 5):
   ya no usan la clase .view, se muestran siempre dentro de su panel. */
.cfg-embedded { display: block; }

/* Sub-pestañas de CONFIGURACION */
.cfg-subtab {
  padding: 8px 18px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--text-light);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}
.cfg-subtab:hover { color: var(--text); }

/* Cada sub-pestaña de CONFIGURACION lleva el color de su subsistema:
   GENERAL rojo · ASIGNACIONES azul · PROPUESTA naranja · EJECUCION verde ·
   CALENDARIO lila. Inactiva: borde tenue de su color. Activa: color pleno. */
.cfg-subtab[data-cfg="general"]      { border-bottom-color: rgba(192,57,43,0.30); }
.cfg-subtab[data-cfg="asignaciones"] { border-bottom-color: rgba(46,134,193,0.30); }
.cfg-subtab[data-cfg="propuesta"]    { border-bottom-color: rgba(230,126,34,0.30); }
.cfg-subtab[data-cfg="ejecucion"]    { border-bottom-color: rgba(30,132,73,0.30); }
.cfg-subtab[data-cfg="calendario"]   { border-bottom-color: rgba(125,60,152,0.30); }

.cfg-subtab[data-cfg="general"].active      { color: var(--tab-config);        border-bottom-color: var(--tab-config); }
.cfg-subtab[data-cfg="asignaciones"].active { color: var(--tab-asignaciones);  border-bottom-color: var(--tab-asignaciones); }
.cfg-subtab[data-cfg="propuesta"].active    { color: var(--tab-propuestas);    border-bottom-color: var(--tab-propuestas); }
.cfg-subtab[data-cfg="ejecucion"].active    { color: var(--tab-ejecucion);     border-bottom-color: var(--tab-ejecucion); }
.cfg-subtab[data-cfg="calendario"].active   { color: var(--tab-calendario);    border-bottom-color: var(--tab-calendario); }

/* El encabezado de cada panel toma el color de su subsistema */
#cfgPanelGeneral   .card-header { background: var(--tab-config); }
#cfgPanelPropuesta .card-header { background: var(--tab-propuestas); }
#cfgPanelEjecucion .card-header { background: var(--tab-ejecucion); }
#cfgPanelCalendario .card-header { background: var(--tab-calendario); }
/* ASIGNACIONES conserva el azul corporativo (--primary) por defecto. */

/* Interior del panel GENERAL en tono rojo (botón principal + foco) */
#cfgPanelGeneral .btn-primary { background: var(--tab-config); }
#cfgPanelGeneral .btn-primary:hover { background: #a93226; }
#cfgPanelGeneral .btn-outline:hover { background: rgba(192,57,43,0.08); border-color: var(--tab-config); }

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--brand-gray);
}

.card-header {
  padding: 14px 20px;
  background: var(--primary);
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-body {
  padding: 16px 20px;
}

/* --- Toolbar / Filtros --- */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toolbar .search-box {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.toolbar .search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  transition: border 0.2s;
}

.toolbar .search-box input:focus {
  border-color: var(--primary-light);
}

.toolbar .search-box::before {
  content: '\1F50D';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
}

.filter-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-light);
  white-space: nowrap;
}

.filter-group select,
.filter-group input[type="date"] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
  background: white;
}

/* --- Buttons --- */
.btn {
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: var(--primary-dark); font-weight: 600; }
.btn-accent:hover { background: var(--accent-hover); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #2f855a; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c53030; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #c05621; }
.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #0F679C; }
.btn-sm { padding: 4px 10px; font-size: 0.75rem; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

/* --- Table --- */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  font-size: 0.82rem;
}

thead th {
  background: var(--primary);
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  font-size: 0.78rem;
}

tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover { background: #edf2f7; }

tbody tr.asignada { background: #fff5f5; }
tbody tr.asignada:hover { background: #fee; }

/* Centrado de tablas en Reporte de Resultado y Administración */
#viewResultado table th,
#viewResultado table td,
#viewAdministracion table th,
#viewAdministracion table td {
  text-align: center;
}
/* Mantener nombres (primera columna) alineados al inicio para legibilidad */
#viewResultado table tbody td:first-child,
#viewAdministracion table tbody td:first-child {
  text-align: left;
}

/* --- Status badges --- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-vigente { background: #c6f6d5; color: #22543d; }
.badge-cerrada { background: #fed7d7; color: #742a2a; }
.badge-pendiente { background: #fefcbf; color: #744210; }
.badge-aceptada { background: #c6f6d5; color: #22543d; }
.badge-rechazada { background: #fed7d7; color: #742a2a; }
.badge-adjudicada { background: #d6e9f5; color: #1C435E; }
.badge-no-adjudicada { background: #fbd38d; color: #744210; }
.badge-desierta { background: #e2e8f0; color: #2d3748; }
.badge-cancelada { background: #cbd5e0; color: #1a202c; }
.badge-enviado { background: #d6e9f5; color: #0F679C; }
.badge-asignada { background: #e9d8fd; color: #44337a; }
.badge-libre { background: #c6f6d5; color: #22543d; }
.badge-rol-administrador { background: #fbd38d; color: #7b341e; }
.badge-rol-gestor { background: #d6e9f5; color: #1C435E; }
.badge-rol-visualizador { background: #e2e8f0; color: #2d3748; }

/* Destacado de procesos que cierran en menos de 24h */
tr.cierra-24h {
  background: #fff5f5 !important;
  box-shadow: inset 3px 0 0 #e53e3e;
}
.urgente-icon {
  display: inline-block;
  margin-right: 4px;
  font-size: 1rem;
  animation: pulso 1.4s ease-in-out infinite;
}
.cierre-urgente {
  color: #c53030;
  font-weight: 600;
}
@keyframes pulso {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.85; }
}

/* Modo solo lectura (visualizador) */
body.modo-visualizador .accion-solo-edicion {
  display: none !important;
}

/* Cabeceras ordenables */
.th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.15s;
}
.th-sortable:hover {
  background: var(--primary-dark);
  color: white;
}
.sort-icon {
  display: inline-block;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.7);
  margin-right: 2px;
}
.sort-icon.sort-asc,
.sort-icon.sort-desc { color: var(--brand-sky); }

/* Link de correlativo a OneDrive */
.cr-link {
  color: #0F679C;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px dotted #0F679C;
  padding: 1px 2px;
}
.cr-link:hover {
  background: #ebf8ff;
  border-bottom-style: solid;
}

.badge-tipo {
  background: var(--primary-light);
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.7rem;
}

/* --- Modal --- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  justify-content: center;
  align-items: flex-start;
  padding-top: 60px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  padding: 14px 20px;
  background: var(--primary);
  color: white;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header .close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-body {
  padding: 20px;
}

.modal-body .form-group {
  margin-bottom: 14px;
}

.modal-body .form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text);
}

.modal-body .form-group input,
.modal-body .form-group select,
.modal-body .form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
}

.modal-body .form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* --- Stats cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--brand-gray);
  border-left: 5px solid var(--primary);
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.stat-card.accent { border-left-color: var(--accent); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.info { border-left-color: var(--info); }
.stat-card.warning { border-left-color: var(--warning); }

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* --- Detail panel (inline) --- */
.detail-panel {
  display: none;
  background: #f7fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 8px 0;
}

.detail-panel.active {
  display: block;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-item {
  font-size: 0.82rem;
}

.detail-item .label {
  font-weight: 600;
  color: var(--text-light);
  font-size: 0.75rem;
  text-transform: uppercase;
}

/* --- Toast notifications --- */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: white;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 350px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- Monto format --- */
.monto {
  font-weight: 600;
  white-space: nowrap;
}

/* --- Loading --- */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.loading::after {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .header-top { flex-direction: column; gap: 8px; }
  .tabs { overflow-x: auto; }
  .tab { padding: 8px 14px; font-size: 0.78rem; }
  .toolbar { flex-direction: column; }
  .toolbar .search-box { min-width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .main-content { padding: 12px; }

  /* --- Responsivo móvil (Instrucciones 15 #1) --- */
  /* Pestañas principales: desplazables horizontalmente, sin recortar texto. */
  .main-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding: 8px 8px 0;
    gap: 4px;
  }
  .main-nav::-webkit-scrollbar { height: 4px; }
  .main-tab {
    padding: 9px 16px 10px;
    font-size: 0.72rem;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex: 0 0 auto;
  }

  /* Sub-navegaciones (Ejecución, Configuración, Propuestas) desplazables. */
  .sub-nav, .cfg-subnav, .pt-subnav, .prop-subnav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .sub-tab, .cfg-subtab, .pt-tab { flex: 0 0 auto; white-space: nowrap; }

  /* Tablas: scroll horizontal en su contenedor para no romper el layout. */
  .table-container, .tabla-container, .historico-table-wrap, .scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table { font-size: 0.8rem; }

  /* Formularios y filas: apilar en una columna. */
  .form-row, .row-2, .row-3, .grid-2, .grid-3 { grid-template-columns: 1fr !important; display: grid; }
  .filtros, .filters, .toolbar { flex-wrap: wrap; }

  /* Modales: ocupar casi todo el ancho y permitir scroll vertical. */
  .modal-overlay { padding: 10px; }
  .modal { width: 96%; max-width: 96%; max-height: 92vh; overflow-y: auto; }
  .modal-body { max-height: 70vh; overflow-y: auto; }

  /* iframes embebidos (Ejecución / Calendario): aprovechar el alto disponible. */
  #ejecucionDiplomasFrame, #calendarioFrame { height: calc(100vh - 150px); }
}

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 12px;
}

.pagination .page-btn {
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: white;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
}

.pagination .page-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pagination .page-info {
  font-size: 0.8rem;
  color: var(--text-light);
  margin: 0 8px;
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.95rem;
}

/* --- Action column --- */
.action-cell {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* --- Bitacora inline --- */
.bitacora-entry {
  padding: 8px 12px;
  border-left: 3px solid var(--primary-light);
  margin-bottom: 8px;
  background: #f7fafc;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.8rem;
}

.bitacora-entry .fecha {
  font-size: 0.72rem;
  color: var(--text-light);
}

/* Table link */
.codigo-link {
  color: var(--primary-light);
  cursor: pointer;
  font-weight: 600;
  text-decoration: underline;
}

.codigo-link:hover {
  color: var(--primary-dark);
}

/* --- Acciones masivas de Procesos (Instrucciones 6 · Asignaciones item 1) --- */
.procesos-bulkbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 4px;
}
/* La columna de casillas y los controles masivos solo se ven como admin */
body.proc-admin .col-proc-check { display: table-cell !important; }
body.proc-admin #procesoCheckAll { display: inline-block; }
body.proc-admin #procesosBulkAdmin { display: flex !important; }
.proceso-check { width: 16px; height: 16px; cursor: pointer; }
