
:root {
  --bg:         #0a0a0f;
  --bg2:        rgba(15, 17, 23, 0.65);
  --bg3:        rgba(255, 255, 255, 0.04);
  --border:     rgba(255, 255, 255, 0.08);
  --accent:     #6366f1;
  --accent-dim: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.5);
  --text:       #f8fafc;
  --text-muted: #94a3b8;
  --danger:     #ef4444;
  --success:    #10b981;
  --warn:       #f59e0b;

  --v0: #6366f1;
  --v1: #ec4899;
  --v2: #eab308;
  --v3: #10b981;
  --v4: #8b5cf6;

  --sidebar-w: 380px;
  --radius: 12px;
  --font: 'Outfit', 'Segoe UI', system-ui, sans-serif;
}

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

body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
}


.app-shell {
  display: block;
  position: relative;
  height: 100dvh;
  background: var(--bg);
}

.sidebar {
  position: absolute;
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: var(--sidebar-w);
  background: var(--bg2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255,255,255,0.02) inset;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
}

.map-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
}

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

.map-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,17,23,0.85);
  color: var(--text-muted);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  pointer-events: none;
  transition: opacity 0.3s;
}


.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.mode-toggle {
  position: relative;
  display: flex;
  background: var(--bg3);
  border-radius: 8px;
  padding: 4px;
}

.mode-slider {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  background: linear-gradient(135deg, var(--accent), #818cf8);
  border-radius: 6px;
  box-shadow: 0 4px 12px var(--accent-glow);
  transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  z-index: 0;
}

.mode-btn {
  position: relative;
  flex: 1;
  padding: 7px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  z-index: 1;
  transition: color 0.3s ease;
  text-align: center;
}

.mode-btn.active {
  color: #fff;
}


.stop-input-area {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.input-row {
  display: flex;
  gap: 8px;
}

.stop-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.stop-input:focus {
  border-color: var(--accent);
}

.btn-add {
  background: linear-gradient(135deg, var(--accent), #818cf8);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  width: 38px;
  font-size: 20px;
  cursor: pointer;
  font-weight: 400;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-add:hover { 
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--accent-glow);
}


.stop-list-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.stop-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.btn-ghost:hover { color: var(--text); background: var(--bg3); }

.stop-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.stop-item:hover { 
  border-color: rgba(99, 102, 241, 0.4); 
  transform: translateX(4px);
  background: rgba(255,255,255,0.06);
}

.stop-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stop-name {
  flex: 1;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stop-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.stop-remove:hover { opacity: 1; color: var(--danger); }


.options-panel {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.option-row label {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.mini-select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  max-width: 160px;
}


.vehicle-builder {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vehicle-builder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.vehicle-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vehicle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
}

.vehicle-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.vehicle-label {
  flex: 1;
  font-size: 12px;
  color: var(--text);
}

.vehicle-cap-input {
  width: 50px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 3px 6px;
  font-size: 12px;
  text-align: center;
  outline: none;
}

.vehicle-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.vehicle-remove:hover { opacity: 1; color: var(--danger); }


.optimize-wrap {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.btn-optimize {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-optimize:hover:not(:disabled) { 
  transform: translateY(-2px);
  box-shadow: 0 12px 32px var(--accent-glow);
}
.btn-optimize:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; transform: none; background: var(--bg3); color: var(--text-muted); }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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


.results-panel {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-stat {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.result-stat .val {
  font-weight: 600;
  color: var(--accent);
}

.vehicle-result-card {
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 10px;
  border-left: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vehicle-result-card .v-label {
  font-weight: 600;
  font-size: 12px;
}

.vehicle-result-card .v-stats {
  font-size: 11px;
  color: var(--text-muted);
}

.route-order {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
  background: var(--bg2);
  padding: 4px 6px;
  border-radius: 4px;
  word-break: break-all;
}


.fallback-warning {
  padding: 8px 16px;
  font-size: 11px;
  color: var(--warn);
  background: rgba(240,165,0,0.08);
  border-top: 1px solid rgba(240,165,0,0.2);
}


.btn-gmaps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 9px 12px;
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
  margin-top: 2px;
}

.btn-gmaps:hover { background: #1557b0; }

.btn-gmaps svg { flex-shrink: 0; }

.gmaps-vehicle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
  margin-top: 6px;
  width: 100%;
  justify-content: center;
}

.gmaps-vehicle-btn:hover { background: #1557b0; }


.hidden { display: none !important; }


.leaflet-container {
  background: #1a1f2e !important;
}

.leaflet-tile {
  filter: brightness(0.75) saturate(0.5);
}


@media (max-width: 640px) {
  .app-shell { flex-direction: column-reverse; }
  .sidebar { width: 100%; min-width: unset; max-height: 50vh; border-right: none; border-top: 1px solid var(--border); }
  .map-wrap { flex: 1; }
}
