/* ================================================================
   Cullen Brokerage — Contract Add Form
   Paleta y sistema de diseño unificado con tracking.css
================================================================ */
:root {
  /* Paleta Cullen Brokerage */
  --cullen-gold:        #D4AF37;
  --cullen-dark-gold:   #B8941F;
  --cullen-green:       #2D5016;
  --cullen-light-green: #4A7C2E;
  --cullen-bg:          #FAFAFA;

  /* Estados semafóricos */
  --status-success: #28a745;
  --status-warning: #ffc107;
  --status-danger:  #dc3545;
  --status-pending: #6c757d;
  --status-info:    #17a2b8;

  /* Aliases internos para legibilidad */
  --surface:  #ffffff;
  --line:     #e9ecef;
  --muted:    #6c757d;
  --ink:      var(--cullen-green);
  --radius:   6px;
  --shadow:   0 1px 3px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
}

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

body {
                                     
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  background-color: var(--cullen-bg);
  color: #333;
  min-height: 100vh;
  padding-bottom: 3rem;
}

/* ── Page header — mismo estilo que tracking ── */
.page-header {
  background: linear-gradient(135deg, var(--cullen-green) 0%, var(--cullen-light-green) 100%);
  color: white;
  padding: 5px 0;
  margin-bottom: 5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.page-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}
.page-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}

.page-header .subtitle {
  margin: 5px 0 0 0;
  opacity: 0.9;
  font-size: 14px;
}

.page-wrapper {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Filtros y búsqueda */
.tracking-controls {
  background: white;
  padding: 5px 10px;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 10px;
  /* Debajo de la barra de solapas (.tracking-nav-bar, z:110). La altura de
     la barra la mide tracking_v2.js (stickyOffsets) en --tracking-nav-h. */
  position: sticky;
  top: var(--tracking-nav-h, 0px);
  z-index: 100;
}

.search-box {
  max-width: 350px;
}

.filter-buttons .btn {
  font-size: 13px;
  padding: 6px 16px;
  margin-right: 8px;
}

.btn-filter-all {
  background-color: var(--cullen-green);
  border-color: var(--cullen-green);
  color: white;
}

.btn-filter-all:hover,
.btn-filter-all.active {
  background-color: var(--cullen-light-green);
  border-color: var(--cullen-light-green);
  color: white;
}

.btn-filter-starred {
  background-color: var(--cullen-gold);
  border-color: var(--cullen-gold);
  color: white;
}

.btn-filter-starred:hover,
.btn-filter-starred.active {
  background-color: var(--cullen-dark-gold);
  border-color: var(--cullen-dark-gold);
  color: white;
}

.btn-filter-critical {
  background-color: var(--status-danger);
  border-color: var(--status-danger);
  color: white;
}

.btn-filter-critical:hover,
.btn-filter-critical.active {
  background-color: #c82333;
  border-color: #bd2130;
  color: white;
}

.btn-filter-delayed {
  background-color: var(--status-warning);
  border-color: var(--status-warning);
  color: #333;
}

.btn-filter-delayed:hover,
.btn-filter-delayed.active {
  background-color: #e0a800;
  border-color: #d39e00;
  color: #333;
}

.btn-filter-siblings {
  background-color: #2e7d32;
  border-color: #2e7d32;
  color: white;
}

.btn-filter-siblings:hover,
.btn-filter-siblings.active {
  background-color: #1b5e20;
  border-color: #1b5e20;
  color: white;
}

/* Secciones por estado */
.tracking-section {
  margin-bottom: 30px;
}

.section {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.section-header {
  background: white;
  padding: 12px 20px;
  border-left: 4px solid var(--cullen-gold);
  margin-bottom: 0;
  cursor: pointer;
  user-select: none;
  font-size: 16px;
  font-weight: 600;
  color: var(--cullen-green);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  display: flex;
/*  justify-content: space-between; */
  align-items: center;
  gap: 10px;
}

.section-header:hover {
  background-color: #8f9faf;
}

.section-header .toggle-icon {
  transition: transform 0.3s;
  color: var(--cullen-gold);
}

.section-header.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.section-badge {
  background-color: var(--cullen-gold);
  color: var(--cullen-green);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  margin-left: 10px;
}

.section-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background-color: var(--cullen-gold);
  color: var(--cullen-green);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.section-body {
  padding: 20px;
}
/* Tabla de seguimiento */
.tracking-table-wrapper {
  background: white;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  /* overflow-x: clip permite que position:sticky del thead funcione contra el
     viewport (a diferencia de overflow:auto que crea un contexto de scroll y
     rompe el sticky). overflow-y: visible asegura que el sticky no quede
     atrapado dentro del wrapper. */
  overflow-x: clip;
  overflow-y: visible;
}

.tracking-table {
  margin-bottom: 0;
  font-size: 13px;
}

.tracking-table thead th {
  background-color: #f8f9fa;
  border-bottom: 2px solid var(--cullen-gold);
  color: var(--cullen-green);
  font-weight: 600;
  text-align: center;
  vertical-align: middle;
  padding: 12px 8px;
  white-space: nowrap;
  /* Sticky debajo de la barra de solapas y de .tracking-controls (ambas
     sticky): --tracking-head-top = suma de sus alturas, la mide
     tracking_v2.js (stickyOffsets). Antes iba fijo en 48px y los controles
     (top:0, z:100) tapaban los títulos al scrollear.
     z-index alto para cubrir las filas, menor que las barras de arriba. */
  position: sticky;
  top: var(--tracking-head-top, 48px);
  z-index: 50;
  box-shadow: 0 2px 2px -1px rgba(0,0,0,0.08);
}

.tracking-table tbody td {
  vertical-align: middle;
  text-align: center;
  padding: 10px 8px;
  border-bottom: 1px solid #e9ecef;
}

.tracking-table tbody tr:hover {
  background-color: #f8f9fa;
}

.tracking-table tbody tr:last-child td {
  border-bottom: none;
}

/* Highlight de fila recién actualizada */
.tracking-table tbody tr.highlight-row {
  background-color: #d4edda !important;
  transition: background-color 2s ease;
}

/* Columna de contrato */
.contract-cell {
  text-align: left !important;
  font-weight: 600;
  color: var(--cullen-green);
  white-space: nowrap;
}

/* Columna de detalles */
.details-cell {
  text-align: center !important;
  padding: 10px 5px !important;
}

.show-details {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--cullen-gold);
  color: white;
  cursor: pointer;
  transition: all 0.2s;
}

.show-details:hover {
  background-color: var(--cullen-dark-gold);
  transform: scale(1.1);
}

.show-details i {
  font-size: 14px;
}

/* Columna de estrella/destacado */
.starred-cell {
  text-align: center !important;
  padding: 10px 5px !important;
}

.star-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.star-toggle i {
  font-size: 20px;
  color: #ccc;
  transition: all 0.2s;
}

.star-toggle:hover i {
  color: var(--cullen-gold);
  transform: scale(1.2);
}

.star-toggle.starred i {
  color: var(--cullen-gold);
  animation: star-pulse 1.5s ease-in-out infinite;
}

.star-toggle.starred:hover i {
  color: var(--cullen-dark-gold);
}

/* Animación sutil para estrellas activas */
@keyframes star-pulse {
  0%, 100% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.05);
    filter: brightness(1.2);
  }
}

/* Highlight para filas destacadas */
.tracking-table tbody tr.row-starred {
  background-color: #fffbf0;
  border-left: 3px solid var(--cullen-gold);
}

/* Embarque activo — visual aid persistente para no perder de vista cuál
   es el shipment que el usuario está trabajando cuando va y vuelve entre
   tracking, detalles del contrato, mail, factura, etc. Se activa al copiar
   número, abrir detalles, abrir checklist, o clickear cualquier link de
   contexto. Se persiste en localStorage hasta cambiar de embarque o filtros.

   Acentúa con verde Cullen para distinguirlo del dorado de "destacado".
   Contraste fuerte para que sea fácil de localizar en una tabla larga. */
.tracking-table tbody tr.row-active-shipment {
  background-color: #d3e3bf;                       /* verde Cullen ~18% sobre blanco */
  border-left: 5px solid var(--cullen-green);
  box-shadow: inset 0 0 0 1px rgba(45, 80, 22, .35);
}
.tracking-table tbody tr.row-active-shipment td {
  font-weight: 500;                                /* sutil refuerzo tipográfico */
}
.tracking-table tbody tr.row-active-shipment .contract-number {
  color: var(--cullen-green);
  font-weight: 700;
}
.tracking-table tbody tr.row-active-shipment:hover {
  background-color: #c4d8ad;
}
/* Si además está destacado, conserva el indicador dorado al lado del verde
   — borde verde con un raya dorada al costado, fondo intermedio. */
.tracking-table tbody tr.row-active-shipment.row-starred {
  background-color: #e9e7c0;
  border-left: 5px solid var(--cullen-green);
  box-shadow:
    inset 5px 0 0 0 var(--cullen-gold),
    inset 0 0 0 1px rgba(45, 80, 22, .30);
}
.tracking-table tbody tr.row-active-shipment.row-starred:hover {
  background-color: #ddd9a3;
}

.tracking-table tbody tr.row-starred:hover {
  background-color: #fff9e6;
}

.contract-cell a {
  color: var(--cullen-green);
  text-decoration: none;
}

.contract-cell a:hover {
  color: var(--cullen-light-green);
  text-decoration: underline;
}

.contract-number {
  /* inline-block para que el ícono "copy-contract" quede al lado del número
     y no debajo. white-space: nowrap del .contract-cell mantiene la línea. */
  display: inline-block;
  font-size: 14px;
  vertical-align: middle;
}

.shipment-number {
  display: block;
  font-size: 12px;
  color: #6c757d;
  font-weight: normal;
}

/* copy-contract: ícono al lado del número, en la misma línea */
.contract-cell .copy-contract {
  vertical-align: middle;
}

/* Indicadores de estado */
.status-indicator {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s;
  min-width: 80px;
}

.status-indicator:hover {
  transform: scale(1.1);
}

/*
.status-indicator.status-pending-inactive {
  cursor: default;
}

.status-indicator.status-pending-inactive:hover {
  transform: none;
}

.status-indicator.status-not-applicable {
  cursor: default;
}

.status-indicator.status-not-applicable:hover {
  transform: none;
}
*/

.status-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.status-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  line-height: 1.2;
  text-align: center;
}

.status-date {
  font-size: 10px;
  color: #6c757d;
  margin-top: 2px;
}

.status-days {
  font-size: 10px;
  font-weight: 600;
  margin-top: 2px;
  /* Se oculta globalmente el texto "+2años", "-11 meses", etc.
     El helper lo sigue emitiendo (info semántica/data-* queda disponible),
     pero en pantalla no se muestra para evitar ruido visual. Si alguna
     vista puntual lo quiere mostrar, puede re-activarlo localmente. */
  display: none !important;
}

/* Estados específicos */

/* COMPLETADOS - Discretos pero legibles (subido el contraste y tamaño) */
.status-complete-ontime .status-icon {
  color: #5aaa7a;   /* Verde apagado pero visible */
  opacity: 0.9;
  font-size: 23px;
}
.status-complete-delayed .status-icon {
  color: #c89a3e;   /* Amarillo-ocre más contrastado */
  opacity: 0.9;
  font-size: 23px;
}
.status-complete-late .status-icon {
  color: #c4686d;   /* Rojo apagado pero visible */
  opacity: 0.9;
  font-size: 23px;
}

/* PENDIENTES - Llamativos, saturados, tamaño normal o mayor */
.status-pending-ok .status-icon { 
  color: var(--status-success);
  opacity: 0.8;
}
.status-pending-warning .status-icon { 
  color: #ffa000; /* Naranja más llamativo */
  font-size: 26px; /* Más grande */
  animation: pulse-warning 2s infinite;
}
.status-pending-critical .status-icon { 
  color: var(--status-danger);
  font-size: 28px; /* Más grande */
  animation: pulse-critical 1.5s infinite;
}
.status-pending-inactive .status-icon { 
  color: var(--status-pending);
  opacity: 0.4;
}
.status-not-applicable .status-icon { 
  color: #95a5a6;
  opacity: 0.5;
}

/* LABELS - Completados: discretos pero legibles */
.status-complete-ontime .status-label {
  color: #495057; /* Gris un poco más oscuro */
  font-size: 10px;
  opacity: 0.85;
}
.status-complete-delayed .status-label {
  color: #495057;
  font-size: 10px;
  opacity: 0.85;
}
.status-complete-late .status-label {
  color: #495057;
  font-size: 10px;
  opacity: 0.85;
}

/* LABELS - Pendientes más visibles */
.status-pending-ok .status-label { 
  color: #6c757d;
  font-size: 10px;
}
.status-pending-warning .status-label { 
  color: #d68000;
  font-weight: 700;
}
.status-pending-critical .status-label { 
  color: var(--status-danger);
  font-weight: 700;
}
.status-pending-inactive .status-label { 
  color: #adb5bd;
  opacity: 0.6;
}
.status-not-applicable .status-label { 
  color: #95a5a6; 
  font-weight: 700;
  opacity: 0.6;
}

/* Días - Completados discretos */
.status-complete-ontime .status-days,
.status-complete-delayed .status-days,
.status-complete-late .status-days {
  opacity: 0.6;
  font-size: 9px;
}

/* Días - Pendientes más visibles */
.status-days.positive { color: var(--status-success); }
.status-days.warning { 
  color: #d68000;
  font-weight: 700;
}
.status-days.negative { 
  color: var(--status-danger);
  font-weight: 700;
}

/* Animaciones para pendientes críticos */
@keyframes pulse-critical {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

@keyframes pulse-warning {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

/* Hover - Completados mantienen discreto */
.status-complete-ontime:hover .status-icon,
.status-complete-delayed:hover .status-icon,
.status-complete-late:hover .status-icon {
  opacity: 1;
}

/* Hover - Pendientes se destacan más */
.status-pending-warning:hover .status-icon,
.status-pending-critical:hover .status-icon {
  filter: brightness(1.2);
}

/* Columna courier especial */
.courier-info {
  font-size: 11px;
  line-height: 1.3;
}

.courier-company {
  font-weight: 600;
  color: var(--cullen-green);
}

.tracking-number {
  color: #6c757d;
  font-family: monospace;
}

/* Modal personalizado */
.modal-header {
  background: linear-gradient(135deg, var(--cullen-green) 0%, var(--cullen-light-green) 100%);
  color: white;
}

.modal-header .close {
  color: white;
  opacity: 0.8;
}

.modal-header .close:hover {
  opacity: 1;
}

.btn-cullen-primary {
  background-color: var(--cullen-green);
  border-color: var(--cullen-green);
  color: white;
}

.btn-cullen-primary:hover {
  background-color: var(--cullen-light-green);
  border-color: var(--cullen-light-green);
  color: white;
}

/* Exportar */
.export-btn {
  background-color: white;
  border: 1px solid var(--cullen-gold);
  color: var(--cullen-green);
}

.export-btn:hover {
  background-color: var(--cullen-gold);
  color: white;
  border-color: var(--cullen-gold);
}

/* Alertas de tracking */
.tracking-alert {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  min-width: 300px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

/* Tooltips */
.tooltip-inner {
  max-width: 300px;
  text-align: left;
}


/* ── Grid ── */
.xrow { display: grid; gap: 15px; margin-bottom: 15px; }
.xrow:last-child { margin-bottom: 0; }
.xcol-2  { grid-template-columns: 1fr 1fr; }
.xcol-3  { grid-template-columns: 1fr 1fr 1fr; }
.xcol-1  { grid-template-columns: 1fr; }
.xcol-1-2 { grid-template-columns: 1fr 2fr; }
.xcol-2-1 { grid-template-columns: 2fr 1fr; }

/* ── Fields ── */
.field { display: flex; flex-direction: column; gap: 4px; }

label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cullen-green);
}
label .req { color: var(--status-danger); margin-left: 2px; }

input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #ced4da;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  color: #333;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--cullen-light-green);
  box-shadow: 0 0 0 3px rgba(74,124,46,0.15);
}
select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236c757d' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* ── Checkboxes ── */
.check-group { display: flex; align-items: center; gap: 8px; }
.check-group input[type="checkbox"] {
  width: 15px; height: 15px;
  cursor: pointer;
  accent-color: var(--cullen-green);
  flex-shrink: 0;
}
.check-group label {
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  color: #444;
  font-weight: 400;
  cursor: pointer;
}

/* ── Hint text ── */
.hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

/* ── Divider ── */
.divider { height: 1px; background: var(--line); margin: 18px 0; }

/* ── Inline row (flex) ── */
.inline-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-row .field { flex: 1; min-width: 110px; }

/* ================================================================
   PAYMENT BUILDER
================================================================ */
.payment-builder {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.payment-type-tabs {
  display: flex;
  border-bottom: 2px solid var(--cullen-gold);
  background: #f8f9fa;
  overflow-x: auto;
}
.payment-type-tabs button {
  flex-shrink: 0;
  padding: 8px 14px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.payment-type-tabs button:hover {
  color: var(--cullen-green);
  background: rgba(212,175,55,0.08);
}
.payment-type-tabs button.active {
  color: var(--cullen-green);
  border-bottom-color: var(--cullen-gold);
  font-weight: 600;
  background: white;
}

.payment-params { padding: 16px; display: none; }
.payment-params.active { display: block; }

.payment-preview {
  margin-top: 12px;
  padding: 10px 14px;
  background: #f0f7ee;
  border-left: 3px solid var(--cullen-light-green);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12px;
  color: var(--cullen-green);
  font-style: italic;
  min-height: 36px;
}
.payment-preview strong { font-style: normal; font-weight: 600; }

/* ================================================================
   DOCUMENT BUILDER
================================================================ */
.doc-builder {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.doc-type-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8f9fa;
}
.doc-pill {
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid #ced4da;
  background: white;
  font-size: 12px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  transition: all 0.15s;
}
.doc-pill:hover {
  border-color: var(--cullen-gold);
  color: var(--cullen-green);
  background: rgba(212,175,55,0.08);
}
.doc-pill.active {
  border-color: var(--cullen-gold);
  background: var(--cullen-gold);
  color: var(--cullen-green);
  font-weight: 600;
}

.doc-params { padding: 16px; display: none; }
.doc-params.active { display: block; }

.doc-preview {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fffbf0;
  border-left: 3px solid var(--cullen-gold);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12px;
  color: var(--cullen-dark-gold);
  font-style: italic;
  min-height: 36px;
}
.doc-preview strong { font-style: normal; font-weight: 600; color: var(--cullen-green); }

/* ================================================================
   SHIPMENT BLOCK
================================================================ */
.shipment-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.shipment-row {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: white;
}
.shipment-row:last-child { border-bottom: none; }
.shipment-row:nth-child(even) { background: #fafafa; }
.shipment-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cullen-green);
  width: 145px;
  flex-shrink: 0;
}
.shipment-row .field { flex: 1; margin: 0; }
.shipment-row .field label { display: none; }

/* ================================================================
   SUBMIT AREA
================================================================ */
.submit-area {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-bottom: 10px;
}
.btn {
  padding: 8px 24px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-ghost {
  background: white;
  border-color: #ced4da;
  color: var(--muted);
}
.btn-ghost:hover { border-color: #adb5bd; color: #333; }

/* Botón primario = verde Cullen, igual que btn-cullen-primary en tracking */
.btn-primary {
  background-color: var(--cullen-green);
  border-color: var(--cullen-green);
  color: white;
}
.btn-primary:hover {
  background-color: var(--cullen-light-green);
  border-color: var(--cullen-light-green);
  color: white;
  box-shadow: 0 3px 8px rgba(45,80,22,0.25);
}

.copy-contract {
  color:#888;
}
.copy-contract:hover {
  color:#000;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .col-2, .col-3, .col-1-2, .col-2-1 { grid-template-columns: 1fr; }
  .inline-row { flex-direction: column; }
  .shipment-label { width: 100px; }
}
@media (max-width: 1200px) {
  .col-3 { grid-template-columns: 1fr 1fr; }
}

/* Responsive ajustes */
@media (max-width: 1400px) {
  .tracking-table {
    font-size: 12px;
  }
  .status-icon {
    font-size: 20px;
  }
}

@media (max-width: 1200px) {
  .tracking-controls .row {
    flex-direction: column;
  }
  
  .tracking-controls .col-md-6 {
    width: 100%;
    margin-bottom: 10px;
  }
  
  .tracking-controls .text-right {
    text-align: left !important;
  }
  
  .search-box {
    max-width: 100%;
  }
}

/* =========================================================
   SIMPLIFICACIÓN VISUAL — Fase 1
   Indicadores compactos sin texto, con tooltip.
   Se ubican al final para sobreescribir los bloques previos.
   ========================================================= */

/* Todos los indicadores de columna usan layout compacto e inline */
.tracking-table .status-indicator {
  min-width: 32px;
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

/* Ocultar spans de label vacíos (para no reservar espacio) */
.status-indicator .status-label:empty { display: none; }

/* REALIZADOS — apagados pero legibles, con matiz por variante.
   (Antes quedaban casi invisibles con opacity 0.35 / 14px).
   La grilla conserva un look discreto vs. los pendientes, pero
   ahora se distingue de un vistazo que la tarea está cumplida. */
.tracking-table .status-complete-ontime .status-icon {
  color: #5aaa7a;   /* verde apagado */
  opacity: 0.9;
  font-size: 20px;
}
.tracking-table .status-complete-delayed .status-icon {
  color: #c89a3e;   /* ocre */
  opacity: 0.9;
  font-size: 20px;
}
.tracking-table .status-complete-late .status-icon {
  color: #c4686d;   /* rojo apagado */
  opacity: 0.9;
  font-size: 20px;
}
.tracking-table .status-complete-ontime:hover .status-icon,
.tracking-table .status-complete-delayed:hover .status-icon,
.tracking-table .status-complete-late:hover .status-icon {
  opacity: 1;
  transform: none;
}
/* Labels: dejan de ocultarse y se muestran discretos. status-days
   sigue oculto por la regla global `.status-days { display: none; }`. */
.tracking-table .status-complete-ontime .status-label,
.tracking-table .status-complete-delayed .status-label,
.tracking-table .status-complete-late .status-label {
  color: #495057;
  font-size: 10px;
  opacity: 0.85;
  display: inline;
}

/* NO APLICABLE — desaturado, mínimo */
.tracking-table .status-not-applicable .status-icon {
  font-size: 14px;
  color: #cfd4d8;
  opacity: 0.6;
}
.tracking-table .status-not-applicable .status-label { display: none; }

/* PENDIENTES — sin label; días solo en warning/critical */
.tracking-table .status-pending-ok .status-icon {
  font-size: 16px;
  opacity: 0.6;
}
.tracking-table .status-pending-ok .status-label,
.tracking-table .status-pending-ok .status-days { display: none; }

.tracking-table .status-pending-warning .status-icon {
  font-size: 18px;
}
.tracking-table .status-pending-warning .status-label { display: none; }

.tracking-table .status-pending-critical .status-icon {
  font-size: 18px;
}
.tracking-table .status-pending-critical .status-label { display: none; }

.tracking-table .status-pending-inactive .status-icon {
  font-size: 14px;
  opacity: 0.3;
}
.tracking-table .status-pending-inactive .status-label,
.tracking-table .status-pending-inactive .status-days { display: none; }

/* Badge de días — más chico, inline */
.tracking-table .status-days {
  font-size: 10px;
  font-weight: 600;
  margin-top: 0;
  white-space: nowrap;
}

/* La columna "Embarque" (boarding_date) mantiene su label, no se toca */
.tracking-table td .status-indicator:has(> .status-label:not(:empty)) {
  min-width: 80px;
  flex-direction: column;
}

/* Hover — feedback sutil, sin escalado agresivo */
.tracking-table .status-indicator:hover { transform: none; }

/* ──────────────────────────────────────────────────────────────
   invoice-stack — layout específico para cullenInvoiceIndicator
   cuando hay factura emitida. Icono a la izquierda, número arriba
   y fecha abajo a la derecha. Más compacto que el label única-línea
   con <br> embebido que se veía como texto literal.
   ────────────────────────────────────────────────────────────── */
.tracking-table .invoice-stack {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 100px;
  text-align: left;
}
.tracking-table .invoice-stack .status-icon {
  font-size: 18px;
  margin-bottom: 0;
}
.tracking-table .invoice-stack__text {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: left;
}
.tracking-table .invoice-stack__number {
  font-size: 10px;
  font-weight: 600;
  color: #495057;
  text-transform: none;
  white-space: nowrap;
}
.tracking-table .invoice-stack__date {
  font-size: 9px;
  color: #6c757d;
  white-space: nowrap;
}

/* Botón de checklist en la fila */
.tracking-table .checklist-cell { text-align: center; }
.tracking-table .open-checklist {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  color: #6c757d;
  transition: background-color .15s, color .15s;
}
.tracking-table .open-checklist:hover {
  background: #e9f1f7;
  color: var(--status-primary, #0d6efd);
}

/* =========================================================
   MODAL CHECKLIST — Fases Embarque y Comisión
   Ambos modales comparten layout; los selectores ahora apuntan
   al form (.checklist-form) para cubrir las dos instancias.
   ========================================================= */
.checklist-form .checklist-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.checklist-form .checklist-row {
  display: grid;
  /* bulk por defecto: icon / label / status-buttons (ancho fijo para
     encolumnar entre filas) / reloj / info-followup. Si alguna fila no
     tiene followup la columna queda vacía pero la columna persiste,
     así los botones de estado quedan alineados verticalmente.
     El ancho de la columna de botones (320px) garantiza que "Pendiente"
     y "Realizado" entren sin truncarse con su ícono. */
  grid-template-columns: 28px minmax(140px, 1fr) 320px 38px minmax(0, 180px);
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  background: #fafbfc;
  gap: 12px;
}
.checklist-form .checklist-row.modified {
  background: #fff9e6;
  border-color: #ffd966;
}
.checklist-form .checklist-row .checklist-row-icon {
  text-align: center;
  color: #6c757d;
  font-size: 16px;
}
.checklist-form .checklist-row .checklist-row-label {
  font-weight: 600;
  color: #212529;
}
.checklist-form .checklist-row .checklist-row-hint {
  display: block;
  font-size: 11px;
  font-weight: normal;
  color: #6c757d;
  margin-top: 2px;
}
.checklist-form .checklist-row-readonly-info {
  font-size: 11px;
  color: #6c757d;
  margin-top: 2px;
}
.checklist-form .checklist-buttons {
  display: flex;
  width: 100%;
  border: 1px solid #ced4da;
  border-radius: 4px;
  overflow: hidden;
  justify-self: start;
}
.checklist-form .checklist-buttons .cl-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 12px;
  background: #fff;
  border: none;
  border-right: 1px solid #ced4da;
  font-size: 12.5px;
  font-weight: 600;
  color: #495057;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: background .15s, color .15s;
}
.checklist-form .checklist-buttons .cl-btn i { margin-right: 4px; }
.checklist-form .checklist-buttons .cl-btn:last-child { border-right: none; }
.checklist-form .checklist-buttons .cl-btn:hover { background: #f1f3f5; }
.checklist-form .checklist-buttons .cl-btn.active[data-value="0"] {
  background: #adb5bd; color: #fff;
}
.checklist-form .checklist-buttons .cl-btn.active[data-value="1"] {
  background: #ffa000; color: #fff;
}
.checklist-form .checklist-buttons .cl-btn.active[data-value="2"] {
  background: #198754; color: #fff;
}

/* Botones del selector de tránsito (modal Embarque). Mismo look que el
   checklist pero fuera de .checklist-form, con los colores del semáforo
   (rojo sin embarcar / azul en el agua / verde en destino). */
.transit-buttons {
  display: flex;
  width: 100%;
  border: 1px solid #ced4da;
  border-radius: 4px;
  overflow: hidden;
}
.transit-buttons .cl-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 12px;
  background: #fff;
  border: none;
  border-right: 1px solid #ced4da;
  font-size: 12.5px;
  font-weight: 600;
  color: #495057;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: background .15s, color .15s;
}
.transit-buttons .cl-btn i { margin-right: 4px; }
.transit-buttons .cl-btn:last-child { border-right: none; }
.transit-buttons .cl-btn:hover { background: #f1f3f5; }
/* Color propio de cada estado, siempre visible (no sólo al estar activo). */
.transit-buttons .cl-btn[data-value=""]  { color: #6c757d; }
.transit-buttons .cl-btn[data-value="0"] { color: #dc3545; }
.transit-buttons .cl-btn[data-value="1"] { color: #2563eb; }
.transit-buttons .cl-btn[data-value="2"] { color: #16a34a; }
/* Activo: fondo sólido del estado + texto blanco (mayor especificidad, gana). */
.transit-buttons .cl-btn.active[data-value=""]  { background: #6c757d; color: #fff; }
.transit-buttons .cl-btn.active[data-value="0"] { background: #dc3545; color: #fff; }
.transit-buttons .cl-btn.active[data-value="1"] { background: #2563eb; color: #fff; }
.transit-buttons .cl-btn.active[data-value="2"] { background: #16a34a; color: #fff; }

/* Fila read-only (ej: cullen_invoice en el modal Comisión) */
.checklist-form .checklist-row--readonly {
  background: #f8f9fa;
  border-style: dashed;
  opacity: 0.85;
}
.checklist-form .checklist-readonly-action {
  text-align: right;
}

/* Botón follow-up ⏰ dentro del checklist.
   En el bulk el reloj va en su propia columna (38px) y la info del
   reclamo vigente queda en la columna siguiente (hasta 180px, elidido).
   En el --solo rompemos a layout vertical y el conjunto se estira. */
.checklist-form .checklist-followup {
  display: contents; /* bulk: delegamos grid al padre */
}
/* Filas no-followupables: ocultamos btn+info. Se alterna con data-followupable
   (fuente de verdad) en vez de toggle() inline, que pisaría display:contents. */
.checklist-form .checklist-row[data-followupable="0"] .checklist-followup-btn,
.checklist-form .checklist-row[data-followupable="0"] .checklist-followup-info {
  display: none;
}
.checklist-form .checklist-followup-btn {
  justify-self: center;
}
.checklist-form .checklist-followup-info {
  justify-self: start;
  align-self: center;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.checklist-form .checklist-followup-btn {
  padding: 4px 10px;
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 13px;
  color: #6c757d;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.checklist-form .checklist-followup-btn:hover {
  background: #e9f1f7;
  color: #0d6efd;
  border-color: #0d6efd;
}
.checklist-form .checklist-followup-btn.has-followup {
  background: #e7f5ff;
  color: #0d6efd;
  border-color: #0d6efd;
}
.checklist-form .checklist-followup-btn.has-followup.expired {
  background: #fff3cd;
  color: #b94700;
  border-color: #ffb703;
}
.checklist-form .checklist-followup-info {
  font-size: 11px;
  color: #6c757d;
  max-width: 180px;
  line-height: 1.3;
}
.checklist-form .checklist-followup-info.active { color: #0d6efd; }
.checklist-form .checklist-followup-info.expired { color: #b94700; font-weight: 600; }

/* =========================================================
   PANEL FOLLOWUP INLINE
   Aparece colapsable bajo la fila cuando se hace click en el
   reloj ⏰. Reemplaza al modalFollowup cuando el contexto es un
   form (checklist bulk o tracking per-field).
   ========================================================= */
.checklist-form .checklist-followup-panel {
  margin-top: -2px;
  padding: 10px 12px;
  background: #f1f8ff;
  border: 1px solid #bcd8f3;
  border-radius: 0 0 6px 6px;
  border-top: none;
  margin-bottom: 6px;
}
.checklist-form .checklist-followup-panel .followup-panel-header {
  font-size: 13px;
  color: #0d6efd;
}
.checklist-form .checklist-followup-panel .followup-panel-current {
  background: #fff3cd;
  border: 1px solid #ffeaa0;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  color: #6b4e00;
}
.checklist-form .checklist-followup-panel label.small {
  color: #495057;
  font-weight: 600;
  font-size: 11px;
}
/* Cuando una fila tiene el panel abierto, destaca la fila */
.checklist-form .checklist-row.followup-open {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-color: #bcd8f3;
  background: #e9f1f7;
}

/* =========================================================
   MODAL PER-FIELD estilo checklist (una sola fila, con aire)
   Layout distinto del bulk: el título va arriba junto al ícono
   y los botones de estado ocupan su propia línea — así cuando
   se abre el panel de followup la fila no queda apretada.
   ========================================================= */
.checklist-form--solo .checklist-rows { margin-top: 0; }
.checklist-form--solo .checklist-row--solo {
  display: grid;
  /* col1: icon (28px) · col2: grupo de botones · col3: reloj.
     Las cols 2 y 3 son "auto" (se dimensionan al contenido) y
     `justify-content: start` evita que el grid se estire al ancho
     del modal — así el reloj queda pegado al grupo de botones en
     vez de flotar en el extremo derecho. El espacio sobrante queda
     libre a la derecha del row. */
  grid-template-columns: 28px auto auto;
  grid-template-areas:
    "icon  label label"
    "btns  btns  clock";
  row-gap: 12px;
  column-gap: 14px;
  padding: 14px 16px;
  align-items: center;
  justify-content: start;
}
.checklist-form--solo .checklist-row-icon   { grid-area: icon;   align-self: center; font-size: 18px; }
.checklist-form--solo .checklist-row-label  { grid-area: label;  align-self: center; font-size: 14px; }
.checklist-form--solo .checklist-buttons    {
  grid-area: btns;
  width: auto;
  /* Ancho mínimo suficiente para que las tres etiquetas entren cómodas
     ("Pendiente" y "Realizado" con ícono); con flex:1 en los cl-btn se
     reparten de manera uniforme. */
  min-width: 440px;
  max-width: 560px;
  justify-self: start;
}
.checklist-form--solo .checklist-buttons .cl-btn {
  flex: 1 1 0;
  padding: 8px 18px;
  font-size: 13px;
}
/* Reloj aparte — el panel inline ya expone la info del reclamo vigente */
.checklist-form--solo .checklist-followup-btn  {
  grid-area: clock;
  align-self: center;
  padding: 7px 12px;
}
.checklist-form--solo .checklist-followup-info { display: none; }

/* Panel followup en modo solo: más aire arriba y borde propio
   (no comparte borde con la tarjeta porque ahora hay respiro) */
.checklist-form--solo .checklist-followup-panel {
  margin-top: 10px;
  margin-bottom: 0;
  padding: 14px 16px;
  border-radius: 6px;
  border-top: 1px solid #bcd8f3;
}
.checklist-form--solo .checklist-row.followup-open {
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
}

/* Extras (ETD/ETA, courier, cullen invoice...) bajo la fila */
.checklist-form .checklist-row-extras {
  margin-top: 12px;
  padding: 12px 14px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
}
.checklist-form .checklist-row-extras .form-group { margin-bottom: 10px; }
.checklist-form .checklist-row-extras .form-group:last-child { margin-bottom: 0; }

/* Responsive: en modales angostos el grid del bulk colapsa
   a label arriba + botones + followup abajo (dos filas). */
@media (max-width: 720px) {
  .checklist-form:not(.checklist-form--solo) .checklist-row {
    grid-template-columns: 28px 1fr auto;
    grid-template-areas:
      "icon  label    clock"
      "btns  btns     info";
    row-gap: 8px;
  }
  .checklist-form:not(.checklist-form--solo) .checklist-row-icon    { grid-area: icon; }
  .checklist-form:not(.checklist-form--solo) .checklist-row-label   { grid-area: label; }
  .checklist-form:not(.checklist-form--solo) .checklist-buttons     { grid-area: btns; }
  .checklist-form:not(.checklist-form--solo) .checklist-followup-btn  { grid-area: clock;  justify-self: end;   }
  .checklist-form:not(.checklist-form--solo) .checklist-followup-info { grid-area: info;   justify-self: start; }
}

/* =========================================================
   INDICADOR SNOOZED en la grilla
   - snoozed (pending): reloj apagado, apagado como not-applicable
   - snoozed-expired  : reloj alerta, parecido a pending-critical
   ========================================================= */
.tracking-table .status-snoozed .status-icon {
  font-size: 15px;
  color: #6c9ccf;      /* azul apagado — "estamos esperando" */
  opacity: 0.7;
}
.tracking-table .status-snoozed .status-label,
.tracking-table .status-snoozed .status-days { display: none; }
.tracking-table .status-snoozed:hover .status-icon {
  color: #0d6efd;
  opacity: 1;
}

.tracking-table .status-snoozed-expired .status-icon {
  font-size: 17px;
  color: #b94700;      /* naranja rojizo — promesa rota */
}
.tracking-table .status-snoozed-expired .status-label { display: none; }
.tracking-table .status-snoozed-expired .status-days {
  color: #b94700;
  font-weight: 700;
}
.tracking-table .status-snoozed-expired:hover .status-icon {
  color: #dc3545;
}

/* Embarque sin importe de FC comercial definitivo (comisión estimada) */
.client-ref-cell .client-ref-unknown {
  display: block; margin-top: 2px; font-size: 11px; color: #6b7280; text-decoration: none;
}
.client-ref-cell .client-ref-unknown:hover { color: #374151; text-decoration: underline; }
.invoice-cell .badge-legacy-paid {
  display: block; margin-top: 3px; font-size: 11px; color: #6b7280;
  white-space: nowrap; text-decoration: none;
}
.invoice-cell .badge-legacy-paid:hover { color: #16a34a; text-decoration: underline; }
.invoice-cell .badge-missing-fc {
  display: block; margin-top: 3px; padding: 1px 5px; border-radius: 3px;
  font-size: 10px; font-weight: 600; white-space: nowrap;
  color: #8a4b08; background: rgba(230,150,40,0.18);
}

/* ── Factura comercial: zona de arrastre + vista previa (2026-11-20) ── */
.ci-drop {
  position: relative;
  min-height: 420px;
  border: 2px dashed #c9d3cd;
  border-radius: 8px;
  background: #f8faf9;
  display: flex;
  align-items: stretch;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, background .15s;
}
.ci-drop:hover, .ci-drop:focus { border-color: var(--cullen-green); outline: none; }
.ci-drop.has-file { cursor: default; border-style: solid; background: #fff; }
.ci-drop__empty {
  align-self: center;
  text-align: center;
  color: #6b7770;
  padding: 24px;
}
.ci-drop__empty i { font-size: 44px; color: var(--cullen-green); opacity: .7; margin-bottom: 10px; }
.ci-drop__empty strong { color: var(--cullen-green); font-size: 15px; }
.ci-drop__empty small { display: block; margin-top: 8px; color: #98a39d; }
.ci-drop__preview { flex: 1; display: flex; }
.ci-drop__preview iframe { flex: 1; width: 100%; height: 60vh; min-height: 420px; border: 0; }
.ci-drop__preview img { max-width: 100%; max-height: 60vh; margin: auto; object-fit: contain; }
.ci-drop__noprev { margin: auto; text-align: center; color: #6b7770; padding: 24px; }
.ci-drop__noprev i { font-size: 48px; display: block; margin-bottom: 8px; color: #98a39d; }
.ci-drop__noprev small { display: block; margin-top: 6px; color: #98a39d; }
/* Overlay mientras se arrastra un archivo sobre el modal */
.ci-drop__overlay {
  display: none;
  position: absolute; inset: 0;
  background: rgba(45, 80, 22, .88);
  color: #fff;
  font-size: 18px; font-weight: 600;
  align-items: center; justify-content: center; gap: 10px;
  z-index: 2;
}
.ci-drop.is-dragover { border-color: var(--cullen-gold); }
.ci-drop.is-dragover .ci-drop__overlay { display: flex; }
.ci-file-info { margin-top: 6px; }
.ci-drop.is-dragover iframe { pointer-events: none; }

/* Guardado de la factura comercial en curso (CommercialInvoiceBusy, tracking_v2.js) */
.ci-progress { flex: 1 1 100%; height: 6px; margin: 0 0 10px; background: #e9ecef; }
.ci-progress .progress-bar { background-color: var(--cullen-green); transition: width .2s ease; }
#formCommercialInvoice.is-busy .ci-drop,
#formCommercialInvoice.is-busy .modal-body input,
#formCommercialInvoice.is-busy .modal-body textarea { pointer-events: none; opacity: .7; }

