html, body, #map { 
  height: 100%; 
  margin: 0; 
}

body { 
  font-family: 'Quicksand', 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif; 
}

.status-bar {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(32, 32, 32, 0.85);
  color: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  z-index: 1000;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #2ecc71; /* green by default */
}

.status-bar.error .status-dot { 
  background: #e74c3c; /* red on error */
}

.status-bar.stale .status-dot { 
  background: #f1c40f; /* yellow on stale */
}

/* DivIcon styling for a circle with a tiny bearing arrow (CSS transform) */
.bus-marker {
  position: relative;
  width: 16px;
  height: 16px;
  background: #1976d2;           /* blue circle */
  border: 2px solid white;       /* white edge for contrast */
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
}

.bus-marker .bearing-arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 10px;
  background: #111;
  transform-origin: 50% 90%;
  border-radius: 1px;
  /* default rotation is 0; we set inline style transform to rotate(deg) at runtime */
}

.bus-marker .bearing-tip {
  position: absolute;
  left: 50%;
  top: 2px;
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-bottom: 5px solid #111;
  transform: translateX(-50%);
}

/* Popup table */
.popup-table {
  border-collapse: collapse;
  font-size: 12px;
}

.popup-table td {
  padding: 2px 4px;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}

.popup-table td:first-child {
  color: #555;
  white-space: nowrap;
}

.vehicle-count {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(32, 32, 32, 0.82);
  color: #fff;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  z-index: 500;
  pointer-events: none;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ── Filter panel ───────────────────────────────────────────────── */
#filterPanel {
  display: block;
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 10px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
  padding: 12px 14px 14px;
  z-index: 1001;
  font-size: 18px;
  font-family: inherit;
  width:350px;
  min-width: 230px;
  max-width: 290px;
}
#filterPanel.open { display: block; /* already block by default */ }

.filter-title {
  font-weight: 700;
  font-size: 22px;
  margin-bottom: 10px;
}

.filter-section { margin-bottom: 10px; }

.filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.filter-row label {
  font-weight: 600;
}

.filter-select-all {
  font-size: 15px;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid #bbb;
  background: #f5f5f5;
  cursor: pointer;
  font-family: inherit;
}
.filter-select-all:hover { background: #e0e0e0; }

select.filter-select {
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 3px 4px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  box-sizing: border-box;
}

.filter-apply {
  width: 100%;
  margin-top: 4px;
  padding: 7px 0;
  background: #1976d2;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.filter-apply:hover { background: #1565c0; }

/* Agency Selector Row (within filter panel) */
.agency-selector-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.agency-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 6px;
  font-size: 26px;
  font-weight: 900;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.agency-ttc {
  background: #f5f5f5;
  color: #c41e3a;
  border: 2px solid #c41e3a;
}

.agency-ttc:hover:not(.active) {
  background: #fee;
}

.agency-ttc.active {
  background: #c41e3a;
  color: white;
  box-shadow: 0 3px 8px rgba(196, 30, 58, 0.25);
}

.agency-translink {
  background: #f5f5f5;
  color: #0066cc;
  border: 2px solid #0066cc;
}

.agency-translink:hover:not(.active) {
  background: #eef;
}

.agency-translink.active {
  background: #0066cc;
  color: white;
  box-shadow: 0 3px 8px rgba(0, 102, 204, 0.25);
}

/* View Recordings button */
.view-recordings-btn {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(67, 160, 71, 0.9);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 12px 24px;
  width: 325px;
  font-size: 25px;
  font-weight: 600;
  cursor: pointer;
  z-index: 500;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.2s;
}

.view-recordings-btn:hover {
  background: rgba(56, 142, 60, 0.95);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transform: translateY(-2px);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .vehicle-count {
    bottom: 8px;
    right: 8px;
    font-size: 11px;
  }
}
