@font-face { font-family: Inter; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: Inter; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: Sora; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/sora-500.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/ibm-plex-mono-400.woff2') format('woff2'); }

:root {
  --grafito: #23262B;
  --papel: #FAF9F7;
  --senal: #6B4E8E;
  --via: #E4DCEF;
  --anden: #9FC9C4;
  --muted: #61616B;
  --linea: #dedbe1;
  --mono: 'IBM Plex Mono', monospace;
  font-family: Inter, sans-serif;
  color: var(--grafito);
  background: var(--papel);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, .app-shell, #map { width: 100%; height: 100%; margin: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--senal); outline-offset: 4px; }
.app-shell { position: relative; overflow: hidden; }
#map { position: absolute; inset: 0; }
.dashboard {
  position: absolute; z-index: 2; top: 24px; left: 24px;
  width: min(490px, calc(100vw - 48px)); padding: 0 25px 20px;
  background: var(--papel); border: 1px solid var(--linea); border-radius: 5px;
  box-shadow: 0 8px 32px #23262b14;
  max-height: calc(100dvh - 110px); overflow-y: auto;
  transition: max-height .3s cubic-bezier(.2,.7,.2,1), padding-bottom .3s ease, box-shadow .3s ease;
}
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 -25px; padding: 14px 25px; background: #e4dcef55; border-bottom: 1px solid var(--linea); }
.brand-link { display: inline-flex; flex: none; border-radius: 2px; }
.brand-logo { display: block; width: 160px; height: 40px; object-fit: contain; }
.brand-actions { display: flex; align-items: center; gap: 13px; }
.heading-row { padding-top: 21px; }
.heading-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font: 500 26px/1.25 Sora, sans-serif; letter-spacing: -.045em; }
.heading-title-row h1 { min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.period { color: var(--senal); }
.live-pill { display: flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--grafito); font: 400 9px/1.5 var(--mono); }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--senal); box-shadow: 0 0 0 4px var(--via); }
.panel-toggle { display: grid; place-items: center; width: 32px; height: 32px; flex: none; padding: 0; color: var(--senal); background: transparent; border: 1px solid transparent; border-radius: 3px; cursor: pointer; transition: color .18s ease, background .18s ease, border-color .18s ease, transform .25s ease; }
.panel-toggle:hover { color: var(--grafito); background: var(--via); border-color: #6b4e8e24; }
.panel-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s cubic-bezier(.2,.7,.2,1); }
.dashboard > #dashboard-content { opacity: 1; transform: translateY(0); transition: opacity .2s ease .06s, transform .25s cubic-bezier(.2,.7,.2,1); }
.dashboard.is-collapsed { max-height: 72px; padding-bottom: 0; overflow: hidden; box-shadow: 0 5px 20px #23262b12; }
.dashboard.is-collapsed > #dashboard-content { opacity: 0; transform: translateY(-7px); transition: opacity .13s ease, transform .22s cubic-bezier(.2,.7,.2,1); }
.dashboard.is-collapsed .panel-toggle svg { transform: rotate(180deg); }
.dashboard.is-collapsed .brand-row { border-bottom-color: transparent; background: #e4dcef75; }
.summary-row { display: grid; grid-template-columns: 1fr 1fr 126px; border-bottom: 1px solid var(--linea); padding: 16px 0; }
.stat { min-width: 0; display: flex; align-items: center; gap: 9px; border-right: 1px solid var(--linea); }
.stat-icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; color: var(--senal); }
.bus-stat .stat-icon { background: var(--anden); color: var(--grafito); border-radius: 3px; padding: 2px; }
.stat strong { display: block; font: 400 25px/1 var(--mono); font-variant-numeric: tabular-nums; }
.stat small { display: block; margin-top: 7px; font-size: 10px; color: var(--muted); }
.bus-stat { padding-left: 14px; }
.updated { padding-left: 14px; display: flex; flex-direction: column; justify-content: center; }
.updated span { font: 400 8px/1.5 var(--mono); color: var(--muted); }
.updated strong { margin-top: 7px; font: 400 14px/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.toolbar { display: flex; gap: 10px; margin-top: 16px; }
.filters { display: flex; flex: 1; background: var(--via); padding: 3px; border-radius: 3px; }
.filter, .refresh { border: 0; cursor: pointer; font: 400 10px/1.4 var(--mono); transition: background .15s, color .15s; }
.filter { flex: 1; padding: 10px 5px; border-radius: 2px; color: var(--senal); background: transparent; }
.filter.active { color: var(--papel); background: var(--senal); }
.filter:hover:not(.active) { background: #6b4e8e14; }
.refresh { padding: 0 12px; border-radius: 3px; background: var(--papel); border: 1px solid var(--senal); color: var(--senal); white-space: nowrap; }
.refresh:hover { background: var(--via); }
.refresh:disabled { opacity: .55; cursor: wait; }
.refresh span { font-size: 18px; vertical-align: -1px; margin-right: 3px; }
.cercanias-legend { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--linea); }
.nucleus-picker { display: flex; align-items: center; flex: none; min-width: 0; }
.nucleus-picker select { width: 132px; max-width: 32vw; min-width: 0; padding: 8px 28px 8px 10px; border: 1px solid var(--linea); border-radius: 3px; appearance: none; background: var(--papel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%236B4E8E' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 9px center; color: var(--grafito); font: 500 12px/1.4 Inter, sans-serif; cursor: pointer; }
.nucleus-picker select:focus-visible { outline: 2px solid var(--senal); outline-offset: 2px; }
.network-heading { display: flex; align-items: center; justify-content: space-between; min-height: 22px; gap: 12px; font: 400 9px/1.4 var(--mono); color: var(--muted); }
.network-brand { display: flex; align-items: center; gap: 14px; }
.renfe-logo { display: block; flex: none; width: 92px; height: auto; }
.network-brand > span { padding-left: 14px; border-left: 1px solid var(--linea); }
.network-heading button { padding: 3px 0; background: none; border: 0; color: var(--senal); font: inherit; text-decoration: underline; cursor: pointer; }
.line-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.line-chip { min-width: 40px; min-height: 34px; padding: 6px 8px; border: 1px solid #23262b20; border-radius: 3px; background: var(--line-color); color: var(--line-ink); font: 500 12px/1.4 Inter, sans-serif; cursor: pointer; transition: opacity .15s; }
.line-chip.dimmed { opacity: .45; }
.line-chip:hover { opacity: 1; }
.line-chip[aria-pressed="true"] { outline: 2px solid var(--grafito); outline-offset: 2px; }
.network-status { min-height: 15px; margin: 10px 0 0; font-size: 10px; line-height: 1.5; color: var(--muted); }
.provider-row { display: flex; flex-wrap: wrap; gap: 9px 20px; margin-top: 17px; }
.provider { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 500; }
.provider-text { color: var(--muted); font-weight: 400; }
.status-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; }
.status-dot.ok { background: #397b69; }
.status-dot.empty, .status-dot.not_configured, .status-dot.neutral { background: #8c8b93; }
.status-dot.pending_authorization { background: #ad752b; }
.status-dot.unavailable { background: #ad752b; }
.status-dot.error, .status-dot.authentication_error, .status-dot.timeout, .status-dot.rate_limit, .status-dot.invalid_response { background: #b84c51; }
.notice { margin: 15px 0 0; padding: 10px 12px; border-left: 2px solid var(--senal); background: var(--via); color: var(--grafito); font-size: 11px; line-height: 1.55; }
.map-caption { position: absolute; z-index: 1; left: 24px; bottom: 30px; display: flex; align-items: center; gap: 9px; padding: 10px 12px; background: var(--papel); border: 1px solid var(--linea); border-radius: 3px; font: 400 9px/1.4 var(--mono); color: var(--muted); }
.caption-line { width: 16px; height: 2px; background: var(--senal); }
.map-legend { position: absolute; z-index: 1; right: 65px; bottom: 45px; display: flex; gap: 16px; padding: 11px 14px; background: var(--papel); border: 1px solid var(--linea); border-radius: 3px; font: 400 11px/1.5 var(--mono); }
.map-legend span { display: flex; align-items: center; gap: 7px; }
.legend-dot { width: 10px; height: 10px; display: inline-block; border-radius: 50%; }
.legend-dot.train { background: var(--papel); border: 2px solid var(--grafito); }
.legend-dot.bus { background: var(--anden); border: 1px solid var(--grafito); }
.maplibregl-popup { font-family: Inter, sans-serif; }
.maplibregl-popup-content { min-width: 205px; border-radius: 4px; padding: 17px; background: var(--papel); border-top: 3px solid var(--senal); box-shadow: 0 6px 24px #23262b20; }
.maplibregl-popup-close-button { font-size: 20px; right: 7px; top: 4px; color: var(--grafito); }
.popup-title { margin: 0 20px 6px 0; font: 500 20px/1.3 Sora, sans-serif; color: var(--senal); }
.popup-line-badge { display: inline-block; padding: 4px 10px; border-radius: 3px; font-size: 17px; }
.popup-subtitle { margin: 0 0 13px; font: 400 11px/1.4 var(--mono); color: var(--muted); }
.popup-row { display: flex; gap: 10px; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--linea); font-size: 11px; line-height: 1.5; }
.popup-row span { color: var(--muted); }
.popup-row strong { text-align: right; max-width: 140px; font-weight: 500; }
.maplibregl-ctrl-group { border-radius: 3px; background: var(--papel); }

@media (max-width: 580px) {
  .dashboard { top: 12px; left: 12px; width: calc(100vw - 24px); padding: 0 17px 15px; }
  .brand-row { margin: 0 -17px; padding: 8px 17px; }
  .dashboard.is-collapsed { max-height: 56px; }
  .brand-logo { width: 140px; height: 35px; }
  .heading-row { padding-top: 16px; }
  h1 { font-size: clamp(19px, 5.2vw, 25px); }
  .heading-title-row { align-items: flex-start; gap: 8px; }
  .heading-title-row h1 { font-size: clamp(19px, 5.2vw, 25px); }
  .nucleus-picker { padding-top: 1px; }
  .nucleus-picker select { width: 116px; padding: 7px 24px 7px 8px; font-size: 11px; }
  .live-pill { font-size: 8px; }
  .summary-row { grid-template-columns: 1fr 1fr 104px; padding: 12px 0; }
  .stat { gap: 6px; }
  .stat-icon { width: 20px; height: 20px; }
  .stat strong { font-size: 22px; }
  .stat small { font-size: 9px; }
  .bus-stat { padding-left: 9px; }
  .updated { padding-left: 9px; }
  .updated span { font-size: 7px; }
  .updated strong { font-size: 12px; }
  .toolbar { margin-top: 12px; gap: 7px; }
  .cercanias-legend { margin-top: 13px; padding-top: 10px; }
  .network-brand { gap: 10px; }
  .renfe-logo { width: 78px; }
  .network-brand > span { padding-left: 10px; font-size: 8px; }
  .line-filters { gap: 7px; }
  .line-chip { min-width: 42px; }
  .filter { font-size: 9px; padding: 10px 3px; }
  .refresh { font-size: 9px; padding: 0 8px; }
  .provider-row { margin-top: 13px; gap: 7px 14px; }
  .map-caption { display: none; }
  .map-legend { right: 54px; bottom: 60px; }
}
@media (max-width: 360px) {
  .summary-row { grid-template-columns: 1fr 1fr 94px; }
  .stat-icon { display: none; }
  .refresh { font-size: 8px; padding: 0 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .dashboard, .dashboard > #dashboard-content, .panel-toggle, .panel-toggle svg { transition: none; }
}
