/*
 * Estilos propios de la zona «cost». Los componentes comunes están en app.css:
 * aquí sólo lo que no reutiliza ninguna otra pantalla.
 */

/* ---- Las cuatro cifras ---- */

.cost-kpis {
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.cost-kpis .stat {
  gap: 4px;
}

.cost-kpis .stat__value {
  font-size: 30px;
}

.cost-kpis__unknown {
  color: var(--text-muted);
}

/* ---- Gasto por día: barras en HTML ---- */

.cost-chart-card__note {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.cost-chart {
  padding-top: 26px;
}

/* La altura útil de las barras. Arriba queda sitio para la cifra de la barra más alta. */
.cost-chart__plot {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 160px;
}

.cost-chart__limit {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1.5px dashed #e0cfd3;
  pointer-events: none;
}

.cost-chart__col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.cost-chart__bar {
  position: relative;
  width: 100%;
  max-width: 56px;
  min-height: 2px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--brand-primary), var(--brand-magenta));
}

/* Día sin precio: rayado y con borde discontinuo, para que se vea que falta y no que fue barato. */
.cost-chart__bar--missing {
  background: repeating-linear-gradient(45deg, var(--warning-bg), var(--warning-bg) 4px, #fff 4px, #fff 8px);
  border: 1.5px dashed var(--warning-border);
}

.cost-chart__bar--empty {
  background: var(--neutral-100);
}

.cost-chart__value {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.cost-chart__value--missing {
  color: var(--warning);
}

.cost-chart__bar--empty .cost-chart__value {
  color: var(--border-strong);
}

.cost-chart__axis {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.cost-chart__axis span {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.cost-chart__axis .is-today {
  color: var(--brand-primary);
}

/* Con 30 barras no caben las cifras: quedan en el título de cada barra. */
.cost-chart--dense .cost-chart__plot,
.cost-chart--dense .cost-chart__axis {
  gap: 4px;
}

.cost-chart--dense .cost-chart__value {
  display: none;
}

.cost-chart--dense .cost-chart__bar {
  border-radius: 4px 4px 2px 2px;
}

.cost-chart--dense .cost-chart__axis span {
  font-size: 10.5px;
}

.cost-chart--dense {
  padding-top: 8px;
}

/* ---- Por agente · hoy, y por origen ---- */

.cost-split {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}

.cost-agents {
  flex: 2 1 480px;
  overflow: hidden;
}

.cost-sources {
  flex: 1 1 280px;
}

.cost-agents__list,
.cost-sources__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cost-agent {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
  border-top: 1px solid var(--divider);
  flex-wrap: wrap;
}

.cost-agent__name {
  width: 200px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.cost-agent__meter {
  flex: 1;
  min-width: 120px;
}

.cost-agent__fill--none {
  background: #e0cfd3;
}

.cost-agent__value {
  width: 150px;
  text-align: right;
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cost-agent__value--out {
  color: var(--brand-orange-dark);
}

.cost-sources__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cost-source {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.cost-source__dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.cost-source__dot--1 { background: var(--brand-magenta); }
.cost-source__dot--2 { background: var(--brand-primary); }
.cost-source__dot--3 { background: var(--brand-orange-dark); }
.cost-source__dot--4 { background: var(--brand-orange); }
.cost-source__dot--5 { background: var(--brand-accent); }
.cost-source__dot--6 { background: var(--brand-primary-dark); }

.cost-source__label {
  flex: 1;
  font-weight: 600;
}

.cost-source__value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cost-sources__note {
  margin-top: 14px;
  font-size: 12.5px;
}

/* ---- Detalle plegado ---- */

.cost-detail > summary {
  align-items: center;
}

.cost-detail[open] > summary {
  border-bottom: 1px solid var(--divider);
  padding-bottom: 16px;
}

.cost-detail > .card__body {
  padding-top: 20px;
}

.cost-detail__block {
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  overflow: hidden;
}

.cost-detail__block > .card__header {
  padding: 14px 18px 10px;
}

.cost-detail__block > .card__body {
  padding: 4px 18px 18px;
}

.cost-detail__block > .card__footer {
  padding: 12px 18px;
}

/* ---- Precios y límites ---- */

.cost-prices {
  min-width: 700px;
}

.cost-prices td {
  font-variant-numeric: tabular-nums;
}

.cost-prices__model {
  font: 700 13.5px var(--font-mono);
  color: var(--text-primary);
}

.cost-prices__missing td {
  background: var(--warning-bg);
}

.cost-limits {
  max-width: 720px;
}

/* Campo con su unidad al lado («60,00  $ / día»). */
.cost-unit {
  display: flex;
  align-items: center;
  max-width: 280px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  overflow: hidden;
}

.cost-unit:focus-within {
  border-color: var(--brand-primary);
  outline: 2px solid var(--focus-ring);
}

.cost-unit .input {
  border: 0;
  outline: 0;
  border-radius: 0;
}

.cost-unit__suffix {
  padding: 0 14px;
  white-space: nowrap;
  font-weight: 700;
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .cost-chart__plot,
  .cost-chart__axis {
    gap: 6px;
  }

  .cost-chart__value {
    font-size: 10.5px;
  }

  .cost-agent {
    padding: 12px 16px;
  }

  .cost-agent__name {
    width: 100%;
  }

  .cost-agent__value {
    width: auto;
  }
}

@media (max-width: 600px) {
  .cost-chart__value {
    display: none;
  }

  .cost-chart {
    padding-top: 8px;
  }
}

/* El aviso de precio que falta, en una línea como en el prototipo. */
.cost-missing .alert__title {
  display: inline;
}

.cost-prices__actions {
  flex-wrap: nowrap;
  gap: 4px;
}

.cost-prices__actions form {
  margin: 0;
}

@media (max-width: 600px) {
  .cost-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .cost-kpis .stat {
    padding: 16px;
  }

  .cost-kpis .stat__value {
    font-size: 24px;
  }

  .cost-missing {
    flex-wrap: wrap;
  }

  .cost-detail > summary .card__subtitle {
    display: none;
  }
}

/* Las etiquetas .sr-only de las cabeceras se posicionan contra el recuadro con scroll:
   sin esto se salen de él y ensanchan la página en el móvil. */
.cost-wrap {
  position: relative;
}
