:root {
  --bg: #0a0e17;
  --bg-2: #0f1522;
  --panel: #141c2e;
  --panel-2: #1b2540;
  --border: #26324f;
  --text: #e6ecf7;
  --text-dim: #8b98b8;
  --accent: #4f8cff;
  --accent-2: #6ea8ff;
  --danger: #ff5c6c;
  --ok: #37d39a;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ---------- Top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border-bottom: 1px solid var(--border);
  z-index: 20;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.brand .logo { font-size: 22px; }
.brand .title { font-size: 16px; }

/* ---------- Map selector ---------- */
.map-selector {
  position: relative;
  flex: 1 1 260px;
  max-width: 420px;
}
.selector-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.selector-button:hover { border-color: var(--accent); }
.selector-button .caret { color: var(--text-dim); font-size: 12px; }

.selector-maps {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 60vh;
  overflow-y: auto;
  z-index: 30;
}
.selector-maps li {
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.selector-maps li:hover { background: var(--panel-2); }
.selector-maps li.active { background: rgba(79, 140, 255, 0.18); color: var(--accent-2); }
.selector-maps li .id { color: var(--text-dim); font-size: 12px; font-family: ui-monospace, monospace; }

/* ---------- Controls ---------- */
.controls {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.ctl {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.ctl:hover { border-color: var(--accent); }
.ctl:active { transform: scale(0.95); }
.ctl.active { background: rgba(79, 140, 255, 0.22); border-color: var(--accent); color: var(--accent-2); }

/* ---------- Map canvas ---------- */
.map {
  position: relative;
  flex: 1;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(79, 140, 255, 0.08), transparent 60%),
    var(--bg);
  overflow: hidden;
}
.map .ol-viewport { background: transparent !important; }
.map .ol-overlay-container { pointer-events: none; }

/* ---------- Status ---------- */
.status {
  position: absolute;
  left: 16px;
  bottom: 16px;
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-dim);
  box-shadow: var(--shadow);
  z-index: 15;
  max-width: 70%;
}
.status.error { color: var(--danger); border-color: var(--danger); }

/* ---------- Info panel ---------- */
.info-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 320px;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 32px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 25;
}
.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.info-body { padding: 12px 14px; font-size: 13px; line-height: 1.6; }
.info-body .row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.info-body .row .k { color: var(--text-dim); }
.info-body .row .v { font-family: ui-monospace, monospace; text-align: right; word-break: break-all; }
.info-body h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); }
.info-body .grid-item { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.info-body .grid-item:last-child { border-bottom: none; }

/* ---------- Loading ---------- */
.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(10, 14, 23, 0.7);
  backdrop-filter: blur(2px);
  z-index: 40;
}
.loading.hidden { display: none; }
.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.loading-text { color: var(--text-dim); font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel-2); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }
