:root {
  color-scheme: light;
  --ink: #153331;
  --muted: #607472;
  --panel: rgba(255, 252, 243, 0.96);
  --teal: #123c3a;
  --teal-light: #d7ebe5;
  --bus: #176f63;
  --tram: #ce5c37;
  --trolley: #5757a6;
  --cream: #fff8e8;
  --line: rgba(18, 60, 58, 0.15);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body, .app-shell, #map { width: 100%; height: 100%; margin: 0; }
body { overflow: hidden; color: var(--ink); background: #dce8e4; }
button, input, select { font: inherit; }

.app-shell { position: relative; }
#map { z-index: 0; background: #dce8e4; }

.control-panel {
  position: absolute;
  z-index: 500;
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  width: min(340px, calc(100vw - 36px));
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 18px 55px rgba(18, 60, 58, 0.22);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 13px;
  color: var(--cream);
  background: var(--teal);
  font-weight: 850;
  letter-spacing: -0.05em;
}
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: 0.68rem; font-weight: 750; letter-spacing: 0.13em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.55rem; font-weight: 600; letter-spacing: -0.025em; }

.status-row { display: flex; align-items: center; margin: 14px 0 16px; color: var(--muted); font-size: 0.76rem; }
.status-dot { width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; }
.status-dot.live { background: #1d9a68; box-shadow: 0 0 0 4px rgba(29, 154, 104, 0.13); }
.status-dot.updating { background: #d49a32; animation: pulse 1s ease-in-out infinite; }
.status-dot.unavailable { background: #bd563f; }
.status-separator { margin: 0 6px; color: #a6b2b0; }
@keyframes pulse { 50% { opacity: 0.4; } }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; }
.filters label { color: var(--ink); font-size: 0.72rem; font-weight: 750; }
.field { display: grid; align-content: start; gap: 7px; min-width: 0; }
.filters select, .filters input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  background: #fff;
}
.filters select:focus, .filters input:focus { border-color: var(--bus); box-shadow: 0 0 0 3px rgba(23, 111, 99, 0.12); }
.field-help { color: var(--muted); font-size: 0.65rem; }
.filter-error { grid-column: 1 / -1; margin: 2px 0 0; color: #a53c29; font-size: 0.72rem; }
.filter-actions { display: flex; grid-column: 1 / -1; gap: 8px; margin-top: 7px; }
.button { height: 39px; padding: 0 15px; border: 0; border-radius: 11px; cursor: pointer; font-size: 0.78rem; font-weight: 750; }
.button.primary { flex: 1; color: #fff; background: var(--teal); }
.button.primary:hover { background: #1d5551; }
.button.secondary { color: var(--ink); background: var(--teal-light); }

.summary-row { display: flex; align-items: center; justify-content: space-between; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); font-size: 0.76rem; font-weight: 700; }
.active-line { padding: 4px 9px; border-radius: 99px; color: #fff; background: var(--teal); }
.legend { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 12px; color: var(--muted); font-size: 0.65rem; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.legend-dot.bus { background: var(--bus); }
.legend-dot.tram { background: var(--tram); }
.legend-dot.trolleybus { background: var(--trolley); }
.legend-dot.stop { border: 2px solid var(--teal); background: var(--cream); }

.map-message {
  position: absolute;
  z-index: 450;
  left: 50%;
  bottom: 42px;
  max-width: min(520px, calc(100vw - 40px));
  padding: 10px 15px;
  transform: translateX(-50%);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 252, 243, 0.96);
  box-shadow: 0 8px 30px rgba(18, 60, 58, 0.18);
  font-size: 0.8rem;
  text-align: center;
}
.data-credit { position: absolute; z-index: 400; right: 8px; bottom: 3px; padding: 3px 6px; border-radius: 4px; color: #4b5d5b; background: rgba(255,255,255,.82); font-size: 0.58rem; }
.data-credit a { color: inherit; }

.vehicle-icon-shell { background: transparent; border: 0; }
.vehicle-marker { position: relative; width: 44px; height: 44px; filter: drop-shadow(0 4px 5px rgba(10, 30, 29, 0.25)); }
.line-number {
  position: absolute;
  top: 13px;
  left: 13px;
  display: grid;
  place-items: center;
  min-width: 29px;
  height: 25px;
  padding: 0 4px;
  border: 2px solid #fff;
  border-radius: 8px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 850;
  line-height: 1;
}
.vehicle-marker.bus .line-number { background: var(--bus); }
.vehicle-marker.tram .line-number { background: var(--tram); }
.vehicle-marker.trolleybus .line-number { background: var(--trolley); }
.direction-arrow {
  position: absolute;
  top: -5px;
  left: 20px;
  width: 15px;
  height: 24px;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  transform-origin: 50% 27px;
}
.direction-arrow.neutral { color: #9aa5a3; opacity: 0.7; }

.leaflet-popup-content-wrapper { border-radius: 13px; color: var(--ink); box-shadow: 0 8px 30px rgba(18, 60, 58, 0.22); }
.leaflet-popup-content { margin: 13px 15px; }
.popup-title { margin-bottom: 9px; font-size: 0.95rem; font-weight: 850; }
.popup-title.bus { color: var(--bus); }
.popup-title.tram { color: var(--tram); }
.popup-title.trolleybus { color: var(--trolley); }
.popup-row { display: flex; justify-content: space-between; gap: 18px; margin: 5px 0; font-size: 0.72rem; }
.popup-row span { color: var(--muted); }
.popup-row strong { max-width: 170px; text-align: right; }
.stop-popup { display: grid; gap: 4px; }
.stop-popup strong { font-size: 0.84rem; }
.stop-popup span { color: var(--muted); font-size: 0.7rem; }

@media (max-width: 600px) {
  .control-panel { top: max(10px, env(safe-area-inset-top)); left: 10px; width: calc(100vw - 20px); padding: 13px 14px; border-radius: 16px; }
  .brand-mark { width: 37px; height: 37px; border-radius: 11px; font-size: 0.85rem; }
  h1 { font-size: 1.3rem; }
  .status-row { margin: 9px 0 11px; }
  .filters select, .filters input { height: 38px; }
  .button { height: 36px; }
  .summary-row { margin-top: 10px; padding-top: 9px; }
  .legend { margin-top: 8px; }
  .map-message { bottom: 34px; }
}

@media (max-height: 610px) {
  .legend, .field-help { display: none; }
  .control-panel { padding-block: 10px; }
  .status-row { margin-block: 7px; }
  .filter-actions { margin-top: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot.updating { animation: none; }
}
