/* Rutas (07/11/2026): listado de realizadas y planificadas (.rt-*) y detalle del
   trayecto (.rd-*). Ver js/rutas.js. Usa las piezas comunes de css/dashboard.css
   (.fx-*, .db-titulo, .db-enlace, .db-unidad, .db-metrica, .db-bloque-cab). */

.rt-pagina { max-width: 1400px; margin: 0 auto; }
.rt-cuenta { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: var(--radius-full); background: rgba(255, 255, 255, .08); color: var(--text-secondary); font-size: var(--letra-xs); font-weight: 600; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.rt-cuenta:empty { display: none; }
.segmento > [aria-pressed="true"] .rt-cuenta { background: rgba(0, 159, 227, .2); color: var(--text-primary); }

/* Filtros: una fila sobre la lista; el periodo como segmento y los campos con su etiqueta. */
.rt-filtros { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 14px; }
.rt-campos { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.rt-campo { display: flex; flex-direction: column; gap: 4px; font-size: var(--letra-xs); color: var(--text-secondary); }
.rt-campo .form-input { min-height: 40px; height: 40px; padding: 0 12px; width: 160px; font-size: var(--letra-md); }
.rt-campo-porte .form-input, .rt-campo-buscar .form-input { width: 220px; }
.rt-periodo > button, .rt-estados > button { min-height: 36px; padding: 0 14px; font-size: var(--letra-sm); }
.rt-limpiar { min-height: 40px; }
.rt-chip-filtro { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; padding: 8px 8px 8px 14px; border: 1px solid var(--border-accent); border-radius: var(--radius-sm); background: var(--accent-primary-dim); font-size: var(--letra-md); }
.rt-chip-filtro .ico { width: 16px; height: 16px; }
.rt-chip-filtro .btn:first-of-type { margin-left: auto; }

/* La lista: una tabla de reglas y alineación, sin bandas ni cebra. */
.rt-lista { border: 1px solid var(--border-card); border-radius: var(--radius-md); background: var(--bg-surface); overflow: hidden; transition: opacity .2s ease; }
.rt-recargando { opacity: .55; pointer-events: none; }
.rt-tabla { width: 100%; border-collapse: collapse; font-size: var(--letra-md); }
.rt-tabla th { padding: 12px 14px 10px; text-align: left; font-size: var(--letra-xs); font-weight: 500; color: var(--text-secondary); border-bottom: 1px solid var(--border-card); white-space: nowrap; }
.rt-tabla td { padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); color: var(--text-primary); vertical-align: top; }
.rt-tabla tbody tr:last-child td { border-bottom: 0; }
.rt-tabla tbody tr { transition: background-color .15s ease; }
.rt-tabla tbody tr[onclick] { cursor: pointer; }
.rt-tabla tbody tr:hover td { background: var(--bg-card-hover); }
.rt-sub { display: block; margin-top: 3px; font-size: var(--letra-sm); color: var(--text-secondary); }
.rt-num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-secondary) !important; }
.rt-num strong { color: var(--text-primary); font-weight: 600; }
.rt-ruta { min-width: 220px; max-width: 360px; }
.rt-abrir { display: block; max-width: 100%; padding: 0; border: 0; background: none; color: var(--text-primary); font: inherit; font-weight: 600; text-align: left; cursor: pointer; border-radius: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-abrir:hover { color: var(--accent-primary); }
.rt-abrir:focus-visible, .rt-icono:focus-visible, .rt-enlace:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }
.rt-persona, .rt-cuando { white-space: nowrap; }
.rt-persona { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.rt-tenue, .rt-nada { color: var(--text-muted); }
.rt-check { width: 40px; }
.rt-check input { width: 18px; height: 18px; accent-color: var(--accent-primary); }
.rt-avisos { min-width: 120px; }
.rt-avisos .rt-aviso + .rt-aviso { margin-top: 4px; }

/* Avisos y estados: pastilla clara con texto del mismo tono, siempre con icono o palabra. */
.rt-aviso { display: inline-flex; align-items: center; gap: 5px; flex: none; max-width: 100%; padding: 2px 8px; border-radius: var(--radius-full); background: rgba(255, 255, 255, .06); color: var(--text-secondary); font-size: var(--letra-xs); font-weight: 600; line-height: 18px; white-space: nowrap; }
.rt-aviso .ico { width: 13px; height: 13px; flex: none; }
.rt-aviso-atencion { background: rgba(255, 152, 0, .14); color: #FDBA74; }
.rt-aviso-adr { background: rgba(255, 152, 0, .14); color: #FDBA74; }
.rt-pastilla { display: inline-block; flex: none; padding: 2px 10px; border-radius: var(--radius-full); font-size: var(--letra-xs); font-weight: 600; line-height: 20px; white-space: nowrap; background: rgba(255, 255, 255, .07); color: var(--text-secondary); }
.rt-pastilla-asignada { background: rgba(0, 159, 227, .16); color: #7DD3FC; }
.rt-pastilla-en_curso { background: rgba(0, 159, 227, .9); color: #04111C; }
.rt-pastilla-completada { background: rgba(76, 175, 80, .16); color: #86EFAC; }
.rt-pastilla-cancelada { background: rgba(239, 83, 80, .14); color: #FCA5A5; }
.rt-estado { width: 1%; white-space: nowrap; }

.rt-acciones { width: 1%; white-space: nowrap; text-align: right; }
.rt-acciones > * { vertical-align: middle; }
.rt-acciones .btn { margin-right: 4px; }
.rt-icono { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: none; color: var(--text-secondary); cursor: pointer; touch-action: manipulation; transition: var(--transicion-ui); }
.rt-icono:hover { background: rgba(255, 255, 255, .07); color: var(--text-primary); }
.rt-icono .ico { width: 17px; height: 17px; }
.rt-icono-peligro:hover, .rt-texto-peligro:hover { color: #FCA5A5; }
.rt-tabla .ruta-deca { margin-top: 4px; }

.rt-pie { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border-subtle); font-size: var(--letra-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.rt-paginas { display: flex; gap: 8px; }
.rt-vacio { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 18px; }
.rt-vacio p { margin: 0; flex: 1 1 320px; }
.rt-enlace { padding: 0; border: 0; background: none; font: inherit; font-size: var(--letra-sm); font-weight: 600; cursor: pointer; }
.rt-fila-hueso td { padding: 16px 14px; }

/* ── Detalle del trayecto ─────────────────────────────── */
.rd-pagina { max-width: 1400px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; padding-bottom: 32px; }
.rd-cab { display: flex; flex-direction: column; gap: 8px; }
.rd-titulo { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 700; color: var(--text-primary); text-wrap: balance; }
.rd-flecha { color: var(--accent-primary); }
.rd-meta { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: var(--letra-md); color: var(--text-secondary); }
.rd-meta > span:not(.rt-pastilla) + span::before { content: none; }

/* Índice de secciones: enlaces dentro de la página. */
.rd-indice { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; padding: 0 4px; }
.rd-indice::-webkit-scrollbar { display: none; }
.rd-indice a { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 36px; padding: 0 14px; border-radius: var(--radius-full); color: var(--text-secondary); font-size: var(--letra-sm); font-weight: 600; text-decoration: none; transition: var(--transicion-ui); }
.rd-indice a:hover { background: rgba(255, 255, 255, .06); color: var(--text-primary); }
.rd-indice a:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }
.rd-pagina section[id] { scroll-margin-top: 90px; }

.rd-kpis { margin: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--border-card); border-radius: var(--radius-md); background: var(--bg-surface); overflow: hidden; }
.rd-kpi { padding: 14px 18px; border-left: 1px solid var(--border-subtle); min-width: 0; }
.rd-kpi:first-child { border-left: 0; }
.rd-kpi dt { font-size: var(--letra-sm); color: var(--text-secondary); }
.rd-kpi dd { margin: 6px 0 0; display: flex; flex-direction: column; gap: 4px; }
.rd-kpi-valor { font-size: 26px; line-height: 1.15; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-kpi-sub { font-size: var(--letra-sm); color: var(--text-secondary); }

.rd-rejilla { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 16px; }
/* El recorrido ocupa toda la altura de la columna lateral: el mapa crece. */
.rd-recorrido { display: flex; flex-direction: column; }
.rd-recorrido .rd-mapa { flex: 1 1 380px; }
.rd-lateral { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.rd-tres { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 32px; }
.rd-tres .rd-sub { margin-top: 0; }
.rd-bloque { min-width: 0; padding: 18px 20px; border: 1px solid var(--border-card); border-radius: var(--radius-md); background: var(--bg-surface); }
.rd-bloque > .fx-hueso { margin-bottom: 10px; }
.rd-nota { margin: 0; font-size: var(--letra-sm); color: var(--text-secondary); }
.rd-sub { margin: 16px 0 10px; font-size: var(--letra-md); font-weight: 600; color: var(--text-primary); }

.rd-mapa { min-height: 380px; border-radius: 12px; overflow: hidden; background: #0B1222; }
.rd-mapa-hueso { height: 420px; background: var(--bg-elevated); opacity: .4; }
.rd-perfil { position: relative; height: 200px; margin-top: 16px; }
.rd-perfil canvas:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 4px; border-radius: 6px; }
.rd-punto { margin: 10px 0 0; min-height: 20px; font-size: var(--letra-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.rd-punto strong { color: var(--text-primary); }

/* Hitos del mapa: salida en blanco, llegada en azul, paradas numeradas. */
.rd-pin { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 3px solid #0B1222; box-sizing: border-box; font: 700 12px/1 Inter, system-ui, sans-serif; color: #0B1222; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.rd-pin-salida { background: #F1F5F9; }
.rd-pin-llegada { background: var(--accent-primary); border-color: #F1F5F9; }
.rd-pin-parada { background: #FDBA74; }

/* Línea de tiempo: hora a la izquierda, un hilo vertical con las marcas. */
.rd-tiempo { list-style: none; margin: 0; padding: 0; }
.rd-hito { position: relative; display: grid; grid-template-columns: 22px 92px minmax(0, 1fr); gap: 4px 10px; padding-bottom: 18px; }
.rd-hito:last-child { padding-bottom: 0; }
.rd-hito::before { content: ''; position: absolute; left: 10px; top: 22px; bottom: 0; width: 2px; background: var(--border-card); }
.rd-hito:last-child::before { content: none; }
.rd-hito-marca { position: relative; z-index: 1; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--bg-elevated); color: #0B1222; font-size: 11px; font-weight: 700; }
.rd-hito-salida .rd-hito-marca { background: #F1F5F9; }
.rd-hito-llegada .rd-hito-marca { background: var(--accent-primary); }
.rd-hito-parada .rd-hito-marca { background: #FDBA74; }
.rd-hito-hora { padding-top: 2px; font-size: var(--letra-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rd-hito-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: var(--letra-sm); color: var(--text-secondary); }
.rd-hito-txt strong { font-size: var(--letra-md); color: var(--text-primary); font-weight: 600; }
.rd-hito-txt .rt-enlace { align-self: flex-start; margin-top: 2px; }

.rd-avisos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rd-avisos li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; font-size: var(--letra-md); color: var(--text-primary); }
.rd-avisos .ico { width: 18px; height: 18px; margin-top: 1px; color: var(--text-secondary); }
.rd-aviso-atencion .ico { color: #FDBA74; }

.rd-doc { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--bg-base); }
.rd-doc > .ico { width: 20px; height: 20px; color: var(--accent-primary); }
.rd-doc div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rd-doc div span { font-size: var(--letra-sm); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-envios { list-style: none; margin: 12px 0 0; padding: 0; }
.rd-envios li { padding: 12px 0; border-top: 1px solid var(--border-subtle); }
.rd-envios li:first-child { border-top: 0; }
.rd-envio-cab { display: flex; justify-content: space-between; gap: 12px; }
.rd-envio-cab span { color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rd-adr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 8px; margin: 8px 0 0; font-size: var(--letra-sm); color: var(--text-primary); }
.rd-lista { margin: 0; padding-left: 20px; font-size: var(--letra-md); color: var(--text-primary); }
.rd-lista li + li { margin-top: 6px; }
.rd-datos { margin: 12px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.rd-datos dt { font-size: var(--letra-xs); color: var(--text-secondary); }
.rd-datos dd { margin: 2px 0 0; font-size: var(--letra-md); color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* Comparación estimado / real: dos barras en la misma escala. */
.rd-comp + .rd-comp { margin-top: 10px; }
.rd-comp-fila { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: var(--letra-sm); color: var(--text-secondary); }
.rd-comp-fila strong { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.rd-comp-pista { display: block; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.rd-comp-pista > span { display: block; height: 100%; border-radius: 4px; background: var(--accent-primary); transform-origin: left; }
.rd-comp-pista > span.rd-comp-gris { background: #64748B; }
@media (prefers-reduced-motion: no-preference) {
  .rd-comp-pista > span { animation: db-llena .7s cubic-bezier(.2, .8, .2, 1) both; }
}
.rd-dif { margin: 10px 0 0; font-size: var(--letra-sm); color: var(--text-secondary); }
.rd-dif span { font-weight: 600; }

/* ── Tableta ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .rd-rejilla { grid-template-columns: minmax(0, 1fr); }
  .rd-tres { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 32px; }
  .rd-tres > :last-child { grid-column: 1 / -1; }
  .rd-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rd-kpi:nth-child(4) { border-left: 0; }
  .rd-kpi:nth-child(n+4) { border-top: 1px solid var(--border-subtle); }
  .rd-kpi:nth-child(5) { grid-column: span 2; }
}

/* Hasta 900 px la lista deja de ser tabla: cada fila, un bloque de dos o tres líneas. */
@media (max-width: 900px) {
  .rt-tabla, .rt-tabla tbody { display: block; }
  .rt-tabla thead { display: none; }
  .rt-tabla tbody tr { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; padding: 14px; border-bottom: 1px solid var(--border-subtle); }
  .rt-tabla tbody tr:last-child { border-bottom: 0; }
  .rt-tabla td { padding: 0; border: 0; background: none !important; }
  .rt-tabla td.rt-check { position: absolute; top: 14px; right: 14px; width: auto; }
  .rt-tabla tbody tr:has(.rt-check) .rt-ruta { padding-right: 32px; }
  .rt-ruta { grid-column: 1 / -1; max-width: none; min-width: 0; }
  .rt-persona, .rt-cuando { grid-column: 1; white-space: normal; max-width: none; }
  .rt-num { grid-column: 2; }
  .rt-tabla:not(.rt-tabla-plan) .rt-persona { grid-row: 2; }
  .rt-tabla:not(.rt-tabla-plan) .rt-cuando { grid-row: 3; }
  .rt-tabla .rt-km { grid-row: 2; }
  .rt-tabla .rt-co2 { grid-row: 3; }
  .rt-avisos { grid-column: 1 / -1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px; }
  .rt-avisos .rt-aviso + .rt-aviso { margin-top: 0; }
  .rt-avisos:has(.rt-nada) { display: none; }
  .rt-acciones { grid-column: 1 / -1; width: auto; text-align: left; margin-left: -8px; }
  .rt-tabla-plan .rt-estado { grid-column: 1 / -1; }
  .rt-tabla-plan .rt-persona { grid-row: 3; }
  .rt-tabla-plan .rt-cuando { grid-row: 4; }
  .rt-tabla-plan .rt-num { grid-row: 3 / span 2; }
  .rt-filtros { align-items: stretch; flex-direction: column; }
  .rt-periodo, .rt-estados { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
}

@media (max-width: 768px) {
  .rd-titulo { font-size: 20px; }
  .rd-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rd-kpi { padding: 12px 14px; }
  .rd-kpi:nth-child(n) { border-left: 1px solid var(--border-subtle); border-top: 1px solid var(--border-subtle); grid-column: auto; }
  .rd-kpi:nth-child(odd) { border-left: 0; }
  .rd-kpi:nth-child(-n+2) { border-top: 0; }
  .rd-kpi:last-child { grid-column: 1 / -1; }
  .rd-kpi-valor { font-size: 22px; }
  .rd-bloque { padding: 14px; }
  .rd-mapa { min-height: 300px; }
  .rd-perfil { height: 180px; }
  .rd-tres { grid-template-columns: minmax(0, 1fr); }
  .rd-hito { grid-template-columns: 22px minmax(0, 1fr); }
  .rd-hito-hora { grid-column: 2; padding-top: 0; }
  .rd-hito-txt { grid-column: 2; }
  .rd-doc { grid-template-columns: 22px minmax(0, 1fr); }
  .rd-doc .btn { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 520px) {
  .rt-campos { display: grid; grid-template-columns: 1fr 1fr; }
  .rt-campo .form-input, .rt-campo-porte .form-input, .rt-campo-buscar .form-input { width: 100%; }
  .rt-campo-porte, .rt-campo-buscar, .rt-limpiar { grid-column: 1 / -1; }
}
