* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#sidebar {
  width: 360px;
  min-width: 360px;
  background: #1a1a2e;
  color: #eee;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

h1 {
  font-size: 28px;
  color: #00d4aa;
  margin-bottom: 2px;
}

.subtitle {
  color: #888;
  font-size: 13px;
  margin-bottom: 12px;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: #aaa;
  letter-spacing: 0.5px;
}

input[type="text"] {
  padding: 10px 12px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #16213e;
  color: #eee;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="text"].field-active {
  border-color: #00d4aa;
  box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.2);
}

.pac-container {
  z-index: 10000;
  border-radius: 8px;
  border: 1px solid #333;
  background: #16213e;
  color: #eee;
  font-family: inherit;
}

.pac-item {
  padding: 8px 12px;
  border-top: 1px solid #333;
  color: #ccc;
  cursor: pointer;
}

.pac-item:hover {
  background: #1a2a4e;
}

.pac-item-query {
  color: #eee;
}

.pac-icon {
  display: none;
}

.hint {
  font-size: 11px;
  color: #00d4aa;
  text-decoration: none;
}

.primary-btn {
  margin-top: 10px;
  padding: 12px;
  background: #00d4aa;
  color: #1a1a2e;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.primary-btn:hover {
  background: #00eabb;
}

.primary-btn:disabled {
  background: #555;
  color: #999;
  cursor: not-allowed;
}

.quota-info {
  font-size: 11px;
  color: #666;
  padding: 4px 0;
  text-align: center;
}

.quota-info.quota-warn {
  color: #ffa726;
  font-weight: bold;
}

.status {
  font-size: 13px;
  color: #aaa;
  min-height: 20px;
  padding: 4px 0;
}

.status.error {
  color: #ff6b6b;
}

#routesList {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.route-card {
  background: #16213e;
  border: 2px solid #333;
  border-left: 4px solid #333;
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.route-card:hover {
  background: #1a2a4e;
}

.route-card.active {
  border-color: #00d4aa;
}

.card-header {
  display: flex;
  align-items: center;
}

.route-card .rank {
  font-size: 20px;
  font-weight: 800;
  color: #00d4aa;
  margin-right: 8px;
}

.route-card .route-name {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
}

.combined-score {
  font-size: 16px;
  font-weight: 800;
  color: #ffeaa7;
}

.route-card .route-details {
  margin-top: 6px;
  font-size: 12px;
  color: #aaa;
  display: flex;
  gap: 16px;
}

.bars-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.bar-group {
  flex: 1;
}

.bar-label {
  font-size: 10px;
  color: #777;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.traffic-bar {
  height: 6px;
  border-radius: 3px;
  background: #333;
  overflow: hidden;
}

.traffic-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s;
}

.traffic-low { background: #00d4aa; }
.traffic-med { background: #ffc107; }
.traffic-high { background: #ff6b6b; }

.veg-row {
  color: #6ecf6e;
}

.veg-score {
  font-weight: 600;
}

.veg-bar-bg {
  background: #2a3a2a;
}

.veg-fill {
  height: 100%;
  border-radius: 3px;
  background: #4caf50;
  transition: width 0.5s;
}

.speed-bar-bg {
  background: #2a2a3a;
}

.speed-fill {
  height: 100%;
  border-radius: 3px;
  background: #5b9bd5;
  transition: width 0.5s;
}

.speed-row {
  color: #5b9bd5;
}

.speed-label, .speed-score {
  font-size: 11px;
}

/* --- Slider section --- */
.slider-section {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #333;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.slider-row-labeled {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-name {
  font-size: 11px;
  color: #888;
  white-space: nowrap;
  min-width: 72px;
}

.slider-val {
  font-size: 11px;
  color: #aaa;
  min-width: 22px;
  text-align: right;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #00d4aa, #4caf50);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #eee;
  border: 2px solid #00d4aa;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #eee;
  border: 2px solid #00d4aa;
  cursor: pointer;
}

.weight-label {
  text-align: center;
  font-size: 12px;
  color: #aaa;
  margin-top: 6px;
}

#map {
  flex: 1;
  height: 100vh;
}

.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #555;
  border-top-color: #00d4aa;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Mobile responsive --- */
@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  #sidebar {
    width: 100%;
    min-width: 100%;
    max-height: 45vh;
    padding: 14px 16px;
    gap: 6px;
  }

  h1 {
    font-size: 22px;
  }

  .subtitle {
    font-size: 11px;
    margin-bottom: 6px;
  }

  #map {
    flex: 1;
    height: 55vh;
  }

  .primary-btn {
    margin-top: 6px;
    padding: 10px;
    font-size: 14px;
  }

  .slider-section {
    padding-top: 10px;
    margin-top: 8px;
  }

  .route-card {
    padding: 10px;
  }

  .route-card .rank {
    font-size: 16px;
  }
}
