:root {
  --bg: #edf3f9;
  --panel: #ffffff;
  --text: #12202f;
  --muted: #4a5b6d;
  --accent: #0b6bcb;
  --accent-soft: #e8f1fb;
  --danger: #b3261e;
  --border: #d8e0e8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 45%, #e7eef5 100%);
}

.app {
  max-width: 1560px;
  margin: 0 auto;
  padding: 10px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 6px 18px rgba(18, 32, 47, 0.08);
}

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

.icon-btn {
  width: 42px;
  min-width: 42px;
  height: 42px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.28rem;
}

.app-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.layout {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(330px, 390px) 1fr;
  gap: 10px;
  align-items: start;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding-right: 4px;
}

.card,
.onboarding {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 5px 16px rgba(18, 32, 47, 0.06);
}

.onboarding ol {
  margin: 0 0 10px 18px;
  color: var(--muted);
}

.card h2,
.onboarding h2 {
  margin: 0 0 8px;
  font-size: 0.98rem;
}

.pane-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.pane-btn {
  min-height: 38px;
  font-size: 0.82rem;
  padding: 6px;
}

.pane-btn.active {
  background: var(--accent-soft);
  border-color: #c4dbf4;
}

.pane {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.pane.active {
  display: flex;
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
}

.field label {
  font-size: 0.8rem;
  color: var(--muted);
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

button,
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px;
  background: #fff;
  color: var(--text);
  font-size: 0.92rem;
}

input[type="checkbox"] {
  width: auto;
  min-width: auto;
}

button {
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.1s ease;
  min-height: 42px;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(11, 107, 203, 0.15);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.ghost {
  background: var(--accent-soft);
  border-color: #c4dbf4;
}

button.danger {
  border-color: #f0c4c1;
  color: var(--danger);
}

.grid {
  display: grid;
  gap: 8px;
}

.grid.two {
  grid-template-columns: 1fr 1fr;
}

.mini-help {
  margin: 4px 0 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.metrics {
  display: grid;
  gap: 6px;
}

.metrics div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px dashed var(--border);
  border-radius: 9px;
  padding: 7px 9px;
}

.metrics span {
  color: var(--muted);
}

.status {
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: #1f4a77;
  position: sticky;
  bottom: 0;
}

.map-wrap {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  min-height: calc(100vh - 96px);
  background: #dbe6f2;
  box-shadow: 0 8px 24px rgba(18, 32, 47, 0.1);
}

#map {
  height: 100%;
  min-height: calc(100vh - 96px);
}

.vertex-icon {
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 0 0 2px #0b6bcb;
  background: #0b6bcb;
  touch-action: none;
}

.edge-insert-icon {
  width: 14px;
  height: 14px;
  border: 2px solid #0b6bcb;
  background: #ffffff;
  transform: rotate(45deg);
  border-radius: 2px;
}

.map-legend {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font: 12px/1.35 "Segoe UI", sans-serif;
  color: #12202f;
  min-width: 190px;
}

.map-legend strong {
  display: block;
  margin-bottom: 4px;
}

.map-legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: middle;
}

.busy {
  position: fixed;
  inset: 0;
  background: rgba(15, 26, 39, 0.34);
  display: grid;
  place-items: center;
  z-index: 9999;
}

.busy[hidden] {
  display: none;
}

.busy-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  width: min(320px, 86vw);
  text-align: center;
}

.spinner {
  margin: 0 auto 8px;
  width: 22px;
  height: 22px;
  border: 3px solid #d5e5f7;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .panel {
    position: fixed;
    top: 66px;
    left: 8px;
    right: 8px;
    max-height: calc(100vh - 80px);
    z-index: 6000;
    background: transparent;
    transform: translateY(-130%);
    transition: transform 0.22s ease;
  }

  .panel.open {
    transform: translateY(0);
  }

  .map-wrap,
  #map {
    min-height: calc(100vh - 92px);
  }

  .pane-nav {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 680px) {
  .app {
    padding: 6px;
  }

  .app-header {
    padding: 8px;
  }

  .app-header h1 {
    font-size: 1.1rem;
  }

  .app-header p {
    font-size: 0.8rem;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  button,
  input,
  select,
  textarea {
    font-size: 16px;
  }
}
