* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #1c1e21;
}

body { display: flex; }

#map { flex: 1; height: 100%; background: #e8e6e1; }

/* ---- sidebar ---- */

#panel {
  width: 320px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #e2e2e2;
  z-index: 1000;
}

#panel header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid #eee;
}

#panel h1 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
}

.status { font-size: 12.5px; color: #5a5f66; min-height: 16px; }
.status.error { color: #c62828; }

.controls {
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid #eee;
}

#search {
  width: 100%;
  padding: 8px 10px;
  font-size: 13.5px;
  border: 1px solid #d5d7da;
  border-radius: 8px;
  outline: none;
}
#search:focus { border-color: #DC3D3E; }

#clear-filter {
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #DC3D3E;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
#clear-filter:hover { background: #c33334; }

.route-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
}

.route-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  font-size: 12.5px;
  border: 1.5px solid #d5d7da;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  line-height: 1.3;
}
.route-chip:hover { border-color: #9aa0a6; }
.route-chip.selected { color: #fff; }
.route-chip .count {
  font-size: 11px;
  color: #80858c;
  min-width: 14px;
  text-align: right;
}
.route-chip.selected .count { color: rgba(255, 255, 255, 0.85); }
.route-chip .num { font-weight: 700; }

#panel footer {
  padding: 10px 16px;
  font-size: 11px;
  color: #80858c;
  border-top: 1px solid #eee;
}

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  font-size: 11.5px;
  color: #45494e;
}
.legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 3px;
  vertical-align: -1px;
}
.legend .hint { color: #80858c; }

/* ---- map elements ---- */

.bus-tooltip {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 7px;
}

.bus-label {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  padding: 0 4px;
  font-size: 10.5px;
  font-weight: 700;
}
.bus-label::before { display: none; }

.bus-popup { font-size: 13px; line-height: 1.45; }
.bus-popup .route-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  margin-right: 6px;
}
.bus-popup .muted { color: #6a6f75; font-size: 12px; }

#panel-toggle.error {
  border-color: #c62828;
  color: #c62828;
}

#panel-toggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1100;
  width: 40px;
  height: 40px;
  font-size: 18px;
  border: 1px solid #d5d7da;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

/* ---- mobile ---- */

@media (max-width: 720px) {
  #panel {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
  }
  #panel.open { transform: translateX(0); }
  #panel-toggle { display: block; }
}
