:root {
  --ink: #1c252b;
  --navy: #0b3142;
  --teal: #0e7c86;
  --sand: #f5f0e8;
  --sand-strong: rgba(245, 240, 232, 0.96);
  --glass: rgba(255, 255, 255, 0.84);
  --border: rgba(18, 42, 58, 0.1);
  --shadow: 0 18px 48px rgba(10, 24, 34, 0.16);
  --muted: #5d6c75;
  --bus: #ef8d32;
  --metro-red: #d14b44;
  --metro-green: #27905f;
  --metro-blue: #1378c8;
  --tram: #0d6f77;
  --train: #8157d6;
  --ship: #0b9bbf;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(14, 124, 134, 0.2), transparent 30%),
    linear-gradient(180deg, #efe8dc 0%, #f8f4ee 100%);
  color: var(--ink);
}

body {
  overflow: hidden;
}

#map,
#loadingOverlay {
  position: absolute;
  inset: 0;
}

#map {
  background: #e6dfd3;
}

#panel {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 10;
  width: min(420px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 16px 16px 18px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), var(--sand-strong)),
    rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.panel-header,
.panel-row,
.brand,
.stats-grid,
.mode-row,
.route-row,
.clock-header,
.clock-footer {
  display: flex;
}

.panel-header,
.panel-row,
.clock-header,
.clock-footer {
  align-items: center;
}

.panel-header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.brand {
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 66px;
  height: auto;
}

.brand-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy);
}

.brand-subtitle,
.meta,
.notes,
.stat-label,
.route-sub,
.mode-row-label,
.mode-row-value,
.section-label,
.checkbox {
  color: var(--muted);
}

.brand-subtitle,
.meta,
.notes,
.stat-label,
.route-sub,
.mode-row-label,
.mode-row-value,
.checkbox {
  font-size: 12px;
}

.meta + .meta {
  margin-top: 3px;
}

.section-label {
  margin: 14px 0 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mode-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.city-pills {
  margin: 10px 0 2px;
}

.pill,
.btn,
.action-btn {
  border-radius: 999px;
  font-family: inherit;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    opacity 0.15s ease,
    background 0.15s ease;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.pill.off {
  opacity: 0.35;
}

.pill:hover,
.btn:hover,
.action-btn:hover {
  transform: translateY(-1px);
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.panel-row {
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.panel-row.compact {
  margin-top: 6px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn,
.action-btn {
  border: 0;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 800;
}

.btn {
  background: var(--navy);
  color: #fff;
}

.btn.secondary {
  background: rgba(11, 49, 66, 0.12);
  color: var(--navy);
}

.action-btn {
  background: rgba(14, 124, 134, 0.12);
  color: var(--teal);
}

.stats-grid {
  margin-top: 12px;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-card {
  min-width: calc(50% - 5px);
  padding: 11px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(17, 38, 53, 0.07);
}

.stat-value {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
}

#timelineCanvas {
  width: 100%;
  height: 92px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(17, 38, 53, 0.06);
}

.mode-bars,
.table-list {
  display: grid;
  gap: 8px;
}

.ooh-summary {
  margin: 2px 0 10px;
  font-size: 12px;
  color: var(--muted);
}

.ooh-pie-card {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(18, 42, 58, 0.06);
}

.ooh-pie-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ooh-pie-chart {
  position: relative;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: conic-gradient(rgba(11, 49, 66, 0.16) 0deg 360deg);
  box-shadow: inset 0 0 0 1px rgba(18, 42, 58, 0.06);
}

.ooh-pie-chart::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: inset 0 0 0 1px rgba(18, 42, 58, 0.05);
}

.ooh-pie-center {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.ooh-pie-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
}

.ooh-pie-label {
  margin-top: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.ooh-pie-legend {
  display: grid;
  gap: 8px;
}

.ooh-pie-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.ooh-pie-row strong {
  color: var(--ink);
}

.mode-row {
  align-items: center;
  gap: 10px;
}

.mode-row-label {
  width: 74px;
  flex: 0 0 auto;
  font-weight: 700;
}

.mode-row-bar {
  flex: 1 1 auto;
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.mode-row-fill {
  height: 100%;
  border-radius: inherit;
}

.mode-row-value {
  width: 48px;
  text-align: right;
  font-weight: 700;
}

.route-row {
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(18, 42, 58, 0.06);
  gap: 12px;
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.route-row:hover,
.route-row:focus-visible {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(11, 82, 119, 0.26);
  box-shadow: 0 8px 18px rgba(10, 24, 34, 0.08);
  transform: translateY(-1px);
}

.route-row:focus-visible {
  outline: 0;
}

.route-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.route-metric {
  font-size: 20px;
  font-weight: 800;
  color: var(--navy);
}

.notes {
  line-height: 1.45;
}

.map-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 12;
  display: flex;
  gap: 8px;
  align-items: center;
}

.mini-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 12px 26px rgba(10, 24, 34, 0.14);
  border: 1px solid rgba(18, 42, 58, 0.08);
  backdrop-filter: blur(10px);
}

.mini-toggle-btn {
  border: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.mini-toggle-btn.active {
  background: rgba(14, 124, 134, 0.14);
  color: var(--navy);
}

.mini-toggle.disabled {
  opacity: 0.5;
}

.mini-toggle.disabled .mini-toggle-btn {
  cursor: default;
}

#loadingOverlay {
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  background: rgba(245, 240, 232, 0.92);
  color: var(--navy);
}

#loadingOverlay.is-hidden {
  display: none;
}

#loadingError {
  max-width: 420px;
  padding: 0 20px;
  text-align: center;
  color: #a2392a;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(11, 49, 66, 0.18);
  border-top-color: var(--navy);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#clockDock {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
}

.clock-analog {
  width: 78px;
  height: 78px;
  padding: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 26px rgba(10, 24, 34, 0.16);
  backdrop-filter: blur(10px);
}

.clock-face {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(11, 49, 66, 0.08), rgba(255, 255, 255, 0.95));
  border: 1px solid rgba(18, 42, 58, 0.12);
}

.clock-hand {
  position: absolute;
  left: calc(50% - 1.5px);
  bottom: 50%;
  width: 3px;
  transform-origin: center bottom;
  border-radius: 999px;
  background: var(--navy);
}

.hour-hand {
  height: 22px;
}

.minute-hand {
  height: 30px;
  background: var(--teal);
}

.clock-center {
  position: absolute;
  inset: calc(50% - 4px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--navy);
}

.clock-card {
  min-width: 190px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 40px rgba(10, 24, 34, 0.18);
  backdrop-filter: blur(12px);
}

.clock-header,
.clock-footer {
  justify-content: space-between;
}

.clock-dow,
.clock-period,
.clock-month,
.clock-day,
.clock-year {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.clock-time {
  margin: 6px 0;
  font-size: 32px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
}

.maplibregl-popup-content {
  border-radius: 14px;
  padding: 12px 14px;
  font-family: inherit;
}

.hover-popup .maplibregl-popup-content {
  box-shadow: 0 14px 32px rgba(10, 24, 34, 0.16);
}

.popup-title {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 800;
  color: var(--navy);
}

.popup-copy {
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink);
}

@media (max-width: 900px) {
  #panel {
    width: calc(100vw - 24px);
    max-height: min(58vh, calc(100vh - 24px));
    top: 12px;
    left: 12px;
    right: 12px;
  }

  #clockDock {
    left: 12px;
    right: 12px;
    bottom: 12px;
    justify-content: flex-end;
  }

  .map-controls {
    top: auto;
    right: 12px;
    bottom: 124px;
    max-width: calc(100vw - 24px);
  }

  .clock-card {
    min-width: 0;
  }
}

@media (max-width: 620px) {
  #panel {
    max-height: 62vh;
    padding: 14px;
  }

  .brand img {
    width: 54px;
  }

  .ooh-pie-card {
    grid-template-columns: 1fr;
  }

  .clock-analog {
    display: none;
  }

  .clock-card {
    width: min(220px, calc(100vw - 24px));
  }

  .stat-card {
    min-width: 100%;
  }

  .mini-toggle {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
  }
}
