/* =====================================
   FACTURAS CSS AISLADO - FTX
   Vista crítica / responsive / independiente
===================================== */

/* =========================
   LAYOUT
========================= */
.ftx-layout{
  padding:20px;
  width:100%;
  box-sizing:border-box;
}

/* =========================
   HEADER
========================= */
.ftx-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  margin-bottom:22px;
}

.ftx-header h2{
  margin:0;
  font-size:34px;
  font-weight:700;
  color:#111827;
}

/* =========================
   BOTONES
========================= */
.ftx-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;
}

.ftx-btn:hover{
  transform:translateY(-1px);
}

.ftx-btn-primary{
  background:#2f56a6;
  color:#fff;
}

.ftx-btn-primary:hover{
  background:#24468a;
}

.ftx-btn-danger{
  background:#ea4335;
  color:#fff;
}

.ftx-btn-danger:hover{
  background:#cf3528;
}

.ftx-btn-light{
  background:#eef2f7;
  color:#111827;
}

.ftx-btn-light:hover{
  background:#dde5ef;
}

/* =========================
   CARDS
========================= */
.ftx-cards{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:18px;
  margin-bottom:22px;
}

.ftx-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);
}

.ftx-card::before{
  content:"";
  position:absolute;
  left:0;
  top:0;
  bottom:0;
  width:5px;
  border-radius:14px 0 0 14px;
}

.ftx-card.facturado::before{ background:#27ae60; }
.ftx-card.cobrado::before{ background:#16a34a; }
.ftx-card.cartera::before{ background:#e74c3c; }
.ftx-card.porcentaje::before{ background:#3498db; }

.ftx-card h3{
  margin:0 0 8px;
  font-size:12px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.4px;
  color:#6b7280;
}

.ftx-card p{
  margin:0;
  font-size:24px;
  font-weight:800;
  color:#111827;
}

/* =========================
   FILTROS
========================= */
.ftx-filtros{
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:18px;
  margin-bottom:22px;

  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:16px;
  align-items:end;
}

.ftx-group{
  display:flex;
  flex-direction:column;
}

.ftx-group label{
  font-size:12px;
  font-weight:600;
  color:#6b7280;
  margin-bottom:6px;
}

.ftx-group input,
.ftx-group select{
  width:100%;
  height:44px;
  padding:0 14px;
  border:1px solid #d1d5db;
  border-radius:10px;
  font-size:14px;
  background:#fff;
  box-sizing:border-box;
}

.ftx-group input:focus,
.ftx-group select:focus{
  outline:none;
  border-color:#2f56a6;
  box-shadow:0 0 0 3px rgba(47,86,166,.12);
}

/* =========================
   TABLA
========================= */
.ftx-table-card{
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:16px;
}

.ftx-table-scroll{
  width:100%;
  max-height:620px;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
}

.ftx-table-scroll::-webkit-scrollbar{
  width:10px;
  height:10px;
}

.ftx-table-scroll::-webkit-scrollbar-thumb{
  background:#c7ced8;
  border-radius:20px;
}

.ftx-table{
  width:max-content;
  min-width:100%;
  border-collapse:collapse;
}

.ftx-table th{
  background:#f3f4f6;
  color:#111827;
  font-size:13px;
  font-weight:700;
  text-align:left;
  padding:12px 14px;
  white-space:nowrap;
}

.ftx-table td{
  padding:12px 14px;
  font-size:14px;
  border-bottom:1px solid #f1f1f1;
  white-space:nowrap;
  vertical-align:middle;
}

.ftx-table tbody tr:hover{
  background:#fafafa;
}

/* =========================
   BADGES ESTADO
========================= */
.badge{
  display:inline-block;
  padding:5px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
  white-space:nowrap;
}

.badge.pagada{
  background:#e8f5e9;
  color:#2e7d32;
}

.badge.pendiente{
  background:#fff7e6;
  color:#d97706;
}

.badge.vencida{
  background:#fdeaea;
  color:#c62828;
}

/* =========================
   MODALES
========================= */
.ftx-modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.45);
  display:flex;
  justify-content:center;
  align-items:center;
  z-index:10000;
}

.hidden{
  display:none !important;
}

.ftx-modal-box,
.ftx-confirm-box{
  background:#fff;
  width:min(94vw,640px);
  max-height:92vh;
  overflow-y:auto;
  border-radius:16px;
  padding:24px;
  box-shadow:0 20px 50px rgba(0,0,0,.18);
}

.ftx-confirm-box{
  width:min(94vw,420px);
}

.ftx-modal-box::-webkit-scrollbar,
.ftx-confirm-box::-webkit-scrollbar{
  width:8px;
}

.ftx-modal-box::-webkit-scrollbar-thumb,
.ftx-confirm-box::-webkit-scrollbar-thumb{
  background:#d1d5db;
  border-radius:20px;
}

.ftx-modal-box h3,
.ftx-confirm-box h3{
  margin:0 0 18px;
  font-size:24px;
  color:#111827;
}

.ftx-confirm-box p{
  margin:0 0 18px;
  color:#4b5563;
  font-size:14px;
}

/* =========================
   FORM MODAL
========================= */
.ftx-form-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
}

.ftx-modal-actions{
  margin-top:18px;
  display:flex;
}

.ftx-modal-actions .ftx-btn{
  width:100%;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width:1200px){

  .ftx-cards{
    grid-template-columns:repeat(2,1fr);
  }

  .ftx-filtros{
    grid-template-columns:repeat(3,1fr);
  }
}

@media (max-width:768px){

  .ftx-layout{
    padding:14px;
  }

  .ftx-header{
    flex-direction:column;
    align-items:stretch;
  }

  .ftx-header h2{
    font-size:28px;
  }

  .ftx-header .ftx-btn,
  .ftx-btn{
    width:100%;
  }

  .ftx-cards{
    grid-template-columns:1fr;
  }

  .ftx-filtros{
    grid-template-columns:1fr;
  }

  .ftx-form-grid{
    grid-template-columns:1fr;
  }

  .ftx-table{
    min-width:1200px;
  }
}

@media (max-width:480px){

  .ftx-header h2{
    font-size:24px;
  }

  .ftx-card,
  .ftx-filtros,
  .ftx-table-card,
  .ftx-modal-box,
  .ftx-confirm-box{
    padding:14px;
  }

  .ftx-card p{
    font-size:20px;
  }
}

/* =====================================
   SELECT BUSCADOR MANIFIESTOS
===================================== */

.select-search-wrapper{
  position:relative;
  width:100%;
}

.select-search-input{
  width:100%;
  height:44px;
  padding:0 14px;
  border:1px solid #d1d5db;
  border-radius:10px;
  font-size:14px;
  background:#fff;
  box-sizing:border-box;
}

.select-search-input:focus{
  outline:none;
  border-color:#2f56a6;
  box-shadow:0 0 0 3px rgba(47,86,166,.12);
}

/* ?? dropdown flotante */
.select-search-dropdown{
  position:absolute;
  top:calc(100% + 6px);
  left:0;
  right:0;

  background:#fff;
  border:1px solid #d1d5db;
  border-radius:12px;
  box-shadow:0 18px 40px rgba(0,0,0,.12);

  /* ?? SOLO 5 ITEMS */
  max-height:241px;

  overflow-y:auto;
  overflow-x:hidden;

  z-index:9999;
}

/* scrollbar */
.select-search-dropdown::-webkit-scrollbar{
  width:8px;
}

.select-search-dropdown::-webkit-scrollbar-thumb{
  background:#d1d5db;
  border-radius:20px;
}

/* opciones */
.select-option{
  padding:12px 14px;
  font-size:14px;
  cursor:pointer;
  border-bottom:1px solid #f1f1f1;
  transition:.15s ease;
}

.select-option:last-child{
  border-bottom:none;
}

.select-option:hover{
  background:#f8fafc;
}

/* opción usada */
.select-option.disabled{
  opacity:.45;
  cursor:not-allowed;
}

/* sin resultados */
.no-results{
  padding:14px;
  text-align:center;
  color:#6b7280;
  font-size:14px;
}

.select-option{
  height:48px;
  padding:0 14px;

  display:flex;
  align-items:center;

  font-size:14px;
  cursor:pointer;
  border-bottom:1px solid #f1f1f1;
  transition:.15s ease;

  box-sizing:border-box;
}

/* =====================================
   AJUSTE COMPACTO FACTURAS
   AGREGAR AL FINAL
===================================== */

/* layout */
.ftx-layout{
  padding:14px !important;
}

/* header */
.ftx-header{
  gap:12px !important;
  margin-bottom:14px !important;
}

.ftx-header h2{
  font-size:28px !important;
}

/* botones */
.ftx-btn{
  height:34px !important;
  padding:0 14px !important;
  font-size:12px !important;
  border-radius:9px !important;
}

/* =========================
   CARDS MÁS PEQUEÑAS
========================= */
.ftx-cards{
  gap:10px !important;
  margin-bottom:14px !important;
  grid-template-columns:repeat(4,1fr) !important;
}

.ftx-card{
  padding:12px 14px !important;
  border-radius:12px !important;
}

.ftx-card::before{
  width:4px !important;
}

.ftx-card h3{
  font-size:10px !important;
  margin-bottom:4px !important;
}

.ftx-card p{
  font-size:18px !important;
  line-height:1.2 !important;
}

/* =========================
   FILTROS MÁS COMPACTOS
========================= */
.ftx-filtros{
  padding:14px !important;
  margin-bottom:14px !important;

  /* 6 por fila */
  grid-template-columns:repeat(7,1fr) !important;
  gap:8px !important;
}

.ftx-group label{
  font-size:11px !important;
  margin-bottom:4px !important;
}

.ftx-group input,
.ftx-group select{
  height:34px !important;
  min-height:34px !important;
  padding:0 10px !important;
  font-size:12px !important;
  border-radius:9px !important;
}

.ftx-filtros .ftx-btn{
  width:100% !important;
}

/* buscador manifiestos */
.select-search-input{
  height:34px !important;
  padding:0 10px !important;
  font-size:12px !important;
  border-radius:9px !important;
}

.select-search-dropdown{
  max-height:205px !important;
}

.select-option{
  height:40px !important;
  font-size:12px !important;
  padding:0 10px !important;
}

/* =========================
   TABLA MÁS COMPACTA
========================= */
.ftx-table-card{
  padding:12px !important;
}

.ftx-table-scroll{
  max-height:560px !important;
}

.ftx-table th{
  font-size:12px !important;
  padding:10px 12px !important;
}

.ftx-table td{
  font-size:12px !important;
  padding:10px 12px !important;
}

/* badges */
.badge{
  font-size:11px !important;
  padding:4px 8px !important;
}

/* =========================
   MODALES MÁS COMPACTOS
========================= */
.ftx-modal-box,
.ftx-confirm-box{
  padding:18px !important;
}

.ftx-modal-box h3,
.ftx-confirm-box h3{
  font-size:22px !important;
}

.ftx-form-grid{
  gap:12px !important;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width:1400px){

  .ftx-cards{
    grid-template-columns:repeat(2,1fr) !important;
  }

  .ftx-filtros{
    grid-template-columns:repeat(3,1fr) !important;
  }
}

@media (max-width:768px){

  .ftx-cards{
    grid-template-columns:1fr !important;
  }

  .ftx-filtros{
    grid-template-columns:1fr !important;
  }

  .ftx-btn{
    width:100% !important;
  }
}

/* =====================================
   NUEVA UX FACTURAS MULTIMANIFIESTO
===================================== */

.ftx-manifiestos-section{
  margin-top:18px;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:16px;
  background:#fafafa;
}

.ftx-manifiestos-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin-bottom:14px;
}

.ftx-manifiestos-header h4{
  margin:0;
  font-size:15px;
  font-weight:700;
  color:#111827;
}

.ftx-manifiestos-header p{
  margin:4px 0 0;
  font-size:12px;
  color:#6b7280;
}

.ftx-manifiesto-add{
  margin-bottom:14px;
}

.ftx-chips{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}

.ftx-chip{
  display:flex;
  align-items:center;
  gap:10px;

  background:#e8eefc;
  color:#24468a;

  border-radius:999px;

  padding:8px 12px;

  font-size:12px;
  font-weight:700;
}

.ftx-chip button{
  border:none;
  background:none;
  color:#dc2626;
  cursor:pointer;
  font-size:14px;
  font-weight:700;
}

.ftx-total-card{
  margin-top:18px;

  background:#f3f6fb;

  border:1px solid #dbe4f0;

  border-radius:14px;

  padding:18px;

  display:flex;
  justify-content:space-between;
  align-items:center;
}

.ftx-total-card span{
  font-size:14px;
  color:#6b7280;
  font-weight:600;
}

.ftx-total-card strong{
  font-size:28px;
  color:#111827;
}

.factura-manifiestos-wrapper{
    display:flex;
    align-items:center;
    gap:6px;
    flex-wrap:wrap;
}

.factura-chip-manifiesto{
    background:#eef2ff;
    color:#24408e;
    border-radius:999px;
    padding:4px 10px;
    font-size:11px;
    font-weight:600;
    white-space:nowrap;
}

.factura-more-wrapper{
    position:relative;
}

.factura-chip-more{
    background:#f3f4f6;
    color:#374151;
    border-radius:999px;
    padding:4px 8px;
    font-size:11px;
    font-weight:700;
    cursor:pointer;
}

.factura-manifiestos-tooltip{
    position:absolute;
    top:34px;
    left:0;
    min-width:220px;
    background:#fff;
    border-radius:14px;
    padding:14px;
    box-shadow:0 10px 30px rgba(0,0,0,.12);
    border:1px solid #e5e7eb;
    opacity:0;
    visibility:hidden;
    transition:.2s ease;
    z-index:999;
}

.factura-more-wrapper:hover .factura-manifiestos-tooltip{
    opacity:1;
    visibility:visible;
}

.factura-tooltip-title{
    font-size:12px;
    font-weight:700;
    margin-bottom:10px;
}

.factura-tooltip-item{
    font-size:12px;
    color:#4b5563;
    margin-bottom:6px;
}

/* =====================================
   MANIFIESTOS FACTURA - MODERNO
===================================== */

.ftx-manifiestos-table{
  position:relative;
}

.ftx-manifiestos-chips{
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
}

/* chip */
.ftx-chip-mini{
  background:#eef2ff;
  color:#24468a;
  border-radius:999px;
  padding:4px 10px;
  font-size:11px;
  font-weight:700;
  line-height:1;
  white-space:nowrap;
}

/* botón +N */
.ftx-more-dropdown{
  position:relative;
}

.ftx-more-btn{
  border:none;
  background:#f3f4f6;
  color:#374151;
  border-radius:999px;
  padding:4px 9px;
  font-size:11px;
  font-weight:700;
  cursor:pointer;
  transition:.2s ease;
}

.ftx-more-btn:hover{
  background:#e5e7eb;
}

/* menu */
.ftx-more-menu{
  position:absolute;
  top:34px;
  left:0;
  min-width:220px;
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:12px;
  box-shadow:0 10px 30px rgba(0,0,0,.12);
  opacity:0;
  visibility:hidden;
  transform:translateY(6px);
  transition:.2s ease;
  z-index:50;
}

/* abrir */
.ftx-more-dropdown.open .ftx-more-menu{
  opacity:1;
  visibility:visible;
  transform:translateY(0);
}

/* title */
.ftx-more-title{
  font-size:11px;
  font-weight:800;
  color:#111827;
  margin-bottom:8px;
  padding-bottom:6px;
  border-bottom:1px solid #f1f1f1;
}

/* items */
.ftx-more-item{
  font-size:12px;
  padding:6px 0;
  color:#374151;
}

/* hover item */
.ftx-more-item:hover{
  color:#111827;
}

/* mobile */
@media (max-width:768px){

  .ftx-more-menu{
    left:auto;
    right:0;
    min-width:180px;
  }

}

/* =========================================
   INLINE CHIPS
========================================= */

.ftx-manifiestos-inline{
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
}

.ftx-chip-mini{
  background:#eef2ff;
  color:#24468a;
  border-radius:999px;
  padding:4px 10px;
  font-size:11px;
  font-weight:700;
  white-space:nowrap;
}

.ftx-more-link{
  border:none;
  background:none;
  color:#2563eb;
  font-size:11px;
  font-weight:700;
  cursor:pointer;
  padding:0;
}

.ftx-more-link:hover{
  text-decoration:underline;
}

/* =========================================
   MODAL
========================================= */

.ftx-modal-overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.35);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:9999;
}

.ftx-modal-overlay.open{
  display:flex;
}

.ftx-modal-content{
  width:420px;
  max-width:95%;
  background:#fff;
  border-radius:20px;
  padding:20px;
  box-shadow:0 20px 60px rgba(0,0,0,.2);
}

.ftx-modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:18px;
}

.ftx-modal-header h3{
  font-size:18px;
  font-weight:800;
  margin:0;
}

.ftx-close-btn{
  width:34px;
  height:34px;
  border:none;
  border-radius:10px;
  background:#f3f4f6;
  cursor:pointer;
  font-size:18px;
  font-weight:700;
}

.ftx-close-btn:hover{
  background:#e5e7eb;
}

.ftx-modal-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.ftx-modal-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 14px;
  border:1px solid #eef2f7;
  border-radius:14px;
  background:#fafafa;
}

.ftx-modal-chip{
  font-size:12px;
  font-weight:800;
  color:#1e3a8a;
}

.ftx-modal-client{
  font-size:12px;
  color:#6b7280;
}

.factura-impuestos-grid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:12px;
  margin-top:14px;
  margin-bottom:14px;
}

.factura-mini-card{
  background:#f8fafc;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:6px;
}

.factura-mini-card span{
  font-size:11px;
  color:#6b7280;
  font-weight:600;
  text-transform:uppercase;
}

.factura-mini-card strong{
  font-size:18px;
  font-weight:800;
  color:#111827;
}

.factura-neto{
  background:#eefbf3;
  border-color:#b7ebc6;
}

.factura-neto strong{
  color:#166534;
}

@media(max-width:900px){

  .factura-impuestos-grid{
    grid-template-columns:1fr 1fr;
  }

}

/* =========================
   BOTONES PERIODO FACTURAS
========================= */

#btnEsteMesFacturas{
  background:#2f56a6 !important;
  color:#fff !important;
  border:none !important;
}

#btnEsteMesFacturas:hover{
  background:#24468a !important;
}

#btnMesAnteriorFacturas{
  background:#eef2f7 !important;
  color:#111827 !important;
}

#btnMesAnteriorFacturas:hover{
  background:#dde5ef !important;
}

/* OJO */

.ftx-eye-btn{
  border:none;
  background:transparent;
  cursor:pointer;
  font-size:14px;
  color:#2f56a6;
  margin-right:6px;
}

.ftx-eye-btn:hover{
  opacity:.8;
}

/* ... */

.ftx-more-dots{
  font-weight:700;
  color:#6b7280;
  padding:0 4px;
}

/* MODAL DETALLE */

.ftx-modal-manifiestos-detalle{
  width:700px;
  max-width:90vw;
}

.ftx-manifiesto-card{
  border:1px solid #e5e7eb;
  border-radius:10px;
  padding:12px;
  margin-bottom:10px;
}

.ftx-manifiesto-title{
  font-size:15px;
  font-weight:700;
  margin-bottom:10px;
  color:#2f56a6;
}

.ftx-manifiesto-grid{

  display:grid;

  grid-template-columns:
    repeat(7,1fr);

  gap:12px;

}

.ftx-manifiesto-grid label{
  display:block;
  font-size:11px;
  color:#6b7280;
  margin-bottom:4px;
}

.ftx-manifiesto-grid strong{
  font-size:14px;
}

/* =========================
   RESUMEN FACTURA MODAL
========================= */

.ftx-factura-resumen{

  margin-top:16px;

  padding:18px;

  border-radius:12px;

  background:#eef6ff;

  border:2px solid #2f56a6;

  text-align:center;

}

.ftx-factura-resumen-label{

  font-size:12px;

  text-transform:uppercase;

  color:#64748b;

  margin-bottom:6px;

  font-weight:600;

}

.ftx-factura-resumen-valor{

  font-size:32px;

  font-weight:700;

  color:#2f56a6;

  margin-bottom:12px;

}

.ftx-factura-resumen-extra{

  display:flex;

  justify-content:center;

  gap:20px;

  flex-wrap:wrap;

  font-size:13px;

  color:#475569;

}

.ftx-factura-resumen-extra span{

  font-weight:600;

}

/* =========================
   ELIMINAR FACTURA
========================= */

.ftx-btn-delete-factura{

  border:none;
  background:transparent;

  color:#ef4444;

  cursor:pointer;

  font-size:14px;
  font-weight:700;

  padding:0;

  line-height:1;

}

.ftx-btn-delete-factura:hover{

  color:#dc2626;

  transform:scale(1.1);

}

.ftx-saldo-pendiente{

  color:#dc2626;

  font-weight:700;

}