* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0f172a; --surface: #1e293b; --surface2: #334155;
  --primary: #3b82f6; --primary-hover: #2563eb;
  --green: #22c55e; --red: #ef4444; --amber: #f59e0b;
  --text: #f1f5f9; --text2: #94a3b8; --text3: #64748b;
  --border: #334155; --radius: 12px; --radius-sm: 8px;
}
html, body { height: 100%; font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); }
#app { display: flex; height: 100vh; }
#map-container { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }
#sidebar {
  width: 400px; background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden; z-index: 10;
}
#sidebar-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
#sidebar-header h1 { font-size: 18px; font-weight: 700; }
#sidebar-header .badge {
  font-size: 10px; padding: 2px 8px; border-radius: 99px;
  background: var(--primary); color: white; font-weight: 600;
}
#sidebar-content { flex: 1; overflow-y: auto; padding: 16px 20px; }
.section { margin-bottom: 16px; }
.section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text3); margin-bottom: 8px;
}
.input-group { position: relative; margin-bottom: 8px; }
.input-group label {
  display: block; font-size: 11px; font-weight: 600; color: var(--text2); margin-bottom: 4px;
}
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row input {
  flex: 1; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 13px; outline: none; transition: border-color 0.2s;
}
.input-row input:focus { border-color: var(--primary); }
.input-row input::placeholder { color: var(--text3); }
.btn {
  padding: 10px 16px; border-radius: var(--radius-sm); border: none;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon {
  width: 36px; height: 36px; padding: 0; display: flex; align-items: center;
  justify-content: center; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text2); cursor: pointer; transition: all 0.15s;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-green { background: var(--green); color: white; }
.btn-green:hover { background: #16a34a; }
.btn-amber { background: var(--amber); color: #000; }
.btn-red { background: var(--red); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text2); }
.btn-outline:hover { background: var(--surface2); color: var(--text); }
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  max-height: 200px; overflow-y: auto; margin-top: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: none;
}
.autocomplete-list.active { display: block; }
.autocomplete-item {
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text); transition: background 0.1s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--surface2); }
.autocomplete-item .city { color: var(--text2); font-size: 11px; margin-top: 2px; }
.autocomplete-item .coords { color: var(--text3); font-size: 10px; font-family: monospace; }
.route-info {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.route-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.route-stat { text-align: center; }
.route-stat .value { font-size: 22px; font-weight: 800; color: var(--primary); }
.route-stat .label { font-size: 11px; color: var(--text3); margin-top: 2px; }
.route-endpoints { font-size: 12px; color: var(--text2); line-height: 1.6; }
.route-endpoints .ep { display: flex; gap: 8px; align-items: flex-start; }
.route-endpoints .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.route-endpoints .dot-green { background: var(--green); }
.route-endpoints .dot-red { background: var(--red); }
.instructions { margin-top: 12px; }
.instruction {
  display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text2);
}
.instruction:last-child { border-bottom: none; }
.instruction .num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--text); flex-shrink: 0;
}
.instruction .dist { color: var(--text3); font-size: 10px; margin-top: 2px; }
.diag-list { display: flex; flex-direction: column; gap: 6px; }
.diag-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--bg); border-radius: var(--radius-sm); font-size: 12px;
}
.diag-item .icon { font-size: 14px; flex-shrink: 0; }
.diag-item .name { flex: 1; color: var(--text2); }
.diag-item .status { font-weight: 600; }
.diag-item .status.ok { color: var(--green); }
.diag-item .status.error { color: var(--red); }
.diag-item .status.pending { color: var(--amber); }
.export-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.alt-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.alt-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--bg); border-radius: var(--radius-sm); font-size: 12px;
  cursor: pointer; border: 1px solid transparent; transition: all 0.15s;
}
.alt-item:hover { border-color: var(--primary); }
.alt-item.active { border-color: var(--primary); background: rgba(59,130,246,0.1); }
.alt-item .info { flex: 1; }
.alt-item .dist { font-weight: 600; color: var(--text); }
.alt-item .dur { color: var(--text2); }
.mode-bar {
  display: flex; gap: 4px; padding: 4px; background: var(--bg);
  border-radius: var(--radius-sm); margin-bottom: 8px;
}
.mode-btn {
  flex: 1; padding: 8px; text-align: center; border-radius: 6px;
  border: none; background: transparent; color: var(--text2); font-size: 12px;
  font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.mode-btn.active { background: var(--primary); color: white; }
.mode-btn:hover:not(.active) { background: var(--surface2); }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }
.empty-state { text-align: center; padding: 32px 16px; color: var(--text3); }
.empty-state .icon { font-size: 32px; margin-bottom: 8px; }
.empty-state .text { font-size: 13px; }
.click-mode-indicator {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--primary); color: white; padding: 8px 16px; border-radius: 99px;
  font-size: 13px; font-weight: 600; z-index: 50; pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3); display: none;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
.reverse-popup {
  background: var(--surface); border-radius: var(--radius); padding: 12px;
  min-width: 250px; max-width: 320px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.reverse-popup .address { font-size: 13px; color: var(--text); margin-bottom: 8px; line-height: 1.4; }
.reverse-popup .coords { font-size: 10px; color: var(--text3); font-family: monospace; margin-bottom: 8px; }
.reverse-popup .actions { display: flex; gap: 6px; }
@media (max-width: 768px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; height: 45vh; order: 2; border-left: none; border-top: 1px solid var(--border); }
  #map-container { order: 1; height: 55vh; }
}
