/* SPDX-License-Identifier: GPL-3.0-or-later · Trenalia */
/* Análisis (puntualidad, tramos, oferta): ventana propia; hoja a pantalla completa en el móvil */
.an-modal { z-index: 2100; }
.an-box { position: relative; width: min(980px, 100%); max-height: min(92vh, 900px); display: flex; flex-direction: column; background: var(--modal-bg, var(--panel)); color: var(--text);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 64px var(--shadow); overflow: hidden; }
.an-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 6px; }
.an-head h2 { margin: 0; font-size: 19px; }
.an-x { position: static; }
.an-tabs { display: flex; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.an-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 10px; color: var(--muted); font: inherit; font-weight: 600; font-size: 14px; white-space: nowrap; cursor: pointer; }
.an-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--blue); }
.an-ctrl { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 18px 0; }
.an-ctrl[hidden] { display: none; }
.an-seg { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); }
.an-seg button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; padding: 6px 11px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.an-seg button[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px var(--shadow); }
.an-sel select { font: inherit; font-size: 13px; padding: 6px 28px 6px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.an-body { padding: 12px 18px 18px; overflow-y: auto; overscroll-behavior: contain; }
.an-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; font-weight: 700; }
.an-range { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.an-wait, .an-empty, .an-off { color: var(--muted); padding: 18px 0; }
.an-off { color: var(--text); background: var(--panel-2); border-radius: 10px; padding: 14px; }
.an-note { color: var(--faint, var(--muted)); font-size: 12.5px; line-height: 1.5; margin: 18px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
.an-demo { display: inline-block; font-size: 12px; font-weight: 700; color: var(--amber); border: 1px dashed var(--amber); border-radius: 6px; padding: 2px 8px; margin: 0 0 8px; }
.an-warn { background: color-mix(in srgb, var(--amber) 14%, transparent); border: 1px solid color-mix(in srgb, var(--amber) 45%, transparent); border-radius: 9px; padding: 8px 10px; font-size: 13px; }
.an-few { display: inline-block; font-size: 11px; font-weight: 700; color: var(--amber); border: 1px solid currentColor; border-radius: 999px; padding: 0 6px; margin-left: 4px; vertical-align: 1px; white-space: nowrap; }

/* KPIs */
.an-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.an-kpis > div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.an-kpis b { display: block; font: 700 26px/1.1 var(--mono); }
.an-kpis span { display: block; color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* Evolución semanal */
.an-trend { display: flex; gap: 6px; align-items: flex-end; height: 150px; padding: 4px 0; }
.an-trend .col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; height: 100%; }
.an-trend .v { font: 600 11px var(--mono); color: var(--muted); }
.an-trend .bar { flex: 1; width: 100%; max-width: 34px; display: flex; align-items: flex-end; background: var(--panel-2); border-radius: 6px 6px 2px 2px; margin: 3px 0; }
.an-trend .bar i { display: block; width: 100%; background: var(--blue); border-radius: 6px 6px 2px 2px; }
.an-trend .w { font-size: 10.5px; color: var(--muted); white-space: nowrap; }

/* Barras horizontales */
.an-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.an-bars { list-style: none; margin: 0; padding: 0; }
.an-bars li { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 54px; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 4px 0; font-size: 13px; }
.an-bars .lb { grid-row: 1 / 3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-bars .tr { height: 10px; background: var(--panel-2); border-radius: 5px; overflow: hidden; }
.an-bars .tr i { display: block; height: 100%; background: var(--blue); border-radius: 5px; }
.an-bars .vl { font: 600 12.5px var(--mono); text-align: right; }
.an-bars .nn { grid-column: 2 / 4; font-size: 11px; color: var(--muted); }
.an-bars li.nil { opacity: .55; }

/* Tramos */
.an-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.an-btn { background: var(--blue); color: var(--on-accent, #fff); border: 0; border-radius: 9px; padding: 8px 14px; font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer; }
.an-segs { margin: 6px 0 0; padding-left: 26px; }
.an-segs li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.an-segs .nm { font-weight: 600; font-size: 14px; }
.an-segs .tr { height: 8px; background: var(--panel-2); border-radius: 4px; margin: 5px 0 3px; overflow: hidden; }
.an-segs .tr i { display: block; height: 100%; border-radius: 4px; background: #e8710a; }
.an-segs.gain .tr i { background: #34a853; }
.an-segs .dt { font-size: 12.5px; color: var(--muted); }
.an-segs .dt b { color: var(--text); font-family: var(--mono); }

/* Leyenda de tramos en el mapa */
.an-chip { position: absolute; z-index: 800; left: 12px; bottom: 96px; display: flex; align-items: center; gap: 8px; max-width: calc(100% - 24px);
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 12px; box-shadow: 0 6px 18px var(--shadow); font-size: 12.5px; font-weight: 600; }
.an-chip .sw { width: 34px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #f2b600, #e8710a, #d93025); flex: none; }
.an-chip.gain .sw { background: linear-gradient(90deg, #34a853, #0f9d58); }
.an-chip button { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 16px; line-height: 1; cursor: pointer; flex: none; }

/* Oferta por corredor */
.op-renfe { background: #7c3aed; } .op-iryo { background: #dc2626; } .op-ouigo { background: #0891b2; } .op-otro { background: #64748b; }
.an-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; margin: 4px 0 8px; }
.an-legend span { display: inline-flex; align-items: center; gap: 6px; }
.an-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.an-corr { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 8px; background: var(--panel); }
.an-corr summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: minmax(150px, 30%) 96px 1fr; grid-template-rows: auto auto; gap: 2px 12px; align-items: center; padding: 10px 12px; }
.an-corr summary::-webkit-details-marker { display: none; }
.an-corr .nm { font-weight: 700; font-size: 14px; grid-row: 1 / 3; }
.an-corr .tp { font: 600 12.5px var(--mono); color: var(--muted); grid-row: 1 / 3; }
.an-corr .stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--panel-2); }
.an-corr .stack i { display: block; height: 100%; }
.an-corr .sh { font-size: 11.5px; color: var(--muted); }
.an-corr[open] summary { border-bottom: 1px solid var(--line); }
.an-corr-b { padding: 8px 12px 12px; font-size: 13px; }
.an-corr-b p { margin: 4px 0 8px; }
.an-prods { display: flex; flex-wrap: wrap; gap: 6px; }
.an-prods span { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; font-size: 12px; }
.an-hist { margin: 8px 0; }
.an-hist .hl { font-size: 12px; color: var(--muted); }
.an-hist .hb { display: flex; align-items: flex-end; gap: 2px; height: 46px; margin-top: 3px; }
.an-hist .hb i { flex: 1; background: var(--blue); border-radius: 2px 2px 0 0; min-height: 1px; opacity: .85; }
.an-hist .hx { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); }

@media (max-width: 760px) {
  .an-modal { padding: 0; place-items: stretch; }
  .an-box { width: 100%; max-height: none; height: 100dvh; border-radius: 0; border: 0; }
  .an-kpis { grid-template-columns: 1fr 1fr; }
  .an-kpis b { font-size: 22px; }
  .an-grid { grid-template-columns: 1fr; }
  .an-trend { height: 120px; gap: 3px; }
  .an-trend .w { font-size: 9.5px; }
  .an-corr summary { grid-template-columns: 1fr auto; }
  .an-corr .nm, .an-corr .tp { grid-row: auto; }
  .an-corr .stack, .an-corr .sh { grid-column: 1 / -1; }
  .an-chip { bottom: calc(var(--sheet-visible, 140px) + 12px); }
}
.an-head, .an-tabs, .an-ctrl { flex: none; }
/* Incidencias con impacto */
.an-hbars .tr i { background: var(--amber, #e8710a); }
.an-incs { list-style: decimal; margin: 6px 0 12px; padding-left: 22px; display: grid; gap: 8px; }
.an-incs li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.an-incs .nm { font-weight: 600; font-size: 14px; line-height: 1.3; }
.an-incs .dt { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.an-open { display: inline-block; font-size: 11px; font-weight: 700; color: var(--red, #d93025); border: 1px solid currentColor; border-radius: 999px; padding: 0 6px; margin-left: 4px; vertical-align: 1px; }
/* Línea de impacto en las tarjetas del panel de incidencias */
.inc-impact { margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--amber, #b06000); cursor: help; }
.inc-impact::before { content: '≈ '; }
.an-hbars .vl { white-space: nowrap; }

/* Mercancías (CNMC) */
.an-src { font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.an-src a { color: var(--blue); }
.an-link { background: none; border: 0; padding: 0; color: var(--blue); text-decoration: underline; cursor: pointer; font: inherit; }
.fr-trend .bar { position: relative; }
.fr-trend .bar i { position: absolute; left: 0; right: 0; bottom: 0; }
.fr-trend .bar i.im { background: var(--green, #12935c); opacity: .85; }
.fr-sh .nn { display: none; }
.an-report { margin-left: auto; font-size: 13px; color: var(--blue); text-decoration: underline; text-underline-offset: 2px; align-self: center; }
.an-report + .an-report { margin-left: 12px; }
