:root {
  --ink: #151922;
  --muted: #657184;
  --line: #d8dee8;
  --soft-line: #e8edf4;
  --panel: #ffffff;
  --panel-soft: #f6f8fb;
  --blue: #0a4d8f;
  --blue-dark: #07345f;
  --green: #0f766e;
  --map-bg: #eef3f4;
  --shadow: 0 16px 38px rgba(21, 31, 45, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #dce5ee;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  transition: grid-template-columns 180ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}

.sidebar {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 96px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  border-right: 1px solid #b9c3d1;
  background: var(--panel);
  overflow: visible;
}

.sidebar-toggle {
  position: absolute;
  top: 84px;
  right: -15px;
  z-index: 8;
  display: grid;
  width: 30px;
  height: 46px;
  place-items: center;
  border: 1px solid #b9c3d1;
  border-radius: 0 8px 8px 0;
  background: #fff;
  color: var(--blue-dark);
  box-shadow: 0 8px 20px rgba(21, 31, 45, 0.12);
  font-size: 24px;
  font-weight: 900;
}

.search-panel {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--soft-line);
}

.sidebar-collapsed .sidebar {
  grid-template-rows: auto minmax(0, 1fr);
}

.sidebar-collapsed .search-panel {
  padding: 16px 8px;
  border-bottom: 0;
}

.sidebar-collapsed .brand-row {
  display: flex;
  justify-content: center;
  margin-bottom: 0;
}

.sidebar-collapsed .brand-row > div:not(.brand-mark),
.sidebar-collapsed .search-box,
.sidebar-collapsed .route-results,
.sidebar-collapsed .route-panel,
.sidebar-collapsed .insight-dock {
  display: none;
}

.mode-list .sidebar {
  grid-template-rows: minmax(0, 1fr) 96px;
}

.mode-list .search-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
}

.mode-list .route-panel {
  display: none;
}

.mode-list .route-results {
  max-height: none;
  min-height: 0;
}

.mode-detail .search-box,
.mode-detail .route-results {
  display: none;
}

.brand-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.brand-copy {
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
}

.brand-row h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.1;
}

.brand-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.language-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, auto);
  align-self: start;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7f9fc;
}

.language-switch button {
  min-width: 32px;
  height: 28px;
  border: 0;
  background: transparent;
  color: #667386;
  font-size: 11px;
  font-weight: 900;
}

.language-switch button.active {
  background: var(--blue);
  color: #fff;
}

.search-box {
  display: grid;
  gap: 7px;
}

.search-box span {
  color: #47505f;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.search-box input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 2px solid #b9c3d0;
  border-radius: 6px;
  outline: 0;
  color: var(--ink);
  background: #fff;
  font-size: 17px;
  font-weight: 750;
}

.search-box input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(10, 77, 143, 0.14);
}

.route-results {
  display: grid;
  gap: 8px;
  max-height: 196px;
  margin-top: 12px;
  overflow: auto;
  padding-right: 2px;
}

.route-result,
.stop-row,
.ranking-row,
.period-stat-row {
  border: 1px solid var(--soft-line);
  background: #fff;
  color: inherit;
  text-align: left;
}

.route-result {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 9px 10px;
  border-left: 5px solid transparent;
  border-radius: 8px;
}

.route-result:hover,
.route-result.active {
  border-color: #b8c7d9;
  border-left-color: var(--blue);
  background: #f5f8fc;
}

.route-pill {
  display: grid;
  min-width: 46px;
  height: 36px;
  place-items: center;
  border-radius: 18px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
}

.route-result-main {
  min-width: 0;
}

.route-result-main strong {
  display: block;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-result-main span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 999px;
  background: var(--tier-color, #e5e7eb);
  color: #1b1e24;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.tier-4,
.tier-5 {
  color: #fff;
}

.route-panel {
  min-height: 0;
  overflow: auto;
  padding: 16px 18px 22px;
}

.route-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.back-to-list {
  grid-column: 1 / -1;
  justify-self: start;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 850;
}

.back-to-list:hover {
  border-color: var(--blue);
  background: #f4f8fc;
}

.route-badge-large {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 24px;
  font-weight: 950;
}

.route-heading {
  min-width: 0;
}

.route-heading h2 {
  margin: 0;
  overflow: hidden;
  font-size: 22px;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.level-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 12px 14px;
  border: 1px solid var(--soft-line);
  border-left: 8px solid var(--tier-color);
  border-radius: 8px;
  background: #fff;
}

.level-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.level-card strong {
  font-size: 22px;
  line-height: 1;
}

.period-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 0 12px;
}

.period-tab {
  min-width: 0;
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #303846;
  font-size: 13px;
  font-weight: 800;
}

.period-tab:hover,
.period-tab.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.period-stats {
  display: grid;
  gap: 7px;
  margin-bottom: 18px;
}

.period-stat-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 88px;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 39px;
  padding: 8px 10px;
  border-radius: 8px;
}

.period-stat-row.active {
  border-color: #a9bfd8;
  background: #f4f8fc;
}

.period-stat-row span,
.period-stat-row strong {
  font-size: 12px;
}

.period-stat-row strong {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  display: block;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eaf1;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--tier-color);
}

.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 9px;
}

.section-title-row h2 {
  margin: 0;
  font-size: 15px;
}

.section-title-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.stop-list {
  display: grid;
  gap: 7px;
  padding-bottom: 6px;
}

.stop-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 54px;
  padding: 8px 10px;
  border-radius: 8px;
}

.stop-row:hover,
.stop-row.active {
  border-color: #abc0d8;
  background: #f4f8fc;
}

.stop-sequence {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #edf1f6;
  color: #3f4a5a;
  font-size: 12px;
  font-weight: 850;
}

.stop-row-main {
  min-width: 0;
}

.stop-row-main strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stop-row-main span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.tier-dot-label {
  display: grid;
  justify-items: end;
  gap: 3px;
  min-width: 78px;
}

.tier-dot-label i {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
}

.tier-dot-label strong {
  font-size: 11px;
  white-space: nowrap;
}

.insight-dock {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 8px;
  align-items: center;
  padding: 9px 12px 8px;
  border-top: 1px solid var(--soft-line);
  background: #f8fafc;
}

.dock-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #2d3748;
  font-size: 13px;
  font-weight: 850;
}

.dock-button.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.dock-icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: rgba(10, 77, 143, 0.12);
}

.dock-button.active .dock-icon {
  background: rgba(255, 255, 255, 0.18);
}

.statement-link {
  grid-column: 1 / -1;
  justify-self: center;
  min-height: 18px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: #7a8492;
  font-size: 11px;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.statement-link:hover {
  color: var(--blue-dark);
}

.map-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--map-bg);
}

.map-topbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.map-route-badge,
.map-actions,
.insight-panel,
.map-legend,
.stop-popup {
  pointer-events: auto;
}

.map-route-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: min(520px, 58vw);
  padding: 10px 12px;
  border: 1px solid rgba(110, 123, 140, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(21, 31, 45, 0.12);
}

.map-route-badge div {
  min-width: 0;
}

.map-route-badge strong,
.map-route-badge span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-route-badge > .route-pill {
  display: grid;
  flex: 0 0 auto;
  overflow: visible;
  color: #fff;
  text-overflow: clip;
}

.map-route-badge strong {
  font-size: 14px;
}

.map-route-badge span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.map-route-badge i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
}

.direction-select {
  width: 100%;
  max-width: 190px;
  height: 30px;
  margin-top: 8px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #263244;
  font-size: 12px;
  font-weight: 800;
}

.map-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(110, 123, 140, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(21, 31, 45, 0.12);
  font-size: 20px;
  font-weight: 850;
}

.route-map {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.route-map.dragging {
  cursor: grabbing;
}

.map-bg {
  fill: #eef3f4;
}

.tile-layer {
  pointer-events: none;
}

.map-tile {
  opacity: 0.96;
}

.map-grid {
  stroke: rgba(92, 108, 125, 0.1);
  stroke-width: 1;
}

.district-label {
  fill: rgba(44, 60, 76, 0.32);
  font-size: 21px;
  font-weight: 800;
  text-anchor: middle;
}

.route-line-halo {
  fill: none;
  stroke: rgba(255, 255, 255, 0.95);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 16;
}

.route-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 8;
}

.direction-label {
  fill: var(--blue-dark);
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 5px;
  font-size: 24px;
  font-weight: 950;
}

.stop-marker circle {
  stroke: #fff;
  stroke-width: 2.5;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.stop-marker:hover circle,
.stop-marker.active circle {
  stroke: #121822;
  stroke-width: 3;
}

.stop-popup {
  position: absolute;
  z-index: 6;
  display: grid;
  gap: 4px;
  width: min(280px, calc(100% - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  transform: translate(-50%, calc(-100% - 14px));
}

.stop-popup.hidden,
.loading-state.hidden {
  display: none;
}

.stop-popup strong {
  font-size: 14px;
  line-height: 1.2;
}

.stop-popup span,
.popup-route {
  color: var(--muted);
  font-size: 12px;
}

.stop-popup em {
  display: inline-flex;
  width: fit-content;
  margin-top: 2px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--tier-color);
  color: #fff;
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
}

.stop-popup em.tier-1,
.stop-popup em.tier-2,
.stop-popup em.tier-3 {
  color: #1b1e24;
}

.insight-panel {
  position: absolute;
  right: 16px;
  bottom: 70px;
  z-index: 4;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(360px, calc(100% - 32px));
  max-height: min(560px, calc(100% - 160px));
  overflow: hidden;
  border: 1px solid rgba(110, 123, 140, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.insight-panel.hidden {
  display: none;
}

.insight-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--soft-line);
}

.insight-header span {
  font-size: 13px;
  font-weight: 900;
}

.insight-header strong {
  color: var(--muted);
  font-size: 12px;
}

.insight-close {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #364152;
  font-size: 18px;
  font-weight: 900;
}

.insight-close:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.ranking-list {
  overflow: auto;
  padding: 8px;
}

.ranking-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  margin-bottom: 6px;
  padding: 7px 8px;
  border-radius: 8px;
}

.ranking-row:hover,
.ranking-row.active {
  border-color: #adc2d9;
  background: #f4f8fc;
}

.ranking-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #edf1f6;
  color: #3f4a5a;
  font-size: 12px;
  font-weight: 900;
}

.empty-report {
  padding: 18px;
}

.empty-report h2 {
  margin: 0;
  font-size: 18px;
}

.empty-report p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.map-legend {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 392px);
  padding: 10px 12px;
  border: 1px solid rgba(110, 123, 140, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 24px rgba(21, 31, 45, 0.12);
  color: #3d4756;
  font-size: 12px;
  font-weight: 750;
}

.map-attribution {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: #5c6675;
  font-size: 10px;
  pointer-events: none;
}

.statement-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
}

.statement-modal.hidden {
  display: none;
}

.statement-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(13, 22, 34, 0.42);
  cursor: default;
}

.statement-card {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  max-height: min(720px, calc(100vh - 44px));
  overflow: auto;
  padding: 24px;
  border: 1px solid rgba(110, 123, 140, 0.28);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.statement-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #344155;
  font-size: 20px;
  font-weight: 900;
}

.statement-close:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.statement-eyebrow {
  margin: 0 42px 8px 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.statement-card h2 {
  margin: 0 42px 14px 0;
  font-size: 22px;
  line-height: 1.15;
}

.statement-body {
  display: grid;
  gap: 12px;
  color: #354153;
  font-size: 14px;
  line-height: 1.6;
}

.statement-body p {
  margin: 0;
}

.statement-body ul {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 20px;
}

.legend-line {
  display: inline-block;
  width: 28px;
  height: 6px;
  margin-right: 5px;
  border-radius: 999px;
  background: #f03b20;
  vertical-align: middle;
}

.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 5px;
  border-radius: 50%;
  background: #feb24c;
  vertical-align: middle;
}

.legend-ramp {
  display: inline-grid;
  grid-template-columns: repeat(5, 18px);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
}

.legend-ramp i {
  display: block;
  height: 12px;
}

.loading-state {
  position: fixed;
  inset: 16px;
  z-index: 20;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-weight: 850;
}

.loading-state.error {
  color: #991b1b;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(430px, 52vh) minmax(430px, 48vh);
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(430px, 1fr) 76px;
  }

  .sidebar {
    order: 2;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: auto;
    min-height: 620px;
    border-top: 1px solid #b9c3d1;
    border-right: 0;
  }

  .sidebar-collapsed .sidebar {
    min-height: 76px;
  }

  .map-panel {
    order: 1;
    min-height: 430px;
  }

  .route-panel {
    max-height: none;
  }

  .route-results {
    max-height: 142px;
  }

  .map-topbar {
    top: 10px;
    left: 10px;
    right: 10px;
  }

  .sidebar-toggle {
    top: 16px;
    right: 12px;
    border-radius: 8px;
  }

  .map-route-badge {
    max-width: calc(100vw - 84px);
  }

  .insight-panel {
    right: 10px;
    bottom: 102px;
    width: min(340px, calc(100% - 20px));
    max-height: 220px;
  }

  .map-legend {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
    flex-wrap: wrap;
  }

  .map-attribution {
    right: 10px;
    bottom: 86px;
  }
}

@media (max-width: 520px) {
  .search-panel,
  .route-panel {
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand-row h1 {
    font-size: 17px;
  }

  .route-result {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .route-result .tier-badge {
    grid-column: 2;
    justify-self: start;
  }

  .period-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .period-stat-row {
    grid-template-columns: 64px minmax(0, 1fr) 78px;
  }

  .stop-row {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .tier-dot-label {
    grid-column: 2;
    justify-items: start;
    grid-auto-flow: column;
    align-items: center;
  }

  .insight-panel {
    left: 10px;
    right: 10px;
    width: auto;
  }
}

@media (max-width: 900px) {
  body {
    background: #eef3f6;
  }

  .app-shell {
    grid-template-rows: clamp(390px, 56svh, 540px) auto;
    min-height: 100svh;
  }

  .app-shell.sidebar-collapsed {
    grid-template-rows: minmax(430px, calc(100svh - 76px)) 76px;
  }

  .map-panel {
    height: clamp(390px, 56svh, 540px);
    min-height: 0;
  }

  .sidebar {
    min-height: calc(100svh - clamp(390px, 56svh, 540px));
    border-top: 1px solid rgba(135, 150, 170, 0.55);
    box-shadow: 0 -10px 24px rgba(23, 37, 53, 0.08);
  }

  .sidebar-toggle {
    top: 18px;
    right: 12px;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    font-size: 23px;
  }

  .brand-row {
    position: relative;
    grid-template-columns: 50px minmax(0, 1fr);
    padding-right: 112px;
    margin-bottom: 14px;
  }

  .language-switch {
    position: absolute;
    top: 0;
    right: 58px;
  }

  .brand-mark {
    width: 50px;
    height: 50px;
  }

  .map-topbar {
    align-items: start;
    gap: 8px;
  }

  .map-actions {
    display: grid;
    grid-template-columns: repeat(3, 38px);
    gap: 6px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 18px;
  }

  .map-route-badge {
    max-width: calc(100vw - 152px);
    padding: 8px;
    border-radius: 10px;
    gap: 8px;
  }

  .map-route-badge > .route-pill {
    min-width: 48px;
    height: 44px;
    border-radius: 22px;
  }

  .map-route-badge strong {
    font-size: 13px;
  }

  .map-route-badge span {
    font-size: 11px;
  }

  .direction-select {
    height: 34px;
    max-width: 100%;
    margin-top: 7px;
    border-radius: 8px;
    font-size: 12px;
  }

  .map-legend {
    display: grid;
    grid-template-columns: auto auto auto minmax(88px, 1fr) auto;
    gap: 7px;
    padding: 8px 9px;
    overflow-x: auto;
    white-space: nowrap;
  }

  .legend-ramp {
    grid-template-columns: repeat(5, minmax(16px, 1fr));
    min-width: 92px;
  }

  .map-attribution {
    bottom: 64px;
    max-width: calc(100% - 20px);
    font-size: 9px;
  }

  .insight-dock {
    position: static;
    z-index: 1;
  }
}

@media (max-width: 520px) {
  .search-panel {
    padding: 14px 14px 12px;
  }

  .brand-row {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 10px;
    padding-right: 108px;
  }

  .brand-mark {
    width: 54px;
    height: 54px;
    font-size: 14px;
  }

  .brand-row h1 {
    font-size: 18px;
    line-height: 1.12;
  }

  .brand-row p {
    font-size: 11px;
  }

  .language-switch button {
    min-width: 30px;
    height: 30px;
    font-size: 11px;
  }

  .search-box input {
    height: 48px;
    font-size: 16px;
  }

  .route-results {
    gap: 7px;
    margin-top: 10px;
    padding-right: 0;
  }

  .route-result {
    grid-template-columns: 58px minmax(0, 1fr) auto;
    gap: 8px;
    min-height: 66px;
    padding: 9px 8px;
    border-left-width: 4px;
  }

  .route-result .route-pill {
    min-width: 48px;
    height: 42px;
    border-radius: 22px;
    font-size: 15px;
  }

  .route-result-main strong {
    font-size: 15px;
  }

  .route-result-main span {
    font-size: 11px;
  }

  .route-result .tier-badge {
    grid-column: auto;
    min-width: 64px;
    min-height: 26px;
    padding: 4px 7px;
    font-size: 10px;
  }

  .map-topbar {
    top: 8px;
    left: 8px;
    right: 8px;
  }

  .map-actions {
    grid-template-columns: repeat(3, 35px);
    gap: 5px;
  }

  .icon-button {
    width: 35px;
    height: 35px;
    font-size: 17px;
  }

  .map-route-badge {
    max-width: calc(100vw - 128px);
    padding: 7px;
  }

  .map-route-badge > .route-pill {
    min-width: 42px;
    height: 40px;
    border-radius: 20px;
    font-size: 14px;
  }

  .direction-select {
    height: 32px;
  }

  .map-legend {
    left: 8px;
    right: 8px;
    bottom: 8px;
    grid-template-columns: auto auto auto minmax(76px, 1fr) auto;
    gap: 6px;
    padding: 7px 8px;
    font-size: 11px;
  }

  .legend-line {
    width: 22px;
  }

  .legend-dot {
    width: 10px;
    height: 10px;
  }

  .legend-ramp {
    min-width: 78px;
  }

  .map-attribution {
    right: 8px;
    bottom: 58px;
  }
}

@media (max-width: 380px) {
  .brand-row {
    padding-right: 96px;
  }

  .language-switch {
    right: 54px;
  }

  .sidebar-toggle {
    width: 38px;
    height: 38px;
  }

  .map-route-badge {
    max-width: calc(100vw - 122px);
  }

  .map-route-badge span {
    white-space: normal;
  }

  .route-result {
    grid-template-columns: 52px minmax(0, 1fr) auto;
  }

  .route-result .tier-badge {
    min-width: 58px;
    padding-inline: 6px;
  }
}
