/* =====================================================================
   Gemelo Digital TransMilenio — mundo visual «Mapa troncal»
   Papel impreso, tinta, líneas gruesas de color, estaciones blancas.
   ===================================================================== */
:root {
  --paper: #f4f2ec; --paper-2: #fbfaf7; --paper-3: #ebe8df; --white: #ffffff;
  --rule: #dcd8cd; --rule-2: #c4bfb1;
  --ink: #16181d; --ink-2: #3c3e44; --ink-3: #66676c;
  --red: #e3172b; --red-ink: #c4101f; --blue: #0f6fd1;
  --good: #0b7d16; --warning: #9a6a00; --serious: #c2410c; --critical: #c4101f; --early: #1d5fbf; --none: #7a7b80;
  --good-f: #0ca30c; --warning-f: #fab219; --serious-f: #ec835a; --critical-f: #d03b3b; --early-f: #3987e5;
  --f-ui: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-cond: 'Barlow Semi Condensed', 'Barlow', system-ui, sans-serif;
  --shadow: 0 2px 4px rgba(22,24,29,.06), 0 8px 24px rgba(22,24,29,.10);
  --ease: cubic-bezier(.2,.75,.2,1);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font: 14px/1.42 var(--f-ui); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
button { font-family: var(--f-cond); font-weight: 600; font-size: 13.5px; background: var(--paper-2); border: 1px solid var(--rule-2); border-radius: 8px; padding: 5px 11px; cursor: pointer; transition: border-color .15s, background .15s, color .15s; }
button:hover { border-color: var(--ink); }
button:active { transform: translateY(1px); }
button.primary { background: var(--ink); border-color: var(--ink); color: var(--white); }
button.primary:hover { background: #000; }
button svg, summary svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 5px; }
:focus-visible { outline: 2.5px solid var(--blue); outline-offset: 2px; }
select, input[type=number], input[type=time], input:not([type]) { background: var(--white); border: 1px solid var(--rule-2); border-radius: 8px; padding: 5px 8px; }
select:hover, input:hover { border-color: var(--ink-3); }
.muted { color: var(--ink-3); }
small { color: var(--ink-3); }
b { font-weight: 600; }

/* ---------------------------------------------------------------- barra superior */
#top { position: relative; z-index: 900; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 9px 16px 8px; background: var(--paper-2); border-bottom: 1px solid var(--rule); }
#top::after { /* la paleta oficial de troncales como filete inferior */
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 3px;
  background: linear-gradient(90deg, #284195 0 9%, #7ec23a 0 18%, #fab41d 0 27%, #6e5baf 0 36%, #8f5f19 0 45%, #be1d28 0 54%, #1ea6e6 0 63%, #f57a14 0 72%, #de8ba3 0 81%, #bea369 0 90%, #00aaa9 0);
}
.brand { display: flex; gap: 10px; align-items: center; }
.mark { width: 34px; height: 34px; flex: none; }
.bt b { display: block; font: 700 18px/1.05 var(--f-cond); letter-spacing: .01em; }
.bt span { display: block; font-size: 12px; color: var(--ink-3); }
.tag { font: 700 11px/1 var(--f-cond); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); border: 1.5px solid var(--ink-2); border-radius: 4px; padding: 3px 5px; cursor: help; }
.grow { flex: 1; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--paper-3); border: 1px solid var(--rule); border-radius: 999px; }
.seg[hidden], .modes[hidden] { display: none; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 5px 13px; color: var(--ink-2); }
.seg button:hover { background: var(--white); color: var(--ink); }
.seg button.on { background: var(--ink); color: var(--white); }
.persona i { display: inline-block; width: 16px; height: 5px; border-radius: 3px; background: var(--lc); margin-right: 7px; vertical-align: 2px; box-shadow: 0 0 0 1.5px var(--white); }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--rule); background: var(--white); font: 600 12.5px/1.2 var(--f-cond); color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warning-f); }
.pill.ok::before { background: var(--red); animation: live 1.8s infinite; }
.pill.err::before { background: var(--none); }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(227,23,43,.45); } 70% { box-shadow: 0 0 0 7px rgba(227,23,43,0); } 100% { box-shadow: 0 0 0 0 rgba(227,23,43,0); } }
.clockbox { text-align: right; line-height: 1.05; }
#clock { font: 700 28px/1 var(--f-cond); letter-spacing: .01em; }
#clocksub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.transport { display: flex; gap: 6px; align-items: center; }
.icon { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; background: var(--white); }
.icon svg { width: 18px; height: 18px; margin: 0; }
.livebtn { display: inline-flex; align-items: center; gap: 7px; border: 1.5px solid var(--red); color: var(--red-ink); background: var(--white); border-radius: 999px; padding: 5px 12px; }
.livebtn .ld { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.livebtn.on { background: var(--red); color: var(--white); }
.livebtn:hover { border-color: var(--red-ink); }
/* sin posiciones nuevas: gris, sin rojo de «en vivo» */
.livebtn.parado, .livebtn.parado.on { border-color: var(--rule-2); color: var(--ink-3); background: var(--paper-3); }
.tl { flex-basis: 100%; padding: 2px 4px 0; }
/* la línea del tiempo como una línea del mapa con su estación */
#timeline { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; margin: 0; cursor: pointer; }
#timeline::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--ink); }
#timeline::-moz-range-track { height: 6px; border-radius: 3px; background: var(--ink); }
#timeline::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: var(--white); border: 3.5px solid var(--ink); }
#timeline::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--white); border: 3.5px solid var(--ink); }
#timeline:focus-visible::-webkit-slider-thumb { border-color: var(--blue); }

/* ---------------------------------------------------------------- disposición */
main { display: grid; grid-template-columns: 1fr 440px; height: calc(100% - 92px); }
#mapwrap { position: relative; min-height: 320px; overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--paper-3); }
#overlay { position: absolute; inset: 0; z-index: 450; pointer-events: none; }
#map3d { position: absolute; inset: 0; z-index: 500; background: var(--paper-3); }
#load3d { position: absolute; inset: 0; z-index: 550; display: grid; place-content: center; gap: 10px; text-align: center; background: rgba(244,242,236,.82); color: var(--ink-2); font: 600 15px var(--f-cond); }
#load3d[hidden] { display: none; }

/* herramientas flotantes sobre el mapa */
#maptools { position: absolute; top: 12px; left: 56px; right: 12px; z-index: 700; display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; pointer-events: none; }
#maptools > * { pointer-events: auto; }
#maptools .seg, #maptools .sel, #layers summary { background: var(--paper-2); box-shadow: var(--shadow); }
#maptools .sel { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule); border-radius: 999px; padding: 3px 4px 3px 12px; font: 600 13px var(--f-cond); color: var(--ink-2); }
#maptools .sel select { border: 0; background: var(--paper-3); border-radius: 999px; padding: 4px 8px; font: 600 13px var(--f-cond); }
#layers { position: relative; }
#layers summary { list-style: none; cursor: pointer; border: 1px solid var(--rule); border-radius: 999px; padding: 6px 13px; font: 600 13.5px var(--f-cond); color: var(--ink-2); }
#layers summary::-webkit-details-marker { display: none; }
#layers[open] summary { background: var(--ink); color: var(--white); border-color: var(--ink); }
#layers .menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 280px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 6px; display: grid; }
#layers .menu label { display: flex; gap: 9px; align-items: center; padding: 5px 9px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
#layers .menu label:hover { background: var(--paper-3); }
#layers .menu input { accent-color: var(--ink); width: 15px; height: 15px; }
#layers hr { border: 0; border-top: 1px solid var(--rule); margin: 5px 6px; }
/* celular: el menú abre hacia la izquierda, no se sale de la pantalla y se puede desplazar si no cabe */
@media (max-width: 640px) {
  #layers .menu { left: auto; right: 0; min-width: 0; width: min(290px, calc(100vw - 24px)); max-height: min(62vh, 430px); overflow-y: auto; overscroll-behavior: contain; z-index: 30; }
  #layers .menu label { white-space: normal; line-height: 1.25; }
}

/* convenciones (leyenda) */
#legend { position: absolute; left: 12px; bottom: 50px; z-index: 600; max-width: 470px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 12px; box-shadow: var(--shadow); padding: 9px 30px 9px 12px; font-size: 12.5px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 12px; }
#legend .lg-title { width: 100%; font: 700 13.5px var(--f-cond); color: var(--ink); }
#legend .lg-row { display: flex; flex-wrap: wrap; gap: 4px 12px; width: 100%; align-items: center; }
#legend .lg-row b { font: 600 12px var(--f-cond); color: var(--ink-3); margin-right: 2px; }
#legend .sw { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; box-shadow: 0 0 0 1.5px var(--white), 0 0 0 2.5px rgba(22,24,29,.25); }
#legend .bar { display: inline-block; width: 22px; height: 6px; border-radius: 3px; margin-right: 5px; vertical-align: 2px; }
#legend .lgbtn { position: absolute; top: 6px; right: 6px; border: 0; background: none; padding: 0 5px; color: var(--ink-3); font-size: 13px; }
#legend.min { padding: 0; } #legend.min .lgbtn { position: static; padding: 7px 12px; }

#banner { position: absolute; top: 60px; right: 12px; z-index: 800; max-width: 360px; background: var(--paper-2); border: 1.5px solid var(--red); border-radius: 10px; padding: 9px 12px; box-shadow: var(--shadow); }
#banner[hidden] { display: none; }

/* cinta «estado del servicio» */
#ticker { position: absolute; left: 0; right: 0; bottom: 0; z-index: 650; display: flex; align-items: stretch; height: 38px; background: var(--paper-2); border-top: 1px solid var(--rule); }
#ticker[hidden] { display: none; }
.tk-l { flex: none; display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--ink); color: var(--white); font: 700 13px var(--f-cond); letter-spacing: .02em; }
.tk-l .ld { width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: live 1.8s infinite; }
.tk-w { flex: 1; overflow: hidden; position: relative; -webkit-mask: linear-gradient(90deg, transparent 0, #000 24px, #000 calc(100% - 40px), transparent); mask: linear-gradient(90deg, transparent 0, #000 24px, #000 calc(100% - 40px), transparent); }
#tk-items { display: inline-flex; align-items: center; height: 100%; white-space: nowrap; padding-left: 24px; animation: tick var(--tk-d, 90s) linear infinite; }
#ticker:hover #tk-items { animation-play-state: paused; }
.tk-i { display: inline-flex; align-items: center; gap: 8px; padding-right: 34px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.tk-i:hover { color: var(--ink); }
.tk-i time { font: 600 12.5px var(--f-cond); color: var(--ink-3); }
.tk-i svg { width: 15px; height: 15px; flex: none; }
.tk-i + .tk-i::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--white); box-shadow: 0 0 0 2.5px var(--ink); margin-right: 26px; margin-left: -8px; }
@keyframes tick { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* controles de Leaflet y MapLibre en clave de papel */
.leaflet-container { background: var(--paper-3); font: inherit; }
.leaflet-bar { border: 1px solid var(--rule) !important; box-shadow: var(--shadow) !important; border-radius: 10px !important; overflow: hidden; }
.leaflet-bar a { background: var(--paper-2) !important; color: var(--ink) !important; border-color: var(--rule) !important; }
.leaflet-control-attribution, .maplibregl-ctrl-attrib { background: rgba(251,250,247,.85) !important; color: var(--ink-3) !important; font-size: 10.5px; }
.leaflet-control-attribution a, .maplibregl-ctrl-attrib a { color: var(--ink-2) !important; }
.maplibregl-ctrl-group { background: var(--paper-2) !important; border: 1px solid var(--rule); box-shadow: var(--shadow) !important; border-radius: 10px !important; }
.maplibregl-ctrl-bottom-right { bottom: 40px; }
.leaflet-bottom { bottom: 38px; }

/* ---------------------------------------------------------------- panel lateral */
#side { background: var(--paper-2); border-left: 1px solid var(--rule); display: flex; flex-direction: column; min-height: 0; }
/* pestañas: una línea del sistema con una estación por pestaña */
.tabs { position: relative; display: flex; gap: 0; padding: 12px 10px 8px; border-bottom: 1px solid var(--rule); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs::before { content: ""; position: absolute; left: 22px; right: 22px; top: 22px; height: 5px; border-radius: 3px; background: var(--ink); }
.tab { position: relative; flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 7px 2px; border-radius: 6px; color: var(--ink-3); font: 600 13px var(--f-cond); white-space: nowrap; }
.tab[hidden] { display: none; }
.tab::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--white); border: 3px solid var(--ink); transition: transform .2s var(--ease), background .2s; }
.tab:hover { color: var(--ink); background: none; }
.tab:hover::before { transform: scale(1.12); }
.tab.on { color: var(--ink); }
.tab.on::before { background: var(--red); transform: scale(1.3); }
.count { position: absolute; top: -2px; right: 0; min-width: 17px; padding: 0 4px; border-radius: 9px; background: var(--red); color: var(--white); font: 700 10.5px/17px var(--f-cond); text-align: center; }
.count:empty { display: none; }
.panel { display: none; overflow-y: auto; padding: 16px 18px 28px; flex: 1; min-height: 0; }
.panel.on { display: block; animation: panel .28s var(--ease); }
@keyframes panel { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.panel h2, .panel-title { font: 700 22px/1.15 var(--f-cond); margin: 2px 0 10px; letter-spacing: .005em; }
.panel h3 { font: 700 15.5px/1.2 var(--f-cond); color: var(--ink); margin: 24px 0 9px; }
.panel h3:first-child { margin-top: 2px; }
.note { font-size: 12px; color: var(--ink-3); margin: 7px 0; }
.side-foot { flex: none; padding: 8px 18px; border-top: 1px solid var(--rule); font-size: 11px; color: var(--ink-3); }

/* cifras: una tabla de filetes, como el reverso de un mapa impreso */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; }
.tile { background: var(--white); padding: 10px 12px 11px; min-width: 0; }
.tile .v { font: 700 25px/1.08 var(--f-cond); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.005em; }
.tile .l { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-top: 2px; }
.tile .s { font-size: 11.5px; color: var(--ink-3); line-height: 1.3; }
.tile .tr { font: 600 11.5px var(--f-cond); display: block; margin-top: 2px; }
.tr.up { color: var(--good); } .tr.down { color: var(--critical); } .tr.flat { color: var(--ink-3); }

/* placas de ruta y de troncal */
.chip, .plate { display: inline-grid; place-items: center; min-width: 24px; height: 20px; padding: 0 5px; border-radius: 4px; background: var(--pc, var(--ink)); color: var(--pt, var(--white)); font: 700 12.5px/1 var(--f-cond); letter-spacing: .02em; vertical-align: 1px; box-shadow: inset 0 0 0 1px rgba(22,24,29,.12); }
.plate.sm { min-width: 0; height: 18px; font-size: 12px; margin-right: 6px; }

/* estados */
.st { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st-good { color: var(--good); } .st-warning { color: var(--warning); } .st-serious { color: var(--serious); } .st-critical { color: var(--critical); } .st-early { color: var(--early); } .st-none { color: var(--none); }

/* gráficas */
.chart { position: relative; }
.chart canvas { display: block; width: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.chart-legend i { display: inline-block; width: 16px; height: 0; border-top: 2.5px solid; margin-right: 6px; vertical-align: 3px; }
.chart-legend i.dash { border-top-style: dashed; }

/* tablas */
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; color: var(--ink-3); font: 600 12px var(--f-cond); border-bottom: 1.5px solid var(--ink); padding: 5px 5px; position: sticky; top: 0; background: var(--paper-2); }
table.t td { border-bottom: 1px solid var(--rule); padding: 6px 5px; }
table.t td.n, table.t th.n { text-align: right; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--paper-3); }

.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.row label { color: var(--ink-2); }
.ctl { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin: 12px 0; }
.ctl label { color: var(--ink-2); font-weight: 600; }
.ctl output { font: 700 15px var(--f-cond); }
.ctl input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--ink); }
.ctl .hint { grid-column: 1 / -1; font-size: 11.5px; color: var(--ink-3); }
.delta-good { color: var(--good); font-weight: 600; } .delta-bad { color: var(--critical); font-weight: 600; } .delta-flat { color: var(--ink-3); }

/* avisos e incidencias */
.alert { background: var(--white); border: 1px solid var(--rule); border-radius: 10px; padding: 9px 11px; margin: 7px 0; }
.alert b { display: flex; align-items: center; gap: 7px; font: 700 14px var(--f-cond); }
.alert.tr b::before { content: ""; flex: none; width: 14px; height: 12px; background: var(--red); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.alert.tr { cursor: pointer; } .alert.tr:hover { border-color: var(--ink-3); }
.alert .meta { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.inc { display: flex; gap: 10px; align-items: flex-start; padding: 8px 4px; border-bottom: 1px solid var(--rule); cursor: pointer; border-radius: 6px; }
.inc:hover { background: var(--paper-3); }
.inc .ic { flex: none; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; background: var(--ink); color: var(--white); }
.inc .ic svg { width: 15px; height: 15px; }
.inc small { display: block; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 0; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; }
.arrivals { list-style: none; padding: 0; margin: 0; }
.arrivals li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--rule); }

/* sensores: el flujo como una línea con un bus que viaja */
.pipe { display: grid; }
.stage { display: flex; gap: 12px; align-items: center; background: var(--white); border: 1px solid var(--rule); border-radius: 12px; padding: 10px 12px; }
.stage .ico { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--white); }
.stage .ico svg { width: 19px; height: 19px; }
.stage .txt span { display: block; font-size: 11.5px; color: var(--ink-3); }
.stage .txt b { display: block; font: 700 16px/1.2 var(--f-cond); }
.stage .txt small { display: block; font-size: 11.5px; }
.flow { position: relative; height: 26px; margin-left: 29px; width: 5px; background: var(--ink); }
.flow i { position: absolute; left: -3.5px; width: 12px; height: 12px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2.5px var(--white); animation: flow 1.6s var(--ease) infinite; }
.flow i:nth-child(2), .flow i:nth-child(3) { display: none; }
@keyframes flow { from { top: -6px; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } to { top: 20px; opacity: 0; } }
.feeds { display: grid; gap: 6px; }
.feed { background: var(--white); border: 1px solid var(--rule); border-radius: 10px; padding: 8px 11px; }
.feed .fh { display: flex; align-items: center; gap: 8px; font-family: var(--f-cond); font-size: 14.5px; }
.feed .fh small { margin-left: auto; font-family: var(--f-ui); }
.feed .fm { display: flex; gap: 16px; margin-top: 3px; color: var(--ink-3); font-size: 12.5px; }
.feed .fm b { color: var(--ink); font: 700 14px var(--f-cond); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--good-f); box-shadow: 0 0 0 3px rgba(12,163,12,.18); } .dot.err { background: var(--critical-f); } .dot.wait { background: var(--warning-f); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.chipbtn { padding: 3px 10px; font-size: 12.5px; border-radius: 999px; background: var(--white); }
.chipbtn.on { background: var(--ink); color: var(--white); border-color: var(--ink); }
.events { max-height: 440px; overflow-y: auto; background: var(--white); border: 1px solid var(--rule); border-radius: 10px; }
.ev { display: grid; grid-template-columns: 58px 22px 1fr; gap: 7px; align-items: start; padding: 6px 10px; border-bottom: 1px solid var(--rule); font-size: 12.5px; }
.ev[data-bus], .ev[data-lat] { cursor: pointer; } .ev:hover { background: var(--paper-3); }
.ev time { color: var(--ink-3); font: 600 12px var(--f-cond); padding-top: 1px; }
.ev .ei { width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; background: var(--ink); color: var(--white); font: 700 11px var(--f-cond); }
.ev .ei svg { width: 13px; height: 13px; }

/* ciudadano: estado de las líneas */
.status-hero { padding: 4px 0 8px; }
.status-hero h2 { font: 800 28px/1.08 var(--f-cond); margin: 0 0 6px; }
.status-hero.st-good h2 { color: var(--good); } .status-hero.st-warning h2 { color: var(--warning); } .status-hero.st-serious h2 { color: var(--serious); } .status-hero.st-critical h2 { color: var(--critical); }
.status-hero p { margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.5; max-width: 60ch; }
.corr-list { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--ink); }
.corr-list li { display: grid; grid-template-columns: 30px 1fr auto 66px; gap: 10px; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--rule); }
.corr-list .cn { font: 600 15px var(--f-cond); }
.corr-list .cs { font: 700 14px var(--f-cond); }
.corr-list .cv { text-align: right; color: var(--ink-3); font: 600 13px var(--f-cond); }
.corr-list .plate { width: 26px; height: 22px; font-size: 14px; }

/* ciudadano: mi viaje */
.search { display: flex; gap: 8px; }
.search input { flex: 1; font-size: 15.5px; padding: 10px 12px; border: 1.5px solid var(--ink); border-radius: 10px; }
.search input::placeholder { color: var(--ink-3); }
.search button { border: 1.5px solid var(--ink); border-radius: 10px; padding: 0 13px; }
.empty { margin-top: 16px; color: var(--ink-2); }
.empty p { margin: 0 0 10px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { border-radius: 999px; background: var(--white); }
.board { margin-top: 14px; border: 1.5px solid var(--ink); border-radius: 12px; overflow: hidden; background: var(--white); }
.board-h { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--ink); color: var(--white); }
.board-h b { flex: 1; font: 700 17px/1.1 var(--f-cond); }
.board-h time { font: 700 17px var(--f-cond); color: #cfd2d8; }
.board-r { display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; gap: 0 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--rule); animation: rowin .4s var(--ease) both; }
.board-r:last-child { border-bottom: 0; }
.board-r .plate { grid-row: span 2; height: 26px; min-width: 44px; font-size: 15px; }
.board-r .dest { font: 600 15px var(--f-cond); }
.board-r .eta { grid-row: span 2; font: 800 24px/1 var(--f-cond); text-align: right; }
.board-r .dl { font-size: 12px; }
.board-empty { padding: 14px; margin: 0; color: var(--ink-3); }
@keyframes rowin { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.passes { list-style: none; margin: 0; padding: 0; }
.passes li { padding: 6px 0; border-bottom: 1px solid var(--rule); color: var(--ink-2); }
.linkbtn { margin-top: 14px; background: none; border: 0; padding: 0; color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }

/* elección de perfil (primera visita) */
#chooser { position: fixed; inset: 0; z-index: 2500; display: grid; place-items: center; background: rgba(22,24,29,.32); padding: 16px; }
#chooser[hidden] { display: none; }
.chooser-card { width: min(560px, 100%); background: var(--paper-2); border-radius: 18px; box-shadow: 0 24px 60px rgba(22,24,29,.28); padding: 24px 24px 18px; animation: rise .45s var(--ease); }
.chooser-card h2 { font: 800 28px/1.1 var(--f-cond); margin: 0 0 6px; }
.chooser-card p { margin: 0 0 16px; color: var(--ink-2); }
.ch-opts { display: grid; gap: 8px; }
.ch-opt { display: grid; grid-template-columns: 54px 1fr; grid-template-rows: auto auto; gap: 1px 12px; text-align: left; padding: 12px 14px; border-radius: 12px; background: var(--white); border: 1.5px solid var(--rule); }
.ch-opt:hover { border-color: var(--ink); }
.ch-opt::before { content: ""; grid-row: span 2; align-self: center; height: 7px; border-radius: 4px; background: var(--lc); box-shadow: 0 0 0 2px var(--white); }
.ch-opt b { font: 700 18px var(--f-cond); }
.ch-opt span { font: 400 13.5px var(--f-ui); color: var(--ink-3); }
.ch-skip { margin-top: 12px; background: none; border: 0; color: var(--ink-3); padding: 4px 0; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* tooltip */
#tip { position: fixed; z-index: 3000; pointer-events: none; background: var(--paper-2); color: var(--ink); border: 1px solid var(--rule-2); border-radius: 9px; padding: 7px 10px; font-size: 12.5px; max-width: 290px; display: none; box-shadow: var(--shadow); }
#tip b { font-family: var(--f-cond); font-size: 14px; }

/* carga: el mapa del sistema se dibuja mientras conecta */
#loading { position: fixed; inset: 0; z-index: 4000; background: var(--paper); display: grid; place-content: center; grid-template-columns: minmax(0, min(100%, 420px)); justify-items: center; text-align: center; gap: 6px; padding: 16px; transition: opacity .5s var(--ease), visibility .5s; }
#loading.done { opacity: 0; visibility: hidden; }
.drawmap { width: min(300px, 80vw); height: auto; margin-bottom: 8px; }
.drawmap .ln { fill: none; stroke: var(--c); stroke-width: 10; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 460; stroke-dashoffset: 460; animation: draw 1.15s var(--ease) var(--d) forwards; }
.drawmap .st { fill: var(--white); stroke: var(--ink); stroke-width: 3.5; opacity: 0; transform-box: fill-box; transform-origin: center; animation: pop .35s var(--ease) var(--d) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: none; } }
#loading h1 { font: 800 clamp(24px, 8vw, 30px)/1.1 var(--f-cond); margin: 0; max-width: 100%; text-wrap: balance; }
#loading h1 span { color: var(--red); }
#loadmsg { margin: 0; color: var(--ink-3); }
.spinner { width: 30px; height: 30px; margin: 0 auto; border: 3px solid var(--rule); border-top-color: var(--ink); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .drawmap .ln { stroke-dashoffset: 0; } .drawmap .st { opacity: 1; }
  #tk-items { animation: none; }
}

@media (max-width: 1100px) { main { grid-template-columns: 1fr 380px; } #legend { max-width: 340px; } }
@media (max-width: 900px) {
  html, body { height: auto; }
  #top { padding: 8px 12px; gap: 8px 10px; }
  .bt span, .tag { display: none; }
  .personas { order: 10; flex-basis: 100%; justify-content: space-between; }
  .personas button { flex: 1; padding: 6px 4px; }
  #clocksub { display: none; }
  #clock { font-size: 22px; }
  main { grid-template-columns: 1fr; grid-template-rows: 58vh auto; height: auto; }
  #maptools { left: 52px; }
  #maptools .sel, #cam3d { display: none; }
  #legend { display: none; }
  #side { border-left: 0; border-top: 1px solid var(--rule); }
  .side-foot { padding-bottom: 18px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}

/* ---- ronda 1 de ajustes ---- */
#timeline::-webkit-slider-runnable-track { height: 4px; background: var(--ink-2); }
#timeline::-moz-range-track { height: 4px; background: var(--ink-2); }
#timeline::-webkit-slider-thumb { margin-top: -7px; }
table.t td.n { white-space: nowrap; }
table.t td:first-child { white-space: nowrap; }
@media (max-width: 900px) {
  #top { gap: 6px 8px; }
  .brand { order: 1; } .grow { order: 2; } .clockbox { order: 3; }
  #feed { order: 4; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
  .transport { order: 5; } #play, #speed { display: none; }
  .livebtn { padding: 4px 10px; }
  .tl { display: none; }
  .mark { width: 30px; height: 30px; } .bt b { font-size: 17px; }
  .personas { order: 10; }
  .modes { order: 11; }
  main { grid-template-rows: 62vh auto; }
}
@media (max-width: 900px) { #feed { display: none; } }

/* ---- correcciones de la revisión final ---- */
html, body { height: 100%; }
body { display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
main { height: auto; min-height: 0; }
.tl { display: flex; align-items: center; gap: 10px; }
.tl #timeline { flex: 1; }
#tl-a, #tl-b { flex: none; font: 600 12px var(--f-cond); color: var(--ink-3); white-space: nowrap; }
#tl-b { color: var(--red-ink); }
body[data-persona="ciudadano"] .tl, body[data-persona="ciudadano"] #play, body[data-persona="ciudadano"] #speed { display: none; }
/* elección de perfil acoplada al panel, sin velo sobre la ciudad */
#side { position: relative; }
#chooser { position: absolute; inset: 0; z-index: 60; display: block; background: var(--paper-2); padding: 18px; overflow-y: auto; }
#chooser[hidden] { display: none; }
.chooser-card { width: auto; box-shadow: none; padding: 4px 2px; border-radius: 0; background: none; }
@media (max-width: 900px) {
  html, body { height: auto; }
  body { display: block; overflow: auto; }
  #legend { display: flex; bottom: 50px; }
  #chooser { position: relative; }
}
@media (max-width: 900px) { .tk-l { padding: 0 10px; font-size: 12px; } .tk-l .tk-t { display: none; } }

/* enlace al índice de gemelos */
.brand .home { display: flex; }
.brand .sib { color: inherit; text-decoration: underline; text-decoration-color: var(--rule-2); text-underline-offset: 2px; }
.brand .sib:hover { text-decoration-color: currentColor; }

/* marca Datos de Colombia */
.brand .bandera { width: 34px; height: 23px; border-radius: 3px; }

/* TransMilenio dejó de publicar: aviso dentro de la cabecera, ocupa su propia fila */
.aviso-fuente { order: 30; flex-basis: 100%; display: flex; gap: 10px; align-items: flex-start; margin: 2px 0 2px; padding: 9px 12px; border-radius: 10px; background: var(--paper-3); border-left: 6px solid var(--ink); font-size: 13.5px; line-height: 1.4; color: var(--ink); }
.aviso-fuente[hidden] { display: none; }
.aviso-fuente svg { flex: none; width: 20px; height: 20px; margin-top: 1px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.aviso-fuente p { margin: 0; }
.aviso-fuente span { display: block; color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }
.aviso-fuente a { color: inherit; }

/* enlaces a las páginas públicas en el pie del panel */
.foot-links { display: block; margin: 0 0 8px; font: 700 13px var(--f-cond); }
.foot-links a { color: var(--ink-2); }

/* en el celular nada puede ser más ancho que la pantalla: las columnas de la cuadrícula no crecen por su contenido
   (antes, mientras cargaba, las 9 pestañas ensanchaban la página a 558 px y el logo de carga salía cortado) */
main > * { min-width: 0; }
@media (max-width: 380px) {
  .tabs { padding-left: 4px; padding-right: 4px; }
  .tab { padding: 4px 3px 2px; font-size: 12px; }
}

/* «N personas usando ahora»: junto a «En vivo», dentro de la cabecera (nada flota) */
.presentes { display: inline-flex; align-items: center; gap: 5px; margin-right: 8px; font: 600 13px var(--f-cond); color: var(--ink-2); white-space: nowrap; }
.presentes[hidden] { display: none; }
.presentes b { font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.presentes i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.presentes .pr-vivo { background: var(--good, #0b7d16); box-shadow: 0 0 0 3px rgba(11, 125, 22, .18); animation: prlate 2s ease-in-out infinite; }
.presentes .pr-hoy { background: var(--ink-3); }
@keyframes prlate { 50% { box-shadow: 0 0 0 5px rgba(11, 125, 22, .06); } }
@media (max-width: 900px) { .presentes .pr-l { display: none; } .presentes { font-size: 12px; margin-right: 6px; } }
@media (prefers-reduced-motion: reduce) { .presentes .pr-vivo { animation: none; } }

/* interruptor «SITP» en la barra del mapa */
.btn-sitp { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 12px; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper-2); box-shadow: var(--shadow); font: 700 13.5px var(--f-cond); color: var(--ink); cursor: pointer; }
.btn-sitp i { width: 10px; height: 10px; border-radius: 50%; background: #1f5fa8; box-shadow: 0 0 0 2px #fff, 0 0 0 3px #1f5fa8; }
.btn-sitp.off { color: var(--ink-3); }
.btn-sitp.off i { background: transparent; box-shadow: 0 0 0 2px var(--ink-3) inset; }
.btn-acc span { font-size: 15px; line-height: 1; }
.btn-acc.off span { filter: grayscale(1); opacity: .45; }
.btn-metro { text-decoration: none; color: #fff; background: #c43c1b; border-color: #c43c1b; }
.btn-metro:hover { background: #a8321a; }
.btn-sitp:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
