/* The network overview, layered over performance.css.
 *
 * Self-contained: the chart classes are redefined here rather than borrowed
 * from punctuality.css, because this page does not load that stylesheet and
 * a page that silently depends on another page's CSS breaks the day that
 * page is refactored. Values match, deliberately, so the two charts look
 * like one product.
 *
 * Two series, two axes. They differ by hue *and* by whether they carry dots,
 * because hue alone is not a signal everybody receives -- the punctuality
 * line has dots, the hours line does not, and the legend names the axis.
 */

.viz-root {
  --axis: #c3c2b7;
  --series-punctuality: #cf5f12;
  --series-hours: #3c6e8f;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    --axis: #383835;
    --series-punctuality: #ff8f45;
    --series-hours: #7fb6d9;
  }
}

:root[data-theme="dark"] .viz-root {
  --axis: #383835;
  --series-punctuality: #ff8f45;
  --series-hours: #7fb6d9;
}

/* ---------- Filters ---------- */

.filter-band {
  padding: 22px 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 5px;
  /* Flex children default to min-width:auto, and a long operator name in a
     select then sets the row's width and pushes the page sideways. */
  min-width: 0;
}

.filter > span {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.filter input,
.filter select {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
  color: var(--text-primary);
  font: inherit;
  font-size: 13.5px;
  max-width: 100%;
}

.filter select {
  max-width: 220px;
}

.filter-actions {
  display: flex;
  align-items: flex-end;
}

.filter-actions .btn-quiet {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

.filter-actions .btn-quiet:hover {
  color: var(--text-primary);
}

.held-note {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ---------- Tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.tiles.loading {
  opacity: 0.55;
}

.tile {
  min-width: 0;
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
}

.tile-label {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.tile-value {
  margin: 8px 0 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.tile-sub {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---------- Chart ---------- */

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.section-sub {
  margin: 0;
  flex: 1 1 320px;
  min-width: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
  flex: none;
}

.swatch-punctuality { background: var(--series-punctuality); }
.swatch-hours { background: var(--series-hours); }

.chart-holder {
  position: relative;
}

.chart-holder svg {
  display: block;
  max-width: 100%;
  cursor: crosshair;
}

.axis-text {
  font-size: 11px;
  fill: var(--text-muted);
}

.grid-line {
  stroke: var(--grid);
  stroke-width: 1;
}

.series-punctuality {
  fill: none;
  stroke: var(--series-punctuality);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.series-hours {
  fill: none;
  stroke: var(--series-hours);
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.dot-punctuality {
  fill: var(--series-punctuality);
  stroke: var(--surface-1);
  stroke-width: 1.5;
}

.crosshair {
  stroke: var(--axis);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  white-space: nowrap;
  z-index: 5;
}

.tip-date {
  margin: 0 0 6px;
  font-weight: 600;
}

.tip-row {
  margin: 0 0 3px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.tip-meta {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.chart-note {
  margin: 14px 0 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 62ch;
}

.empty-note {
  color: var(--text-muted);
  font-size: 13px;
  padding: 22px 4px;
}

/* ---------- Benchmarks ---------- */

.table-holder {
  min-width: 0;
}

/* The scroll lives here, not on the page: forty routes wide should scroll
   inside its own box rather than making the whole page move sideways. */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  max-height: 60vh;
  overflow-y: auto;
}

table.bench-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.bench-table th,
.bench-table td {
  padding: 8px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.bench-table thead th {
  position: sticky;
  top: 0;
  background: var(--page);
  color: var(--text-secondary);
  font-weight: 600;
  z-index: 1;
  /* A sticky header loses its bottom border when rows scroll under it,
     because the border belongs to the cell rather than the row. */
  box-shadow: inset 0 -1px 0 var(--border);
}

.bench-table tbody tr:hover td {
  background: var(--accent-soft);
}

.cell-route {
  font-weight: 600;
}

.cell-num {
  text-align: right;
}

/* The sign is in the number as well as the colour: the warning yellow on this
   palette sits below 3:1 on the light surface, so colour never carries a
   meaning on its own here. */
.delta-up { color: var(--status-good); }
.delta-down { color: var(--fault); }

/* ---------- Caveats ---------- */

.caveats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 18px;
}

.caveat {
  min-width: 0;
}

.caveat h3 {
  margin: 0 0 7px;
  font-size: 14px;
  color: var(--text-primary);
}

.caveat p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* The day the road geometry arrived, marked on the chart. Dashed and quiet:
   it is an annotation about the measurement, not a third series. */
.basis-line {
  stroke: var(--text-muted);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.basis-text {
  font-size: 10.5px;
  fill: var(--text-muted);
}

/* Said on the tile, not in a footnote: somebody reading the speed is looking
   at the tile, not at the bottom of the page. */
.tile-warn {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.5;
  color: var(--fault);
}

/* Sortable headings. A button, not a span with a click handler: it has to be
   reachable and operable from the keyboard, and a <button> is that for free. */
.bench-table th {
  padding: 0;
}

button.sort-button {
  width: 100%;
  padding: 8px 14px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: inherit;
  cursor: pointer;
  white-space: nowrap;
}

button.sort-button:hover {
  color: var(--text-primary);
}

.bench-table th.sorted button.sort-button {
  color: var(--text-primary);
}

/* The numeric headings sit over right-aligned cells and must agree with them. */
.bench-table th:nth-child(n + 3) button.sort-button {
  text-align: right;
}
