* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #1a1a2e;
  color: #eee;
}

.app-container {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 340px;
  background: #16213e;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px;
  background: #0f3460;
  border-bottom: 1px solid #1a1a2e;
}

.sidebar-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
}

.subtitle {
  font-size: 0.85rem;
  color: #888;
  margin-top: 4px;
}

section {
  padding: 16px 20px;
  border-bottom: 1px solid #1a1a2e;
}

section h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.routes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.route-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #1a1a2e;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.route-item:hover {
  background: #0f3460;
}

.route-name {
  font-size: 0.9rem;
  font-weight: 500;
}

.route-congestion {
  display: flex;
  align-items: center;
  gap: 6px;
}

.congestion-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.congestion-dot.low { background: #4CAF50; }
.congestion-dot.moderate { background: #FFC107; }
.congestion-dot.heavy { background: #FF9800; }
.congestion-dot.severe { background: #F44336; }
.congestion-dot.unknown { background: #888; }

.congestion-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ccc;
}

.last-update {
  margin-top: 12px;
  font-size: 0.8rem;
  color: #666;
}

.controls-section {
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #e94560;
  color: white;
}

.btn-primary:hover {
  background: #ff6b6b;
}

.btn-secondary {
  background: #0f3460;
  color: #ccc;
}

.btn-secondary:hover {
  background: #1a4a7a;
}

.btn-secondary.active {
  background: #4CAF50;
  color: white;
}

.chart-container {
  height: 180px;
  background: #1a1a2e;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}

.route-filter {
  display: flex;
  align-items: center;
  gap: 10px;
}

.route-filter label {
  font-size: 0.85rem;
  color: #888;
}

.route-filter select {
  flex: 1;
  padding: 8px 12px;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  color: #eee;
  font-size: 0.85rem;
}

.peak-hours-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.peak-hour-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #1a1a2e;
  border-radius: 6px;
}

.peak-hour-time {
  font-size: 0.9rem;
  font-weight: 500;
}

.peak-hour-bar {
  flex: 1;
  height: 6px;
  background: #0f3460;
  border-radius: 3px;
  margin: 0 12px;
  overflow: hidden;
}

.peak-hour-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.peak-hour-fill.low { background: #4CAF50; }
.peak-hour-fill.moderate { background: #FFC107; }
.peak-hour-fill.heavy { background: #FF9800; }
.peak-hour-fill.severe { background: #F44336; }

.map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

.connection-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 100;
}

.connection-badge.connected {
  background: rgba(76, 175, 80, 0.9);
  color: white;
}

.connection-badge.disconnected {
  background: rgba(244, 67, 54, 0.9);
  color: white;
}

.loading {
  text-align: center;
  padding: 20px;
  color: #666;
  font-size: 0.9rem;
}

.mapboxgl-popup-content {
  background: #16213e;
  color: #eee;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.mapboxgl-popup-close-button {
  color: #888;
  font-size: 18px;
}

.mapboxgl-popup-tip {
  border-top-color: #16213e;
}

.popup-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.popup-info {
  font-size: 0.85rem;
  color: #aaa;
}

.popup-congestion {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-weight: 500;
}

/* Events section */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.event-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #1a1a2e;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.event-item:hover {
  background: #0f3460;
}

.event-severity {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.event-info {
  flex: 1;
  min-width: 0;
}

.event-type {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-location {
  font-size: 0.75rem;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sensors section */
.sensors-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.sensor-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #1a1a2e;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.sensor-item:hover {
  background: #0f3460;
}

.sensor-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.sensor-data {
  display: flex;
  gap: 10px;
  font-size: 0.8rem;
}

.sensor-speed {
  font-weight: 600;
}

.sensor-speed.fast { color: #4CAF50; }
.sensor-speed.normal { color: #FFC107; }
.sensor-speed.slow { color: #FF9800; }
.sensor-speed.congested { color: #F44336; }
.sensor-speed.unknown { color: #888; }

.sensor-flow {
  color: #888;
}

.sensors-section .btn {
  width: 100%;
  margin-top: 8px;
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    max-height: 40vh;
  }

  .map-container {
    height: 60vh;
  }
}
