/* =========================================================
   COSTES · DETALLE KILÓMETROS / PARTIDOS / EVENTOS
   Diseño más limpio + grids con header fijo y body scroll
   ========================================================= */

:root{
  --costes-bg-1: #0d1318;
  --costes-bg-2: #101820;
  --costes-bg-3: #151f28;

  --costes-line: rgba(130, 155, 178, 0.18);
  --costes-line-soft: rgba(130, 155, 178, 0.10);

  --costes-text: rgba(255,255,255,0.92);
  --costes-text-soft: rgba(255,255,255,0.74);
  --costes-text-dim: rgba(255,255,255,0.58);

  --costes-green: #37f2a6;
  --costes-green-soft: rgba(55,242,166,0.08);

  --costes-hover: rgba(55,242,166,0.05);

  --costes-radius-xl: 18px;
  --costes-radius-lg: 14px;
  --costes-radius-md: 12px;

  --costes-shadow-block: 0 12px 28px rgba(0,0,0,0.22);

  --costdet-scrollbar-w: 10px;
}

/* =========================================================
   BODY GENERAL
   ========================================================= */

.costes-detail-body{
  padding: 20px 10px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

/* =========================================================
   BLOQUES
   ========================================================= */

.costes-detail-block{
  border-radius: var(--costes-radius-xl);
  border: 1px solid var(--costes-line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.018) 0%, rgba(255,255,255,0.008) 100%),
    var(--costes-bg-1);
  box-shadow: var(--costes-shadow-block);
  overflow: hidden;
  min-height: 0;
}

.costes-detail-blockhead{
  padding: 12px 14px;
  border-bottom: 1px solid var(--costes-line);
  background: linear-gradient(180deg, rgba(255,255,255,0.018) 0%, rgba(255,255,255,0.00) 100%);
}

.costes-detail-blockhead--row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.costes-detail-blocktitle{
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--costes-text);
  font-weight: 800;
  letter-spacing: 0.1px;
  font-size: 12px;
}

.costes-detail-blockicon{
  height: 15px;
  width: 15px;
  opacity: 0.92;
  filter: none;
}

.costes-detail-blockbody{
  padding: 10px;
  min-height: 0;
}

.costes-detail-blockbody--timeline{
  padding: 10px;
  min-height: 0;
}

.costes-detail-btn{
  height: 28px !important;
  padding: 0 10px !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  border-radius: 9999px !important;
}

/* =========================================================
   CARDS INTERNAS
   ========================================================= */

.costes-detail-card{
  border-radius: var(--costes-radius-lg);
  border: 1px solid var(--costes-line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.015) 0%, rgba(255,255,255,0.008) 100%),
    var(--costes-bg-2);
  box-shadow: none;
  overflow: hidden;

  height: 57.75vh;
  min-height: 495px;

  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.costes-detail-panel{
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.costes-detail-panel--big{
  height: 64.625vh;
  min-height: 561px;
  border-radius: var(--costes-radius-lg);
  border: 1px solid var(--costes-line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.015) 0%, rgba(255,255,255,0.008) 100%),
    var(--costes-bg-2);
  box-shadow: none;
  overflow: hidden;
  min-height: 0;
}

/* =========================================================
   EMPTY
   ========================================================= */

.costes-detail-empty{
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
}

.costes-detail-emptyimg{
  max-height: 100%;
  max-width: 100%;
  opacity: 0.82;
}

/* =========================================================
   MAPA + GRÁFICO
   ========================================================= */

.costes-detail-card--mapchart{
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.costes-detail-map-wrap{
  flex: 0 0 auto;
  min-height: 0;
  padding: 0;
}

.costes-detail-map{
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #0f161c;
}

.costes-detail-map-wrap .leaflet-container{
  border-radius: 12px;
  overflow: hidden;
}

.costes-detail-chartbox{
  flex: 1 1 auto;
  min-height: 130px;
  margin: 10px;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid rgba(130, 155, 178, 0.16);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.012) 0%, rgba(255,255,255,0.004) 100%),
    rgba(13, 19, 24, 0.92);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.025);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.costes-detail-chart{
  flex: 1 1 auto;
  min-height: 0;
  width: 100% !important;
  height: 100% !important;
}

.costes-detail-chart .js-plotly-plot,
.costes-detail-chart .plot-container,
.costes-detail-chart .svg-container{
  width: 100% !important;
  height: 100% !important;
}

.costes-detail-link{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  margin: 10px;
  border-radius: 9999px;
  border: 1px solid var(--costes-line);
  background: rgba(255,255,255,0.03);
  color: var(--costes-text-soft);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  width: fit-content;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.costes-detail-link:hover{
  color: var(--costes-text);
  border-color: rgba(55,242,166,0.26);
  background: rgba(55,242,166,0.06);
}

/* =========================================================
   TIMELINE
   ========================================================= */

.costes-detail-timeline{
  width: 100%;
  min-height: 120px;
  border-radius: 12px;
  border: 1px solid var(--costes-line);
  background: var(--costes-bg-2);
  box-shadow: none;
  padding: 10px;
  overflow: hidden;
}

.costes-detail-timeline *{
  min-width: 0;
}

/* =========================================================
   TOGGLES GRID / TABLA
   ========================================================= */

.costdet-rightbar{
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.costdet-viewbar{
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.costdet-viewbtn{
  border-radius: 999px !important;
  font-weight: 800 !important;
  letter-spacing: 0.15px;
  padding: 6px 12px !important;
  border: 1px solid rgba(255,255,255,0.14) !important;
  background: rgba(255,255,255,0.05) !important;
  color: rgba(255,255,255,0.80) !important;
  line-height: 1;
  box-shadow: none !important;
}

.costdet-viewbtn--active{
  border-color: rgba(55,242,166,0.30) !important;
  background: rgba(55,242,166,0.08) !important;
  color: rgba(255,255,255,0.94) !important;
}

/* =========================================================
   WRAPPERS TABLAS / GRIDS
   ========================================================= */

.costes-detail-tablewrap,
.costdet-wrap{
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.costdet-grid-scope{
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.costdet-grid-scope > div{
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* =========================================================
   GRID CUSTOM · HEADER FIJO + BODY SCROLL
   ========================================================= */

.costdet-table{
  width: 100%;
  height: 100%;
  min-height: 0;

  border-radius: 12px;
  overflow: hidden;

  background: var(--costes-bg-2);
  border: 1px solid var(--costes-line);
  box-shadow: none;

  display: flex;
  flex-direction: column;
}

.costdet-head,
.costdet-row{
  box-sizing: border-box;
  display: grid;
  align-items: center;
  column-gap: 12px;
  grid-template-columns: var(--costdet-cols);
  width: 100%;
  min-width: 0;
}

.costdet-head > *,
.costdet-row > *{
  min-width: 0;
  max-width: 100%;
}

.costdet-head{
  flex: 0 0 auto;
  min-height: 44px;
  padding: 10px 12px;
  padding-right: calc(12px + var(--costdet-scrollbar-w));
  background: #15202a;
  border-bottom: 1px solid var(--costes-line);
  position: relative;
  z-index: 2;
}

.costdet-body{
  flex: 1 1 auto;
  min-height: 0;
  height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: transparent;
  scrollbar-gutter: stable;

  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.16) transparent;
}

.costdet-body::-webkit-scrollbar{
  width: var(--costdet-scrollbar-w);
  height: var(--costdet-scrollbar-w);
}

.costdet-body::-webkit-scrollbar-track{
  background: transparent;
}

.costdet-body::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,0.16);
  border-radius: 999px;
}

.costdet-body::-webkit-scrollbar-thumb:hover{
  background: rgba(255,255,255,0.24);
}

.costdet-row{
  min-height: 44px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--costes-line-soft);
  transition: background 120ms ease;
}

.costdet-row:nth-child(odd){
  background: rgba(255,255,255,0.012);
}

.costdet-row:hover{
  background: var(--costes-hover);
}

/* Header cells */
.costdet-hcell{
  min-width: 0;
  max-width: 100%;
  font-weight: 800;
  font-size: 10.5px;
  letter-spacing: 0.45px;
  color: var(--costes-text-dim);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.costdet-hcell--center{
  text-align: center;
}

/* Body cells */
.costdet-cell{
  min-width: 0;
  max-width: 100%;
  color: var(--costes-text);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.costdet-cell--kms,
.costdet-cell--money{
  text-align: right;
}

.costdet-cell--money{
  color: var(--costes-green);
  font-weight: 800;
}

.costdet-cell--idx{
  text-align: center;
  font-weight: 800;
  color: rgba(255,255,255,0.86);
}

.costdet-cell--ico{
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden !important;
  text-overflow: clip !important;
  white-space: nowrap !important;
}

.costdet-icoimg{
  height: 17px;
  width: 17px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}

.costdet-icoimg--round{
  border-radius: 50%;
  object-fit: cover;
  box-shadow: none;
}

.costdet-cell--cat{
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
}

.costdet-cell--cat .costdet-cat-text{
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.costdet-body--empty{
  display: flex;
  align-items: center;
  justify-content: center;
}

.costdet-empty{
  color: var(--costes-text-dim);
  font-weight: 700;
  font-size: 12px;
}

/* =========================================================
   DETALLE KM · badges / chips
   ========================================================= */

.costdet-pill-wrap{
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  max-width: 100%;
}

.costdet-pill{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  max-width: 100%;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.90);
}

.costdet-pill--kms{
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.90);
}

.costdet-pill--money{
  background: rgba(55,242,166,0.12);
  border-color: rgba(55,242,166,0.28);
  color: var(--costes-green);
  box-shadow:
    inset 0 0 0 1px rgba(55,242,166,0.05),
    0 0 14px rgba(55,242,166,0.10);
}

.costdet-num-wrap{
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: 100%;
}

.costdet-num-badge{
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  color: rgba(255,255,255,0.96);
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.03) 100%);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.03) inset,
    0 4px 12px rgba(0,0,0,0.18);
  flex: 0 0 auto;
}

.costdet-num-badge--empty{
  opacity: 0;
}

/* =========================================================
   ANCHOS DE COLUMNAS
   ========================================================= */

/* Kilómetros */
.costdet-grid-scope--km{
  --costdet-cols:
    102px
    72px
    38px
    minmax(0, 1fr)
    minmax(0, 1fr)
    92px
    96px
    36px
    36px;
}

/* Partidos */
.costdet-grid-scope--partidos{
  --costdet-cols:
    116px
    78px
    48px
    220px
    40px
    minmax(0, 1fr)
    40px
    minmax(0, 1fr)
    minmax(0, 1.2fr)
    44px;
}

/* Eventos */
.costdet-grid-scope--eventos{
  --costdet-cols:
    116px
    78px
    40px
    minmax(0, 1.1fr)
    minmax(0, 1fr)
    40px
    150px
    44px;
}

/* =========================================================
   DATATABLE
   ========================================================= */

.costdet-dt-scope{
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--costes-line);
  background: var(--costes-bg-2);
}

.costdet-dt-scope .dash-table-container,
.costdet-dt-scope .dash-spreadsheet-container,
.costdet-dt-scope .dash-spreadsheet-inner{
  height: 100% !important;
  max-height: 100% !important;
  min-height: 0 !important;
}

.costdet-dt-scope .dash-table-container{
  height: 100% !important;
}

.costdet-dt-scope .dash-spreadsheet-container{
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  overflow: hidden !important;
}

.costdet-dt-scope .dash-spreadsheet-inner{
  overflow: auto !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.16) transparent;
}

.costdet-dt-scope .dash-spreadsheet-inner::-webkit-scrollbar{
  width: var(--costdet-scrollbar-w);
  height: var(--costdet-scrollbar-w);
}

.costdet-dt-scope .dash-spreadsheet-inner::-webkit-scrollbar-track{
  background: transparent;
}

.costdet-dt-scope .dash-spreadsheet-inner::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,0.16);
  border-radius: 999px;
}

.costdet-dt-scope .dash-spreadsheet-inner::-webkit-scrollbar-thumb:hover{
  background: rgba(255,255,255,0.24);
}

.costdet-dt-scope .dash-header{
  background: #15202a !important;
  border-bottom: 1px solid var(--costes-line) !important;
}

.costdet-dt-scope .dash-header div{
  color: var(--costes-text-dim) !important;
  font-size: 10.5px !important;
  font-weight: 800 !important;
  letter-spacing: 0.45px !important;
  text-transform: uppercase !important;
}

.costdet-dt-scope .dash-cell{
  background: transparent !important;
  border: none !important;
  color: var(--costes-text) !important;
  font-size: 12px !important;
}

.costdet-dt-scope .dash-row{
  border-bottom: 1px solid var(--costes-line-soft) !important;
}

.costdet-dt-scope .dash-row:nth-child(odd) .dash-cell{
  background: rgba(255,255,255,0.012) !important;
}

.costdet-dt-scope .dash-row:hover .dash-cell{
  background: var(--costes-hover) !important;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 992px){
  .costes-detail-card{
    height: auto;
    min-height: 440px;
  }

  .costes-detail-panel--big{
    height: auto;
    min-height: 539px;
  }

  .costdet-head,
  .costdet-row{
    padding-left: 10px;
    padding-right: 10px;
    column-gap: 10px;
  }

  .costdet-head{
    padding-right: calc(10px + var(--costdet-scrollbar-w));
  }
}