:root {
  --bg: #04101f;
  --bg-2: #061a2e;
  --panel: rgba(8, 24, 42, 0.85);
  --panel-border: rgba(0, 212, 255, 0.18);
  --text: #d8ecff;
  --text-dim: #7da4c8;
  --accent: #00d4ff;
  --accent-2: #4cffd5;
  --warn: #ffb454;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(ellipse at top, #062138 0%, #03080f 70%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { position: relative; width: 100%; height: 100%; }

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(180deg, rgba(3, 12, 22, 0.85), rgba(3, 12, 22, 0));
  pointer-events: none;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent), 0 0 4px #fff inset;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}
.brand-text {
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 14px;
}

.topbar-info {
  font-size: 12px;
  color: var(--text-dim);
}

#panel {
  position: absolute;
  top: 60px;
  right: 14px;
  width: 320px;
  max-height: calc(100% - 80px);
  overflow-y: auto;
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 16px 18px;
  z-index: 9;
  font-size: 13px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
#panel::-webkit-scrollbar { width: 8px; }
#panel::-webkit-scrollbar-thumb {
  background: rgba(0, 212, 255, 0.2);
  border-radius: 4px;
}

.mode-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: rgba(0, 212, 255, 0.05);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
}
.mode-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 7px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.mode-tab.active {
  background: rgba(0, 212, 255, 0.18);
  color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
}
.mode-tab:hover:not(.active) { color: var(--text); }

.mode-pane.hidden { display: none; }

#mosaic-map,
#single-map {
  width: 100%;
  height: 200px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  background: #04111f;
  margin-bottom: 8px;
  cursor: crosshair;
}
#single-map { cursor: pointer; }
.leaflet-container { background: #04111f; }
.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(0,0,0,0.5) !important;
  color: #7da4c8 !important;
}
.leaflet-control-attribution a { color: #00d4ff !important; }

.coord-row {
  font-size: 11px;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 2px 0;
}

input[type="datetime-local"] {
  width: 100%;
  background: rgba(0, 212, 255, 0.06);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  color-scheme: dark;
}

.btn-primary {
  background: linear-gradient(135deg, #00d4ff, #4cffd5);
  color: #02141f;
  border: none;
  font-weight: 600;
  margin-top: 8px;
}
.btn-primary:hover { filter: brightness(1.1); background: linear-gradient(135deg, #00d4ff, #4cffd5); }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: none;
}

.mt-6 { margin-top: 6px; }

.stations-status {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  font-size: 11px;
}
.stations-status li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(125, 164, 200, 0.08);
  color: var(--text-dim);
}
.stations-status li:last-child { border-bottom: none; }
.stations-status .ss-id {
  font-weight: 600;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  min-width: 44px;
}
.stations-status .ss-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ss-status.ok { color: var(--accent-2); }
.ss-status.err { color: var(--warn); }
.ss-status.busy { color: var(--accent); }

.panel-section { margin-bottom: 18px; }
.panel-section h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0 0 10px;
  color: var(--accent);
  font-weight: 600;
}

.file-input {
  display: block;
  position: relative;
  border: 1px dashed rgba(0, 212, 255, 0.4);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 8px;
}
.file-input:hover {
  border-color: var(--accent);
  background: rgba(0, 212, 255, 0.06);
}
.file-input input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.file-input-label {
  display: block;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}
.file-input small { color: var(--text-dim); font-size: 11px; }

.btn {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 212, 255, 0.08);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn:hover { background: rgba(0, 212, 255, 0.18); }
.btn-ghost { background: transparent; }

.hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
}
.hint summary {
  cursor: pointer;
  color: var(--accent-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  user-select: none;
  outline: none;
}
.hint p { margin: 8px 0 0; line-height: 1.5; }
.hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(0, 212, 255, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}
.hint a { color: var(--accent); }

.slider-row {
  display: block;
  margin-bottom: 12px;
}
.slider-row span {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.slider-row em {
  font-style: normal;
  color: var(--text);
  font-weight: 600;
}
.slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
}
.check-row input { accent-color: var(--accent); }

.stats {
  list-style: none;
  margin: 0;
  padding: 0;
}
.stats li {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(125, 164, 200, 0.08);
  font-size: 12px;
}
.stats li:last-child { border-bottom: none; }
.stats span { color: var(--text-dim); }
.stats b { color: var(--text); font-weight: 600; }

#legend { font-size: 11px; }
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}
.legend-swatch {
  display: inline-block;
  width: 18px;
  height: 12px;
  border-radius: 2px;
}
.legend-row span { color: var(--text-dim); }

.panel-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(125, 164, 200, 0.12);
  font-size: 11px;
  text-align: center;
}
.panel-foot a { color: var(--text-dim); text-decoration: none; }
.panel-foot a:hover { color: var(--accent); }

#loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(3, 8, 15, 0.7);
  backdrop-filter: blur(4px);
  z-index: 50;
  font-size: 13px;
  color: var(--text-dim);
}
.hidden { display: none !important; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(0, 212, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 24, 42, 0.95);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 12px;
  z-index: 60;
  max-width: 80%;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
#toast.warn { border-color: var(--warn); }

@media (max-width: 720px) {
  #panel {
    width: calc(100% - 28px);
    max-height: 50%;
    top: auto;
    bottom: 14px;
    right: 14px;
    left: 14px;
  }
  .topbar-info { display: none; }
}
