:root {
  --brand: #ff8a00;
  --brand-dark: #d76d00;
  --ink: #172033;
  --muted: #687385;
  --line: #dfe5ec;
  --paper: #ffffff;
  --surface: rgba(255, 255, 255, 0.94);
  --danger: #b42318;
  --shadow: 0 16px 46px rgba(23, 32, 51, 0.16);
  --color-primary: #ff8a00;
  --color-customer: #1773ea;
  --color-driver: #1e293b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: #f3f8fb;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell,
.map {
  position: fixed;
  inset: 0;
}

.map {
  z-index: 0;
  background: #edf6fb;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #edf6fb;
  font: inherit;
}

.map-tile-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #f2f8fb;
  pointer-events: none;
  user-select: none;
}

.cityexpress-vector-layer {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  overflow: hidden;
  background: #f2f8fb;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  transition: opacity 160ms ease-out;
  filter: saturate(1.05) contrast(0.99) brightness(1.015);
  will-change: transform;
}

.cityexpress-vector-layer.is-ready {
  opacity: 1;
}

.cityexpress-vector-layer .maplibregl-canvas,
.cityexpress-vector-layer .maplibregl-canvas-container {
  pointer-events: none;
}

.cityexpress-vector-layer .maplibregl-control-container {
  display: none;
}

.map-tile-backdrop__tile {
  position: absolute;
  left: 0;
  top: 0;
  width: 256px;
  height: 256px;
  border: 0;
  opacity: 1;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-container .leaflet-control-attribution {
  max-width: min(480px, calc(100vw - 16px));
  margin-right: env(safe-area-inset-right, 0px);
  margin-bottom: var(--safe-bottom);
  padding: 3px 6px;
  border-radius: 6px 0 0 0;
  color: #394557;
  background: rgba(255, 255, 255, 0.96);
  font-size: 11px;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.leaflet-control-attribution a {
  color: #175b8c;
}

.leaflet-pane .route-line {
  filter: drop-shadow(0 8px 12px rgba(255, 138, 0, 0.24));
  animation: route-appear 180ms ease-out both;
}

.city-marker-shell {
  border: 0;
  background: transparent;
}

@keyframes route-appear {
  from {
    opacity: 0;
  }
  to {
    opacity: 0.94;
  }
}

.city-marker {
  position: relative;
  display: block;
  width: 48px;
  height: 58px;
}

.city-marker__bubble {
  position: absolute;
  left: 50%;
  top: 0;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--marker-color, var(--color-primary));
  box-shadow: 0 12px 24px rgba(23, 32, 51, 0.2), 0 2px 8px rgba(23, 32, 51, 0.1);
  transform: translateX(-50%);
}

.city-marker__bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 16px;
  height: 16px;
  background: inherit;
  border-right: 3px solid #fff;
  border-bottom: 3px solid #fff;
  transform: translateX(-50%) rotate(45deg);
}

.city-marker__bubble img {
  position: relative;
  z-index: 2;
  width: 24px;
  height: 24px;
}

.city-marker__pulse {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 16px;
  height: 7px;
  border-radius: 50%;
  background: rgba(23, 32, 51, 0.2);
  filter: blur(3px);
  transform: translateX(-50%);
}

.city-marker--merchant {
  --marker-color: var(--color-primary);
}

.city-marker--customer {
  --marker-color: var(--color-customer);
}

.status-pill {
  position: fixed;
  z-index: 500;
  top: calc(14px + var(--safe-top));
  left: 50%;
  max-width: min(92vw, 420px);
  transform: translateX(-50%);
  padding: 9px 14px;
  border: 1px solid rgba(11, 143, 77, 0.18);
  border-radius: 999px;
  color: var(--brand-dark);
  background: var(--surface);
  box-shadow: 0 8px 26px rgba(20, 32, 27, 0.12);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.status-pill--hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
}

.route-card {
  position: fixed;
  z-index: 500;
  right: 14px;
  bottom: calc(14px + var(--safe-bottom) + var(--map-attribution-height, 0px));
  left: 14px;
  padding: 16px;
  border: 1px solid rgba(228, 235, 231, 0.92);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.route-card--hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
}

.card-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
}

.mode-badge {
  flex: 0 0 auto;
  max-width: 42%;
  padding: 7px 10px;
  border-radius: 999px;
  color: #0a5d35;
  background: #e7f7ee;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: normal;
  text-align: center;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  min-width: 0;
  padding: 11px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.metric span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.metric strong {
  display: block;
  min-height: 22px;
  font-size: clamp(15px, 4vw, 18px);
  font-weight: 850;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.route-meta {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.message-box {
  position: fixed;
  z-index: 700;
  top: calc(60px + var(--safe-top));
  right: 14px;
  left: 14px;
  max-width: 520px;
  margin: 0 auto;
  padding: 13px 14px;
  border: 1px solid rgba(180, 35, 24, 0.18);
  border-radius: 8px;
  color: var(--danger);
  background: rgba(255, 251, 250, 0.96);
  box-shadow: 0 12px 34px rgba(20, 32, 27, 0.16);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.message-box--hidden {
  display: none;
}

@media (min-width: 720px) {
  .route-card {
    right: auto;
    left: 50%;
    width: min(440px, calc(100vw - 40px));
    transform: translateX(-50%);
  }

  .route-card--hidden {
    transform: translate(-50%, 14px);
  }

}

@media (max-width: 360px) {
  .route-card {
    right: 10px;
    left: 10px;
    padding: 13px;
  }

  .metric-grid {
    gap: 6px;
  }

  .metric {
    padding: 9px 7px;
  }
}
