:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #1a2027;
  --muted: #5c6773;
  --accent: #2563eb;
  --accent-soft: #eaf0fe;
  --timing: #b54708;
  --warn-bg: #fff7e6;
  --warn-border: #f0c36d;
  --error-bg: #fdeceb;
  --error-border: #e5a09b;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.wrap--wide { max-width: 1400px; }

header.site {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  margin-bottom: 24px;
}
header.site .wrap { display: flex; align-items: baseline; gap: 14px; }
header.site strong { font-size: 17px; }
header.site a { text-decoration: none; }
header.site .tag {
  font-size: 12px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 9px;
}
header.site nav { margin-left: auto; font-size: 14px; }

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.crumb a { text-decoration: none; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.card--pad0 { padding: 0; overflow: hidden; }

.flash { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 14px; }
.flash--error { background: var(--error-bg); border: 1px solid var(--error-border); }
.flash--warn { background: var(--warn-bg); border: 1px solid var(--warn-border); }

.drop {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 30px; text-align: center; background: var(--surface);
}
.drop input[type=file] { display: block; margin: 0 auto 16px; }
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  border-radius: 6px; padding: 8px 16px; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { filter: brightness(1.08); }
.btn--ghost { background: var(--surface); color: var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fbfcfd; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--accent-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .03em;
  padding: 2px 8px; border-radius: 999px; text-transform: uppercase;
}
.badge--track { background: #e7f6ec; color: #17663a; }
.badge--mixed { background: var(--warn-bg); color: #8a5a00; }
.badge--none { background: var(--error-bg); color: #96322b; }
.line-pill {
  display: inline-block; min-width: 34px; text-align: center;
  background: var(--accent); color: #fff; font-weight: 700;
  border-radius: 5px; padding: 2px 8px;
}

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--border); }
.facts div { background: var(--surface); padding: 12px 14px; }
.facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 3px; }
.facts dd { margin: 0; font-size: 15px; font-weight: 600; }

#map { height: 620px; width: 100%; }
.map-legend { display: flex; gap: 18px; font-size: 13px; color: var(--muted); padding: 10px 14px; border-top: 1px solid var(--border); }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; border: 2px solid #fff; box-shadow: 0 0 2px rgba(0,0,0,.5); }
.swatch--stop { background: var(--accent); }
.swatch--timing { background: var(--timing); }
.swatch--line { border-radius: 2px; height: 4px; width: 20px; background: var(--accent); box-shadow: none; border: 0; }

.split { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } #map { height: 420px; } }

.stoplist { max-height: 620px; overflow-y: auto; }
.stoplist ol { list-style: none; margin: 0; padding: 0; }
.stoplist li { display: flex; gap: 10px; padding: 7px 14px; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.stoplist li:hover { background: var(--accent-soft); }
.stoplist .seq { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 22px; }
.stoplist .km { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.stoplist .atco { display: block; color: var(--muted); font-size: 11px; }

.downloads { display: flex; flex-wrap: wrap; gap: 8px; }
.downloads a { font-size: 13px; padding: 6px 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
footer.site { color: var(--muted); font-size: 13px; padding: 30px 0; text-align: center; }

/* --- Tooltips -------------------------------------------------------------
   Rendered into one fixed-position element at the end of <body>, not as a
   ::after on the control. A pseudo-element is a child, so any ancestor that
   scrolls or clips cuts it off -- and this page has three: the facts card
   (overflow hidden for its rounded corners), the route table (scrolls
   sideways) and the stop list (scrolls down). A fixed layer outside all of
   them cannot be clipped by any of them.

   data-tip rather than title, so the browser's own tooltip does not appear
   alongside this one. tooltip.js does the positioning. */
#tooltip {
  position: fixed; z-index: 9999; top: 0; left: 0;
  max-width: 260px; padding: 7px 10px; border-radius: 6px;
  background: #1a2027; color: #fff;
  font: 400 12px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: left; box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
  opacity: 0; visibility: hidden; transition: opacity .12s ease;
  pointer-events: none;
}
#tooltip[data-show] { opacity: 1; visibility: visible; }
#tooltip::after {                     /* the arrow, pointed by tooltip.js */
  content: ""; position: absolute; left: var(--arrow-x, 50%);
  margin-left: -5px; border: 5px solid transparent;
}
#tooltip[data-placement="top"]::after { top: 100%; border-top-color: #1a2027; }
#tooltip[data-placement="bottom"]::after { bottom: 100%; border-bottom-color: #1a2027; }

[data-tip] { cursor: help; }
a[data-tip], button[data-tip], th[data-tip], tr[data-tip], li[data-tip],
select[data-tip], input[data-tip] { cursor: inherit; }

.downloads-group { border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; background: var(--surface); margin-bottom: 14px; }
.downloads-group h3 { margin: 0 0 3px; font-size: 14px; }
.downloads-group p { margin: 0 0 10px; }
.btn--pdf { background: #b54708; border-color: #b54708; color: #fff; }

/* --- Comparison against today --------------------------------------------- */
.verdict { border-radius: var(--radius); padding: 13px 16px; margin-bottom: 14px;
  border: 1px solid var(--border); background: var(--surface); }
.verdict--aligned { border-left: 5px solid #16a34a; }
.verdict--partial { border-left: 5px solid #d97706; }
.verdict--different { border-left: 5px solid #dc2626; }

.swatch--current { background: #64748b; border-radius: 2px; height: 4px; width: 20px;
  box-shadow: none; border: 0; }
.swatch--added { background: #16a34a; border-radius: 2px; height: 4px; width: 20px;
  box-shadow: none; border: 0; }
.swatch--dropped { background: #dc2626; border-radius: 2px; height: 4px; width: 20px;
  box-shadow: none; border: 0; }

.cmp-head { padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 650; }
.cmp-body { padding: 11px 14px; }
table.cmp td:first-child { color: var(--muted); }
.delta { font-size: 12px; font-weight: 700; margin-left: 5px; }
.delta.up { color: #16a34a; }
.delta.down { color: #dc2626; }
td.added, b.added { color: #15803d; }
td.dropped, b.dropped { color: #b91c1c; }

.split-even { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start;
  margin-bottom: 16px; }
@media (max-width: 900px) { .split-even { grid-template-columns: 1fr; } }

.btn--sm { padding: 4px 10px; font-size: 12.5px; }

/* --- Batch comparison ------------------------------------------------------
   Its own two-colour scheme, deliberately not the per-route one: at network
   scale the question is "what changes", not "what is gained versus lost", so
   today is one colour and every change is the other. */
.cur-key { color: #2563eb; }
.chg-key { color: #ea580c; }
.swatch--changed { background: #ea580c; border-radius: 2px; height: 4px; width: 20px;
  box-shadow: none; border: 0; }

.bar { height: 8px; border-radius: 4px; background: #e8ebef; overflow: hidden; margin-top: 10px; }
.bar__fill { height: 100%; background: var(--accent); border-radius: 4px;
  transition: width .35s ease; }
.hidden { display: none; }

.tally { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px; margin-bottom: 16px; }
.tally__item { background: var(--surface); border: 1px solid var(--border);
  border-left-width: 5px; border-radius: var(--radius); padding: 11px 14px; }
.tally__item--aligned { border-left-color: #16a34a; }
.tally__item--partial { border-left-color: #d97706; }
.tally__item--different { border-left-color: #dc2626; }
.tally__item--new { border-left-color: #7c3aed; }
.tally__item--failed { border-left-color: #94a3b8; }
.tally__n { font-size: 23px; font-weight: 700; line-height: 1.1; }
.tally__l { font-size: 12px; color: var(--muted); }

.badge--aligned { background: #e7f6ec; color: #17663a; }
.badge--partial { background: var(--warn-bg); color: #8a5a00; }
.badge--different { background: var(--error-bg); color: #96322b; }
.badge--new { background: #f3e8ff; color: #6b21a8; }

.cluster { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* --- Busy state ------------------------------------------------------------ */
.spinner {
  display: inline-block; width: 12px; height: 12px; margin-right: 7px;
  vertical-align: -1px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.is-busy { opacity: .82; cursor: progress; pointer-events: none; }
button.is-busy, .btn.is-busy { filter: none; }

/* Change grading: weight, not just hue, so it survives being printed or
   looked at by someone who does not separate orange from amber. */
.swatch--major { background: #ea580c; border-radius: 2px; height: 6px; width: 20px;
  box-shadow: none; border: 0; }
.swatch--minor { background: #fbbf24; border-radius: 2px; height: 3px; width: 20px;
  box-shadow: none; border: 0; }
.badge--scale-major { background: #ffedd5; color: #9a3412; }
.badge--scale-minor { background: #fef3c7; color: #92400e; }
.badge--scale-none { background: #eef2f6; color: #52606d; }
.tally__item--major { border-left-color: #ea580c; }
.tally__item--minor { border-left-color: #fbbf24; }
.tally__item--nochange { border-left-color: #94a3b8; }
.tally__item--km { border-left-color: #2563eb; }
