/* Dashboard (07/11/2026) y piezas comunes de los gráficos del Fleet (.fx-*,
   también en Rutas y en el detalle de la ruta). Toma de css/resumen.css
   .rs-cabecera, .rs-fecha y .rs-saludo. Superficies planas con un borde, sin
   sombras ni degradados; el azul de Breiko solo en los datos; cifras en Inter
   con tabular-nums donde se alinean en columna. Ver js/dashboard.js y js/graficos.js. */

/* ── Comunes ─────────────────────────────────────────────── */
/* Verde y rojo claros para cifras de cambio sobre la superficie (8,2:1 y 6,2:1). */
.fx-bien { color: #7DD3A0; }
.fx-mal { color: #F28B89; }

/* Hueso de carga: la forma final en gris plano, sin brillo que recorra. */
.fx-hueso { display: block; max-width: 100%; border-radius: 6px; background: var(--bg-elevated); opacity: .55; }
.fx-hueso + .fx-hueso { margin-top: 8px; }

.fx-error { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border: 1px solid var(--border-card); border-radius: var(--radius-sm); background: var(--bg-surface); color: var(--text-primary); }
.fx-error p { margin: 0; max-width: 60ch; }
.fx-vacio { padding: 14px 16px; border: 1px dashed var(--border-card); border-radius: 8px; color: var(--text-secondary); font-size: var(--letra-md); }

/* Etiqueta emergente de los gráficos: el valor delante, en blanco. */
.fx-tip { position: absolute; top: 0; left: 0; z-index: 3; min-width: 140px; padding: 10px 12px; border: 1px solid var(--border-card); border-radius: 10px; background: #0B1222; box-shadow: var(--shadow-md); pointer-events: none; opacity: 0; transition: opacity .12s ease, transform .12s ease; font-size: var(--letra-sm); white-space: nowrap; }
.fx-tip-ver { opacity: 1; }
.fx-tip-titulo { margin-bottom: 6px; color: var(--text-secondary); font-size: var(--letra-xs); }
.fx-tip-fila { display: flex; align-items: baseline; gap: 6px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.fx-tip-fila strong { color: var(--text-primary); font-weight: 600; }
.fx-tip-principal strong { font-size: var(--letra-lg); }
.fx-tip-principal::before { content: ''; align-self: center; width: 10px; height: 2px; border-radius: 1px; background: var(--accent-primary); }

/* Entrada: cada bloque sube 8 px y aparece, escalonado. Sin movimiento si se pide. */
@media (prefers-reduced-motion: no-preference) {
  .fx-entra { animation: fx-entra .45s cubic-bezier(.2, .8, .2, 1) both; }
  .fx-entra:nth-of-type(2) { animation-delay: 60ms; }
  .fx-entra:nth-of-type(3) { animation-delay: 120ms; }
  .fx-entra:nth-of-type(4) { animation-delay: 180ms; }
  @keyframes fx-entra { from { opacity: 0; transform: translateY(8px); } }
}

/* ── Dashboard ───────────────────────────────────────────── */
.db-pagina { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; padding-bottom: 24px; }
.db-frase { margin: 0; max-width: 72ch; font-size: var(--letra-lg); line-height: 1.6; color: var(--text-primary); text-wrap: pretty; }
.db-historico { margin: -4px 0 0; font-size: var(--letra-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* Cuatro cifras del último mes cerrado en un solo bloque, separadas por una línea. */
.db-kpis { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border-card); border-radius: var(--radius-md); background: var(--bg-surface); overflow: hidden; }
.db-kpi { display: flex; flex-direction: column; gap: 6px; padding: 16px 20px 14px; border-left: 1px solid var(--border-subtle); min-width: 0; }
.db-kpi:first-child { border-left: 0; }
.db-kpi dt { font-size: var(--letra-sm); color: var(--text-secondary); }
.db-kpi dd { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.db-kpi-valor { font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-unidad { margin-left: 4px; font-size: var(--letra-md); font-weight: 400; color: var(--text-secondary); letter-spacing: 0; }
.db-kpi-delta { font-size: var(--letra-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.db-kpi-delta > span { font-weight: 600; }
/* Tendencia de 12 meses: columnas grises, el mes de la cifra en azul y el que va en curso, tenue. */
.db-mini { display: flex; align-items: flex-end; gap: 3px; height: 28px; margin-top: 4px; }
.db-mini i { flex: 1 1 0; height: var(--h); min-height: 0; border-radius: 2px 2px 0 0; background: #475569; }
.db-mini i.db-mini-ultimo { background: var(--accent-primary); }
.db-mini i.db-mini-curso { background: rgba(0, 159, 227, .35); }
@media (prefers-reduced-motion: no-preference) {
  .db-mini i { transform-origin: bottom; animation: db-crece .5s cubic-bezier(.2, .8, .2, 1) both; }
  @keyframes db-crece { from { transform: scaleY(0); } }
}

.db-dos { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.db-bloque { display: flex; flex-direction: column; border: 1px solid var(--border-card); border-radius: var(--radius-md); background: var(--bg-surface); padding: 18px 20px; min-width: 0; }
.db-bloque-cab { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; min-height: 40px; }
.db-titulo { margin: 0; font-size: var(--letra-lg); font-weight: 600; color: var(--text-primary); text-wrap: balance; }
.db-enlace { font-size: var(--letra-sm); font-weight: 600; color: var(--accent-primary); text-decoration: none; border-radius: 4px; padding: 4px 2px; }
.db-enlace:hover { text-decoration: underline; }
.db-metrica > button { min-height: 34px; padding: 0 14px; font-size: var(--letra-sm); }

.db-leyenda { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: -4px 0 8px; font-size: var(--letra-xs); color: var(--text-secondary); }
.db-leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.db-leyenda i { width: 10px; height: 10px; border-radius: 2px; }
.db-ley-cerrado { background: var(--accent-primary); }
.db-ley-curso { background: rgba(0, 159, 227, .35); }

.db-grafico { position: relative; flex: 1 1 260px; min-height: 260px; }
.db-grafico canvas { border-radius: 6px; }
.db-grafico canvas:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 4px; }
.db-grafico-hueso { display: flex; align-items: flex-end; gap: 4%; padding: 24px 8px 24px 40px; }
.db-grafico-hueso span { flex: 1 1 0; border-radius: 4px 4px 0 0; background: var(--bg-elevated); opacity: .5; }
.db-hueso-fila { padding: 8px 0; }

/* Conductores: nombre y cifra en una línea, la barra debajo, que crece al entrar. */
.db-barras { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.db-barra { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; font-size: var(--letra-md); }
.db-barra-nombre { color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-barra-cifra { color: var(--text-primary); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.db-barra-km { margin-left: 8px; color: var(--text-secondary); font-size: var(--letra-sm); }
.db-barra-pista { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.db-barra-pista > span { display: block; height: 100%; border-radius: 3px; background: var(--accent-primary); transform-origin: left; }
@media (prefers-reduced-motion: no-preference) {
  .db-barra-pista > span { animation: db-llena .7s cubic-bezier(.2, .8, .2, 1) both; }
  @keyframes db-llena { from { transform: scaleX(0); } }
}

/* Últimos trayectos: filas de dos líneas, la fila entera abre el detalle. */
.db-recientes { list-style: none; margin: 0 -10px; padding: 0; }
.db-reciente { display: grid; grid-template-columns: minmax(0, 1fr) auto 16px; align-items: center; gap: 16px; width: 100%; min-height: 60px; padding: 10px; border: 0; border-radius: 10px; background: none; color: var(--text-primary); font: inherit; text-align: left; cursor: pointer; transition: var(--transicion-ui); }
.db-recientes li + li .db-reciente { border-top: 1px solid var(--border-subtle); border-radius: 0 0 10px 10px; }
.db-reciente:hover { background: var(--bg-card-hover); }
.db-reciente:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: -2px; }
.db-rec-ruta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.db-rec-ruta strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-rec-sub { display: block; font-size: var(--letra-sm); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-rec-num { text-align: right; color: var(--text-secondary); font-size: var(--letra-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.db-rec-num strong { color: var(--text-primary); font-size: var(--letra-md); font-weight: 600; }
.db-rec-flecha { width: 16px; height: 16px; color: var(--text-muted); transition: transform .2s ease; }
.db-reciente:hover .db-rec-flecha { transform: translateX(2px); }

.db-enlace:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

@media (max-width: 1100px) {
  .db-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .db-kpi:nth-child(odd) { border-left: 0; }
  .db-kpi:nth-child(n+3) { border-top: 1px solid var(--border-subtle); }
  .db-dos { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
  .db-kpi { padding: 12px 14px; }
  .db-kpi-valor { font-size: 22px; }
  .db-mini { height: 22px; }
  .db-bloque { padding: 14px 14px; }
  .db-bloque-cab { align-items: flex-start; }
  .db-grafico { flex-basis: 220px; min-height: 220px; }
  .db-recientes { margin: 0 -6px; }
  .db-reciente { gap: 10px; padding: 10px 6px; }
}
@media (max-width: 420px) {
  .db-kpi-valor { font-size: 20px; }
  .db-metrica { display: flex; width: 100%; }
  .db-metrica > button { flex: 1 1 0; padding: 0 8px; }
}
