:root {
  --navy: #0b2860;
  --blue: #075bd8;
  --blue-dark: #064bc0;
  --teal: #008a89;
  --text: #12295b;
  --muted: #65769e;
  --line: #d9e1ee;
  --soft-blue: #edf4ff;
  --background: #f4f6f9;
  --white: #fff;
  --danger: #b42318;
  --shadow: 0 3px 14px rgba(14, 35, 74, .08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--background); color: var(--text); }
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }

.topbar {
  height: 120px; display: flex; align-items: center; gap: 24px; padding: 0 34px;
  background: var(--white); border-bottom: 1px solid #e8ebf1; box-shadow: 0 4px 18px rgba(14, 35, 74, .05);
}
.brand-mark { color: #00867f; font-size: 54px; font-weight: 750; letter-spacing: -3px; }
.brand-divider { width: 1px; height: 58px; background: #d8dfeb; }
.bus-mark svg { width: 38px; height: 44px; fill: var(--navy); display: block; }
.titles h1 { margin: 0 0 8px; font-size: 34px; line-height: 1; letter-spacing: -.6px; }
.titles p { margin: 0; color: var(--muted); font-size: 18px; }

.workspace { display: grid; grid-template-columns: minmax(320px, 430px) minmax(0, 1fr); gap: 24px; padding: 24px; min-height: calc(100vh - 120px); }
.panel { background: var(--white); border: 1px solid #e8ecf2; border-radius: 14px; box-shadow: var(--shadow); }
.filters { padding: 22px 20px; font-size: 14px; }
.filters h2 { font-size: 23px; }
.results { padding: 24px 20px; min-width: 0; }
h2 { margin: 0; font-size: 27px; letter-spacing: -.4px; }
.field-label, fieldset legend { display: block; margin: 18px 0 7px; font-weight: 700; font-size: 13px; }
.optional { color: var(--muted); font-weight: 400; }
.info { display: inline-grid; place-items: center; width: 16px; height: 16px; border: 1.5px solid var(--muted); border-radius: 50%; color: var(--muted); font-size: 10px; font-style: normal; margin-left: 5px; }
.field-help { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.35; }
input, select { border: 1px solid #cbd6e6; border-radius: 8px; background: white; outline: none; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(7, 91, 216, .13); }
select { width: 100%; padding: 10px 38px 10px 12px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--navy) 50%),linear-gradient(135deg,var(--navy) 50%,transparent 50%); background-position: calc(100% - 18px) 16px,calc(100% - 13px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
.filters select, .filters input { font-size: 13px; }
select:disabled { cursor: not-allowed; background-color: #f6f7f9; color: #8b96aa; }

.station-picker { position: relative; border: 1px solid #cbd6e6; border-radius: 9px; background: white; }
.station-picker:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(7,91,216,.13); }
.station-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 9px 0; }
.station-chips:empty { display: none; }
.station-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 7px; border-radius: 6px; background: var(--soft-blue); color: var(--blue-dark); font-size: 12px; }
.station-chip strong { font-weight: 700; }
.station-chip button { border: 0; background: none; color: var(--blue); padding: 0; font-size: 20px; line-height: 14px; }
.search-row { display: flex; align-items: center; padding: 0 10px; }
.search-row svg { width: 18px; fill: none; stroke: var(--text); stroke-width: 1.8; flex: 0 0 auto; }
.search-row input { flex: 1; min-width: 0; border: 0; padding: 10px 8px; box-shadow: none; font-size: 13px; }
.mini-spinner { width: 16px; height: 16px; border: 2px solid #d9e4f3; border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
.suggestions { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0; max-height: 290px; overflow-y: auto; background: white; border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 14px 30px rgba(14,35,74,.15); padding: 6px; }
.suggestion { width: 100%; display: grid; grid-template-columns: 48px 1fr; gap: 8px; text-align: left; border: 0; background: white; border-radius: 6px; padding: 10px; }
.suggestion:hover, .suggestion.active { background: var(--soft-blue); }
.suggestion .code { color: var(--blue); font-weight: 700; }
.suggestion .name { font-weight: 600; }
.suggestion small { grid-column: 2; color: var(--muted); }
.no-suggestions { padding: 12px; color: var(--muted); }
.input-suffix { display: grid; grid-template-columns: 1fr auto; }
.input-suffix input { width: 100%; border-radius: 8px 0 0 8px; padding: 10px 12px; }
.input-suffix span { display: flex; align-items: center; padding: 0 14px; color: var(--muted); border: 1px solid #cbd6e6; border-left: 0; border-radius: 0 8px 8px 0; background: #f8fafc; }
fieldset { border: 0; padding: 0; margin: 18px 0 0; }
fieldset legend { margin: 0 0 7px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { padding: 10px 7px; text-align: center; border: 1px solid #cbd6e6; color: #324677; cursor: pointer; font-size: 12px; }
.segmented label:first-of-type { border-radius: 8px 0 0 8px; }
.segmented label:last-of-type { border-radius: 0 8px 8px 0; border-left: 0; }
.segmented input:checked + label { color: white; background: var(--blue); border-color: var(--blue); }
.segmented input:focus-visible + label { outline: 3px solid rgba(7,91,216,.25); z-index: 1; }
button.primary, button.secondary { width: 100%; min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 7px; border-radius: 8px; font-weight: 650; font-size: 13px; }
button.primary { margin-top: 0; border: 0; color: white; background: linear-gradient(120deg, #0757d7, #0067e8); }
button.primary:hover { background: var(--blue-dark); }
button.primary:disabled { cursor: wait; opacity: .7; }
button.secondary { margin-top: 0; border: 1.5px solid var(--blue); color: var(--blue); background: white; }
button.secondary:hover { background: var(--soft-blue); }
button.primary svg, button.secondary svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.filter-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }

.results-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 0 2px 24px; }
.result-count { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.sort-label { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.sort-label select { width: 180px; padding-top: 10px; padding-bottom: 10px; background-position: calc(100% - 18px) 16px, calc(100% - 13px) 16px; }
.notice { min-height: 54px; display: flex; align-items: center; gap: 12px; border: 1px solid #b9d1fb; border-radius: 8px; padding: 12px 14px; background: #f7faff; color: #526892; }
.notice svg { width: 24px; flex: 0 0 auto; fill: none; stroke: var(--blue); stroke-width: 1.7; }
.error { margin-top: 16px; border: 1px solid #f2b8b5; border-radius: 8px; padding: 13px 15px; color: var(--danger); background: #fff3f2; }
.empty-state { max-width: 500px; margin: 100px auto; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--text); margin: 18px 0 9px; font-size: 21px; }
.empty-state p { line-height: 1.6; }
.empty-icon { width: 88px; height: 88px; display: grid; place-items: center; margin: auto; border-radius: 50%; background: var(--soft-blue); }
.empty-icon svg { width: 48px; fill: none; stroke: var(--blue); stroke-width: 2; }
.table-wrap { margin-top: 20px; border: 1px solid var(--line); border-radius: 10px; overflow: auto; }
table { width: 100%; min-width: 1260px; border-collapse: collapse; }
th { color: #5e7099; text-align: left; font-size: 13px; font-weight: 500; padding: 16px 18px; background: #fbfcfe; }
td { padding: 25px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
.unapproved-route > td { background-color: rgba(255, 105, 180, .2); }
th + th, td + td { border-left: 1px solid #edf0f5; }
.supplier-cell { font-weight: 700; font-size: 17px; }
.route-cell { font-weight: 700; font-size: 18px; }
.description-cell { max-width: 360px; color: #263e73; }
.crs-list { display: flex; flex-wrap: wrap; gap: 7px; }
.crs-pill { padding: 6px 10px; border: 1px solid transparent; border-radius: 6px; font-size: 13px; font-weight: 700; cursor: help; }
.crs-pill.matched { border-color: #a6d9bd; background: #e8f7ef; color: #087443; }
.crs-pill.unmatched { border-color: #efb5b0; background: #fff0ef; color: #b42318; }
.coverage { display: grid; grid-template-columns: 26px 1fr; align-items: center; font-weight: 700; }
.coverage svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.coverage.full { color: var(--teal); }
.coverage.partial-high { color: #b46900; }
.coverage.partial-low { color: #c4322b; }
.coverage small { grid-column: 2; color: var(--muted); font-weight: 400; margin-top: 4px; white-space: nowrap; }
.approval-status { display: flex; min-width: 170px; flex-direction: column; gap: 4px; }
.approval-status strong { font-size: 14px; }
.approval-status.approved strong { color: #087443; }
.approval-status.unapproved strong { color: #8a3b32; }
.approval-status small { max-width: 220px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.approval-status .bta-supplier { color: #334c79; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.route-actions { display: flex; justify-content: center; margin-top: 18px; }
.table-action { border: 1.5px solid var(--blue); border-radius: 8px; padding: 12px 18px; color: var(--blue); background: white; font-weight: 650; }
.table-action:hover { background: var(--soft-blue); }
.timetable-cell { min-width: 180px; }
.timetable-cell small { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }
.bustimes-link { display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--blue); border-radius: 7px; padding: 9px 11px; color: var(--blue); background: white; font-size: 13px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.bustimes-link:hover { background: var(--soft-blue); }
.timetable-unavailable { color: var(--muted); font-size: 13px; }
.loading { margin-top: 20px; }
.loading-bar { height: 74px; margin-bottom: 10px; border-radius: 8px; background: linear-gradient(90deg,#f0f3f7 25%,#f8fafc 50%,#f0f3f7 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 950px) {
  .topbar { height: 96px; padding: 0 20px; gap: 16px; }
  .brand-mark { font-size: 40px; }.brand-divider { height: 44px; }.bus-mark svg { width: 30px; }.titles h1 { font-size: 26px; }.titles p { font-size: 15px; }
  .workspace { grid-template-columns: 1fr; min-height: calc(100vh - 96px); }
  .filters { padding-bottom: 24px; }
}
@media (max-width: 620px) {
  .topbar { height: 82px; gap: 12px; }.topbar .brand-divider, .bus-mark, .titles p { display: none; }.brand-mark { font-size: 32px; }.titles h1 { font-size: 23px; }
  .workspace { padding: 12px; gap: 12px; }.filters, .results { padding: 20px 14px; }h2 { font-size: 23px; }
  .results-heading { align-items: flex-start; flex-direction: column; }.sort-label { width: 100%; }.sort-label select { flex: 1; }
  .segmented { grid-template-columns: 1fr; }.segmented label:first-of-type { border-radius: 8px 8px 0 0; }.segmented label:last-of-type { border-left: 1px solid #cbd6e6; border-top: 0; border-radius: 0 0 8px 8px; }
  .filter-actions { margin-top: 20px; }
  .table-wrap { border: 0; overflow: visible; }
  table, tbody { display: block; min-width: 0; }thead { display: none; }tr { display: block; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }td { display: grid; grid-template-columns: 110px 1fr; gap: 8px; padding: 13px 14px; border: 0; border-top: 1px solid var(--line); font-size: 15px; }td:first-child { border-top: 0; }td + td { border-left: 0; }td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 500; }.empty-state { margin: 65px auto; }
}
@media (max-width: 390px) {
  .filter-actions { grid-template-columns: 1fr; }
}
