/*
 * SIGOS V37 · R8F
 * PARIDAD ANALÍTICA RESPONSIVE
 */

.r8fAnalytics{
  width:100%;
  min-width:0;
  overflow:hidden;
}

.r8fEngineState{
  display:flex;
  align-items:center;
  gap:7px;
  margin:2px 0 12px;
  font-size:12px;
  font-weight:700;
}

.r8fDot{
  width:8px;
  height:8px;
  flex:0 0 8px;
  border-radius:50%;
  background:#16803a;
}

.r8fKpiViewport,
.r8fFilterViewport{
  width:100%;
  min-width:0;
  overflow:hidden;
}

.r8fKpis{
  display:grid;
  grid-auto-flow:column;
  grid-auto-columns:minmax(150px,220px);
  gap:9px;
  overflow-x:auto;
  overscroll-behavior-x:contain;
  -webkit-overflow-scrolling:touch;
  scroll-snap-type:x proximity;
  scrollbar-width:none;
  padding:1px 12px 8px 1px;
}

.r8fKpis::-webkit-scrollbar,
.r8fFilters::-webkit-scrollbar,
.r8fTableViewport::-webkit-scrollbar,
.r8fExistingTableViewport::-webkit-scrollbar{
  display:none;
}

.r8fKpiCard{
  scroll-snap-align:start;
  min-height:78px;
  padding:12px 14px;
  border:1px solid rgba(15,23,42,.11);
  border-radius:14px;
  background:#fff;
  box-shadow:0 3px 12px rgba(15,23,42,.05);
}

.r8fKpiCard span{
  display:block;
  margin-bottom:7px;
  color:#687386;
  font-size:10px;
  line-height:1.25;
  font-weight:800;
  letter-spacing:.04em;
  text-transform:uppercase;
}

.r8fKpiCard strong{
  display:block;
  color:#101828;
  font-size:18px;
  line-height:1.15;
  font-weight:850;
}

.r8fKpiCard.secondary{
  background:#fafbfc;
}

.r8fToolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin:10px 0 8px;
}

.r8fSearchWrap{
  flex:1 1 260px;
  min-width:140px;
}

.r8fSearch{
  width:100%;
  min-height:39px;
  padding:8px 12px;
  border:1px solid rgba(15,23,42,.14);
  border-radius:11px;
  outline:none;
  background:#fff;
  color:#101828;
  font:inherit;
}

.r8fSearch:focus{
  border-color:#86a7d2;
  box-shadow:0 0 0 3px rgba(57,108,171,.08);
}

.r8fExports{
  display:flex;
  align-items:center;
  gap:6px;
  flex:0 0 auto;
}

.r8fExportBtn,
.r8fRefreshBtn{
  min-height:36px;
  padding:7px 10px;
  border:1px solid rgba(15,23,42,.14);
  border-radius:10px;
  background:#fff;
  color:#27364a;
  font-size:11px;
  font-weight:800;
  white-space:nowrap;
}

.r8fRefreshBtn{
  background:#2f5f93;
  border-color:#2f5f93;
  color:#fff;
}

.r8fFilters{
  display:flex;
  align-items:center;
  gap:6px;
  overflow-x:auto;
  overscroll-behavior-x:contain;
  -webkit-overflow-scrolling:touch;
  padding:2px 12px 7px 1px;
}

.r8fFilterChip{
  flex:0 0 auto;
  min-height:32px;
  padding:6px 11px;
  border:1px solid rgba(15,23,42,.13);
  border-radius:999px;
  background:#fff;
  color:#415067;
  font-size:11px;
  font-weight:750;
  white-space:nowrap;
}

.r8fFilterChip.active{
  border-color:#2f5f93;
  background:#eaf1f8;
  color:#234f7c;
}

.r8fResultMeta{
  margin:3px 0 7px;
  color:#687386;
  font-size:11px;
  font-weight:700;
}

.r8fTableViewport,
.r8fExistingTableViewport{
  width:100%;
  max-width:100%;
  overflow-x:auto;
  overscroll-behavior-x:contain;
  -webkit-overflow-scrolling:touch;
  border:1px solid rgba(15,23,42,.10);
  border-radius:13px;
  background:#fff;
}

.r8fTable{
  width:max-content;
  min-width:100%;
  border-collapse:separate;
  border-spacing:0;
  font-size:11px;
}

.r8fTable th,
.r8fTable td{
  min-width:115px;
  max-width:240px;
  padding:9px 10px;
  border-bottom:1px solid rgba(15,23,42,.07);
  border-right:1px solid rgba(15,23,42,.05);
  vertical-align:top;
  text-align:left;
  white-space:normal;
  overflow-wrap:anywhere;
}

.r8fTable th{
  position:relative;
  z-index:2;
  background:#f6f8fb;
  color:#35445a;
  font-size:9px;
  font-weight:850;
  letter-spacing:.035em;
  text-transform:uppercase;
}

.r8fTable tbody tr:last-child td{
  border-bottom:0;
}

.r8fTable .r8fSticky{
  position:sticky;
  left:0;
  z-index:3;
  min-width:104px;
  max-width:140px;
  background:#fff;
  box-shadow:7px 0 10px -10px rgba(15,23,42,.5);
}

.r8fTable th.r8fSticky{
  z-index:4;
  background:#f6f8fb;
}

.r8fDetailCell{
  min-width:108px !important;
}

.r8fDetails summary{
  cursor:pointer;
  color:#2f5f93;
  font-size:10px;
  font-weight:800;
  white-space:nowrap;
}

.r8fDetails dl{
  min-width:250px;
  margin:8px 0 0;
}

.r8fDetailItem{
  display:grid;
  grid-template-columns:minmax(90px,1fr) 1.4fr;
  gap:8px;
  padding:5px 0;
  border-bottom:1px solid rgba(15,23,42,.06);
}

.r8fDetailItem dt{
  color:#687386;
  font-size:9px;
  font-weight:800;
}

.r8fDetailItem dd{
  margin:0;
  color:#182230;
  font-size:10px;
}

.r8fEmpty{
  padding:18px;
  border:1px solid rgba(15,23,42,.10);
  border-radius:12px;
  background:#fafbfc;
  color:#687386;
  text-align:center;
  font-size:12px;
}

/*
 * Pestañas ya existentes como SBBT / Resumen / Fuentes:
 * se conserva su renderer y se mejora la composición móvil.
 */

.r8fExistingKpis{
  min-width:0;
}

[id^="m5"] table{
  font-size:11px;
}

/* MOBILE */

@media (max-width:640px){

  .r8fKpis{
    grid-auto-columns:min(76vw,245px);
    gap:8px;
    padding-right:20px;
  }

  .r8fKpiCard{
    min-height:72px;
    border-radius:13px;
    padding:11px 12px;
  }

  .r8fKpiCard strong{
    font-size:17px;
  }

  .r8fToolbar{
    align-items:stretch;
    flex-direction:column;
    gap:7px;
  }

  .r8fSearchWrap{
    flex:0 0 auto;
    width:100%;
  }

  .r8fExports{
    width:100%;
    overflow-x:auto;
    padding-bottom:1px;
  }

  .r8fExportBtn,
  .r8fRefreshBtn{
    flex:0 0 auto;
  }

  .r8fTable th,
  .r8fTable td{
    min-width:118px;
    padding:8px 9px;
  }

  .r8fTable .r8fSticky{
    min-width:92px;
    max-width:116px;
  }

  /*
   * KPIs que todavía pertenecen a renderers existentes.
   * Swipe NATIVO; no JS de auto-retorno.
   */

  .r8fExistingKpis{
    display:grid !important;
    grid-auto-flow:column !important;
    grid-auto-columns:min(76vw,245px) !important;
    grid-template-columns:none !important;
    gap:8px !important;
    overflow-x:auto !important;
    overscroll-behavior-x:contain;
    -webkit-overflow-scrolling:touch;
    scroll-snap-type:x proximity;
    padding-right:20px !important;
  }

  .r8fExistingKpis > *{
    scroll-snap-align:start;
  }

}
