:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --text: #17201c;
  --muted: #617069;
  --line: #d9e1dc;
  --green: #125c4c;
  --green-2: #1f7a63;
  --blue: #125c9a;
  --orange: #e25842;
  --yellow: #f5c84b;
  --shadow: 0 18px 50px rgba(24, 34, 29, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 64px 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  z-index: 1200;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}

.brand img {
  width: 38px;
  height: 38px;
  border-radius: 8px;
}

.brand span {
  display: grid;
  line-height: 1.05;
}

.brand strong {
  font-size: 18px;
  letter-spacing: 0;
}

.brand small,
.hint,
.panel-head p,
.metric span,
.eyebrow {
  color: var(--muted);
}

.toolbar,
.admin-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.button,
.ghost-button,
.wide-action,
.segmented button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-height: 40px;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.icon-button {
  width: 42px;
  border-radius: 8px;
  font-size: 20px;
}

.filter-icon {
  width: 20px;
  height: 18px;
  display: inline-block;
  background: currentColor;
  clip-path: polygon(0 0, 100% 0, 62% 46%, 62% 82%, 38% 100%, 38% 46%);
}

.icon-button:hover,
.button:hover,
.ghost-button:hover,
.wide-action:hover,
.segmented button:hover {
  border-color: var(--green-2);
}

.icon-button.active,
.segmented button.active,
.button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.button.danger {
  background: #fff0ed;
  border-color: #f0b3a8;
  color: #8b2c20;
}

.admin-link,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  text-decoration: none;
}

.admin-link {
  color: var(--green);
  font-weight: 700;
}

.map-layout {
  position: relative;
  min-height: 0;
}

.map-stage,
#map {
  width: 100%;
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
}

.map-style-light .leaflet-tile {
  filter: grayscale(0.3) saturate(0.62) brightness(1.08) contrast(0.9);
}

.map-style-contrast .leaflet-tile {
  filter: saturate(0.85) contrast(1.14);
}

.mobile-board-actions,
.mobile-routes-actions,
.mobile-stop-picker {
  display: none;
}

.geo-dialog {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.geo-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 15, 0.58);
  backdrop-filter: blur(5px);
}

.geo-dialog__content {
  position: relative;
  width: min(390px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.geo-dialog__icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--green);
  font-size: 34px;
}

.geo-dialog h2,
.geo-dialog p {
  margin: 0;
}

.geo-dialog h2 {
  font-size: 22px;
}

.geo-dialog p {
  color: var(--muted);
  line-height: 1.45;
}

.geo-dialog__confirm {
  width: 100%;
  min-height: 50px;
  font-weight: 800;
}

.geo-dialog__map {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--green);
  cursor: pointer;
  font-weight: 800;
}

.icon-button.is-locating span {
  display: inline-block;
  animation: locate-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes locate-pulse {
  to { transform: scale(1.25); opacity: 0.55; }
}

.route-panel {
  position: absolute;
  inset: 16px auto 16px 16px;
  z-index: 1000;
  width: min(380px, calc(100vw - 32px));
  height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.panel-tabs button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.panel-tabs button.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.panel-section {
  min-height: 0;
  display: none;
}

.panel-section.active {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.route-panel.collapsed {
  display: none;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.panel-head h1,
.admin-header h1,
.auth-card h1 {
  margin: 0;
  letter-spacing: 0;
}

.panel-head h1 {
  font-size: 24px;
}

.panel-head p {
  margin: 5px 0 0;
  font-size: 14px;
}

.ghost-button,
.wide-action {
  border-radius: 8px;
  padding: 0 12px;
}

.wide-action {
  width: 100%;
  background: var(--surface-2);
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.segmented button {
  border-radius: 8px;
  min-width: 0;
  padding: 0 8px;
  font-size: 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 14px;
}

.route-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.sidebar-stop-board {
  min-height: 0;
  flex: 1;
  display: grid;
}

.route-item {
  display: grid;
  grid-template-columns: 1fr 48px 48px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
}

.route-item.is-filtered-out {
  display: none;
}

.route-code {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--surface-2);
  font-weight: 800;
}

.route-code.bus {
  color: #1f2925;
}

.route-code.trolley {
  color: var(--blue);
}

.dir-button {
  width: 48px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
}

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

.status-card {
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 1000;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #f0b3a8;
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: #8b2c20;
}

.preload-card {
  position: absolute;
  right: 16px;
  bottom: 18px;
  z-index: 1000;
  width: min(330px, calc(100vw - 32px));
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  color: var(--text);
}

.preload-card.is-done {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.preload-card strong {
  font-size: 14px;
}

.preload-card ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.preload-card li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.preload-card li span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c9d3ce;
}

.preload-card li.is-loading span {
  background: var(--yellow);
}

.preload-card li.is-done span {
  background: var(--green);
}

.preload-card li.is-error span {
  background: var(--orange);
}

.preload-card small {
  color: var(--muted);
  line-height: 1.35;
}

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  z-index: 1000;
  background: rgba(23, 32, 28, 0.12);
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
}

.bus-marker {
  transition: transform 0.45s ease-out;
}

.map-touch-transforming .bus-marker,
.map-touch-transforming .leaflet-marker-icon,
.map-touch-transforming .leaflet-marker-shadow {
  transition: none !important;
}

.vehicle-popup {
  min-width: 240px;
  max-width: 280px;
}

.vehicle-popup__photo {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 10px;
}

.vehicle-popup__title {
  margin-bottom: 4px;
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
}

.vehicle-popup__rating {
  margin-bottom: 8px;
  color: #c28a08;
  letter-spacing: 0;
}

.vehicle-popup dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.vehicle-popup dl div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.vehicle-popup dt {
  color: var(--muted);
  font-size: 12px;
}

.vehicle-popup dd {
  margin: 0;
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.vehicle-popup__description {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--text);
  line-height: 1.45;
}

.stop-popup {
  min-width: 190px;
  display: grid;
  gap: 10px;
}

.stop-popup__routes {
  display: grid;
  gap: 5px;
}

.stop-popup__routes > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.stop-popup__routes > div {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.stop-popup__routes i {
  min-width: 28px;
  min-height: 24px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 6px;
  background: #27342f;
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.stop-popup__routes i.trolley {
  background: var(--blue);
}

.stop-popup__routes small {
  color: var(--muted);
  font-size: 12px;
}

.stop-board {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 12px;
  border-radius: 8px;
  background: #15211d;
  color: #f5fbf7;
  overflow: hidden;
}

.sidebar-stop-board .stop-board {
  max-height: none;
  height: 100%;
}

.stop-board__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.stop-board__header > div {
  min-width: 0;
}

.stop-board__header > strong {
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--yellow);
  color: #17201c;
}

.stop-board__header > strong.stop-board__selected-route {
  min-width: 48px;
  padding: 0 8px;
  font-size: 14px;
  font-weight: 900;
}

.stop-board__header > strong.stop-board__selected-route.bus {
  background: #f0b429;
  color: #17201c;
}

.stop-board__header > strong.stop-board__selected-route.trolley {
  background: #125c9a;
  color: #fff;
}

.stop-board__subtitle {
  margin-top: 2px;
  color: #f5fbf7;
  font-size: 14px;
  font-weight: 800;
}

.stop-board__sequence {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 7px;
  margin-top: 4px;
  line-height: 1.35;
}

.stop-board__sequence span {
  color: #9baba4;
  font-size: 12px;
  font-weight: 600;
}

.stop-board__sequence strong {
  color: #fff;
  font-size: 14px;
  font-weight: 900;
}

.stop-board__sequence i {
  color: #71837b;
  font-size: 12px;
  font-style: normal;
}

.stop-board__sequence span,
.stop-board__sequence strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.stop-board-direction {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #f5fbf7;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.stop-board-direction:hover,
.stop-board-direction:focus-visible {
  border-color: var(--yellow);
  color: var(--yellow);
}

.stop-board-direction:disabled {
  cursor: wait;
  opacity: 0.55;
}

.stop-board__title {
  color: #9dd7bf;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.stop-board__controls {
  min-height: 0;
  display: grid;
  grid-template-rows: 32px 30px 92px;
  gap: 7px;
}

.stop-board__filters,
.stop-board__bulk,
.stop-board__routes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 2px;
}

.stop-board__filters,
.stop-board__bulk {
  overflow: hidden;
}

.stop-board__routes {
  align-content: start;
  overflow: auto;
}

.stop-board__filters button,
.stop-board__bulk button,
.stop-board__routes button {
  min-height: 30px;
  flex: 0 1 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 0 9px;
  background: rgba(255, 255, 255, 0.08);
  color: #f5fbf7;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.stop-board__filters button.active,
.stop-board__routes button.active {
  border-color: var(--yellow);
  background: var(--yellow);
  color: #17201c;
}

.stop-board__routes button.bus.active {
  border-color: #f0b429;
  background: #f0b429;
  color: #17201c;
}

.stop-board__routes button.trolley.active {
  border-color: #6bb7ff;
  background: #125c9a;
  color: #fff;
}

.stop-board__bulk button {
  background: rgba(255, 255, 255, 0.14);
}

.stop-board__routes button:not(.active) {
  opacity: 0.55;
}

.stop-board__routes button:disabled {
  cursor: default;
}

.stop-board__routes span {
  color: #dce7e1;
  font-size: 12px;
}

.stop-board__list {
  display: grid;
  align-content: start;
  gap: 7px;
  overflow: auto;
}

.stop-board__row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  font-size: 13px;
}

.stop-board__row.active {
  box-shadow: inset 0 0 0 2px var(--yellow);
  background: rgba(245, 200, 75, 0.14);
}

.stop-board__route {
  display: grid;
  place-items: center;
  height: 34px;
  border-radius: 8px;
  background: #f0b429;
  color: #17201c;
  font-weight: 900;
}

.stop-board__route.trolley {
  background: var(--blue);
  color: #fff;
}

.stop-board__vehicle {
  display: grid;
  gap: 2px;
  overflow: hidden;
}

.stop-board__vehicle strong,
.stop-board__vehicle small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stop-board__vehicle strong {
  color: #fff;
  font-size: 13px;
}

.stop-board__vehicle small {
  color: #cfe2d9;
  font-size: 11px;
}

.stop-board__eta {
  color: var(--yellow);
  font-size: 13px;
  font-weight: 900;
  max-width: 150px;
  overflow-wrap: anywhere;
  text-align: right;
}

.stop-board__eta.is-server-fallback {
  color: #ffe7a0;
}

.stop-board__empty {
  color: #dce7e1;
  font-size: 12px;
}

.stop-routes-button {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--green);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.stop-selected-note {
  min-height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef6f2;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.active-stop-marker {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: 286px;
  height: 66px;
  white-space: nowrap;
  pointer-events: none;
}

.active-stop-marker__platform {
  width: 86px;
  height: 50px;
  flex: 0 0 86px;
  display: grid;
  place-items: center;
  color: #151716;
  transform: rotate(var(--stop-bearing));
  transform-origin: center;
  filter: drop-shadow(0 9px 18px rgba(23, 32, 28, 0.42));
}

.active-stop-marker__platform.is-pending {
  color: #4a4f4c;
}

.active-stop-marker__platform svg {
  display: block;
}

.active-stop-marker__label {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 8px 11px;
  border: 2px solid var(--green);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 6px 18px rgba(23, 32, 28, 0.14);
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
}

.leaflet-control a {
  color: var(--text);
}

.leaflet-control-touch-mode__button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: #fff;
  color: var(--green);
  cursor: pointer;
  font-size: 23px;
  font-weight: 900;
  line-height: 1;
}

.leaflet-control-touch-mode__button:hover,
.leaflet-control-touch-mode__button:focus-visible {
  background: var(--surface-2);
}

.leaflet-control-touch-mode__button.is-rotate {
  background: var(--green);
  color: #fff;
}

.admin-auth,
.admin-shell {
  min-height: 100vh;
  padding: 28px;
}

.admin-auth {
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(440px, 100%);
  display: grid;
  gap: 16px;
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand.centered {
  justify-content: center;
}

.auth-card label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.auth-card input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.alert {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff0ed;
  color: #8b2c20;
}

.hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.admin-shell {
  display: grid;
  align-content: start;
  gap: 22px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.admin-tabs {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 24px rgba(20, 45, 37, 0.08);
  scrollbar-width: thin;
}

.admin-tabs a {
  min-height: 42px;
  display: inline-flex;
  flex: 1 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.admin-tabs a:hover,
.admin-tabs a:focus-visible {
  background: var(--surface-2);
  color: var(--green);
}

.admin-tabs a.is-active {
  background: var(--green);
  color: #fff;
}

.admin-tab-panel:not(.is-active) {
  display: none !important;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
}

.metrics-grid,
.dashboard-grid {
  display: grid;
  gap: 14px;
}

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

.telemetry-admin {
  display: grid;
  gap: 14px;
}

.telemetry-settings-panel,
.telemetry-view-panel {
  overflow: visible;
}

.telemetry-state {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.telemetry-state.is-enabled {
  background: #e8f5ef;
  color: var(--green);
}

.telemetry-state.is-disabled {
  background: #fff0ed;
  color: #8b2c20;
}

.telemetry-settings-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr)) auto;
  align-items: end;
  gap: 10px;
  margin-top: 16px;
}

.telemetry-settings-form label,
.telemetry-range-controls label,
.telemetry-inspector label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.telemetry-settings-form input,
.telemetry-settings-form select,
.telemetry-range-controls input,
.telemetry-inspector input,
.telemetry-inspector select,
.telemetry-timeline select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: var(--surface);
  color: var(--text);
}

.telemetry-settings-form .telemetry-enabled {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.telemetry-settings-form .telemetry-enabled input {
  width: auto;
  min-height: auto;
}

.telemetry-live-metric {
  min-width: 120px;
  display: grid;
  justify-items: end;
  gap: 2px;
}

.telemetry-live-metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.telemetry-live-metric strong {
  color: var(--green);
  font-size: 30px;
}

.telemetry-range-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(190px, 260px)) auto;
  align-items: end;
  gap: 10px;
  margin: 16px 0 12px;
}

.telemetry-map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  min-height: 480px;
  border: 1px solid var(--line);
}

#telemetry-map {
  width: 100%;
  height: 480px;
  min-height: 480px;
}

.telemetry-inspector {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
  border-left: 1px solid var(--line);
  background: var(--surface-2);
}

.telemetry-inspector h3,
.telemetry-charts h3 {
  margin: 0;
  font-size: 15px;
}

.telemetry-near-count {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.telemetry-near-count strong {
  color: var(--green);
  font-size: 34px;
}

.telemetry-near-count span {
  color: var(--muted);
  font-size: 12px;
}

.telemetry-timeline {
  display: grid;
  gap: 8px;
  padding: 14px 0;
}

.telemetry-timeline > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.telemetry-timeline > div > strong {
  margin-right: auto;
}

.telemetry-timeline label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.telemetry-timeline select {
  min-height: 36px;
}

.telemetry-timeline > input {
  width: 100%;
  accent-color: var(--green);
}

.telemetry-charts {
  display: grid;
  grid-template-columns: 1.5fr 0.75fr 0.75fr;
  gap: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.telemetry-charts section {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.telemetry-bars,
.telemetry-mini-chart {
  height: 170px;
  display: flex;
  align-items: end;
  gap: 4px;
  overflow: hidden;
}

.telemetry-mini-chart {
  height: 100px;
}

.telemetry-bar-item {
  min-width: 0;
  height: 100%;
  flex: 1;
  display: grid;
  grid-template-rows: 20px minmax(0, 1fr) 18px;
  align-items: end;
  gap: 3px;
  text-align: center;
}

.telemetry-bar-item strong,
.telemetry-bar-item small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.telemetry-bar-item > span {
  width: 100%;
  align-self: end;
  border-radius: 4px 4px 0 0;
  background: var(--green-2);
}

.telemetry-breakdown {
  display: grid;
  align-content: start;
  gap: 10px;
}

.telemetry-breakdown > div {
  display: grid;
  grid-template-columns: 78px minmax(40px, 1fr) 28px;
  align-items: center;
  gap: 7px;
  font-size: 12px;
}

.telemetry-breakdown i {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-2);
}

.telemetry-breakdown b {
  height: 100%;
  display: block;
  background: var(--blue);
}

.dashboard-grid {
  grid-template-columns: 1.2fr 1fr;
}

.security-admin {
  display: grid;
}

.security-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 12px;
}

.security-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.security-form input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
}

.application-settings-admin,
.application-settings-form {
  display: grid;
  gap: 16px;
}

.application-settings-group {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) minmax(220px, 1fr) minmax(180px, 0.7fr);
  align-items: end;
  gap: 16px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.application-settings-group h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.application-settings-group .arrival-rule-grid {
  grid-column: 2 / -1;
}

.arrival-rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.arrival-rule {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  padding-left: 14px;
  border-left: 3px solid var(--line);
}

.setting-toggle {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.setting-toggle input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--green);
}

.setting-value {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.setting-value input,
.setting-value select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.application-settings-submit {
  justify-self: end;
}

.stop-admin {
  display: grid;
  gap: 14px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.panel-title-row h2 {
  margin-bottom: 6px;
}

.stop-cache-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.stop-cache-stats span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}

.stop-list-panel {
  max-height: 560px;
}

.stop-table td:first-child {
  min-width: 240px;
}

.stop-table td:first-child strong,
.stop-table td:first-child small {
  display: block;
}

.stop-table td:first-child small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.stop-table td:last-child {
  text-align: right;
}

.route-cache-admin {
  display: grid;
  gap: 14px;
}

.route-cache-table td:last-child {
  text-align: right;
}

.cache-status {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.cache-status.is-fresh {
  background: #eef6f2;
  color: var(--green);
}

.cache-status.is-stale {
  background: #fff8dc;
  color: #8c6b00;
}

.cache-status.is-missing {
  background: #fff0ed;
  color: #8b2c20;
}

.vehicle-admin {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.4fr);
  gap: 14px;
}

.vehicle-form,
.vehicle-row {
  display: grid;
  gap: 12px;
}

.vehicle-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.vehicle-form .wide,
.vehicle-form button {
  grid-column: 1 / -1;
}

.vehicle-form label,
.vehicle-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.vehicle-form input,
.vehicle-form textarea,
.vehicle-row input,
.vehicle-row textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
}

.vehicle-form textarea,
.vehicle-row textarea {
  resize: vertical;
}

.vehicle-list {
  display: grid;
  gap: 14px;
}

.vehicle-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.vehicle-row__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vehicle-row__head img {
  width: 56px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
}

.vehicle-row__head div {
  display: grid;
  gap: 3px;
}

.vehicle-row__head small {
  color: var(--muted);
}

.metric,
.data-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(24, 34, 29, 0.07);
}

.metric {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric strong {
  font-size: clamp(28px, 4vw, 44px);
}

.data-panel {
  padding: 18px;
  overflow: auto;
}

.data-panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.bars {
  height: 220px;
  display: flex;
  align-items: end;
  gap: 10px;
  padding-top: 12px;
}

.bar-item {
  flex: 1;
  min-width: 24px;
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  text-align: center;
}

.bar {
  align-self: end;
  display: block;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--green-2), var(--yellow));
}

.empty-state {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
}

@media (max-width: 820px) {
  body.map-page {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .app-shell {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    grid-template-rows: calc(58px + env(safe-area-inset-top)) minmax(0, 1fr);
    overflow: hidden;
  }

  .topbar {
    min-height: calc(58px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  }

  .brand strong {
    font-size: 16px;
  }

  .brand small,
  .admin-link {
    display: none;
  }

  .toolbar {
    gap: 6px;
  }

  #refresh-map {
    display: none;
  }

  .map-stage,
  #map {
    height: 100%;
    min-height: 0;
  }

  .route-panel {
    inset: auto max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    width: auto;
    height: min(70dvh, 620px);
    max-height: min(70dvh, 620px);
  }

  .route-panel.mobile-board-open {
    position: fixed;
    inset: 0;
    z-index: 2400;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    gap: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    border: 0;
    border-radius: 0;
    background: #15211d;
    box-shadow: none;
  }

  .route-panel.mobile-routes-open {
    position: fixed;
    inset: 0;
    z-index: 2400;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    gap: 14px;
    padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    border: 0;
    border-radius: 0;
    background: var(--surface);
    box-shadow: none;
  }

  .route-panel.mobile-routes-open .panel-tabs,
  .route-panel.mobile-routes-open [data-panel-section="board"] {
    display: none;
  }

  .route-panel.mobile-routes-open #routes-panel {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  .route-panel.mobile-routes-open .route-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .route-panel.mobile-routes-open .mobile-routes-actions {
    min-height: 48px;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--line);
  }

  .mobile-routes-close {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 0 4px;
    border: 0;
    background: transparent;
    color: var(--green);
    cursor: pointer;
    font-weight: 900;
  }

  .mobile-routes-close span:first-child {
    font-size: 24px;
  }

  .route-panel.mobile-board-open .panel-head,
  .route-panel.mobile-board-open .mobile-routes-actions,
  .route-panel.mobile-board-open .panel-tabs,
  .route-panel.mobile-board-open [data-panel-section="routes"] {
    display: none;
  }

  .route-panel.mobile-board-open #board-panel {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 0;
  }

  .route-panel.mobile-board-open .sidebar-stop-board {
    min-height: 0;
  }

  .route-panel.mobile-board-open .stop-board {
    border-radius: 0;
    padding: 14px;
  }

  .mobile-board-actions {
    min-height: 54px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    flex: 0 0 auto;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    background: #15211d;
  }

  .mobile-board-close,
  .mobile-board-map {
    min-height: 54px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 16px;
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-weight: 800;
  }

  .mobile-board-map {
    border-left: 1px solid rgba(255, 255, 255, 0.14);
    color: var(--yellow);
  }

  .mobile-board-close span:first-child,
  .mobile-board-map span:first-child {
    font-size: 24px;
  }

  .stop-board__row {
    min-height: 58px;
    padding: 9px;
  }

  .mobile-stop-picker {
    position: fixed;
    inset: 0;
    z-index: 2300;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    background: #f6f7f4;
  }

  .mobile-stop-picker__header {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }

  .mobile-stop-picker__header span {
    color: var(--green);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .mobile-stop-picker__header h2 {
    margin: 3px 0 0;
    font-size: 23px;
  }

  .mobile-overlay-map {
    min-width: 82px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 0 0 auto;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--green);
    cursor: pointer;
    font-weight: 900;
  }

  .mobile-overlay-map span:first-child {
    font-size: 23px;
  }

  .mobile-stop-picker__status {
    padding: 12px 2px 10px;
    color: var(--muted);
    font-size: 14px;
  }

  .mobile-stop-picker__status.is-error {
    color: #8b2c20;
  }

  .mobile-stop-picker__list {
    display: grid;
    align-content: start;
    grid-auto-rows: max-content;
    gap: 9px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 2px 1px 12px;
  }

  .mobile-stop-card {
    width: 100%;
    height: auto;
    min-height: 88px;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 24px;
    align-items: start;
    gap: 10px;
    padding: 13px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-align: left;
  }

  .mobile-stop-card:active {
    border-color: var(--green);
    background: var(--surface-2);
  }

  .mobile-stop-card.is-selected {
    border-color: var(--green);
    background: #e3f1eb;
    box-shadow: inset 0 0 0 2px rgba(18, 92, 76, 0.16);
  }

  .mobile-stop-card.is-selected .mobile-stop-card__order {
    background: var(--yellow);
    color: var(--text);
  }

  .mobile-stop-card.is-selected .mobile-stop-card__arrow {
    color: var(--orange);
  }

  .mobile-stop-card__order {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    font-weight: 900;
    align-self: center;
  }

  .mobile-stop-card__content {
    width: 100%;
    min-width: 0;
    display: grid;
    gap: 3px;
    align-self: stretch;
  }

  .mobile-stop-card__content strong {
    min-width: 0;
    max-width: 100%;
    line-height: 1.2;
    overflow-wrap: anywhere;
    word-break: normal;
    font-size: 16px;
  }

  .mobile-stop-card__content small {
    color: var(--muted);
    font-size: 13px;
  }

  .mobile-stop-card__routes {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 3px;
  }

  .mobile-stop-card__routes i {
    min-width: 27px;
    min-height: 22px;
    display: grid;
    place-items: center;
    padding: 0 6px;
    border-radius: 6px;
    background: #27342f;
    color: #fff;
    font-size: 11px;
    font-style: normal;
    font-weight: 900;
  }

  .mobile-stop-card__routes i.trolley {
    background: var(--blue);
  }

  .mobile-stop-card__arrow {
    color: var(--green);
    font-size: 30px;
    align-self: center;
  }

  .mobile-stop-picker__locate {
    width: 100%;
    min-height: 52px;
    border: 0;
    border-radius: 8px;
    background: var(--green);
    color: #fff;
    cursor: pointer;
    font-weight: 900;
  }

  body.mobile-overlay-open .topbar {
    pointer-events: none;
  }

  .metrics-grid,
  .dashboard-grid,
  .vehicle-admin,
  .security-form,
  .vehicle-form {
    grid-template-columns: 1fr;
  }

  .telemetry-settings-form,
  .telemetry-range-controls,
  .telemetry-map-layout,
  .telemetry-charts,
  .application-settings-group,
  .arrival-rule-grid {
    grid-template-columns: 1fr;
  }

  .application-settings-group .arrival-rule-grid {
    grid-column: auto;
  }

  .arrival-rule {
    padding: 12px 0 0;
    border-top: 3px solid var(--line);
    border-left: 0;
  }

  .application-settings-submit {
    width: 100%;
    justify-self: stretch;
  }

  .telemetry-map-layout {
    min-height: 0;
  }

  #telemetry-map {
    height: 380px;
    min-height: 380px;
  }

  .telemetry-inspector {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .telemetry-timeline > div {
    align-items: stretch;
    flex-direction: column;
  }

  .telemetry-timeline > div > strong {
    margin-right: 0;
  }

  .panel-title-row {
    display: grid;
  }

  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-shell {
    padding: 16px;
  }

  .admin-tabs {
    margin-inline: -16px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
}
