:root {
  --ink: #1c2430;
  --muted: #6b7280;
  --line: #e6eaf0;
  --panel: #f7f8fa;
  --up: #b42318;
  --down: #027a48;
}

body {
  color: var(--ink);
  background: #fff;
  min-height: 100vh;
}

.page-header .site-kicker {
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.page-title {
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 700;
  line-height: 1.15;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

.help-btn,
.metric-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  border: 1px solid #c5ccd6;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
  margin-left: 0.2rem;
  flex: 0 0 auto;
  letter-spacing: 0;
  text-transform: none;
  opacity: 1;
}

.help-btn:hover,
.help-btn:focus,
.help-btn:focus-visible,
.metric-help:hover,
.metric-help:focus,
.metric-help:focus-visible {
  color: var(--ink);
  border-color: #9aa3af;
  background: #fff;
  outline: none;
  opacity: 1;
}

.tooltip .tooltip-inner {
  max-width: 16.5rem;
  padding: 0.55rem 0.7rem;
  text-align: left;
}

.panel,
.stat-tile,
.filter-panel,
.stop-detail-panel,
.stop-departures {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.panel,
.filter-panel {
  padding: 1.1rem 1.2rem;
}

.stat-tile,
.metric-card {
  min-width: 0;
  padding: 0.8rem 0.9rem;
}

.metric-card .card-body {
  padding: 0;
}

.metric-label,
.stat-label {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 600;
  gap: 0.2rem;
  letter-spacing: 0;
  text-transform: none;
}

.metric-value,
.stat-value {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.15;
  margin: 0.2rem 0 0.15rem;
  white-space: nowrap;
}

.metric-value small {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  margin-left: 0.15rem;
}

.metric-note,
.stat-meta {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.25;
  margin: 0;
}

.reliability-card .metric-value {
  font-size: clamp(1.7rem, 4vw, 2.2rem);
}

.progress {
  height: 0.55rem;
  background: #eef1f5;
}

.panel-heading {
  margin-bottom: 0.85rem;
}

.panel-heading .h5,
.panel-heading h2,
.panel-heading h3 {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 650;
  margin-bottom: 0.2rem;
}

.panel-kicker {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.chart-heading {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.trend-tabs {
  gap: 0.35rem;
  flex-wrap: wrap;
}

.trend-tabs .nav-link {
  border-radius: 999px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.3rem 0.8rem;
  font-size: 0.88rem;
}

.trend-tabs .nav-link.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.chart-wrap {
  min-height: 380px;
  position: relative;
}

.chart-wrap.chart-tall {
  min-height: 420px;
}

.chart-wrap canvas {
  max-height: 380px;
}

.chart-wrap.chart-tall canvas {
  max-height: 400px;
}

.heatmap-wrap {
  overflow-x: auto;
  margin-top: 0.35rem;
}

.heatmap-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  font-size: 0.72rem;
}

.heatmap-table th,
.heatmap-table td {
  text-align: center;
  padding: 0.28rem 0.15rem;
  border: 1px solid #fff;
}

.heatmap-table th {
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  left: 0;
  background: var(--panel);
}

.heatmap-table td.heatmap-cell {
  color: #1c2430;
  font-weight: 600;
  min-width: 2rem;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.heatmap-swatch {
  display: inline-block;
  width: 7rem;
  height: 0.65rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #dbeafe, #60a5fa, #1d4ed8);
}

.stop-table-wrap {
  max-height: 520px;
  overflow: auto;
}

.stop-table-wrap thead th {
  background: var(--panel);
  border-bottom-color: var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.stop-table-wrap td,
.stop-table-wrap th {
  border-color: var(--line);
}

.stop-row {
  cursor: pointer;
}

.stop-row:focus-visible {
  outline: 2px solid rgba(28, 36, 48, 0.35);
  outline-offset: -2px;
}

.stop-score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.stop-name {
  font-weight: 600;
}

.stop-code {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
}

.stop-search-wrap {
  max-width: 28rem;
  position: relative;
  width: 100%;
}

.stop-search-results {
  left: 0;
  max-height: 18rem;
  overflow: auto;
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 1040;
}

.stop-search-results .list-group-item {
  text-align: left;
  border-color: var(--line);
}

.stop-search-meta {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

#stopMap {
  background: #eef1f5;
  border: 1px solid var(--line);
  border-radius: 12px;
  height: min(70vh, 640px);
  min-height: 520px;
  overflow: hidden;
  width: 100%;
}

.stop-detail-panel {
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 640px);
  overflow: auto;
  padding: 1.1rem 1.15rem;
}

.stop-detail-stats {
  display: grid;
  gap: 0.85rem;
}

.stop-detail-stats > div {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.85rem;
}

.stop-detail-stats dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
  text-transform: uppercase;
}

.stop-detail-stats dd {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  margin: 0;
  text-align: right;
}

.stop-departures {
  padding: 0.9rem 1rem 1rem;
}

.stop-departures-wrap {
  max-height: 14rem;
  overflow: auto;
}

.stop-departures-table {
  --bs-table-bg: transparent;
  font-size: 0.84rem;
  margin-bottom: 0;
}

.stop-departures-table thead th {
  background: var(--panel);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  text-transform: uppercase;
  white-space: nowrap;
  z-index: 1;
}

.stop-departures-table th,
.stop-departures-table td {
  border-color: var(--line);
  padding: 0.35rem 0.65rem;
  vertical-align: middle;
  white-space: nowrap;
}

.stop-departures-table td:nth-child(2) {
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stop-departures-route {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.stop-departures-destination {
  color: var(--ink);
}

.stop-departures-arrived {
  cursor: help;
}

.stop-departures-arrived.is-missing {
  color: var(--muted);
}

.stop-departures-arrived.is-cancelled {
  color: var(--up);
  font-weight: 600;
}

.stop-departures-table tbody tr.is-on-time {
  --bs-table-bg: rgba(2, 122, 72, 0.12);
  --bs-table-hover-bg: rgba(2, 122, 72, 0.18);
}

.stop-departures-table tbody tr.is-late-mild {
  --bs-table-bg: rgba(245, 158, 11, 0.16);
  --bs-table-hover-bg: rgba(245, 158, 11, 0.24);
}

.stop-departures-table tbody tr.is-late-severe {
  --bs-table-bg: rgba(180, 35, 24, 0.12);
  --bs-table-hover-bg: rgba(180, 35, 24, 0.18);
}

.map-legend {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.8rem;
  gap: 1rem;
}

.legend-dot {
  border-radius: 50%;
  display: inline-block;
  height: 0.75rem;
  margin-right: 0.3rem;
  vertical-align: -0.05rem;
  width: 0.75rem;
}

.score-good {
  background: var(--down);
}

.score-fair {
  background: #d97706;
}

.score-poor {
  background: var(--up);
}

.score-none {
  background: #9aa3af;
}

.empty-state {
  color: var(--muted);
  padding: 3rem 1rem;
  text-align: center;
}

.disclaimer-accordion .accordion-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
}

.disclaimer-accordion .accordion-item + .accordion-item {
  margin-top: 0.65rem;
}

.disclaimer-accordion .accordion-button {
  background: var(--panel);
  box-shadow: none;
  font-size: 0.95rem;
}

.disclaimer-accordion .accordion-button:not(.collapsed) {
  background: #eef1f5;
  color: var(--ink);
}

.disclaimer-accordion .accordion-body {
  font-size: 0.92rem;
  color: #4b5563;
}

.disclaimer-accordion .accordion-body a {
  color: #0d6efd;
}

.disclaimer-accordion .accordion-body a:hover {
  color: #0a58ca;
}

.leaflet-popup-content {
  line-height: 1.45;
}

.leaflet-popup-content strong {
  display: block;
  margin-bottom: 0.25rem;
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(28, 36, 48, 0.16);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: rgba(28, 36, 48, 0.82);
  color: #fff;
  font-weight: 700;
}

footer {
  margin-bottom: 30px;
}

@media (max-width: 991.98px) {
  .stop-search-wrap {
    max-width: none;
  }

  #stopMap {
    height: 460px;
    min-height: 420px;
  }
}

@media (max-width: 767.98px) {
  .chart-wrap {
    min-height: 280px;
  }

  .chart-wrap.chart-tall {
    min-height: 320px;
  }

  #stopMap {
    height: 400px;
    min-height: 360px;
  }

  .stat-tile,
  .metric-card {
    padding: 0.6rem 0.7rem;
  }

  .metric-value,
  .stat-value {
    font-size: 1.25rem;
  }

  .metric-label,
  .stat-label {
    font-size: 0.72rem;
  }

  .metric-note,
  .stat-meta {
    font-size: 0.7rem;
  }
}
