/* ============================================================
   Gemelo Digital · Transporte Urbano de Lima
   Tokens de color (paleta dataviz validada) + layout
   ============================================================ */
:root {
  color-scheme: light;
  /* superficies e ink */
  --plane:        #f4f5f3;
  --surface-1:    #ffffff;
  --surface-2:    #fafaf8;
  --text-1:       #0b0b0b;
  --text-2:       #52514e;
  --muted:        #898781;
  --grid:         #e6e6e0;
  --axis:         #cdccc4;
  --border:       rgba(11,11,11,0.10);
  --border-strong: rgba(11,11,11,0.16);
  --shadow:       0 1px 2px rgba(11,11,11,.06), 0 8px 24px rgba(11,11,11,.06);
  /* acentos */
  --accent:       #2a78d6;
  --accent-ink:   #1c5cab;
  --good:         #0ca30c;
  --warn:         #eda100;
  /* paleta categórica validada (light) */
  --s1:#2a78d6; --s2:#eb6834; --s3:#1baf7a; --s4:#eda100;
  --s5:#e87ba4; --s6:#008300; --s7:#4a3aa7; --s8:#e34948;
  /* mapa */
  --map-bg:       #eef1ee;
  --map-ink:      #0b0b0b;
  --coast:        #b9c6c2;
  --station:      #ffffff;
  --station-ring: #52514e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root:where(:not([data-theme="light"])) { }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane:#0d0d0d; --surface-1:#161615; --surface-2:#1c1c1a;
    --text-1:#ffffff; --text-2:#c3c2b7; --muted:#8f8e86;
    --grid:#2a2a28; --axis:#3a3a37;
    --border:rgba(255,255,255,0.10); --border-strong:rgba(255,255,255,0.18);
    --shadow:0 1px 2px rgba(0,0,0,.5), 0 10px 30px rgba(0,0,0,.45);
    --accent:#3987e5; --accent-ink:#86b6ef; --good:#0ca30c; --warn:#eda100;
    --s1:#3987e5; --s2:#d95926; --s3:#199e70; --s4:#c98500;
    --s5:#d55181; --s6:#008300; --s7:#9085e9; --s8:#e66767;
    --map-bg:#101311; --map-ink:#eef1ee; --coast:#2f3a37;
    --station:#161615; --station-ring:#c3c2b7;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:#0d0d0d; --surface-1:#161615; --surface-2:#1c1c1a;
  --text-1:#ffffff; --text-2:#c3c2b7; --muted:#8f8e86;
  --grid:#2a2a28; --axis:#3a3a37;
  --border:rgba(255,255,255,0.10); --border-strong:rgba(255,255,255,0.18);
  --shadow:0 1px 2px rgba(0,0,0,.5), 0 10px 30px rgba(0,0,0,.45);
  --accent:#3987e5; --accent-ink:#86b6ef;
  --s1:#3987e5; --s2:#d95926; --s3:#199e70; --s4:#c98500;
  --s5:#d55181; --s6:#008300; --s7:#9085e9; --s8:#e66767;
  --map-bg:#101311; --map-ink:#eef1ee; --coast:#2f3a37;
  --station:#161615; --station-ring:#c3c2b7;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--plane); color: var(--text-1);
  -webkit-font-smoothing: antialiased; line-height: 1.5;
}
h1,h2,h3 { line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
a { color: var(--accent-ink); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- Sidebar ---------- */
:root { --sbw: 244px; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sbw); z-index: 60;
  display: flex; flex-direction: column; gap: 4px; padding: 18px 14px;
  background: var(--surface-1); border-right: 1px solid var(--border); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--text-1);
  padding: 4px 6px 14px; }
.brand .dot { width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--s1), var(--s3));
  display: grid; place-items: center; box-shadow: var(--shadow); }
.brand .dot svg { width: 20px; height: 20px; }
.brand b { font-size: 15.5px; letter-spacing: -.01em; }
.brand span { display:block; font-size: 11px; color: var(--muted); font-weight: 500; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px;
  color: var(--text-2); text-decoration: none; font-size: 13.5px; font-weight: 550; }
.side-nav a svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.side-nav a:hover { background: var(--surface-2); color: var(--text-1); }
.side-nav a.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-ink); }
.side-nav a.active svg { opacity: 1; }
.side-foot { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.side-theme { display: flex; align-items: center; gap: 10px; width: 100%; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-1);
  border-radius: 10px; padding: 9px 11px; font-size: 13px; font-weight: 550; font-family: inherit; }
.side-theme:hover { border-color: var(--border-strong); }
.side-theme svg { width: 17px; height: 17px; }
.side-theme .ic-sun { display: none; }
:root[data-theme="dark"] .side-theme .ic-sun { display: block; }
:root[data-theme="dark"] .side-theme .ic-moon { display: none; }
.side-mini { display: flex; align-items: center; gap: 9px; color: var(--muted); text-decoration: none;
  font-size: 12px; padding: 4px 6px; }
.side-mini:hover { color: var(--text-1); }
.side-mini svg { width: 15px; height: 15px; }

/* mobile top bar + scrim (ocultos en escritorio) */
.mtopbar { display: none; }
.scrim { display: none; }

/* ---------- Layout ---------- */
.main { margin-left: var(--sbw); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 26px; }
section { padding: 58px 0; scroll-margin-top: 20px; }
.eyebrow { font-size: 12px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-ink); margin-bottom: 12px; }
.sec-title { font-size: clamp(22px, 3vw, 30px); }
.sec-sub { color: var(--text-2); max-width: 62ch; margin-top: 10px; }

/* ---------- Hero / Twin ---------- */
.hero { padding-top: 26px; }
.hero-head { margin-bottom: 18px; }
.hero-head h1 { font-size: clamp(26px, 4.4vw, 44px); font-weight: 720; max-width: 20ch; }
.hero-head p { color: var(--text-2); max-width: 58ch; margin: 12px 0 0; font-size: 16px; }
.twin { display: grid; grid-template-columns: 1.9fr 1fr; gap: 16px; align-items: stretch; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); }
.mapcard { position: relative; overflow: hidden; min-height: 560px; padding: 0; }
#twinMap { position: absolute; inset: 0; background: var(--map-bg); }
.veh-canvas { position: absolute; inset: 0; z-index: 402; pointer-events: none; }
/* HUD (arriba a la derecha) */
.map-hud { position: absolute; right: 12px; top: 12px; z-index: 1200; display: flex; flex-direction: column;
  align-items: flex-end; gap: 8px; pointer-events: none; }
.map-clock { text-align: right; background: color-mix(in srgb, var(--surface-1) 84%, transparent);
  border: 1px solid var(--border); border-radius: 12px; padding: 7px 12px; backdrop-filter: blur(8px); }
.map-clock .t { font-size: 25px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.map-clock .d { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.hud-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { background: color-mix(in srgb, var(--surface-1) 84%, transparent);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 11px; font-size: 12px;
  color: var(--text-2); backdrop-filter: blur(8px); font-weight: 550; }
.chip b { color: var(--text-1); font-variant-numeric: tabular-nums; }
.map-fit { position: absolute; left: 12px; bottom: 58px; z-index: 1200; width: 34px; height: 34px;
  display: grid; place-items: center; border: 1px solid var(--border); border-radius: 9px; cursor: pointer;
  background: color-mix(in srgb, var(--surface-1) 90%, transparent); color: var(--text-1); backdrop-filter: blur(8px); }
.map-fit:hover { border-color: var(--accent); } .map-fit svg { width: 17px; height: 17px; }
.map-legend { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 1200; display: flex; gap: 6px 12px;
  flex-wrap: wrap; background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px; backdrop-filter: blur(8px); }
.leg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2);
  cursor: pointer; user-select: none; font-weight: 550; }
.leg .sw { width: 13px; height: 4px; border-radius: 2px; }
.leg.off { opacity: .38; text-decoration: line-through; }
/* Leaflet: encaja con el tema */
.leaflet-container { font: inherit; background: var(--map-bg); }
.leaflet-control-zoom a { background: color-mix(in srgb, var(--surface-1) 92%, transparent) !important;
  color: var(--text-1) !important; border-color: var(--border) !important; backdrop-filter: blur(8px); }
.leaflet-control-zoom a:hover { background: var(--surface-2) !important; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface-1) 78%, transparent) !important;
  color: var(--muted) !important; font-size: 10px !important; }
.leaflet-control-attribution a { color: var(--accent-ink) !important; }
.leaflet-bar { border: 1px solid var(--border) !important; box-shadow: var(--shadow) !important; }
.twin-tt { background: var(--text-1) !important; color: var(--surface-1) !important; border: none !important;
  box-shadow: var(--shadow) !important; font-size: 12px !important; padding: 5px 9px !important; }
.twin-tt b { font-weight: 650; } .twin-tt span { display: block; opacity: .7; font-size: 11px; }
.twin-tt::before { display: none !important; }

/* control panel */
.panel { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.controls { display: flex; flex-direction: column; gap: 14px; }
.playrow { display: flex; align-items: center; gap: 10px; }
.play { width: 46px; height: 46px; border-radius: 12px; border: none; cursor: pointer; flex: none;
  background: var(--accent); color: #fff; display: grid; place-items: center; }
.play svg { width: 20px; height: 20px; }
.play:hover { background: var(--accent-ink); }
.field label { font-size: 12px; color: var(--text-2); display: flex; justify-content: space-between;
  margin-bottom: 6px; font-weight: 550; }
.field label b { color: var(--text-1); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); cursor: pointer; }
.livestats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; }
.stat .v { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11px; color: var(--muted); margin-top: 2px; }
.hint { font-size: 11.5px; color: var(--muted); }

/* ---------- KPI strip ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; box-shadow: var(--shadow); }
.kpi .v { font-size: clamp(24px,3vw,32px); font-weight: 720; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 15px; font-weight: 600; color: var(--text-2); margin-left: 3px; }
.kpi .k { font-size: 13px; color: var(--text-1); font-weight: 600; margin-top: 4px; }
.kpi .n { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Dashboards ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chartcard { padding: 18px; }
.chartcard h3 { font-size: 15px; }
.chartcard .csub { font-size: 12.5px; color: var(--muted); margin: 3px 0 12px; }
.chart-holder { position: relative; height: 260px; }
.chart-holder.tall { height: 300px; }
.chart-src { margin-top: 10px; font-size: 11.5px; }
.chart-src a { color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--border-strong); }
.chart-src a:hover { color: var(--accent-ink); border-color: var(--accent); }
.kpi-src { margin: 10px 2px 0; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; }
.legend-row .li { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.legend-row .li i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ---------- Context ---------- */
.prose p { color: var(--text-2); max-width: 70ch; }
.timeline { position: relative; margin-top: 20px; padding-left: 26px; }
.timeline::before { content:""; position:absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--grid); }
.tl-item { position: relative; padding: 0 0 22px 0; }
.tl-item::before { content:""; position:absolute; left: -26px; top: 3px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--surface-1); border: 3px solid var(--accent); }
.tl-item .y { font-size: 13px; font-weight: 700; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.tl-item h4 { margin: 2px 0 3px; font-size: 15px; }
.tl-item p { margin: 0; font-size: 13.5px; color: var(--text-2); max-width: 66ch; }
.cardgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 14px; margin-top: 18px; }
.mini { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.mini h4 { font-size: 14.5px; margin-bottom: 5px; }
.mini .eta { display: inline-block; font-size: 11px; font-weight: 650; color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 12%, transparent); padding: 2px 8px; border-radius: 999px; margin-bottom: 7px; }
.mini p { margin: 0; font-size: 13px; color: var(--text-2); }
.authority { background: var(--surface-1); border: 1px solid var(--border); border-left: 4px solid var(--s7);
  border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); margin-top: 18px; }
.sources { columns: 2; column-gap: 28px; font-size: 12.5px; margin-top: 14px; }
.sources li { margin-bottom: 6px; break-inside: avoid; }

/* ---------- Footer ---------- */
footer { border-top: 1px solid var(--border); padding: 26px 0 44px; color: var(--muted); font-size: 12.5px; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; }
.badge { font-size: 11px; border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; color: var(--text-2); }

.loading { padding: 60px 20px; text-align: center; color: var(--muted); }

/* ---------- Apoyo ---------- */
.support { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px,1fr)); gap: 14px; margin-top: 20px; }
.sup-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; padding: 18px;
  box-shadow: var(--shadow); text-decoration: none; color: var(--text-1); display: flex; flex-direction: column; gap: 8px; }
.sup-card p { margin: 0; font-size: 13px; color: var(--text-2); }
.sup-h { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 650; }
.sup-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 800;
  color: #fff; font-size: 15px; }
.sup-card.yape { border-top: 3px solid #742384; }
.yape .sup-ic { background: #742384; }
.sup-card.coffee { border-top: 3px solid #ff813f; }
.coffee .sup-ic { background: #ffdd00; }
.sup-card.share { border-top: 3px solid var(--s1); }
.share .sup-ic { background: var(--s1); }
.sup-num { font-size: 24px; font-weight: 720; letter-spacing: .01em; margin-top: 2px; }
.sup-btn { align-self: flex-start; margin-top: auto; cursor: pointer; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-1); border-radius: 9px; padding: 8px 13px; font-size: 13px;
  font-weight: 600; font-family: inherit; text-decoration: none; display: inline-block; }
.sup-btn:hover { background: var(--surface-1); border-color: var(--accent); }
.sup-btn.ghost { background: transparent; }
.sup-actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }

/* ---------- Chatbot ---------- */
.chat-fab { position: fixed; right: 22px; bottom: 22px; z-index: 80; width: 58px; height: 58px; border-radius: 50%;
  border: none; cursor: pointer; background: var(--accent); box-shadow: 0 8px 24px rgba(0,0,0,.28);
  display: grid; place-items: center; }
.chat-fab:hover { background: var(--accent-ink); }
.chat-fab svg { width: 26px; height: 26px; }
.chat-panel[hidden] { display: none !important; }
.chat-panel { position: fixed; right: 22px; bottom: 90px; z-index: 80; width: min(384px, calc(100vw - 28px));
  height: min(544px, calc(100vh - 130px)); background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.35); display: flex; flex-direction: column; overflow: hidden;
  animation: chatIn .18s ease; transform-origin: bottom right; }
@keyframes chatIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.chat-fab.hide { transform: scale(0); opacity: 0; }
.chat-fab { transition: transform .18s ease, opacity .18s ease; }
.chat-top { display: flex; align-items: center; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); }
.chat-top b { font-size: 14px; } .chat-top span { display: block; font-size: 11px; color: var(--muted); }
.chat-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); flex: none; }
.chat-x { margin-left: auto; border: none; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; }
.chat-x:hover { color: var(--text-1); }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.msg.err { align-self: flex-start; background: color-mix(in srgb, #d03b3b 14%, var(--surface-1)); border: 1px solid #d03b3b55; font-size: 12.5px; }
.msg .typing { display: inline-flex; gap: 4px; }
.msg .typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.msg .typing i:nth-child(2){animation-delay:.2s}.msg .typing i:nth-child(3){animation-delay:.4s}
@keyframes blink { 0%,60%,100%{opacity:.3} 30%{opacity:1} }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 6px; }
.chat-suggest button { font-size: 11.5px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); border-radius: 999px; padding: 5px 10px; cursor: pointer; font-family: inherit; }
.chat-suggest button:hover { border-color: var(--accent); color: var(--text-1); }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-1);
  border-radius: 10px; padding: 10px 12px; font-size: 13.5px; font-family: inherit; }
.chat-form input:focus { outline: none; border-color: var(--accent); }
.chat-form button { flex: none; width: 42px; border: none; background: var(--accent); color: #fff; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.chat-form button:hover { background: var(--accent-ink); }
.chat-form button svg { width: 18px; height: 18px; }
.chat-form button:disabled { opacity: .5; cursor: default; }

/* ---------- Parque / proyección ---------- */
.proj-callout { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2);
  border: 1px solid var(--border); font-size: 14px; color: var(--text-2); }
.proj-callout b { font-weight: 700; color: var(--text-1); }
.proj-callout .up { color: var(--warn); font-weight: 650; font-size: 13px; }
.fleet-note { margin: 10px 2px 0; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.traffic-stat { display: flex; align-items: center; gap: 18px; margin-top: 14px; padding: 16px 20px; border-radius: 16px;
  background: var(--surface-1); border: 1px solid var(--border); border-left: 4px solid var(--warn); box-shadow: var(--shadow); }
.ts-big { font-size: clamp(34px, 6vw, 52px); font-weight: 800; letter-spacing: -.02em; color: var(--warn); line-height: 1; flex: none; }
.ts-big small { font-size: .5em; font-weight: 700; margin-left: 2px; }
.ts-txt b { font-size: 16px; }
.ts-txt span { display: block; font-size: 12.5px; color: var(--text-2); margin-top: 3px; line-height: 1.5; }
.ts-txt a { color: var(--accent-ink); text-decoration: none; white-space: nowrap; }
.ts-txt a:hover { text-decoration: underline; }
input[type=search] { width: 100%; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-1);
  border-radius: 9px; padding: 8px 11px; font-size: 13px; font-family: inherit; }
input[type=search]:focus { outline: none; border-color: var(--accent); }

/* ---------- Seguridad ---------- */
.sec-map-wrap { margin-top: 10px; }
#secMap { height: 300px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--map-bg); z-index: 0; }

/* ---------- Popup ficha de línea (Leaflet) ---------- */
.twin-pop .leaflet-popup-content-wrapper { background: var(--surface-1); color: var(--text-1);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow); border-radius: 12px; }
.twin-pop .leaflet-popup-tip { background: var(--surface-1); box-shadow: none; }
.twin-pop a.leaflet-popup-close-button { color: var(--muted); }
.twin-pop .leaflet-popup-content { margin: 12px 14px; line-height: 1.4; }
.pop-h { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 8px; }
.pop-sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.pop-t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pop-t td { padding: 3px 0; vertical-align: top; }
.pop-t td:first-child { color: var(--muted); padding-right: 14px; white-space: nowrap; }
.pop-t td:last-child { color: var(--text-1); font-weight: 550; text-align: right; }
.pop-facts { margin: 9px 0 0; padding-left: 16px; font-size: 12px; color: var(--text-2); }
.pop-facts li { margin-bottom: 3px; }
.pop-note { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---------- FAQ ---------- */
.faq { display: flex; flex-direction: column; gap: 8px; }
.faq-item { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.faq-item summary { cursor: pointer; padding: 14px 16px; font-weight: 600; font-size: 14.5px; list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--muted); font-size: 20px; font-weight: 400; line-height: 1; flex: none; }
.faq-item[open] summary::after { content: "−"; }
.faq-item summary:hover { color: var(--accent-ink); }
.faq-item > div { padding: 0 16px 15px; color: var(--text-2); font-size: 13.5px; line-height: 1.6; }
.faq-item > div b { color: var(--text-1); }
.faq-sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px,1fr)); gap: 16px; margin-top: 14px; }
.src-group { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.src-group h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent-ink); margin-bottom: 8px; }
.src-group ul { margin: 0; padding-left: 16px; font-size: 12.5px; color: var(--text-2); }
.src-group li { margin-bottom: 5px; }

/* ---------- Pestañas del panel · Mi viaje ---------- */
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 4px; }
.tab { flex: 1; border: none; background: transparent; color: var(--text-2); font-weight: 600; font-size: 13px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-family: inherit; }
.tab.active { background: var(--surface-1); color: var(--text-1); box-shadow: var(--shadow); }
.tabpane[hidden] { display: none !important; }
.trip-set, .trip-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.trip-set .sup-btn { margin-top: 0; padding: 7px 11px; font-size: 12.5px; }
.chip-btn { font-size: 11.5px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  border-radius: 999px; padding: 5px 10px; cursor: pointer; font-family: inherit; }
.chip-btn:hover { border-color: var(--accent); color: var(--text-1); }
.trip-status { margin-top: 10px; min-height: 18px; }
.trip-results { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.trip-results .mode-card.best { grid-column: 1 / -1; }
.mode-card .mc-h em { white-space: normal; text-align: right; line-height: 1.15; }
@media (max-width: 1100px) { .trip-results { grid-template-columns: 1fr; } }
.mode-card { text-align: left; width: 100%; border: 1px solid var(--border); border-left: 4px solid var(--mc, var(--accent));
  background: var(--surface-2); border-radius: 12px; padding: 10px 12px; cursor: pointer; font-family: inherit; color: var(--text-1); }
.mode-card:hover { border-color: var(--border-strong); }
.mode-card.sel { border-color: var(--mc); box-shadow: 0 0 0 2px color-mix(in srgb, var(--mc) 35%, transparent); }
.mc-h { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.mc-h em { margin-left: auto; font-style: normal; font-size: 10.5px; font-weight: 700; color: var(--good); text-transform: uppercase; letter-spacing: .04em; }
.mc-ic { font-size: 16px; }
.mc-time { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0; }
.mc-det { font-size: 11.5px; color: var(--muted); }
.mc-kv { display: flex; gap: 12px; font-size: 11.5px; color: var(--text-2); margin-top: 6px; flex-wrap: wrap; }
.mc-kv b { color: var(--text-1); }
.veh-tip { position: absolute; z-index: 1300; pointer-events: none; transform: translate(-50%, -140%);
  background: var(--text-1); color: var(--surface-1); padding: 6px 9px; border-radius: 8px; font-size: 12px; white-space: nowrap; box-shadow: var(--shadow); }
.veh-tip span { display: block; opacity: .75; font-size: 11px; }
.veh-tip i { font-style: normal; color: #ff9b9b; }
.od-mk { background: none; border: none; }
.od-mk span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-size: 15px;
  background: var(--surface-1); border: 2.5px solid var(--accent); box-shadow: var(--shadow); }
.od-mk .od-A { border-color: #2f9e6e; } .od-mk .od-B { border-color: #eb6834; }
.leg .sw.traf { background: repeating-linear-gradient(90deg, #2f9e6e 0 4px, #e0a300 4px 8px, #e34948 8px 12px); }
/* leyenda como interruptores: estado visible, sin tachado ambiguo */
button.leg { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px 4px 8px;
  font: inherit; font-size: 12px; color: var(--text-1); cursor: pointer; }
button.leg::before { content: "✓"; font-size: 10px; margin-right: 5px; color: var(--accent); font-weight: 700; }
button.leg:hover { border-color: var(--accent); }
button.leg.off { opacity: .55; text-decoration: none; color: var(--muted); border-style: dashed; }
button.leg.off::before { content: "○"; color: var(--muted); }
button.leg.off .sw { opacity: .35; }
.leg-reset, button.leg-reset { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.leg-reset::before, button.leg-reset::before { content: "↺"; color: #fff; }
.hint.warn { color: var(--gold); font-weight: 600; }

/* ---------- Banner de cookies ---------- */
.cookie { position: fixed; left: 16px; bottom: 16px; z-index: 90; max-width: 420px;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,.35); padding: 14px 16px; }
.cookie p { margin: 0 0 10px; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.cookie p b { color: var(--text-1); }
.cookie a { color: var(--accent-ink); }
.cookie-actions { display: flex; gap: 8px; justify-content: flex-end; }
.ck-btn { cursor: pointer; border: 1px solid var(--border-strong); background: var(--accent); color: #fff;
  border-radius: 9px; padding: 8px 14px; font-size: 13px; font-weight: 600; font-family: inherit; }
.ck-btn:hover { background: var(--accent-ink); }
.ck-btn.ghost { background: transparent; color: var(--text-1); }
.ck-btn.ghost:hover { background: var(--surface-2); }
@media (max-width: 560px) { .cookie { left: 12px; right: 12px; bottom: 12px; max-width: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .main { margin-left: 0; }
  .mtopbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 55;
    padding: 10px 16px; background: color-mix(in srgb, var(--surface-1) 92%, transparent);
    backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
  .mtopbar b { font-size: 15px; }
  .hamb { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--border);
    background: var(--surface-1); color: var(--text-1); border-radius: 9px; cursor: pointer; }
  .hamb svg { width: 20px; height: 20px; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; z-index: 59; background: rgba(0,0,0,.45); }
  .wrap { padding: 0 16px; }
  .twin { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .mapcard { min-height: 420px; }
  .sources { columns: 1; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sidebar { transition: none; }
  .msg .typing i { animation: none; }
}

/* ============================================================
   v2 — identidad "señalética de transporte"
   Barlow Condensed (títulos/cifras) + Barlow (texto). Asfalto azul-gris,
   acentos = colores reales de las líneas; franja por sección con significado.
   ============================================================ */
:root {
  --plane:#F3F2ED; --surface-1:#FFFFFF; --surface-2:#F7F6F1;
  --text-1:#14181C; --text-2:#4B535B; --muted:#7C848C;
  --grid:#E3E2DB; --axis:#CDCCC4; --border:rgba(20,24,28,.10); --border-strong:rgba(20,24,28,.18);
  --shadow:none;
  --accent:#0B7FC2; --accent-ink:#0A6AA3; --gold:#C98500;
  --tone-l1:#2E7D32; --tone-met:#0B7FC2; --tone-red:#C8102E; --tone-gold:#C98500; --tone-purple:#7B2D8E; --tone-ink:#4B535B;
  --map-bg:#E9ECEA;
  --font-display:"Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body:"Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) {
  --plane:#0E1115; --surface-1:#161B21; --surface-2:#1C222A;
  --text-1:#F2F1EC; --text-2:#B7BCC2; --muted:#848C95;
  --grid:#262D35; --axis:#333B44; --border:rgba(242,241,236,.10); --border-strong:rgba(242,241,236,.20);
  --shadow:none; --accent:#22B3F0; --accent-ink:#7FD3F7; --gold:#F2A900;
  --tone-l1:#43A047; --tone-met:#22B3F0; --tone-red:#F0334F; --tone-gold:#F2A900; --tone-purple:#B06BC6; --tone-ink:#B7BCC2;
  --map-bg:#12161B; --station:#12161B;
} }
:root[data-theme="dark"] {
  --plane:#0E1115; --surface-1:#161B21; --surface-2:#1C222A;
  --text-1:#F2F1EC; --text-2:#B7BCC2; --muted:#848C95;
  --grid:#262D35; --axis:#333B44; --border:rgba(242,241,236,.10); --border-strong:rgba(242,241,236,.20);
  --shadow:none; --accent:#22B3F0; --accent-ink:#7FD3F7; --gold:#F2A900;
  --tone-l1:#43A047; --tone-met:#22B3F0; --tone-red:#F0334F; --tone-gold:#F2A900; --tone-purple:#B06BC6; --tone-ink:#B7BCC2;
  --map-bg:#12161B; --station:#12161B;
}
body { font-family: var(--font-body); font-size: 15px; }
h1, h2, h3, .sec-title, .hero-head h1 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0; }
.kpi .v, .stat .v, .map-clock .t, .mc-time, .ts-big, .sup-num, .tl-item .y { font-family: var(--font-display); font-weight: 700; letter-spacing: 0; }
.kpi .v { font-size: clamp(30px, 3.6vw, 40px); line-height: 1; }
.stat .v { font-size: 26px; }
.map-clock .t { font-size: 30px; }
.sec-title { font-size: clamp(30px, 4vw, 46px); line-height: 1.02; max-width: 22ch; }
.sec-sub { font-size: 16px; line-height: 1.55; }
.hero-head h1 { font-size: clamp(40px, 6.2vw, 76px); line-height: .96; max-width: 15ch; font-weight: 800; }
.hero-head p { font-size: 17px; }
.hero-head { margin-bottom: 22px; }

/* franja por sección: el color señala el dominio de datos de la sección */
section[data-tone="l1"] { --tone: var(--tone-l1); } section[data-tone="met"] { --tone: var(--tone-met); }
section[data-tone="red"] { --tone: var(--tone-red); } section[data-tone="gold"] { --tone: var(--tone-gold); }
section[data-tone="purple"] { --tone: var(--tone-purple); } section[data-tone="ink"], section { --tone: var(--tone-ink); }
.eyebrow { display: flex; align-items: center; gap: 10px; text-transform: none; letter-spacing: 0;
  font: 600 15px/1 var(--font-display); color: var(--text-2); margin-bottom: 14px; }
.eyebrow::before { content: ""; width: 34px; height: 5px; border-radius: 3px; background: var(--tone); }

/* superficies: planas, con hairline; radio según jerarquía */
.card, .kpi, .mini, .src-group, .faq-item, .sup-card, .authority, .traffic-stat, .proj-callout, .stat { box-shadow: none; }
.card { border-radius: 18px; } .mapcard { border-radius: 20px; }
.kpi, .mini, .src-group, .faq-item, .sup-card { border-radius: 12px; }
.kpi { border-top: 3px solid var(--tone); }
.kpi .k { font-weight: 500; } .kpi .n { color: var(--muted); }
.authority { border-left-color: var(--tone); }
.brand .dot { box-shadow: none; background: linear-gradient(135deg, var(--tone-met), var(--tone-l1)); }
.brand b { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.side-nav a { font-size: 14px; }
.side-nav a.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text-1); }
.side-nav a.active svg { color: var(--accent); }
.play { background: var(--accent); } .play:hover { background: var(--accent-ink); }
.chip, .map-clock, .map-legend, .map-fit, .leaflet-control-zoom a { backdrop-filter: blur(10px); }
.leg { font-family: var(--font-body); }
.tab.active { box-shadow: none; }
.mode-card.best { background: color-mix(in srgb, var(--mc) 10%, var(--surface-2)); }
.up { color: var(--gold); }
.ts-big { color: var(--gold); }
.traffic-stat { border-left-color: var(--gold); }
.badge { font-family: var(--font-display); font-size: 12.5px; }
.tl-item::before { border-color: var(--tone); }
.timeline::before { background: color-mix(in srgb, var(--tone) 40%, var(--grid)); }
footer { color: var(--muted); }

/* fotos: banda "la red, en la calle" y fondos tenues de sección */
.photos { padding: 18px 0 8px; }
.photo-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.photo-strip figure { margin: 0; position: relative; border-radius: 12px; overflow: hidden; background: var(--surface-2); aspect-ratio: 4 / 3; }
.photo-strip img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(.92) contrast(1.04); }
.photo-strip figcaption { position: absolute; inset: auto 0 0 0; padding: 26px 10px 8px; font-size: 12.5px; color: #fff;
  background: linear-gradient(to top, rgba(10,12,16,.82), rgba(10,12,16,0)); font-family: var(--font-display); font-weight: 600; letter-spacing: .01em; }
.photo-strip figcaption small { display: block; font-family: var(--font-body); font-weight: 400; font-size: 10.5px; opacity: .8; }
section.has-photo { position: relative; isolation: isolate; }
section.has-photo::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(to bottom, var(--plane) 0%, color-mix(in srgb, var(--plane) 55%, transparent) 40%, var(--plane) 100%), var(--photo);
  background-size: cover; background-position: center; opacity: .55; filter: saturate(.6); }
.leaflet-container { font-family: var(--font-body); }
@media (max-width: 900px) { .photo-strip { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .photo-strip { grid-template-columns: 1fr 1fr; gap: 8px; } .hero-head h1 { font-size: 40px; } }

/* ---------- Mobile: ajustes finos ---------- */
@media (max-width: 640px) {
  .hero { padding-top: 14px; }
  .hero-head h1 { font-size: clamp(34px, 11vw, 44px); }
  .hero-head p { font-size: 15px; }
  .mapcard { min-height: 62vh; }
  /* leyenda en una sola fila desplazable para no tapar el mapa */
  .map-legend { left: 8px; right: 8px; bottom: 8px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding: 7px 8px; gap: 6px; }
  .map-legend::-webkit-scrollbar { display: none; }
  button.leg { white-space: nowrap; flex: none; font-size: 11.5px; }
  .map-hud { right: 8px; top: 8px; gap: 6px; }
  .map-clock { padding: 5px 9px; } .map-clock .t { font-size: 22px; }
  .hud-chips { display: none; }                      /* el panel ya muestra estos datos */
  .map-fit { bottom: 56px; left: 8px; }
  .leaflet-control-zoom a { width: 32px; height: 32px; line-height: 32px; }
  .panel { padding: 14px; }
  .livestats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 9px 10px; } .stat .v { font-size: 22px; }
  .trip-results { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .v { font-size: 28px; }
  .traffic-stat { flex-direction: column; align-items: flex-start; gap: 8px; }
  .ts-big { font-size: 44px; }
  .chart-holder { height: 230px; } .chart-holder.tall { height: 260px; }
  #secMap { height: 260px; }
  .photo-strip { grid-template-columns: 1fr 1fr; gap: 8px; }
  .photo-strip figcaption { font-size: 11.5px; padding: 22px 8px 6px; }
  .sources { columns: 1; }
  .chat-panel { right: 10px; left: 10px; width: auto; bottom: 84px; height: min(70vh, 520px); }
  .chat-fab { right: 14px; bottom: 14px; width: 52px; height: 52px; }
  .cookie { left: 10px; right: 10px; bottom: 74px; }  /* no tapa el botón del chat */
  .faq-item summary { font-size: 14px; padding: 12px 14px; }
  .sec-title { font-size: clamp(26px, 8vw, 34px); }
}
@media (max-width: 400px) {
  .kpis { grid-template-columns: 1fr; }
  .livestats { grid-template-columns: 1fr 1fr; }
  .trip-set .sup-btn { padding: 7px 9px; font-size: 12px; }
}
/* touch: tooltips de hover no existen; que el toque abra la ficha */
@media (hover: none) { .veh-tip { display: none !important; } }
