/* =========================================================
   Sistema de Requerimientos — Pro-Agroindustria
   Estilo: inspirado en SAP Fiori (shell bar oscuro, azul de marca,
   esquinas casi rectas, tablas densas, estatus tipo "Object Status")
   Tipografía: Inter (Google Fonts) — SAP usa una fuente propia ("72")
   que no está disponible fuera de sus productos; Inter es el
   sustituto más cercano en look & feel corporativo/plano.
   ========================================================= */

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

:root {
  --color-shell: #354a5f;
  --color-shell-dark: #29394a;
  --color-accent: #0a6ed1;
  --color-accent-dark: #085caf;
  --color-bg: #f7f7f7;
  --color-surface: #ffffff;
  --color-primary: #1d2d3e;
  --color-text: #1d2d3e;
  --color-text-muted: #6a6d70;
  --color-border: #d9d9d9;
  --color-success: #107e3e;
  --color-success-bg: #f1fdf6;
  --color-warning: #e9730c;
  --color-warning-bg: #fef7f1;
  --color-info: #0a6ed1;
  --color-info-bg: #f5faff;
  --color-danger: #bb0000;
  --color-danger-bg: #ffebeb;
  --color-neutral: #6a6d70;
  --color-neutral-bg: #f2f2f2;
  --color-amarillo-bg: #fff9c4;
  --color-amarillo-bg-hover: #fff59d;
  --color-amarillo-texto: #7a5c00;

  --radius: 4px;
  --shadow-sm: 0 0 2px rgba(0, 0, 0, 0.14);
  --shadow: 0 0 4px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.45;
  font-size: 0.875rem;
}

/* ---------- Shell bar (header) ---------- */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-shell);
  color: white;
  padding: 0 20px;
  height: 44px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
header .header-logo-wrap {
  background: #ffffff;
  padding: 3px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}
header .header-logo {
  height: 22px;
  width: auto;
  display: block;
}
header a {
  color: white;
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  opacity: 0.9;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: background 0.1s;
}
header a:hover { opacity: 1; background: rgba(255,255,255,0.1); text-decoration: none; }
header > div { display: flex; align-items: center; gap: 12px; }
header #usuarioNombre { font-size: 0.8125rem; opacity: 0.9; }

/* ---------- Layout general ---------- */

main {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
  margin-bottom: 16px;
}

h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 14px 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}
h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 20px 0 10px 0;
}
h4 { margin: 0 0 8px 0; font-size: 0.8125rem; font-weight: 600; color: var(--color-text-muted); }

.ayuda { color: var(--color-text-muted); font-size: 0.8125rem; margin: 4px 0 14px 0; }

/* ---------- Tablas (estilo tabla densa Fiori) ---------- */

table { width: 100%; border-collapse: collapse; background: var(--color-surface); font-size: 0.8125rem; }
th {
  text-align: left;
  padding: 8px 12px;
  background: #fafafa;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  border-bottom: 2px solid var(--color-border);
}
td { padding: 8px 12px; border-bottom: 1px solid var(--color-border); }
tbody tr:hover { background: var(--color-info-bg); }
table a { color: var(--color-accent); text-decoration: none; font-weight: 500; }
table a:hover { text-decoration: underline; }

/* ---------- Botones ---------- */

button {
  padding: 6px 16px;
  margin: 2px 2px 2px 0;
  cursor: pointer;
  border: 1px solid #89919a;
  border-radius: var(--radius);
  background: var(--color-surface);
  color: #32363a;
  font-size: 0.8125rem;
  font-weight: 400;
  font-family: inherit;
  transition: background 0.1s, border-color 0.1s;
}
button:hover { background: #ebeff0; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

#guardarBtn, #nuevoBtn, .btnAceptar, .login-box button {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
  font-weight: 600;
}
#guardarBtn:hover, #nuevoBtn:hover, .btnAceptar:hover, .login-box button:hover {
  background: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
}

.btnRechazar, #logoutBtn {
  background: transparent;
  border-color: transparent;
}
.btnRechazar { color: var(--color-danger); }
.btnRechazar:hover { background: var(--color-danger-bg); border-color: var(--color-danger-bg); }

header button { border-color: rgba(255,255,255,0.35); color: white; background: transparent; }
header button:hover { background: rgba(255,255,255,0.1); }

#enlaceAlmacen button, #enlaceAdquisiciones button {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: #89919a;
}

/* ---------- Formularios ---------- */

.campo { margin-bottom: 16px; display: flex; flex-direction: column; max-width: 400px; }
.campo label { font-weight: 600; margin-bottom: 6px; font-size: 0.8125rem; color: var(--color-text); }
.campo-ancho { max-width: 100%; }
.campo-ancho textarea { min-height: 140px; }

input, select, textarea {
  padding: 7px 10px;
  font-size: 0.8125rem;
  border: 1px solid #89919a;
  border-radius: var(--radius);
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
  border-color: var(--color-accent);
}
input:disabled, select:disabled, textarea:disabled { background: #f2f2f2; color: var(--color-text-muted); border-color: var(--color-border); }
textarea { min-height: 60px; resize: vertical; }

.dato-tecnico, #folioLabel, input[type="number"] {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

fieldset {
  margin-bottom: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
fieldset legend { font-weight: 600; font-size: 0.8125rem; color: var(--color-text-muted); padding: 0 6px; }
fieldset label { display: block; font-weight: normal; padding: 3px 0; }

.partida-descripcion { width: 100%; min-width: 220px; resize: vertical; }
table th:nth-child(2) { width: 45%; }

.acciones { margin-top: 20px; display: flex; gap: 10px; }

/* ---------- Login ---------- */

.login-body {
  background: var(--color-bg);
  min-height: 100vh;
}

.login-box {
  max-width: 340px;
  margin: 100px auto;
  background: var(--color-surface);
  padding: 32px 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border-top: 3px solid var(--color-accent);
}
.login-box h1 {
  font-size: 1.05rem;
  color: var(--color-text);
  margin: 0 0 20px 0;
  text-align: center;
  font-weight: 700;
}
.login-box form { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Mensajes ---------- */

.error { color: var(--color-danger); font-weight: 600; font-size: 0.8125rem; }
.ok { color: var(--color-success); font-weight: 600; font-size: 0.8125rem; }
#mensaje { margin-top: 10px; }

/* ---------- Estatus tipo "Object Status" ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  background: none;
  padding: 0;
  border-radius: 0;
}
.badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge-en_proceso   { color: var(--color-neutral); }
.badge-en_validacion,
.badge-en_revision   { color: var(--color-warning); }
.badge-en_asignacion { color: var(--color-info); }
.badge-en_invitacion { color: var(--color-success); }
.badge-cuadro_comparativo { color: var(--color-info); }
.badge-cancelado     { color: var(--color-danger); }
.badge-pendiente     { color: var(--color-info); }

/* ---------- Firmas ---------- */

.firma-ayuda-box {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: #fafafa;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
}
.firma-ayuda-box .ayuda { margin: 0; flex: 1; min-width: 200px; }

.firma-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--color-shell);
  color: white;
  border-radius: var(--radius);
  cursor: grab;
  font-weight: 600;
  font-size: 0.8125rem;
  white-space: nowrap;
}
.firma-chip span { font-size: 1rem; }
.firma-chip:active { cursor: grabbing; }

.firmas-container { display: flex; gap: 20px; flex-wrap: wrap; }

.firma-slot {
  flex: 1;
  min-width: 300px;
  max-width: 420px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--color-surface);
  transition: border-color 0.15s, background 0.15s;
}
.firma-slot.drag-over { border-color: var(--color-accent); background: var(--color-info-bg); }

.firma-slot-rol {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  background: #f2f2f2;
  padding: 3px 8px;
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.firma-slot-nombre {
  font-weight: 700;
  font-size: 0.65rem;
  color: var(--color-text);
  margin-bottom: 14px;
  line-height: 1.35;
}

.firma-lienzo {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 130px;
  border: 1px solid #89919a;
  border-radius: var(--radius);
  background: #fff;
  cursor: crosshair;
}

.firma-placeholder {
  width: 100%;
  height: 130px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.firma-imagen-wrap {
  width: 100%;
  height: 130px;
  border: 1px solid #89919a;
  border-radius: var(--radius);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}
.firma-imagen-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.firma-slot-botones { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: #89919a; }
.btn-secondary:hover { background: #ebeff0; }

.btn-success { background: var(--color-success); border-color: var(--color-success); color: white; font-weight: 600; }
.btn-success:hover { background: #0c6631; border-color: #0c6631; }

.buscador-caja { position: relative; margin-top: 8px; }
.buscador-caja input { width: 100%; }
.buscador-resultados {
  list-style: none;
  margin: 4px 0 0 0;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: white;
  max-height: 180px;
  overflow-y: auto;
  position: absolute;
  width: 100%;
  z-index: 10;
  box-shadow: var(--shadow-lg);
}
.buscador-resultados li { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #f2f2f2; font-size: 0.8125rem; }
.buscador-resultados li:hover { background: var(--color-info-bg); }
.buscador-resultados li.sin-resultados { color: var(--color-text-muted); cursor: default; font-style: italic; }

canvas { touch-action: none; }

/* ---------- Bitácora ---------- */

#bitacoraLista ul { list-style: none; padding: 0; margin: 8px 0 0 0; }
#bitacoraLista li {
  padding: 8px 12px;
  border-left: 3px solid var(--color-border);
  background: #fafafa;
  margin-bottom: 6px;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* ---------- Línea de tiempo ---------- */

.timeline { display: flex; align-items: flex-start; margin: 16px 0 8px 0; }
.timeline-paso {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  text-align: center;
  min-width: 0;
}
.timeline-punto {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  margin-bottom: 8px;
  flex-shrink: 0;
  position: relative;
}
.timeline-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.3;
  padding: 0 4px;
  font-weight: 500;
}
.timeline-linea {
  flex: 0 0 40px;
  height: 2px;
  background: var(--color-border);
  margin-top: 18px;
}

.timeline-paso.completado .timeline-punto {
  background: var(--color-success);
  border-color: var(--color-success);
}
.timeline-paso.completado .timeline-punto::after {
  content: '✓';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
}
.timeline-paso.completado .timeline-label { color: var(--color-success); font-weight: 600; }
.timeline-paso.completado + .timeline-linea { background: var(--color-success); }

.timeline-paso.actual .timeline-punto {
  background: var(--color-accent);
  border-color: var(--color-accent);
}
.timeline-paso.actual .timeline-label { color: var(--color-accent); font-weight: 700; }

@media (max-width: 600px) {
  .timeline { flex-wrap: wrap; }
  .timeline-linea { display: none; }
  .timeline-paso { flex: 1 1 45%; margin-bottom: 12px; }
}

/* ============================================================
   CUADRO COMPARATIVO
   ============================================================ */

.celda-mejor-precio {
  background: var(--color-success-bg);
  font-weight: 600;
}

.main-ancho {
  max-width: 96vw;
}
.main-ancho table {
  font-size: 0.72rem;   /* ← letra más chica */
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--color-border);
}

/* ============================================================
   Celdas del cuadro comparativo — padding mínimo
   ============================================================ */

.main-ancho th,
.main-ancho td {
  padding: 3px 4px;
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  vertical-align: middle;
  line-height: 1.2;
  white-space: nowrap;
}

.main-ancho th:last-child,
.main-ancho td:last-child {
  border-right: none;
}

/* Encabezado fila 1 (nombres de proveedores): puede partirse si es muy largo */
.main-ancho thead tr:nth-child(1) th {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  padding: 4px 4px;
}

/* Encabezado general */
.main-ancho thead th {
  padding: 4px 4px;
  background: #eef2f6;
  color: var(--color-text);
  font-weight: 700;
  font-size: 0.7rem;     /* ← letra más chica */
  text-align: center;
  border-bottom: 2px solid var(--color-border);
}

.main-ancho thead .grupo-par   { background: #e3eaf2; }
.main-ancho thead .grupo-impar { background: #f5f7fa; }

.main-ancho thead th:first-child,
.main-ancho thead th:nth-child(2),
.main-ancho thead th:nth-child(3),
.main-ancho thead th:nth-child(4) {
  background: #d8e0e8;
  text-align: left;
}

/* ---------- Cuerpo ---------- */
.main-ancho tbody tr:nth-child(odd) {
  background: #ffffff;
}
.main-ancho tbody tr:nth-child(even) {
  background: #f4f6f9;
}
.main-ancho tbody .grupo-par {
  background: #f4f6f9;
}
.main-ancho tbody .grupo-impar {
  background: #ffffff;
}
.main-ancho tbody tr:hover {
  background: #e6f0fa !important;
}

/* ---------- Separadores entre proveedores ----------
   box-shadow en vez de border-left para NO ocupar ancho extra. */
.main-ancho .col-separador {
  border-left: none;
  box-shadow: inset 2px 0 0 0 #b8c4d0;
}

.main-ancho tbody td:first-child,
.main-ancho tbody td:nth-child(2) {
  background: #eef2f6;
  font-weight: 500;
}
.main-ancho tbody tr:hover td:first-child,
.main-ancho tbody tr:hover td:nth-child(2) {
  background: #dbe7f3;
}

/* ---------- Mejor precio (subtotal más bajo) ---------- */
.main-ancho .celda-mejor-precio {
  background: var(--color-success-bg) !important;
  font-weight: 700;
  color: var(--color-success);
}

/* ============================================================
   RESALTADOS ESPECIALES DEL CUADRO COMPARATIVO
   ============================================================ */

#tablaComparativo tbody td.celda-mejor-importe {
  background-color: var(--color-amarillo-bg) !important;
  font-weight: 700;
  color: var(--color-amarillo-texto);
  box-shadow: inset 0 0 0 1px #f0d800;
}
#tablaComparativo tbody tr:hover td.celda-mejor-importe {
  background-color: var(--color-amarillo-bg-hover) !important;
}
#tablaComparativo tbody tr:nth-child(odd) td.celda-mejor-importe,
#tablaComparativo tbody tr:nth-child(even) td.celda-mejor-importe {
  background-color: var(--color-amarillo-bg) !important;
}

#tablaComparativo tbody td.celda-condiciones-pago {
  color: var(--color-danger) !important;
  font-weight: 600;
}
#tablaComparativo tbody tr:nth-child(odd) td.celda-condiciones-pago,
#tablaComparativo tbody tr:nth-child(even) td.celda-condiciones-pago {
  color: var(--color-danger) !important;
}
#tablaComparativo tbody tr:hover td.celda-condiciones-pago {
  color: var(--color-danger) !important;
}

/* ============================================================
   COLUMNAS Y HEADER FIJOS — CUADRO COMPARATIVO
   ============================================================ */

.tabla-scroll {
  overflow: auto;
  max-width: 100%;
  max-height: 70vh;
}

/* ============================================================
   Anchos de columnas
   - # = 40px
   - Descripción = 260px
   - Cantidad = 70px
   - Unidad = 140px (para "UNIDAD DE SERVICIO")
   - Proveedores = 110px cada una
   ============================================================ */

/* # */
#tablaComparativo th:nth-child(1),
#tablaComparativo td:nth-child(1) {
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  text-align: center;
}

/* Descripción */
#tablaComparativo th:nth-child(2),
#tablaComparativo td:nth-child(2) {
  width: 260px !important;
  min-width: 260px !important;
  max-width: 260px !important;
  white-space: normal !important;
  overflow-wrap: break-word;
}

/* Cantidad */
#tablaComparativo th:nth-child(3),
#tablaComparativo td:nth-child(3) {
  width: 70px !important;
  min-width: 70px !important;
  max-width: 70px !important;
  text-align: center;
}

/* Unidad */
#tablaComparativo th:nth-child(4),
#tablaComparativo td:nth-child(4) {
  width: 140px !important;
  min-width: 140px !important;
  max-width: 140px !important;
  text-align: center;
  white-space: nowrap !important;
}

/* ============================================================
   Columnas de proveedores — TODAS del MISMO ancho (110px)
   ============================================================ */

#tablaComparativo th:nth-child(3n+5),
#tablaComparativo td:nth-child(3n+5),
#tablaComparativo th:nth-child(3n+6),
#tablaComparativo td:nth-child(3n+6),
#tablaComparativo th:nth-child(3n+7),
#tablaComparativo td:nth-child(3n+7) {
  width: 110px !important;
  min-width: 110px !important;
  max-width: 110px !important;
  padding-left: 4px !important;
  padding-right: 4px !important;
  text-align: center;
  box-sizing: border-box;
}

/* ============================================================
   FILA 1 DEL THEAD — sticky vertical
   ============================================================ */
#tablaComparativo thead tr:nth-child(1) th {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: #d8e0e8 !important;
  background-clip: padding-box;
  border-bottom: 2px solid var(--color-border);
  padding: 4px 4px !important;
  font-size: 0.7rem !important;
}

#tablaComparativo thead tr:nth-child(1) th.grupo-par {
  background-color: #e3eaf2 !important;
}
#tablaComparativo thead tr:nth-child(1) th.grupo-impar {
  background-color: #f5f7fa !important;
}

/* ============================================================
   FILA 2 DEL THEAD — sticky vertical
   ============================================================ */
#tablaComparativo thead tr:nth-child(2) th {
  position: sticky;
  top: 28px;
  z-index: 15;
  background-color: #eef2f6 !important;
  background-clip: padding-box;
  border-bottom: 2px solid var(--color-border);
  padding: 4px 4px !important;
  font-size: 0.7rem !important;
}

#tablaComparativo thead tr:nth-child(2) th.grupo-par {
  background-color: #e3eaf2 !important;
}
#tablaComparativo thead tr:nth-child(2) th.grupo-impar {
  background-color: #f5f7fa !important;
}

/* ============================================================
   COLUMNAS FIJAS HORIZONTALES
   # = 0
   Descripción = 40
   Cantidad = 40 + 260 = 300
   Unidad = 300 + 70 = 370
   ============================================================ */

#tablaComparativo thead th:nth-child(1),
#tablaComparativo tbody td:nth-child(1) { left: 0;     z-index: 25; }

#tablaComparativo thead th:nth-child(2),
#tablaComparativo tbody td:nth-child(2) { left: 40px;  z-index: 25; }

#tablaComparativo thead th:nth-child(3),
#tablaComparativo tbody td:nth-child(3) { left: 300px; z-index: 25; }

#tablaComparativo thead th:nth-child(4),
#tablaComparativo tbody td:nth-child(4) { left: 370px; z-index: 25; }

/* Sticky horizontal SOLO en las primeras 4 columnas de la FILA 1 */
#tablaComparativo thead tr:nth-child(1) th:nth-child(1),
#tablaComparativo thead tr:nth-child(1) th:nth-child(2),
#tablaComparativo thead tr:nth-child(1) th:nth-child(3),
#tablaComparativo thead tr:nth-child(1) th:nth-child(4) {
  position: sticky;
  background-color: #d8e0e8 !important;
  background-clip: padding-box;
  z-index: 30;
}

/* Sticky horizontal SOLO en las primeras 4 columnas de la FILA 2 */
#tablaComparativo thead tr:nth-child(2) th:nth-child(1),
#tablaComparativo thead tr:nth-child(2) th:nth-child(2),
#tablaComparativo thead tr:nth-child(2) th:nth-child(3),
#tablaComparativo thead tr:nth-child(2) th:nth-child(4) {
  position: sticky;
  background-color: #eef2f6 !important;
  background-clip: padding-box;
  z-index: 28;
}

/* Sticky horizontal SOLO en las primeras 4 columnas del TBODY */
#tablaComparativo tbody td:nth-child(1),
#tablaComparativo tbody td:nth-child(2),
#tablaComparativo tbody td:nth-child(3),
#tablaComparativo tbody td:nth-child(4) {
  position: sticky;
  background-clip: padding-box;
}

/* Fondos SÓLIDOS para celdas fijas del tbody */
#tablaComparativo tbody tr:nth-child(odd) td:nth-child(1),
#tablaComparativo tbody tr:nth-child(odd) td:nth-child(2),
#tablaComparativo tbody tr:nth-child(odd) td:nth-child(3),
#tablaComparativo tbody tr:nth-child(odd) td:nth-child(4) {
  background-color: #ffffff !important;
}
#tablaComparativo tbody tr:nth-child(even) td:nth-child(1),
#tablaComparativo tbody tr:nth-child(even) td:nth-child(2),
#tablaComparativo tbody tr:nth-child(even) td:nth-child(3),
#tablaComparativo tbody tr:nth-child(even) td:nth-child(4) {
  background-color: #f4f6f9 !important;
}

/* Hover en celdas fijas */
#tablaComparativo tbody tr:hover td:nth-child(1),
#tablaComparativo tbody tr:hover td:nth-child(2),
#tablaComparativo tbody tr:hover td:nth-child(3),
#tablaComparativo tbody tr:hover td:nth-child(4) {
  background-color: #dbe7f3 !important;
}

/* Sombra al borde derecho del bloque fijo */
#tablaComparativo thead tr:nth-child(1) th:nth-child(4),
#tablaComparativo thead tr:nth-child(2) th:nth-child(4),
#tablaComparativo tbody td:nth-child(4) {
  box-shadow: 2px 0 4px -2px rgba(0,0,0,0.2);
}

/* ============================================================
   FILAS Subtotal, Condiciones de pago, Ver detalle
   Ancho total del bloque fijo = 40 + 260 + 70 + 140 = 510px
   ============================================================ */

/* ---------- SUBTOTAL (3ª fila desde el final) ---------- */
#tablaComparativo tbody tr:nth-last-child(3) td[colspan="4"] {
  position: sticky !important;
  left: 0 !important;
  z-index: 35 !important;
  background-color: #eef2f6 !important;
  background-clip: padding-box;
  width: 510px !important;
  min-width: 510px !important;
  max-width: 510px !important;
  box-shadow: 2px 0 4px -2px rgba(0,0,0,0.2);
  font-weight: 700;
}
#tablaComparativo tbody tr:nth-last-child(3) td {
  background-color: #eef2f6 !important;
}

/* ---------- CONDICIONES DE PAGO (2ª fila desde el final) ---------- */
#tablaComparativo tbody tr:nth-last-child(2) td[colspan="4"] {
  position: sticky !important;
  left: 0 !important;
  z-index: 35 !important;
  background-color: #eef2f6 !important;
  background-clip: padding-box;
  width: 510px !important;
  min-width: 510px !important;
  max-width: 510px !important;
  box-shadow: 2px 0 4px -2px rgba(0,0,0,0.2);
  font-weight: 600;
}
#tablaComparativo tbody tr:nth-last-child(2) td {
  background-color: #eef2f6 !important;
}

/* ---------- VER DETALLE (1ª fila desde el final) ---------- */
#tablaComparativo tbody tr:nth-last-child(1) td[colspan="4"] {
  position: sticky !important;
  left: 0 !important;
  z-index: 35 !important;
  background-color: #ffffff !important;
  background-clip: padding-box;
  width: 510px !important;
  min-width: 510px !important;
  max-width: 510px !important;
  box-shadow: 2px 0 4px -2px rgba(0,0,0,0.2);
}
#tablaComparativo tbody tr:nth-last-child(1) td {
  background-color: #ffffff !important;
}

/* ============================================================
   FIX FINAL: forzar 110px a TODAS las columnas de proveedores
   sin excepción (incluido el primer proveedor).
   ============================================================ */

#tablaComparativo th:nth-child(n+5),
#tablaComparativo td:nth-child(n+5) {
  width: 110px !important;
  min-width: 110px !important;
  max-width: 110px !important;
  padding-left: 4px !important;
  padding-right: 4px !important;
  box-sizing: border-box !important;
  text-align: center !important;
  white-space: nowrap !important;
  font-size: 0.72rem !important;
}

#tablaComparativo thead th:nth-child(n+5) {
  font-size: 0.7rem !important;
}

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin-bottom: 16px; }
.tab-btn {
  border: none; border-bottom: 2px solid transparent; border-radius: 0;
  background: transparent; color: var(--color-text-muted);
  padding: 8px 4px; margin: 0 16px 0 0; font-weight: 600;
}
.tab-btn:hover { background: transparent; color: var(--color-text); }
.tab-btn.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }

/* ---------- Tablas de listados ---------- */

#cardPanel table {
  table-layout: fixed;
  font-size: 0.78rem;
}
#cardPanel td, #cardPanel th {
  overflow-wrap: break-word;
  vertical-align: top;
  padding: 6px 8px;
}
#cardPanel td:last-child button {
  margin-bottom: 4px;
  font-size: 0.75rem;
  padding: 4px 8px;
}
#cardPanel th,
#cardPanel td {
  width: auto;
}

.col-corta { white-space: nowrap; }

#tabMios th, #tabMios td { white-space: normal; }
#tabPendientesAutorizar th, #tabPendientesAutorizar td { white-space: normal; }
#tabAsignadosMi th, #tabAsignadosMi td { white-space: normal; }
#tabAsigPend th, #tabAsigPend td { white-space: normal; }
#tabAsigPend select { width: 100%; font-size: 0.78rem; padding: 4px 6px; }
#tabAsigHist th, #tabAsigHist td { white-space: normal; }
#tabAlmPend th, #tabAlmPend td { white-space: normal; }
#tabAlmHist th, #tabAlmHist td,
#tabAdqHist th, #tabAdqHist td { white-space: normal; }
#tabAdqPend th, #tabAdqPend td { white-space: normal; }

/* ---------- Logos del login ---------- */
.login-box { max-width: 420px; }

.login-logos {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding: 0 5px;
}

.login-logos img {
  max-width: 130px;
  height: auto;
  display: block;
}

.login-footer {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  margin: 24px 0 0 0;
}

/* ============================================================
   FIX: la celda con colspan="3" del nombre del proveedor NO debe
   estirar las columnas de Tiempo/Precio/Importe.
   Se fuerza a que mida exactamente 330px (110 × 3).
   ============================================================ */

#tablaComparativo thead tr:nth-child(1) th[colspan="3"] {
  width: 330px !important;
  min-width: 330px !important;
  max-width: 330px !important;
  white-space: normal !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
  text-align: center !important;
  box-sizing: border-box !important;
}

/* Para asegurar que la tabla use fixed layout y respete los anchos
   sin estirar columnas por contenido */
#tablaComparativo {
  table-layout: fixed !important;
  width: max-content !important;   /* ← cambio */
  min-width: 100% !important;
}

/* La fila 1 del thead debe respetar el ancho de las columnas fijas */
#tablaComparativo thead tr:nth-child(1) th:nth-child(1),
#tablaComparativo thead tr:nth-child(1) th:nth-child(2),
#tablaComparativo thead tr:nth-child(1) th:nth-child(3),
#tablaComparativo thead tr:nth-child(1) th:nth-child(4) {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
}

/* ---------- Modal de motivo de rechazo ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-caja {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  width: 90%;
  max-width: 420px;
}
.modal-caja h3 { margin: 0 0 14px 0; }