/* =====================================
   MANIFIESTOS CSS AISLADO - MFX
   Vista principal crítica del sistema
===================================== */

/* =========================
   LAYOUT
========================= */
.mfx-layout{
  padding:20px;
  width:100%;
  box-sizing:border-box;
}

.mfx-main{
  width:100%;
  min-width:0;
}

/* =========================
   HEADER
========================= */
.mfx-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  margin-bottom:22px;
}

.mfx-header h2{
  margin:0;
  font-size:34px;
  font-weight:700;
  color:#111827;
}

/* =========================
   BOTONES
========================= */
.mfx-btn{
  border:none;
  border-radius:10px;
  height:44px;
  padding:0 18px;
  cursor:pointer;
  font-size:14px;
  font-weight:700;
  transition:.2s ease;
  white-space:nowrap;
}

.mfx-btn:hover{
  transform:translateY(-1px);
}

.mfx-btn-primary{
  background:#2f56a6;
  color:#fff;
}

.mfx-btn-primary:hover{
  background:#24468a;
}

.mfx-btn-danger{
  background:#ea4335;
  color:#fff;
}

.mfx-btn-danger:hover{
  background:#cf3528;
}

.mfx-btn-light{
  background:#eef2f7;
  color:#111827;
}

.mfx-btn-light:hover{
  background:#dde5ef;
}

/* =========================
   FILTROS
========================= */
.mfx-filters-box{
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:18px;
  margin-bottom:22px;
}

.mfx-filters-grid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:16px;
  align-items:end;
}

.mfx-group{
  display:flex;
  flex-direction:column;
}

.mfx-group label{
  font-size:12px;
  font-weight:600;
  color:#6b7280;
  margin-bottom:6px;
}

.mfx-group input,
.mfx-group select,
.mfx-group textarea{
  width:100%;
  min-height:44px;
  padding:10px 14px;
  border:1px solid #d1d5db;
  border-radius:10px;
  font-size:14px;
  background:#fff;
  box-sizing:border-box;
}

.mfx-group textarea{
  min-height:110px;
  resize:vertical;
}

.mfx-group input:focus,
.mfx-group select:focus,
.mfx-group textarea:focus{
  outline:none;
  border-color:#2f56a6;
  box-shadow:0 0 0 3px rgba(47,86,166,.12);
}

/* =========================
   CARDS GERENCIALES
========================= */
.mfx-cards{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:18px;
  margin-bottom:22px;
}

.mfx-card{
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:18px 20px;
  position:relative;
  box-shadow:0 2px 8px rgba(0,0,0,.04);
}

.mfx-card::before{
  content:"";
  position:absolute;
  left:0;
  top:0;
  bottom:0;
  width:5px;
  border-radius:14px 0 0 14px;
}

.mfx-card-periodo::before{
  background:#2f56a6;
}

.mfx-card-estados::before{
  background:#16a34a;
}

.mfx-card-futura::before{
  background:#cbd5e1;
}

.mfx-card h4{
  margin:0 0 8px;
  font-size:12px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.4px;
  color:#6b7280;
}

.mfx-card p{
  margin:0;
  font-size:15px;
  font-weight:700;
  color:#111827;
}

.mfx-multi-line{
  line-height:1.5;
}

/* =========================
   TABLA
========================= */
.mfx-table-card{
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:16px;
}

.mfx-table-scroll{
  width:100%;
  max-height:640px;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
}

.mfx-table-scroll::-webkit-scrollbar{
  width:10px;
  height:10px;
}

.mfx-table-scroll::-webkit-scrollbar-thumb{
  background:#c7ced8;
  border-radius:20px;
}

.mfx-table{
  width:max-content;
  min-width:100%;
  border-collapse:collapse;
}

.mfx-table th{
  position:sticky;
  top:0;
  z-index:2;
  background:#f3f4f6;
  color:#111827;
  font-size:13px;
  font-weight:700;
  text-align:left;
  padding:12px 14px;
  white-space:nowrap;
}

.mfx-table td{
  padding:12px 14px;
  font-size:13px;
  border-bottom:1px solid #f1f1f1;
  white-space:nowrap;
  vertical-align:middle;
  max-width:220px;
  overflow:hidden;
  text-overflow:ellipsis;
}

.mfx-table tbody tr:hover{
  background:#fafafa;
}

/* =========================
   BADGES
========================= */
.estado-manifiesto{
  display:inline-block;
  padding:5px 10px;
  border-radius:999px;
  background:#eef4ff;
  color:#1e3c72;
  font-size:12px;
  font-weight:700;
}

.novedad-badge{
  display:inline-block;
  padding:5px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
}

.novedad-badge.badge-si{
  background:#fdeaea;
  color:#c62828;
}

.novedad-badge.badge-no{
  background:#e8f5e9;
  color:#2e7d32;
}

/* =========================
   MODALES
========================= */
.mfx-modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.45);
  display:flex;
  justify-content:center;
  align-items:center;
  z-index:999;
}

.hidden{
  display:none !important;
}

.mfx-modal-box{
  background:#fff;
  border-radius:18px;
  padding:24px;
  box-shadow:0 20px 50px rgba(0,0,0,.18);
  overflow-y:auto;
  max-height:92vh;
}

.mfx-modal-box::-webkit-scrollbar{
  width:8px;
}

.mfx-modal-box::-webkit-scrollbar-thumb{
  background:#d1d5db;
  border-radius:20px;
}

/* modal crear */
.mfx-modal-create{
  width:min(95vw,920px);
}

/* modal detalle */
.mfx-modal-detail{
  width:min(96vw,1450px);
}

/* =========================
   TITULOS MODAL
========================= */
.mfx-modal-box h3{
  margin:0 0 18px;
  font-size:24px;
  color:#111827;
}

/* =========================
   FORMULARIO CREAR
========================= */
.mfx-form-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
}

.mfx-full{
  grid-column:span 2;
}

.mfx-empty{
  visibility:hidden;
}

.mfx-modal-actions{
  margin-top:10px;
  display:flex;
}

.mfx-modal-actions .mfx-btn{
  width:100%;
}

/* =========================
   DETALLE HEADER
========================= */
.mfx-detail-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  margin-bottom:22px;
}

.mfx-detail-header-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.mfx-close-detail{
  width:42px;
  height:42px;
  border:none;
  border-radius:10px;
  background:#eef2f7;
  cursor:pointer;
  font-size:15px;
}

.mfx-close-detail:hover{
  background:#dde5ef;
}

/* =========================
   DETALLE CONTENIDO
========================= */
.mfx-detail-container{
  display:flex;
  flex-direction:column;
  gap:22px;
}

.mfx-detail-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:20px;
}

.mfx-detail-card{
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:16px;
  padding:20px;
  box-shadow:0 6px 18px rgba(0,0,0,.05);
}

.mfx-detail-card h4{
  margin:0 0 10px;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.5px;
  color:#6b7280;
}

.mfx-detail-main{
  text-align:center;
}

.mfx-detail-summary{
  text-align:center;
}

.mfx-detail-summary p{
  margin:10px 0 0;
  font-size:22px;
  font-weight:800;
}

/* =========================
   GRID INFO MANIFIESTO
========================= */
.mfx-info-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:12px;
  margin-top:14px;
  text-align:left;
}

.detalle-info-item{
  background:#f9fafb;
  padding:10px 12px;
  border-radius:10px;
  font-size:13px;
}

.detalle-info-item span{
  display:block;
  font-size:11px;
  color:#6b7280;
  margin-bottom:4px;
}

.detalle-info-item strong{
  color:#111827;
}

/* modo edición heredado JS */
.detalle-info-item.editando input,
.detalle-info-item.editando select,
.detalle-info-item.editando textarea{
  width:100%;
  border:1px solid #d1d5db;
  border-radius:8px;
  padding:8px 10px;
  font-size:13px;
  box-sizing:border-box;
}

.detalle-info-item.full-span{
  grid-column:span 3;
}

/* =========================
   LISTAS FINANCIERAS
========================= */
.mfx-detail-list{
  min-height:160px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.detalle-item{
  display:flex;
  justify-content:space-between;
  gap:10px;
  font-size:13px;
  padding:6px 0;
  border-bottom:1px dashed #ececec;
}

.detalle-item span:last-child{
  font-weight:700;
}

.mfx-detail-total{
  margin-top:14px;
  text-align:right;
  font-size:14px;
  font-weight:800;
}

.mfx-detail-total span{
  font-size:16px;
}

/* =========================
   COLORES FINANCIEROS
========================= */
.valor-ingreso,
.total-ingreso,
.resumen-positivo{
  color:#16a34a;
}

.valor-egreso,
.valor-gasto,
.total-egreso,
.resumen-negativo{
  color:#dc2626;
}

.total-neutral,
.resumen-cero{
  color:#374151;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width:1400px){
  .mfx-detail-grid{
    grid-template-columns:1fr 1fr;
  }
}

@media (max-width:1200px){

  .mfx-cards{
    grid-template-columns:repeat(2,1fr);
  }

  .mfx-filters-grid{
    grid-template-columns:repeat(3,1fr);
  }

  .mfx-table{
    min-width:1250px;
  }
}

@media (max-width:900px){

  .mfx-info-grid{
    grid-template-columns:1fr 1fr;
  }

  .detalle-info-item.full-span{
    grid-column:span 2;
  }

  .mfx-detail-grid{
    grid-template-columns:1fr;
  }
}

@media (max-width:768px){

  .mfx-layout{
    padding:14px;
  }

  .mfx-header{
    flex-direction:column;
    align-items:stretch;
  }

  .mfx-header h2{
    font-size:28px;
  }

  .mfx-header .mfx-btn,
  .mfx-btn{
    width:100%;
  }

  .mfx-cards{
    grid-template-columns:1fr;
  }

  .mfx-filters-grid{
    grid-template-columns:1fr;
  }

  .mfx-form-grid{
    grid-template-columns:1fr;
  }

  .mfx-full,
  .detalle-info-item.full-span{
    grid-column:span 1;
  }

  .mfx-empty{
    display:none;
  }

  .mfx-detail-header{
    flex-direction:column;
    align-items:stretch;
  }

  .mfx-detail-header-actions{
    width:100%;
  }

  .mfx-modal-create,
  .mfx-modal-detail{
    width:96vw;
    padding:16px;
  }

  .mfx-info-grid{
    grid-template-columns:1fr;
  }
}

@media (max-width:480px){

  .mfx-header h2{
    font-size:24px;
  }

  .mfx-card,
  .mfx-filters-box,
  .mfx-table-card,
  .mfx-detail-card{
    padding:14px;
  }

  .mfx-card p,
  .mfx-detail-summary p{
    font-size:20px;
  }
}

/* =====================================
   FIX MODAL MANIFIESTOS TAPADO TOPBAR
   Agrega esto AL FINAL del CSS
===================================== */

/* separa el modal del topbar */
.mfx-modal{
  align-items: flex-start !important;
  padding-top: 78px;   /* ajusta según alto de tu topbar */
  padding-bottom: 20px;
  box-sizing: border-box;
}

/* mejora scroll interno */
.mfx-modal-box{
  margin: 0 auto;
  max-height: calc(100vh - 98px);
}

/* móviles */
@media (max-width: 768px){

  .mfx-modal{
    padding-top: 70px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .mfx-modal-box{
    max-height: calc(100vh - 85px);
  }

}

/* =====================================
   TABLA DINÁMICA RESPONSIVE
===================================== */

.mfx-table{
  width:100%;
  min-width:100%;
  table-layout:auto;
}

.mfx-table th{
  font-size:clamp(10px, 0.75vw, 12px);
  padding:8px 10px;
  white-space:nowrap;
}

.mfx-table td{
  font-size:clamp(10px, 0.72vw, 12px);
  padding:8px 10px;
  white-space:nowrap;
}

.mfx-table-scroll{
  width:100%;
  overflow-x:auto;
}

.estado-manifiesto,
.novedad-badge{
  font-size:clamp(9px,0.7vw,11px);
}

/* =====================================
   AJUSTE COMPACTO MANIFIESTOS
   AGREGAR AL FINAL
===================================== */

/* layout más compacto */
.mfx-layout{
  padding:14px !important;
}

/* header */
.mfx-header{
  margin-bottom:14px !important;
}

.mfx-header h2{
  font-size:28px !important;
}

/* botones */
.mfx-btn{
  height:34px !important;
  padding:0 14px !important;
  font-size:12px !important;
  border-radius:9px !important;
}

/* =========================
   FILTROS - 8 EN UNA FILA
========================= */
.mfx-filters-box{
  padding:14px !important;
  margin-bottom:14px !important;
}

.mfx-filters-grid{
  grid-template-columns:
    1.35fr
    .95fr
    .95fr
    1fr
    1fr
    .95fr
    .95fr
    .95fr   /* NUEVO facturado */
    .85fr
    .45fr !important;
}

.mfx-group label{
  font-size:11px !important;
  margin-bottom:4px !important;
}

.mfx-group input,
.mfx-group select{
  min-height:34px !important;
  height:34px !important;
  padding:0 10px !important;
  font-size:12px !important;
  border-radius:9px !important;
}

.mfx-filters-grid .mfx-btn{
  width:100% !important;
}

/* =========================
   CARDS MÁS PEQUEÑAS
========================= */
.mfx-cards{
  gap:10px !important;
  margin-bottom:14px !important;
}

.mfx-card{
  padding:12px 14px !important;
  border-radius:12px !important;
}

.mfx-card::before{
  width:4px !important;
}

.mfx-card h4{
  font-size:10px !important;
  margin-bottom:4px !important;
}

.mfx-card p{
  font-size:12px !important;
  line-height:1.3 !important;
}

/* tabla compacta */
.mfx-table-card{
  padding:12px !important;
}

.mfx-table th,
.mfx-table td{
  padding:9px 10px !important;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width:1500px){

  .mfx-filters-grid{
    grid-template-columns:repeat(4,1fr) !important;
  }
}

@media (max-width:1024px){

  .mfx-filters-grid{
    grid-template-columns:repeat(2,1fr) !important;
  }

  .mfx-cards{
    grid-template-columns:repeat(2,1fr) !important;
  }
}

@media (max-width:768px){

  .mfx-filters-grid{
    grid-template-columns:1fr !important;
  }

  .mfx-cards{
    grid-template-columns:1fr !important;
  }

  .mfx-btn{
    width:100% !important;
  }
}

.mfx-btn-excel {
  background: #15803d !important;
  color: #fff !important;
  width: 42px !important;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mfx-btn-excel:hover {
  background: #166534 !important;
}

.mfx-btn-excel i {
  font-size: 16px;
}

/* =========================
   TRACKING MANIFIESTO
========================= */
.mfx-tracking{
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0 16px;
  padding: 0 10px;
  height: 50px;
}

/* línea base */
.mfx-track-line{
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  height: 4px;
  background: #e5e7eb;
  border-radius: 10px;
  z-index: 1;
}

/* línea progreso */
.mfx-track-line::after{
  content: "";
  position: absolute;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2f56a6, #16a34a);
  border-radius: 10px;
  transition: width .4s ease;
}

/* step */
.mfx-track-step{
  position: relative;
  z-index: 2;
  text-align: center;
  flex: 1;
}

/* punto */
.mfx-track-step .dot{
  width: 14px;
  height: 14px;
  background: #d1d5db;
  border-radius: 50%;
  margin: 0 auto 6px;
  transition: .3s;
}

/* texto */
.mfx-track-step span{
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
}

/* activo */
.mfx-track-step.active .dot{
  background: #2f56a6;
  transform: scale(1.2);
}

.mfx-track-step.active span{
  color: #111827;
}

/* completado */
.mfx-track-step.completed .dot{
  background: #16a34a;
}

.mfx-track-step.completed span{
  color: #16a34a;
}

/* =========================
   TRACKING MANIFIESTO FIX
========================= */

.mfx-tracking{
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-end; /* ?? clave */
  margin: 10px 0 22px;
  padding: 0 20px;
  height: 70px;
}

/* línea (más abajo) */
.mfx-track-line{
  position: absolute;
  bottom: 18px; /* ?? BAJA la línea */
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 10px;
  background: linear-gradient(
    to right,
    #16a34a var(--progress, 0%),
    #e5e7eb var(--progress, 0%)
  );
  z-index: 1;
}

/* steps */
.mfx-track-step{
  position: relative;
  z-index: 2; /* ?? encima de la línea */
  text-align: center;
  flex: 1;
}

/* texto */
.mfx-track-step span{
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  background: #fff; /* ?? evita que la línea lo ensucie */
  padding: 0 6px;
}

/* ?? TRACTOMULA */
.mfx-truck{
  position: absolute;
  bottom: 30px; /* ?? justo encima de la línea */
  left: 0%;
  transform: translateX(-50%);
  font-size: 24px;
  transition: left .45s ease;
  z-index: 3;
}

/* línea progreso visual */
.mfx-track-line{
  background: linear-gradient(
    to right,
    #16a34a var(--progress, 0%),
    #e5e7eb var(--progress, 0%)
  );
}

/* =========================
   SECCION NEGOCIACION
========================= */

.mfx-section-title{
  margin-top: 6px;
  margin-bottom: -4px;
  padding-top: 6px;
  border-top: 1px solid #e5e7eb;
}

.mfx-section-title span{
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #6b7280;
}

/* =========================
   BOOL NEGOCIACION
========================= */

.mfx-bool-success{
  color:#16a34a !important;
  font-weight:800;
}

.mfx-bool-danger{
  color:#dc2626 !important;
  font-weight:800;
}

/* =========================
   COSTOS EXTRA
========================= */

.mfx-label-tooltip{
  display:flex;
  align-items:center;
  gap:6px;
}

.mfx-info-icon{
  font-size:12px;
  color:#6b7280;
  cursor:pointer;
  transition:.2s ease;
}

.mfx-info-icon:hover{
  color:#2f56a6;
}


/* =========================
   BADGES FACTURADO
========================= */

.mfx-badge-success{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:4px 10px;
  border-radius:999px;
  background:#dcfce7;
  color:#15803d;
  font-size:10px;
  font-weight:700;
}

.mfx-badge-danger{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:4px 10px;
  border-radius:999px;
  background:#fee2e2;
  color:#dc2626;
  font-size:10px;
  font-weight:700;
}

/* =====================================
   MODO EDICION DETALLE - COMPACTO PRO
===================================== */

/* modal detalle más compacto */
.mfx-modal-detail{
  width:min(95vw,1320px) !important;
  padding:18px !important;
}

/* header */
.mfx-detail-header{
  margin-bottom:14px !important;
}

.mfx-detail-header h3{
  font-size:22px !important;
}

/* botones top */
.mfx-detail-header-actions .mfx-btn{
  height:36px !important;
  padding:0 14px !important;
  font-size:12px !important;
  border-radius:10px !important;
}

/* tracking más pequeño */
.mfx-tracking{
  height:52px !important;
  margin:6px 0 14px !important;
}

.mfx-track-step span{
  font-size:11px !important;
}

.mfx-truck{
  font-size:20px !important;
}

/* grid principal */
.mfx-info-grid{
  gap:10px !important;
  margin-top:10px !important;
}

/* cards info */
.detalle-info-item{
  padding:8px 10px !important;
  border-radius:10px !important;
  min-height:auto !important;
}

/* labels */
.detalle-info-item span,
.detalle-info-item label{
  font-size:10px !important;
  margin-bottom:3px !important;
  letter-spacing:.2px;
}

/* textos */
.detalle-info-item strong{
  font-size:12px !important;
  line-height:1.2 !important;
}

/* inputs edición */
.detalle-info-item.editando input,
.detalle-info-item.editando select,
.detalle-info-item.editando textarea{
  min-height:34px !important;
  height:34px !important;
  padding:0 10px !important;
  font-size:12px !important;
  border-radius:8px !important;
}

/* textarea */
.detalle-info-item.editando textarea{
  min-height:70px !important;
  padding:10px !important;
}

/* readonly soft */
.readonly-soft{
  background:#f8fafc !important;
}

/* cards inferiores */
.mfx-detail-card{
  padding:16px !important;
  border-radius:14px !important;
}

/* títulos cards */
.mfx-detail-card h4{
  font-size:11px !important;
  margin-bottom:8px !important;
}

/* items financieros */
.detalle-item{
  font-size:12px !important;
  padding:5px 0 !important;
}

/* totales */
.mfx-detail-total{
  font-size:13px !important;
}

.mfx-detail-total span{
  font-size:15px !important;
}

/* observaciones full */
.detalle-info-item.full-span textarea{
  min-height:90px !important;
}

/* scroll más elegante */
.mfx-modal-box::-webkit-scrollbar{
  width:7px;
}

.mfx-modal-box::-webkit-scrollbar-thumb{
  background:#cbd5e1;
  border-radius:20px;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width:1200px){

  .mfx-info-grid{
    grid-template-columns:repeat(2,1fr) !important;
  }

}

@media (max-width:768px){

  .mfx-info-grid{
    grid-template-columns:1fr !important;
  }

  .mfx-modal-detail{
    width:98vw !important;
    padding:14px !important;
  }

}

/* =========================
   BOTON ESTE MES ACTIVO
========================= */

#btnVerEsteMes{
  background:#2f56a6 !important;
  color:#fff !important;
  border:none !important;
}

#btnVerEsteMes:hover{
  background:#24468a !important;
}

#btnVerMesAnterior{
  background:#eef2f7 !important;
  color:#111827 !important;
}

.btn-icon.btn-delete,
.btn-icon.btn-delete i{
  color:#ef4444 !important;
}

.btn-icon.btn-delete:hover,
.btn-icon.btn-delete:hover i{
  color:#dc2626 !important;
}