:root {
  color-scheme: dark;
  --bg: #0e0f11;
  --surface-1: #17181a;
  --surface-2: #1f2023;
  --surface-3: #2a2b2f;
  --border: #2e2f33;
  --grid: #26272b;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8e86;
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, .16);
  /* estado (fijo): puntual / leve / retrasado / grave */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --nodata: #77766f;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text-primary); font-size: 13px; line-height: 1.4; min-height: 100vh; }
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--text-muted); }
.num, td.num, .tnum { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- barra superior */
.topbar {
  display: flex; align-items: center; gap: 20px; padding: 10px 18px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1200;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand svg { width: 30px; height: 30px; color: var(--accent); background: var(--surface-2); border-radius: 8px; padding: 3px; flex: none; }
.brand strong { font-size: 16px; letter-spacing: .06em; margin-right: 8px; }
.brand span { color: var(--text-secondary); }
.badge-demo { background: rgba(250, 178, 25, .14); color: var(--warning); border: 1px solid rgba(250, 178, 25, .45); border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600; letter-spacing: .08em; }
.badge-demo.rec { background: rgba(208, 59, 59, .14); color: #f08a8a; border-color: rgba(208, 59, 59, .45); }
.feeds { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.feed { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
.feed i { width: 8px; height: 8px; border-radius: 50%; background: var(--nodata); }
.feed.ok i { background: var(--good); }
.feed.warn i { background: var(--warning); }
.feed.bad i { background: var(--critical); }
.top-right { display: flex; align-items: center; gap: 14px; }
.operator { color: var(--text-muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.operator input { width: 110px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); cursor: pointer; display: grid; place-items: center; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .wave { display: none; }
.icon-btn[aria-pressed="true"] { color: var(--text-primary); border-color: var(--accent); }
.icon-btn[aria-pressed="true"] .wave { display: inline; }
.icon-btn[aria-pressed="true"] .mute { display: none; }
.clock { text-align: right; font-variant-numeric: tabular-nums; }
.clock span { font-size: 20px; font-weight: 600; letter-spacing: .02em; display: block; line-height: 1.1; }
.clock small { color: var(--text-muted); font-size: 11px; }

/* ---------------------------------------------------------------- aviso de sitio de pruebas */
.trial { display: flex; align-items: center; gap: 10px; margin: 10px 18px 0; padding: 7px 12px; border-radius: 8px; background: rgba(57, 135, 229, .10); border: 1px solid rgba(57, 135, 229, .35); color: var(--text-secondary); font-size: 12.5px; }
.trial strong { color: var(--text-primary); white-space: nowrap; }
.trial-x { margin-left: auto; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 2px 6px; }
.trial-x:hover { color: var(--text-primary); }
@media (max-width: 640px) { .trial { margin: 8px 12px 0; } }

/* ---------------------------------------------------------------- filtros */
.filters { display: flex; align-items: center; gap: 14px; padding: 10px 18px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.scope { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 12px; }
.scope select { background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; font: inherit; font-size: 13px; max-width: 230px; }
#pais { max-width: 150px; }
.scope.on select { border-color: var(--accent); background: var(--accent-soft); }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); cursor: pointer; }
.chip b { font-weight: 600; color: var(--text-primary); }
.chip small { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text-primary); }
.chip:focus-visible, .seg button:focus-visible, .tabs button:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.search { position: relative; }
.search svg { position: absolute; left: 9px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); color: var(--text-muted); }
.search input { width: 220px; padding: 6px 10px 6px 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); }
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); cursor: pointer; }
.toggle input { accent-color: var(--accent); }

/* ---------------------------------------------------------------- KPIs */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; padding: 0 18px 12px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 14px; min-width: 0; }
.kpi h3 { margin: 0 0 4px; font-size: 11.5px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v { font-size: 26px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-left: 2px; }
.kpi .s { color: var(--text-secondary); font-size: 12px; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .delta-good { color: #3fbf3f; }
.kpi .delta-bad { color: var(--serious); }
.kpi.alarm { border-color: rgba(208, 59, 59, .6); box-shadow: inset 3px 0 0 var(--critical); }

/* ---------------------------------------------------------------- rejilla */
.grid {
  display: grid; gap: 10px; padding: 0 18px 14px;
  grid-template-columns: minmax(0, 1fr) 400px;
  grid-template-areas: "map alerts" "tabs alerts";
  grid-template-rows: 58vh auto;
}
.panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.map-panel { grid-area: map; position: relative; overflow: hidden; }
.alerts { grid-area: alerts; display: flex; flex-direction: column; max-height: calc(58vh + 10px + 520px); position: sticky; top: 64px; align-self: start; }
.tabs-panel { grid-area: tabs; min-height: 420px; }
#map { position: absolute; inset: 0; background: #121315; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.panel-head h2 { white-space: nowrap; }
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.count { display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px; text-align: center; border-radius: 999px; background: var(--surface-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 4px 10px; color: var(--text-secondary); cursor: pointer; font-size: 12px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--surface-3); color: var(--text-primary); }

/* ---------------------------------------------------------------- mapa */
.legend { position: absolute; left: 12px; bottom: 12px; z-index: 500; background: rgba(23, 24, 26, .92); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #121315; box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
.legend .dot-key { background: var(--text-secondary); }
.legend .trail-key { width: 18px; height: 4px; border: 0; border-radius: 2px; box-shadow: none; background: linear-gradient(90deg, rgba(240,239,236,.05), rgba(240,239,236,.7)); }
.legend .ring { background: transparent; border: 2px solid var(--critical); box-shadow: none; }
.map-note { position: absolute; right: 12px; bottom: 12px; z-index: 500; font-size: 11px; color: var(--text-muted); background: rgba(23,24,26,.85); padding: 3px 8px; border-radius: 6px; }
.leaflet-container { font: inherit; background: #121315; }
.leaflet-control-attribution { background: rgba(23,24,26,.75) !important; color: var(--text-muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--text-secondary) !important; }
.rail-gray { filter: grayscale(1) brightness(1.15); }
.osm-dark { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.6); }
.leaflet-control-layers { background: var(--surface-2) !important; color: var(--text-primary) !important; border: 1px solid var(--border) !important; border-radius: 8px !important; }
.leaflet-control-layers-toggle { filter: invert(1) brightness(.9); }
.leaflet-control-zoom a { background: var(--surface-2) !important; color: var(--text-primary) !important; border-color: var(--border) !important; }
.leaflet-tooltip.tt { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.45); padding: 7px 10px; font-size: 12px; }
.leaflet-tooltip.tt::before { display: none; }
.tt strong { font-size: 14px; }
.tt .tv { font-weight: 600; font-variant-numeric: tabular-nums; }
.tt .tl { color: var(--text-secondary); }
.leaflet-tooltip.lbl { background: transparent; border: 0; box-shadow: none; color: var(--text-primary); font-weight: 600; font-size: 11px; padding: 0 4px; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.leaflet-tooltip.lbl::before { display: none; }
/* iconos de tren */
.leaflet-div-icon.tm-wrap { background: transparent; border: 0; }
.tm { width: 24px; height: 24px; position: relative; cursor: pointer; }
.tm-svg { width: 24px; height: 24px; display: block; overflow: visible; transform: rotate(var(--rot, 0deg)); transition: transform .8s ease; }
.tm-arrow { fill: var(--c); stroke: #0e0f11; stroke-width: 1.6; stroke-linejoin: round; }
.tm-dot { fill: var(--c); stroke: #0e0f11; stroke-width: 2; display: none; }
.tm.nohdg .tm-arrow { display: none; }
.tm.nohdg .tm-dot { display: inline; }
.tm.sel .tm-svg { transform: rotate(var(--rot, 0deg)) scale(1.3); }
.tm.sel .tm-arrow, .tm.sel .tm-dot { stroke: #f0efec; stroke-width: 1.8; }
.tm.ghost { opacity: .45; }
.tm:hover .tm-arrow, .tm:hover .tm-dot { stroke: #f0efec; }
.tm-lbl { position: absolute; left: 21px; top: 4px; font-size: 11px; font-weight: 600; color: var(--text-primary); text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 2px #000; white-space: nowrap; pointer-events: none; display: none; }
#map.zoom-hi .tm-lbl { display: block; }
.legend .lg-arrow { width: 12px; height: 12px; fill: var(--text-secondary); transform: rotate(45deg); }
.map-tools a { display: grid !important; place-items: center; background: var(--surface-2) !important; color: var(--text-primary) !important; border-color: var(--border) !important; }
.map-tools svg { width: 16px; height: 16px; }
.map-panel.full { position: fixed; inset: 0; z-index: 1450; border-radius: 0; border: 0; }
body.no-scroll { overflow: hidden; }
.pulse { animation: pulse 1.6s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 0% { opacity: .95; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.6); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; opacity: .8; } }

/* ---------------------------------------------------------------- alertas */
.alert-list { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-height: 120px; }
.alert { text-align: left; width: 100%; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 9px 10px 9px 12px; cursor: pointer; position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; }
.alert::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--sev, var(--nodata)); }
.alert:hover { border-color: #44454a; }
.alert.ack { opacity: .72; }
.alert.new { animation: flash 1.2s ease-out 2; }
@keyframes flash { 0% { background: rgba(208, 59, 59, .35); } 100% { background: var(--surface-2); } }
.alert .ico { grid-row: span 2; width: 22px; height: 22px; color: var(--sev); }
.alert .t { font-weight: 600; font-size: 12.5px; line-height: 1.3; }
.alert .m { grid-column: 2 / 4; color: var(--text-secondary); font-size: 11.5px; display: flex; gap: 8px; flex-wrap: wrap; }
.alert .age { color: var(--text-muted); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sev-label { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-primary); }
.sev-label i { width: 8px; height: 8px; border-radius: 2px; background: var(--sev); }
.empty { color: var(--text-muted); text-align: center; padding: 30px 10px; }
.empty svg { width: 28px; height: 28px; display: block; margin: 0 auto 8px; color: var(--good); }

/* ---------------------------------------------------------------- pestañas */
.tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: transparent; color: var(--text-secondary); padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs button.on { color: var(--text-primary); border-bottom-color: var(--accent); }
.tab { padding: 10px 12px 14px; }
.table-wrap { overflow: auto; max-height: 520px; border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th { position: sticky; top: 0; background: var(--surface-1); text-align: left; font-weight: 500; color: var(--text-muted); padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: default; user-select: none; z-index: 1; }
table.data th.sort { cursor: pointer; }
table.data th.sort:hover { color: var(--text-primary); }
table.data th .arr { opacity: .8; margin-left: 3px; }
table.data td { padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data td.wrap { white-space: normal; }
table.data td.rel { min-width: 220px; max-width: 360px; }
table.data td.nxt { min-width: 140px; max-width: 220px; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tr.sel td { background: var(--accent-soft); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data.compact td { padding: 5px 6px; }
.dly { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-weight: 600; }
.dly i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.prod { display: inline-block; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-secondary); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.st { color: var(--text-secondary); }
.st.hi { color: var(--text-primary); font-weight: 600; }
.st.bad { color: var(--serious); font-weight: 600; }
.station-bar, .analysis-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.station-bar input { width: 340px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.footnote { color: var(--text-muted); font-size: 11.5px; margin: 8px 2px 0; }
code { font-family: var(--mono); font-size: 11px; background: var(--surface-3); padding: 0 4px; border-radius: 4px; }

/* ---------------------------------------------------------------- análisis */
.charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.chart-card, .rank-card { margin: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.chart-card figcaption, .rank-card h3 { font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.chart-card small, .rank-card small { color: var(--text-muted); font-weight: 400; margin-left: 6px; }
.chart { height: 190px; position: relative; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .axis text { fill: var(--text-muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart .gridl { stroke: var(--grid); stroke-width: 1; }
.chart .ref { stroke: var(--text-muted); stroke-dasharray: 3 3; stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: .08; }
.chart .xh { stroke: var(--text-secondary); stroke-width: 1; }
.chart .dot { fill: var(--accent); stroke: var(--surface-2); stroke-width: 2; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-size: 11.5px; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.4); transform: translate(-50%, -110%); z-index: 3; }
.chart-tip b { font-variant-numeric: tabular-nums; font-size: 13px; }
.chart-tip span { color: var(--text-muted); display: block; }
.rank-grid { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, 1.25fr) minmax(0, 1.15fr); gap: 10px; margin-top: 10px; }
.bars { display: flex; flex-direction: column; gap: 9px; margin-top: 6px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 44px; align-items: center; gap: 8px; font-size: 12px; }
.bar-row .lab { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .track { height: 14px; background: var(--surface-3); border-radius: 4px; position: relative; }
.bar-row .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--accent); }
.bar-row .val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-row small { color: var(--text-muted); grid-column: 2 / 4; margin-top: -6px; font-size: 11px; }

/* ---------------------------------------------------------------- drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100vw; z-index: 1500; background: var(--surface-1); border-left: 1px solid var(--border); box-shadow: -14px 0 40px rgba(0,0,0,.45); overflow-y: auto; }
.drawer-inner { padding: 16px 18px 30px; }
.dhead { display: flex; align-items: flex-start; gap: 10px; }
.dhead h2 { margin: 0; font-size: 20px; }
.dhead .x { margin-left: auto; }
.route { color: var(--text-secondary); margin: 4px 0 12px; font-size: 13.5px; }
.bigdelay { display: flex; align-items: baseline; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 12px; }
.bigdelay .v { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-bottom: 14px; }
.facts div { min-width: 0; }
.facts dt { color: var(--text-muted); font-size: 11.5px; }
.facts dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer h3 { font-size: 13px; margin: 18px 0 8px; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.itin { list-style: none; margin: 0; padding: 0; position: relative; }
.itin li { display: grid; grid-template-columns: 18px 1fr auto auto; gap: 8px; align-items: center; padding: 5px 0; position: relative; font-variant-numeric: tabular-nums; }
.itin li::before { content: ""; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.itin li:first-child::before { top: 50%; }
.itin li:last-child::before { bottom: 50%; }
.itin .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-1); border: 2px solid var(--text-muted); z-index: 1; margin-left: 4px; }
.itin .passed { color: var(--text-muted); }
.itin .passed .dot { background: var(--text-muted); }
.itin .next .dot, .itin .current .dot { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.itin .next .nm, .itin .current .nm { font-weight: 600; }
.itin .sched { color: var(--text-muted); }
.itin .pred { font-weight: 600; min-width: 40px; text-align: right; }
.itin .skip .nm { text-decoration: line-through; color: var(--text-muted); }

/* ---------------------------------------------------------------- botones / modal */
.btn { border: 1px solid var(--border); background: var(--surface-2); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: #4a4b50; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: #f08a8a; }
.btn[disabled] { opacity: .45; cursor: default; }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 2000; display: grid; place-items: center; padding: 16px; }
.modal { width: 640px; max-width: 100%; max-height: 88vh; overflow-y: auto; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal h2 { margin: 6px 0 6px; font-size: 17px; line-height: 1.3; }
.modal p { color: var(--text-secondary); margin: 0 0 10px; }
.modal .meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }
.modal .actions { display: flex; gap: 8px; margin: 14px 0 4px; flex-wrap: wrap; }
.modal textarea { width: 100%; min-height: 60px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; color: var(--text-primary); font: inherit; resize: vertical; }
.log { list-style: none; padding: 0; margin: 10px 0 0; border-left: 2px solid var(--border); }
.log li { padding: 4px 0 4px 12px; position: relative; font-size: 12.5px; color: var(--text-secondary); }
.log li time { color: var(--text-muted); margin-right: 8px; font-variant-numeric: tabular-nums; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; text-underline-offset: 2px; }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 2500; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--sev, var(--accent)); border-radius: 8px; padding: 10px 12px; width: 340px; box-shadow: 0 10px 30px rgba(0,0,0,.45); font-size: 12.5px; cursor: pointer; }
.toast b { display: block; margin-bottom: 2px; }

.foot { color: var(--text-muted); font-size: 11px; padding: 0 18px 16px; }

/* ---------------------------------------------------------------- pantallas panorámicas */
@media (min-aspect-ratio: 21/10) and (min-width: 2000px) {
  .grid {
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr) 420px;
    grid-template-areas: "map tabs alerts";
    grid-template-rows: calc(100vh - 300px);
  }
  .tabs-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
  .tabs-panel .tab { flex: 1; min-height: 0; overflow: auto; }
  .tabs-panel .table-wrap { max-height: none; }
  .alerts { position: static; max-height: none; height: 100%; }
  .charts, .rank-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .charts, .rank-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1050px) {
  .grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "map" "alerts" "tabs"; grid-template-rows: 55vh auto auto; }
  .alerts { position: static; max-height: 420px; }
  .feeds { display: none; }
}
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; gap: 10px; }
  .brand span, .operator { display: none; }
  .filters, .kpis, .grid, .foot { padding-left: 12px; padding-right: 12px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search input, .station-bar input { width: 100%; }
  .search { flex: 1 1 100%; }
  .drawer { width: 100vw; }
}
.server-warn { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 3000; max-width: min(860px, 92vw); background: rgba(208, 59, 59, .96); color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 600; font-size: 13px; box-shadow: 0 6px 24px rgba(0, 0, 0, .4); }

/* Ventana de comprobación obligatoria ante un posible alcance (alerta.js) */
.safety-alert { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 4000; width: min(620px, 94vw); background: #1d1416; color: var(--text-primary); border: 2px solid var(--sev); border-radius: 12px; padding: 14px 16px 12px; box-shadow: 0 0 0 4px rgba(0,0,0,.35), 0 12px 48px rgba(0,0,0,.6), 0 0 32px color-mix(in srgb, var(--sev) 45%, transparent); }
.safety-alert.crit { animation: sa-pulse 1.2s ease-in-out infinite; }
.safety-alert.flash { animation: sa-flash .5s ease-out 4; }
@keyframes sa-pulse { 50% { box-shadow: 0 0 0 4px rgba(0,0,0,.35), 0 12px 48px rgba(0,0,0,.6), 0 0 52px var(--sev); } }
@keyframes sa-flash { 50% { background: color-mix(in srgb, var(--sev) 35%, #1d1416); } }
.sa-head { display: flex; align-items: center; gap: 10px; color: var(--sev); letter-spacing: .06em; font-size: 13px; }
.sa-ico { font-size: 20px; line-height: 1; }
.sa-badge { font-size: 11px; color: var(--text-secondary); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; letter-spacing: .04em; }
.sa-id { margin-left: auto; color: var(--text-muted); font-size: 11px; letter-spacing: 0; }
.sa-title { font-size: 17px; font-weight: 600; margin: 8px 0 10px; line-height: 1.3; }
.sa-facts { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 8px; }
.sa-fact { display: flex; flex-direction: column; line-height: 1.15; }
.sa-fact b { font-size: 18px; font-variant-numeric: tabular-nums; }
.sa-fact.big b { font-size: 28px; color: var(--sev); }
.sa-fact.bad b { color: #f08a8a; }
.sa-fact span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.sa-detail { color: var(--text-secondary); font-size: 13px; margin: 6px 0; }
.sa-note { color: var(--text-muted); font-size: 12px; margin: 4px 0 10px; }
.sa-actions { display: flex; gap: 8px; flex-wrap: wrap; }
body.safety-on::after { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 3500; box-shadow: inset 0 0 0 4px rgba(208, 59, 59, .55); }
/* banner del muro (sin acciones: se comprueba en la vista de operador) */
.wall-safety { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 4000; max-width: 92vw; display: flex; gap: 14px; align-items: center; padding: 10px 18px; border-radius: 10px; background: #1d1416; border: 2px solid var(--sev); font-weight: 600; box-shadow: 0 8px 36px rgba(0,0,0,.6); }
.wall-safety .t { font-size: 15px; }
.wall-safety .c { font-size: 24px; color: var(--sev); font-variant-numeric: tabular-nums; }
.wall-safety small { color: var(--text-muted); font-weight: 400; }
.alert .m .chk { color: #fff; background: var(--sev); border-radius: 4px; padding: 0 5px; font-weight: 700; letter-spacing: .05em; }
