:root {
  --bg: #1a2118;
  --panel: #222b1f;
  --panel-2: #2a3426;
  --line: #3d4a38;
  --text: #e8efe3;
  --muted: #9aab90;
  --accent: #c4e07a;
  --accent-dim: #8fad4f;
  --warn: #e8b84a;
  --danger: #e07a5f;
  --ok: #6fcf97;
  --info: #7eb8d4;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "DM Sans", system-ui, sans-serif;
  --radius: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(143, 173, 79, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(126, 184, 212, 0.08), transparent 50%);
}

.app {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  height: 100%;
  min-height: 100dvh;
}

.panel {
  overflow: auto;
  padding: 1.25rem 1.15rem 2rem;
  background: linear-gradient(180deg, var(--panel) 0%, #1e261c 100%);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand {
  margin-bottom: 1.4rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.btn-icon {
  flex-shrink: 0;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
}

.btn-icon:hover {
  border-color: var(--accent-dim);
  background: rgba(196, 224, 122, 0.08);
}

.field code {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
}

.map-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  text-align: center;
  background:
    linear-gradient(160deg, rgba(26, 33, 24, 0.92), rgba(34, 43, 31, 0.88)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%233d4a38' stroke-width='1'%3E%3Cpath d='M0 40h80M40 0v80'/%3E%3C/g%3E%3C/svg%3E");
  color: var(--text);
}

.map-overlay[hidden] {
  display: none !important;
}

.map-overlay p {
  margin: 0;
  max-width: 28rem;
  line-height: 1.45;
  color: var(--muted);
}

.search-results {
  list-style: none;
  margin: -0.35rem 0 0.75rem;
  padding: 0;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.search-results[hidden] {
  display: none !important;
}

.search-results li {
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(61, 74, 56, 0.6);
}

.search-results li:last-child {
  border-bottom: none;
}

.search-results li:hover,
.search-results li.active {
  background: rgba(196, 224, 122, 0.14);
  color: var(--accent);
}

#pinnedParcel {
  margin: -0.25rem 0 0.65rem;
  color: var(--accent);
  font-weight: 600;
}

.brand-name {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.brand-sub {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.block {
  margin-bottom: 1.35rem;
  padding: 1rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.block h2 {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.hint {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.hint.warn {
  margin-top: 0.75rem;
  margin-bottom: 0;
  padding: 0.55rem 0.65rem;
  border-left: 3px solid var(--warn);
  background: rgba(232, 184, 74, 0.08);
  color: #dcc896;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.btn {
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  color: #1a2118;
}

.btn.primary:hover:not(:disabled) {
  background: #d4ed95;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn.ghost:hover:not(:disabled) {
  border-color: var(--accent-dim);
  background: rgba(196, 224, 122, 0.08);
}

.status-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #666;
  flex-shrink: 0;
}

.dot[data-state="off"] {
  background: #666;
}

.dot[data-state="wait"] {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(232, 184, 74, 0.25);
}

.dot[data-state="ok"] {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(111, 207, 151, 0.25);
}

.dot[data-state="bad"] {
  background: var(--danger);
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 0.75rem;
  margin: 0;
}

.metrics.compact {
  margin-top: 0.85rem;
}

.metrics div {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.metrics dt {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.metrics dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 500;
}

.file-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
  cursor: pointer;
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
  transition: border-color 0.15s, color 0.15s;
}

.file-drop:hover {
  border-color: var(--accent-dim);
  color: var(--text);
}

.file-drop input {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.field input,
.field select {
  font-family: var(--sans);
  font-size: 0.92rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(196, 224, 122, 0.35);
  border-color: var(--accent-dim);
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.4rem 0;
  font-size: 0.88rem;
  cursor: pointer;
}

.meta {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.alert-panel {
  border-color: var(--line);
  transition: border-color 0.2s, background 0.2s;
}

.alert-panel[data-level="idle"] {
  background: var(--panel-2);
}

.alert-panel[data-level="ok"] {
  border-color: rgba(111, 207, 151, 0.45);
  background: rgba(111, 207, 151, 0.1);
}

.alert-panel[data-level="edge"] {
  border-color: rgba(232, 184, 74, 0.55);
  background: rgba(232, 184, 74, 0.12);
}

.alert-panel[data-level="vertex"] {
  border-color: rgba(224, 122, 95, 0.55);
  background: rgba(224, 122, 95, 0.14);
}

.alert-panel[data-level="out"] {
  border-color: rgba(126, 184, 212, 0.45);
  background: rgba(126, 184, 212, 0.1);
}

.alert-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.alert-detail {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.35;
}

.vertex-list {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  max-height: 240px;
  overflow: auto;
}

.vertex-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid rgba(61, 74, 56, 0.7);
  font-size: 0.82rem;
}

.vertex-list li.done {
  opacity: 0.7;
}

.vertex-list .idx {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent-dim);
  min-width: 1.5rem;
}

.vertex-list .coords {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.vertex-list .badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: var(--line);
  color: var(--muted);
}

.vertex-list li.done .badge {
  background: rgba(111, 207, 151, 0.2);
  color: var(--ok);
}

.vertex-list li.near .badge {
  background: rgba(224, 122, 95, 0.25);
  color: var(--danger);
}

.map-wrap {
  position: relative;
  min-height: 280px;
}

#map {
  width: 100%;
  height: 100%;
  background: #0f140e;
}

.map-hud {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  background: rgba(26, 33, 24, 0.88);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 600;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.leaflet-container {
  font-family: var(--sans);
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 45vh 1fr;
  }

  .map-wrap {
    order: -1;
  }

  .panel {
    border-right: none;
    border-top: 1px solid var(--line);
  }
}
