/* =========================================================
   BI DASHBOARD OVERRIDES (Metronic-safe)
   - NO cambia colores
   - Solo layout/typography/spacing/tabla/chart sizing
   ========================================================= */

/* 0) Scope fuerte: solo aplica al dashboard */
.bi-page {
  /* Evita que Metronic fuerce line-height/tamaños raros */
  line-height: 1.35;
}

/* 1) Cards: jerarquía, padding, overflow correcto */
.bi-page .card,
.bi-page .bi-card,
.bi-page .panel,
.bi-page .bi-panel {
  overflow: hidden;
}

.bi-page .chead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.bi-page .ctitle {
  font-weight: 700;
  letter-spacing: .2px;
}

.bi-page .muted {
  opacity: .85;
  line-height: 1.25;
}

/* 2) Grid: más respiración */
.bi-page .grid2,
.bi-page .grid3 {
  gap: 16px !important;
}

/* 3) CHARTS (SVG): tamaño consistente tipo “Power BI”
   - Sin cambiar colores
*/
.bi-page .trendWrap,
.bi-page .trendWrap.proy,
.bi-page .trendWrap--resumen,
.bi-page .paretoWrap {
  width: 100%;
  min-height: 280px;
  display: block;
}

.bi-page .trendWrap svg,
.bi-page .paretoWrap svg {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* evita que Metronic “achique” SVG en mobile */
.bi-page svg {
  max-width: 100%;
}

/* 4) TABLES (tu tabla es DIVS, no <table>)
   Metronic aplica estilos a .table que te rompen:
   - margin-bottom
   - color
   - width
   Aquí lo neutralizamos SOLO dentro de .bi-page.
*/
.bi-page .table {
  /* neutraliza bootstrap/metronic table styles */
  width: 100% !important;
  margin: 0 !important;
  color: inherit !important;
  background: transparent !important;
  border-collapse: unset !important;
}

/* Tabla DIV: contenedor scroll real y limpio */
.bi-page .tableScroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
}

/* Header sticky (si la tabla crece) */
.bi-page .tableScroll .thead {
  position: sticky;
  top: 0;
  z-index: 3;
}

/* Layout: fuerza grid estable para headers/rows */
.bi-page .thead,
.bi-page .trow {
  display: grid !important;
  align-items: center;
  gap: 10px;
}

/* Ajustes de padding uniforme */
.bi-page .thead > div,
.bi-page .trow > div {
  padding: 10px 12px;
  min-width: 0; /* clave para ellipsis */
}

/* Tipografía más pro (sin cambiar color) */
.bi-page .thead > div {
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: .2px;
  white-space: nowrap;
}

.bi-page .trow > div {
  font-size: 13px;
  line-height: 1.2;
}

/* Ellipsis controlado para textos largos */
.bi-page .tmain,
.bi-page .cell-ruc,
.bi-page .cell-money,
.bi-page .trow > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* si quieres wrap en campos específicos, usa .wrap */
.bi-page .wrap {
  white-space: normal !important;
  word-break: break-word;
}

/* Separación visual entre filas (sin meter colores nuevos) */
.bi-page .trow {
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* Column templates (ya las usas: cols3, cols4, cols5)
   Asegura consistencia en desktop.
*/
.bi-page .cols3 { grid-template-columns: 2.2fr 1.2fr 1fr !important; }
.bi-page .cols4 { grid-template-columns: 70px 2.2fr 1.2fr 1fr !important; }
.bi-page .thead4.cols4 { grid-template-columns: 70px 2.2fr 1.2fr 1fr !important; }
.bi-page .cols5 { grid-template-columns: 70px 2.2fr 1.2fr 1fr 0.8fr !important; }

/* 5) PAGINACIÓN: alineación y responsive */
.bi-page .pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.bi-page .pagerControls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.bi-page .pgBtn,
.bi-page .pgNum {
  border-radius: 10px;
  padding: 8px 10px;
  line-height: 1;
}

/* 6) Mobile: scroll horizontal limpio */
@media (max-width: 991.98px) {
  .bi-page .grid2,
  .bi-page .grid3 {
    grid-template-columns: 1fr !important;
  }

  /* tablas: deja scroll horizontal sin romper */
  .bi-page .tableScroll {
    overflow-x: auto;
  }

  /* columnas más compactas en móvil */
  .bi-page .cols5 { grid-template-columns: 60px 2fr 1.1fr 1fr 0.9fr !important; }
  .bi-page .cols4 { grid-template-columns: 60px 2fr 1.2fr 1fr !important; }
}


/* FORZAR TABLAS DIV (Metronic override) */
.bi-page .table.table {
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  background: transparent !important;
  color: inherit !important;
}

.bi-page .tableScroll {
  overflow: auto !important;
  -webkit-overflow-scrolling: touch;
}

.bi-page .tableScroll .thead {
  position: sticky !important;
  top: 0;
  z-index: 10;
}

.bi-page .thead,
.bi-page .trow {
  display: grid !important;
  align-items: center !important;
  gap: 10px !important;
}

.bi-page .thead > div,
.bi-page .trow > div {
  min-width: 0 !important;
  padding: 10px 12px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

/* =======================
   BI TABLES (DIV-based) - HARD OVERRIDE
   ======================= */
   .bi-page .table {
    /* neutraliza bootstrap/metronic */
    width: 100% !important;
    margin: 0 !important;
    background: transparent !important;
    color: inherit !important;
  }

  /* contenedor con scroll real */
  .bi-page .tableScroll {
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: 14px;
  }

  /* sticky header */
  .bi-page .tableScroll .thead {
    position: sticky !important;
    top: 0 !important;
    z-index: 20 !important;
  }

  /* grid estable */
  .bi-page .thead,
  .bi-page .trow {
    display: grid !important;
    align-items: center !important;
    gap: 10px !important;
  }

  /* celdas perfectas */
  .bi-page .thead > div,
  .bi-page .trow > div {
    min-width: 0 !important;
    padding: 10px 12px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* tipografía y jerarquía */
  .bi-page .thead > div {
    font-weight: 700 !important;
    font-size: 12.5px !important;
    letter-spacing: .2px !important;
  }
  .bi-page .trow > div {
    font-size: 13px !important;
    line-height: 1.2 !important;
  }

  /* separación sutil (no cambia color base, solo divisor) */
  .bi-page .trow {
    border-top: 1px solid rgba(255,255,255,0.08) !important;
  }

  /* templates (asegura forma) */
  .bi-page .cols3 { grid-template-columns: 2.2fr 1.2fr 1fr !important; }
  .bi-page .cols4 { grid-template-columns: 70px 2.2fr 1.2fr 1fr !important; }
  .bi-page .cols5 { grid-template-columns: 70px 2.2fr 1.2fr 1fr 0.8fr !important; }

  /* responsive: scroll horizontal limpio */
  @media (max-width: 991.98px) {
    .bi-page .tableScroll { overflow-x: auto !important; }
    .bi-page .cols5 { grid-template-columns: 60px 2fr 1.1fr 1fr 0.9fr !important; }
    .bi-page .cols4 { grid-template-columns: 60px 2fr 1.2fr 1fr !important; }
  }
