:root {
  --paper: #f4f7fa;
  --ink: #12324a;
  --muted: #5d7386;
  --green: #0d4f7c;
  --leaf: #1a7eb0;
  --amber: #2aa4d6;
  --rust: #0e6eab;
  --line: #d5e2ec;
  --card: #ffffff;
  --shadow: 0 16px 36px rgba(13, 63, 99, 0.08);
  font-family: Outfit, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #e7f3fa 0, transparent 16rem),
    var(--paper);
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  width: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  padding: 0.35rem 1rem;
}

.brand {
  display: block;
  line-height: 0;
}

.brand img {
  height: 5.6rem;
  width: auto;
  display: block;
}

.compact .brand img { height: 3.15rem; }

.compact .topbar-inner { padding: 0.1rem 0; }

.page {
  width: 100%;
  margin: 0;
  padding: 1.6rem 1rem 3rem;
}

.page.results {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(8.5rem, 11rem);
  align-items: center;
  column-gap: 0.7rem;
  row-gap: 0.35rem;
  padding-top: 0.45rem;
}

.page.results .summary { display: contents; }

.page.results .modify { order: 1; }
.page.results .route { order: 2; }
.page.results .count { order: 3; }
.page.results .filter { order: 4; }
.page.results .search { order: 5; }
.page.results .banner,
.page.results .alias { order: 6; }
.page.results .board { order: 7; }

.page.results .search,
.page.results .board,
.page.results .banner,
.page.results .alias { grid-column: 1 / -1; }

.page.results .filter { margin-left: 0; width: auto; }

.mast h1,
.route {
  font-family: Outfit, "Segoe UI", sans-serif;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--leaf);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.25rem);
  line-height: 1.15;
  font-weight: 650;
}

.lede {
  max-width: 38rem;
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-top: 1.25rem;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  box-shadow: var(--shadow);
}

.search.is-hidden { display: none; }

.modify {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  background: #fff;
  color: var(--green);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modify:hover { background: #e7f3fa; }

.fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: end;
  flex: 1 1 28rem;
}

.station { position: relative; min-width: 0; }

.when { flex: 0 0 11.5rem; }

.when input { width: 100%; }

.suggestions {
  position: absolute;
  z-index: 30;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  box-shadow: var(--shadow);
  max-height: 16rem;
  overflow: auto;
}

.suggestions[hidden] { display: none; }

.suggestions button {
  width: 100%;
  height: auto;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border-radius: 0.5rem;
  padding: 0.55rem 0.65rem;
  font-weight: 500;
}

.suggestions button.active,
.suggestions button:hover { background: #f3f8fc; }

.suggestions .code {
  color: var(--leaf);
  font-weight: 600;
  letter-spacing: 0.04em;
}

label span,
.filter span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: #fff;
  color: var(--ink);
  font: 600 1.15rem/1 Outfit, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.75rem 0.85rem;
}

input:focus {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}

.search input {
  text-transform: none;
  letter-spacing: 0.01em;
}

.filter input,
.trip input,
.trip select {
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
}

.trip select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: #fff;
  color: var(--ink);
  font: 500 1rem/1 Outfit, sans-serif;
  padding: 0.75rem 0.85rem;
}

button {
  border: 0;
  border-radius: 0.7rem;
  cursor: pointer;
  font: 600 1rem/1 Outfit, sans-serif;
}

.swap {
  width: 3.05rem;
  height: 3.05rem;
  padding: 0;
  display: grid;
  place-items: center;
  background: #e7f0f6;
  color: var(--green);
}

.swap svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.find {
  flex: 1 1 9rem;
  height: 3.05rem;
  padding: 0 1.2rem;
  background: var(--rust);
  color: white;
}

.swap:hover { background: #d7e6f0; }
.find:hover { background: #0b5d92; }

.banner {
  margin: 1rem 0 0;
  padding: 0.9rem 1rem;
  border-radius: 0.8rem;
  background: #e8f4fb;
  color: #0c3d5c;
}

.summary {
  display: flex;
  align-items: center;
  gap: 0.45rem 0.9rem;
  margin-top: 0.45rem;
}

.route {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.35rem;
  align-items: baseline;
  margin: 0;
  font-size: 1rem;
  white-space: nowrap;
}

.route small,
.alias,
.count,
.km,
.full,
.via,
.daytext {
  color: var(--muted);
  font-family: Outfit, sans-serif;
  font-weight: 500;
  letter-spacing: 0;
}

.route small {
  font-size: 0.78rem;
}

.arrow {
  color: var(--amber);
  font-size: 0.85rem;
}

.alias { margin: 0.15rem 0 0; font-size: 0.8rem; }

.count {
  margin: 0;
  font-size: 0.82rem;
  white-space: nowrap;
}

.count strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.summary .filter {
  margin-left: auto;
  flex: 0 1 12rem;
  position: relative;
}

.summary .filter span {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.summary .filter input {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 0.5rem;
}

.board {
  overflow-x: auto;
  margin-top: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--card);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
}

.board table { min-width: 920px; }

.board th:nth-child(2),
.board td.train {
  width: 9.5rem;
  max-width: 9.5rem;
}

.board th:last-child,
.board td:last-child {
  width: 70%;
}

th, td {
  padding: 0.75rem 0.8rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

th {
  position: sticky;
  top: 0;
  background: var(--green);
  color: #f4f8fb;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

th .sort {
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  border-radius: 0;
}

th .sort::after {
  content: " ↕";
  opacity: 0.65;
}

th[aria-sort="ascending"] .sort::after { content: " ↑"; opacity: 1; }
th[aria-sort="descending"] .sort::after { content: " ↓"; opacity: 1; }

th .sort:hover,
th .sort:focus-visible {
  text-decoration: underline;
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f3f8fc; }

.num, .time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.train {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.3rem;
  max-width: 9.5rem;
  font-size: 0.82rem;
  line-height: 1.15;
}

.train .num,
.train .name {
  display: inline;
}

.train .full,
.train .kind,
.train .via {
  flex-basis: 100%;
  margin-top: 0;
  font-size: 0.72rem;
  line-height: 1.15;
}

.see-route {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0.15rem;
  display: grid;
  place-items: center;
  background: transparent;
  border-radius: 0.45rem;
}

.see-route img {
  width: 1.85rem;
  height: 1.85rem;
  display: block;
}

.see-route:hover,
.see-route:focus-visible {
  background: #e7f3fa;
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.kind {
  display: block;
  margin-top: 0.15rem;
  color: var(--leaf);
  font-size: 0.82rem;
  font-weight: 600;
}

.fare-head span {
  display: block;
  line-height: 1.35;
  white-space: nowrap;
}

.fare-sheet {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.55rem;
  align-items: flex-start;
  justify-content: flex-start;
}

.fare-offer {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.05rem 0.1rem;
  background: transparent;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.15;
  border-radius: 0.3rem;
}

.fare-code { line-height: 1.15; }

.fare-price {
  white-space: nowrap;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.fare-offer:hover,
.fare-offer:focus-visible {
  color: var(--leaf);
  background: #e7f4fb;
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

.fare-offer:hover .fare-code,
.fare-offer:focus-visible .fare-code {
  text-decoration: underline;
}

#route { width: min(52rem, calc(100% - 1.5rem)); }

#route-body {
  max-height: min(70vh, 36rem);
  overflow: auto;
  padding: 0;
}

.route-note {
  margin: 0;
  padding: 0.75rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.route-table { min-width: 40rem; }
.route-table td { white-space: nowrap; }
.route-table td:nth-child(2) { white-space: normal; }

.route-table tr.boarding td { background: #e7f4fb; }
.route-table tr.alighting td { background: #eef3f8; }

.route-table .mark {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.route-table tr.boarding .mark { color: var(--leaf); }
.route-table tr.alighting .mark { color: var(--rust); }

.time { color: var(--green); font-size: 1.05rem; }

.name, .full, .via, .km, .daytext { display: block; }
.full, .via, .km { font-size: 0.82rem; }
.via { margin-top: 0.15rem; }

.week {
  display: flex;
  gap: 0.2rem;
  margin-top: 0.35rem;
}

.week i,
.week button.on {
  display: grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border-radius: 0.3rem;
  font: 600 0.72rem/1 Outfit, sans-serif;
}

.week button.on {
  background: var(--leaf);
  color: white;
  cursor: pointer;
}

.week button.on:hover,
.week button.on:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

.week .off { background: #e7eef3; color: #8aa0b0; }

.hint {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

dialog {
  width: min(34rem, calc(100% - 1.5rem));
  padding: 0;
  border: 0;
  border-radius: 1rem;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(12, 48, 74, 0.48); }

.trip-head,
.trip { padding: 1rem 1.1rem; }

.trip-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.trip-head h2 {
  margin: 0;
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 1.45rem;
  font-weight: 560;
}

.trip { padding-top: 0.9rem; }

.trip-close,
.secondary {
  background: #e7f0f6;
  color: var(--green);
  height: 2.4rem;
  padding: 0 0.85rem;
}

.book {
  background: var(--rust);
  color: white;
  height: 2.4rem;
  padding: 0 0.9rem;
}

.trip-meta { margin: 0 0 0.35rem; color: var(--muted); }

.popup-offer { margin-top: 0.85rem; overflow-x: auto; }

.popup-offer .fare-head {
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.trip-wait { margin: 0; }

.class-list, .people {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
}

.class-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
}

.status {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.fare, .fare-child { display: block; margin-top: 0.2rem; }
.fare { color: var(--ink); font-weight: 600; }
.fare-child { color: var(--muted); font-size: 0.82rem; }

.fare-box {
  margin: 0.9rem 0 0;
  padding: 0.85rem 0.95rem;
  border-radius: 0.75rem;
  background: #f4f8fb;
}

.fare-caption { margin: 0; color: var(--muted); font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; }

.fare-lines { list-style: none; margin: 0.45rem 0 0; padding: 0; }

.fare-lines li, .fare-total {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
}

.fare-total {
  margin: 0.35rem 0 0;
  border-top: 1px solid var(--line);
  font-weight: 600;
}

.fare-total strong {
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 1.45rem;
}

.status.available { background: #e5f4fb; color: var(--leaf); }
.status.closed { background: #e7eef3; color: var(--muted); }

.person {
  margin: 0 0 0.8rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
}

.person legend { padding: 0 0.3rem; font-weight: 600; }

.stack { display: block; margin-top: 0.55rem; }

.person-grid {
  display: grid;
  grid-template-columns: 5rem 1fr 1fr;
  gap: 0.55rem;
}

.trip-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.9rem;
}

.text-remove {
  margin-top: 0.45rem;
  padding: 0;
  background: transparent;
  color: var(--rust);
  font-size: 0.9rem;
}

.form-error {
  margin: 0.7rem 0 0;
  color: #9b3a3a;
}

.pg-note {
  margin: 1rem 0 0;
  padding: 0.85rem 0.95rem;
  border-radius: 0.75rem;
  background: #e8f4fb;
  color: #0c3d5c;
  font-weight: 600;
}

.booking-id {
  margin: 0 0 0.4rem;
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 2rem;
}

.people li { padding: 0.35rem 0; border-top: 1px solid var(--line); }

.classes { white-space: nowrap; font-size: 0.86rem; letter-spacing: 0.04em; }

@media (max-width: 820px) {
  .board { overflow-x: visible; }
  .board table,
  .board tbody,
  .board tr { display: block; min-width: 0; width: 100%; }
  .board thead tr {
    display: flex;
    gap: 0.4rem;
    background: var(--green);
    border-radius: 0.8rem 0.8rem 0 0;
  }
  .board thead th { width: auto; background: transparent; }
  .board thead th:not(:has(.sort)) { display: none; }
  .board tbody tr {
    display: grid;
    grid-template-columns: 2.6rem auto auto auto minmax(0, 1fr);
    align-items: start;
    gap: 0.35rem 0.85rem;
    padding: 0.7rem 0.75rem;
  }
  .board td {
    display: block;
    width: auto;
    max-width: none;
    border: 0;
    padding: 0;
  }
  .board td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .board td.train { grid-column: 2 / -1; grid-row: 1; width: auto; max-width: none; }
  .board td:last-child { width: auto; }
  .train { max-width: none; }
  .board td[data-field="dep"] { grid-column: 2; grid-row: 2; }
  .board td[data-field="arr"] { grid-column: 3; grid-row: 2; }
  .board td[data-field="travel"] { grid-column: 4; grid-row: 2; }
  .board td:last-child { grid-column: 2 / -1; grid-row: 3; }
  .board td[data-field]::before {
    content: attr(data-field);
    display: block;
    margin-bottom: 0.1rem;
    color: var(--muted);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .fare-sheet { flex-wrap: wrap; }
}

@media (max-width: 640px) {
  .topbar-inner { padding-left: 0.45rem; padding-right: 0.45rem; }
  .page { width: 100%; padding: 0.7rem 0.45rem 2rem; }
  .fields { grid-template-columns: 1fr; }
  .swap, .when { width: 100%; flex-basis: auto; }
  .page.results { grid-template-columns: auto minmax(0, 1fr); }
  .page.results .route { white-space: normal; }
  .page.results .count,
  .page.results .filter { grid-column: 1 / -1; }
  .person-grid { grid-template-columns: 1fr; }
}
