/* UBIIMBEUPM — combined XY map + 3D viewer */

:root {
  --bg: #0d1526;
  --bg2: #101a2e;
  --panel: rgba(16, 26, 46, 0.94);
  --line: #22314f;
  --fg: #e6ecf5;
  --muted: #94a3b8;
  --accent: #e94560;
  --accent2: #38bdf8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
}

/* ───────────────────────── header + tabs ───────────────────────── */
#topbar {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #2ecc71 0%, #d4a017 50%, #c0392b 100%);
}
#topbar h1 { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
#topbar h1 span { color: var(--muted); font-weight: 500; }
#topbar p { font-size: 11px; color: var(--muted); margin-top: 2px; }

#tabs { display: flex; gap: 4px; background: #0a1220; padding: 4px; border-radius: 10px; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 18px; border-radius: 7px; cursor: pointer;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--fg); }
.tab.active { background: var(--accent); color: #fff; }

/* ───────────────────────── views ───────────────────────── */
.view { display: none; height: calc(100vh - 62px); }
.view.active { display: block; }
.stage { position: relative; width: 100%; height: 100%; }
#map-main, #plot-main, #map-cmp, #plot-cmp { position: absolute; inset: 0; }

.cmp-note {
  grid-column: 1 / -1;
  background: #0a1220; border-top: 2px solid var(--line);
  padding: 9px 16px; font-size: 11.5px; line-height: 1.7; color: var(--muted);
}
.cmp-note b { color: var(--fg); font-weight: 600; }
.cmp-note i { color: #cbd5e1; }

.split { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr auto auto; }
.split-pane { position: relative; overflow: hidden; }
.split-pane:first-child { border-right: 2px solid var(--line); }
.pane-title {
  position: absolute; top: 0; left: 0; right: 0; z-index: 500;
  padding: 7px 12px; font-size: 11.5px;
  background: linear-gradient(180deg, rgba(13,21,38,.94), rgba(13,21,38,0));
  display: flex; justify-content: space-between; pointer-events: none;
}
.pane-title span { color: var(--muted); font-variant-numeric: tabular-nums; }

.cmp-strip {
  grid-column: 1 / -1;
  display: flex; gap: 1px; background: var(--line);
  border-top: 2px solid var(--line);
}
.cmp-cell {
  flex: 1; background: var(--bg2); padding: 8px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.cmp-cell .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.cmp-cell .v { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ───────────────────────── compass ───────────────────────── */
.compass {
  position: absolute; top: 14px; right: 14px; z-index: 600;
  width: 62px; text-align: center; pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.5));
}
/* on the map the top-right corner belongs to the Leaflet layer control */
#view-map .compass { top: auto; bottom: 16px; right: 16px; }
.compass svg { width: 62px; height: 62px; display: block; }
.c-ring { fill: rgba(13,21,38,.82); stroke: var(--muted); stroke-width: 1.5; }
.c-lbl { fill: var(--fg); font-size: 13px; font-weight: 700; text-anchor: middle; }
.c-needle { fill: var(--accent); stroke: #fff; stroke-width: .8; }
.c-hub { fill: #fff; }
.compass-cap {
  display: block; margin-top: 3px; font-size: 9px; font-weight: 700;
  letter-spacing: 1px; color: var(--fg);
  background: rgba(13,21,38,.82); border-radius: 4px; padding: 2px 0;
}
#needle3d { transform-origin: 32px 32px; transition: transform .18s ease-out; }

.compass.mini {
  top: auto; bottom: 18px; right: 18px; width: 46px;
}
.compass.mini svg { width: 46px; height: 46px; }
.compass.mini .c-lbl { font-size: 11px; }
#view-compare .leaflet-control-layers { top: 6px; right: 6px; }

/* ───────────────────────── side panels ───────────────────────── */
.panel {
  position: absolute; z-index: 600;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px;
  width: 250px; max-height: calc(100% - 28px); overflow-y: auto;
  backdrop-filter: blur(6px);
}
.panel-left { left: 14px; top: 14px; }
.panel-right { right: 90px; top: 14px; width: 236px; }

.panel h3 {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--accent); margin: 14px 0 7px;
}
.panel h3:first-child { margin-top: 0; }
.panel hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

.btn-row { display: flex; gap: 5px; flex-wrap: wrap; }
.btn-row.col { flex-direction: column; }
.btn {
  flex: 1; border: 1px solid var(--line); background: #0a1220; color: var(--fg);
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 7px 9px; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent2); }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.chk { display: flex; align-items: center; gap: 7px; font-size: 12px; margin: 6px 0; cursor: pointer; }
.chk input { accent-color: var(--accent2); width: 15px; height: 15px; cursor: pointer; }
.chk i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px; }

.readout { font-size: 11px; line-height: 1.8; color: var(--muted); font-variant-numeric: tabular-nums; }
.readout b { color: var(--fg); font-weight: 600; }

.lg { font-size: 11px; line-height: 1.9; color: var(--muted); }
.lg b { color: var(--fg); font-weight: 600; }
.sw { width: 15px; height: 10px; display: inline-block; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.sw.box { border: 2px solid; background: transparent; }
.sw.fill { border: 1.5px solid; }
.sw.dot { width: 9px; height: 9px; border-radius: 50%; }
.sw.dash { border-style: dashed; }
.sw.dot2 { border-style: dotted; }

/* ───────────────────────── colour bars ───────────────────────── */
.cbar {
  display: none; margin-top: 10px; text-align: center;
  background: rgba(255,255,255,.06); border-radius: 7px; padding: 8px;
}
.cbar.on { display: block; }
.cbar-title { font-size: 10px; font-weight: 700; margin-bottom: 5px; }
.cbar img { height: 150px; display: block; margin: 0 auto; }
.cbar-range { font-size: 10px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

.cb3d { margin-bottom: 12px; }
.cb3d-title { font-size: 10px; font-weight: 700; margin-bottom: 4px; }
.cb3d-title span { color: var(--muted); font-weight: 500; }
.cb3d img { height: 150px; display: block; }
.cb3d-foot { font-size: 9px; color: var(--muted); text-align: center; margin-top: 3px; }

/* ───────────────────────── hover readout ───────────────────────── */
#hover-readout {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  z-index: 700; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 16px; font-size: 12px;
  font-variant-numeric: tabular-nums; pointer-events: none;
  opacity: 0; transition: opacity .18s;
}
#hover-readout.on { opacity: 1; }

/* ───────────────────────── leaflet tuning ───────────────────────── */
.leaflet-container { background: #0a1220; font-family: inherit; }
.leaflet-bar a { background: var(--panel); color: var(--fg); border-color: var(--line); }
.leaflet-bar a:hover { background: #1b2947; color: #fff; }
.leaflet-control-layers {
  background: var(--panel); color: var(--fg);
  border: 1px solid var(--line) !important; border-radius: 8px !important;
  backdrop-filter: blur(6px);
}
.leaflet-control-layers-expanded { padding: 9px 12px !important; }
.leaflet-control-layers label { font-size: 11.5px; }
.leaflet-control-scale-line {
  background: rgba(13,21,38,.8); color: #fff; border-color: var(--muted);
  font-size: 10px; text-shadow: none;
}
.leaflet-tooltip {
  background: var(--panel); color: var(--fg); border: 1px solid var(--line);
  font-size: 11px; box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.leaflet-tooltip-top:before { border-top-color: var(--line); }

@media (max-width: 900px) {
  .panel-right { display: none; }
  .split { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr auto; }
  .split-pane:first-child { border-right: 0; border-bottom: 2px solid var(--line); }
}