:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #1f2937; 
  --accent-hover: #111827;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}

button:hover {
  box-shadow: var(--shadow-sm);
}

button.primary {
  background: var(--accent);
  color: white;
  border: none;
}

button.primary:hover {
  background: var(--accent-hover);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
  position: relative;
}

.card1 {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;  
  transition:
    transform 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
  position: relative;
}

.card:hover {
  transform: translateY(-2px);
  background: var(--cardHover);
  box-shadow: var(--shadow);
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--brand);
  opacity: 0;
  transition: opacity 140ms ease;
}
.card:hover::before {
  opacity: 1;
}

.disabled {
  cursor: not-allowed;
  opacity: 0.55;
  filter: grayscale(0.25);
}
.disabled:hover {
  transform: none;
  box-shadow: none;
}

.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  color: #111
}

.input::placeholder {
  color: #888;
}

.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  justify-content: space-between;
}

.title {
  font-weight: 600;
  font-size: 18px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

#selMenu {
  position: fixed;
  display: none;
  z-index: 50;
  min-width: 260px;
  background: #111;
  color: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  font:
    13px/1.3 system-ui,
    sans-serif;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  backdrop-filter: blur(8px);
  border: 1px solid #222;
}

#selMenu .title {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 14px;
}

#selMenu .btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #fff;
  border: none;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease;
}

#selMenu .btn:hover {
  background: #1e1e1e;
}

#selMenu hr {
  border: none;
  border-top: 1px solid #333;
  margin: 8px 0;
}

#selMenu .muted {
  opacity: 0.75;
  font-size: 12px;
  margin: 6px 0 2px;
}

#selMenu.busy {
  pointer-events: none;
  opacity: 0.8;
}

.hero {
  margin-top: 10px;
  padding: 26px 0 14px;
  display: grid;
  place-items: center;
  text-align: center;
}
.logo {
  width: 84px;
  height: 84px;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.logo img {
  width: 74px;
  height: 74px;
  object-fit: contain;
}
.hero h1 {
  margin: 14px 0 0;
  font-size: clamp(24px, 2.2vw, 34px);
  font-weight: 900;
  letter-spacing: 0.2px;
}
.hero .sub {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  max-width: 860px;
}
.hero .sub strong {
  color: var(--text);
  font-weight: 900;
}

/* section divider + controls */
.section {
  margin-top: 18px;
  border-top: 1px solid var(--stroke);
  padding-top: 18px;
}

.hdrSelect {
  height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #cbd5e1; /* outlined */
  background: #ffffff;
  color: #0b1f3a; /* navy */
  font:
    14px/1.2 system-ui,
    sans-serif;
  font-weight: 600;
  outline: none;
}

.hdrSelect:focus {
  border-color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

/* ===== Viewer: full screen canvas ===== */
.viewerHeader {
  display: none !important;
}

.viewerCanvas {
  position: fixed;
  inset: 0;
}

/* =========================
   Dock Context Navigation
   ========================= */

.contextNav {
  display: flex;
  gap: 6px;
  align-items: center;
}

.dockSelect {
  height: 34px;
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(17, 24, 39, 0.75);
  color: var(--txt);
  font:
    600 12px system-ui,
    sans-serif;
  outline: none;
}

.dockSelect:focus {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.dockAction {
  height: 30px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(30, 35, 50, 0.9);
  color: #fff;
  font:
    700 12px system-ui,
    sans-serif;
  cursor: pointer;
}

.dockAction:hover {
  filter: brightness(1.08);
}

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

.dockContextLabel {
  font:
    700 11px system-ui,
    sans-serif;
  letter-spacing: 0.4px;
  opacity: 0.65;
  margin-bottom: 4px;
}

/* ===== Top-right menu button ===== */
#menuBtn {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 9998;

  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(11, 16, 27, 0.72);
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  font-weight: 900;
}

#menuBtn:hover {
  filter: brightness(1.06);
}

/* ===== Drawer ===== */
#drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(360px, 92vw);
  z-index: 9999;

  transform: translateX(102%);
  transition: transform 180ms ease;

  background: rgba(11, 16, 27, 0.92);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.92);
}

#drawer.open {
  transform: translateX(0);
}

#drawerHdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#drawerHdr .ttl {
  font-weight: 900;
  letter-spacing: 0.2px;
}

#drawerHdr .x {
  border-radius: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(17, 24, 39, 0.6);
  color: rgba(255, 255, 255, 0.9);
}

#drawerNav {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#drawerNav .nav-item {
  width: 100%;
  text-align: left;
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(17, 24, 39, 0.55);
  color: rgba(255, 255, 255, 0.92);
  font-weight: 800;
}

#drawerNav .nav-item:hover {
  background: rgba(30, 41, 59, 0.65);
}

/* ===== Modal (Actions) ===== */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.popup {
  width: min(520px, 92vw);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(11, 16, 27, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.92);
}

.popupHdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.popupHdr .x {
  border-radius: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(17, 24, 39, 0.6);
  color: rgba(255, 255, 255, 0.9);
}

.popupBody {
  padding: 14px;
}

/* ===== Small-screen tweaks so rail + dock + menu don’t fight ===== */
@media (max-width: 700px) {
  #controlRail {
    top: 64px; /* give room for menu btn */
    width: calc(100vw - 28px);
  }
  /* your metricsDock CSS already drops to top:72px on mobile; keep that behavior */
}

/* =======================
   Metrics Dock theme tokens (scoped)
   ======================= */

#metricsDock {
  --dock-bg: rgba(11, 16, 27, 0.72);
  --dock-ring: rgba(255, 255, 255, 0.1);
  --card-bg: rgba(17, 24, 39, 0.72);
  --card-ring: rgba(255, 255, 255, 0.1);
  --txt: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.68);
  --hdr-h: 44px;

  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --cool: #38bdf8;
}

#metricsDock {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9997;
  width: min(960px, 92vw);
  max-height: 45vh;
  overflow: auto; 

  backdrop-filter: blur(10px);
  background: linear-gradient(
    180deg,
    rgba(15, 20, 32, 0.85),
    rgba(11, 16, 27, 0.85)
  );
  border: 1px solid var(--dock-ring);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  color: var(--txt);
}

#metricsDock .body {
  padding: 10px;
  max-height: calc(50vh - var(--hdr-h) - 18px);
  overflow: auto;
  border-radius: 0 0 14px 14px;
}

#metricsDock .grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

#metricsDock * {
  pointer-events: auto;
}

#metricsDock .hdr {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas:
    "title updated hide"
    "nav nav nav";
  gap: 8px 14px;

  height: auto;
  min-height: var(--hdr-h);
  padding: 8px 10px;
  border-bottom: 1px solid var(--dock-ring);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
  align-items: center;
}

#metricsDock .dockTitle {
  grid-area: title;
  justify-self: start;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#metricsDock .updated {
  grid-area: updated;
  justify-self: center;
  text-align: center;
  white-space: nowrap;
}

#metricsDock .dockRight {
  display: contents;
}

#toggleMetrics {
  grid-area: hide;
  justify-self: end;
  align-self: center;
  margin-left: 0;
}

#metricsDock .contextNav {
  grid-area: nav;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}

#metricsDock .contextNav .dockSelect {
  flex: 0 0 auto;
}

#metricsDock .dockSearch {
  position: relative;
  flex: 1 1 220px;
  min-width: 180px;
}

#metricsDock .dockSearchInput {
  width: 100%;
  opacity: 1;
  pointer-events: auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(17, 24, 39, 0.72);
  color: rgba(255, 255, 255, 0.92);
  padding: 8px 10px;
  font:
    600 12px/1 system-ui,
    sans-serif;
}

#metricsDock .dockSearchResults {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  max-height: 320px;
  overflow: auto;
  display: none;
  z-index: 10050;

  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 20, 32, 0.92);
  backdrop-filter: blur(10px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

#metricsDock .dockSearchResults.open {
  display: block;
}

@media (max-width: 900px) {
  #metricsDock .hdr {
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
      "title updated hide"
      "nav nav nav";
  }

  #metricsDock .updated {
    justify-self: center;
    text-align: center;
    font-size: 11px;
    white-space: nowrap;
  }

  #metricsDock .contextNav {
    flex-wrap: wrap;
  }

  #metricsDock .dockSearch {
    flex: 1 0 100%;
    min-width: 0;
  }
}

.mcard {
  min-width: 0;
}

@media (max-width: 1100px) {
  #metricsDock .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  #metricsDock {
    top: 72px;
    width: calc(100vw - 24px);
  }

  #metricsDock .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mcard {
    min-height: 78px;
    padding: 9px 9px 7px;
  }

  .mcard .value {
    font-size: 18px;
  }
}

@media (max-width: 520px) {
  #metricsDock .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 380px) {
  #metricsDock .grid {
    grid-template-columns: 1fr;
  }
}

#metricsDock .title {
  font:
    800 13px/1.2 system-ui,
    sans-serif;
  letter-spacing: 0.2px;
}
#metricsDock .updated {
  font:
    12px/1.2 system-ui,
    sans-serif;
  color: var(--muted);
}

#toggleMetrics {
  background: rgba(19, 24, 34, 0.95);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 6px 10px;
  font:
    700 12px/1 system-ui,
    sans-serif;
  cursor: pointer;
}
#toggleMetrics:hover {
  filter: brightness(1.06);
}

.mcard {
  background:
    radial-gradient(
      120% 120% at 120% -20%,
      rgba(255, 255, 255, 0.05),
      rgba(255, 255, 255, 0.02) 55%
    ),
    var(--card-bg);
  border: 1px solid var(--card-ring);
  border-radius: 12px;
  padding: 10px 10px 8px;

  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 90px;

  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease;
}
.mcard:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}

.mcard .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.mcard .label {
  font:
    700 11.5px/1 system-ui,
    sans-serif;
  color: var(--muted);
}
.mcard .dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #384152;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}
.mcard .value {
  font:
    900 22px/1.05 ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Arial;
  letter-spacing: 0.2px;
  text-align: right;
}

.value.good {
  color: var(--good);
}
.value.warn {
  color: var(--warn);
}
.value.bad {
  color: var(--bad);
}
.value.cool {
  color: var(--cool);
}

.dot.good {
  background: var(--good);
}
.dot.warn {
  background: var(--warn);
}
.dot.bad {
  background: var(--bad);
}
.dot.cool {
  background: var(--cool);
}

/* Auto-compact hides the body only */
#metricsDock.compact .body {
  display: none;
}

#metricsDock.pulse {
  transform: translateX(-50%) scale(1.01);
  transition: transform 0.18s ease;
}

/* ---------- Dock Search ---------- */
.dockSearch {
  display: flex;
  align-items: center;
  gap: 7px;
  position: relative;
}

.dockSearchBtn {
  width: 70px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(19, 24, 34, 0.95);
  color: #fff;
  cursor: pointer;
}

.dockSearchResults {
  position: absolute;
  top: 42px;
  left: 0;
  width: 340px;
  max-height: 320px;
  overflow: auto;
  display: none;

  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 20, 32, 0.92);
  backdrop-filter: blur(10px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  z-index: 9999;
}

.dockSearchResults.open {
  display: block;
}

.dockSearchItem {
  padding: 10px 12px;
  cursor: pointer;
}
.dockSearchItem:hover {
  background: rgba(255, 255, 255, 0.06);
}
.dockSearchItem .top {
  font:
    800 12px/1.2 system-ui,
    sans-serif;
}
.dockSearchItem .sub {
  margin-top: 4px;
  font:
    12px/1.2 system-ui,
    sans-serif;
  color: rgba(255, 255, 255, 0.68);
}

/* ---------- Landing Search Shell ---------- */
.searchShell {
  position: relative;
  width: 100%;
  margin: 0 auto;
}
.searchShell .input {
  width: 100%;
}

.searchShell .input {
  color: #0f172a;
  background: #ffffff;
}

.searchShell .input::placeholder {
  color: rgba(15, 23, 42, 0.45);
}

/* Dropdown container lives inside the same shell */
.globalResults {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 50;
}

/* Panel */
.globalResultsPanel {
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(255, 255, 255, 0.98);
  box-shadow:
    0 18px 40px rgba(2, 6, 23, 0.1),
    0 2px 8px rgba(2, 6, 23, 0.06);
  overflow: hidden;
}

/* Group header */
.globalGroupHdr {
  padding: 10px 12px;
  font:
    600 11px/1.1 system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(15, 23, 42, 0.55);
  background: rgba(2, 6, 23, 0.02);
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}
.globalGroupHdr:first-child {
  border-top: 0;
}

/* Result rows */
.globalResultItem {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.globalResultItem:hover {
  background: rgba(2, 6, 23, 0.035);
}

.globalResultLeft {
  min-width: 0;
}

.globalResultTitle {
  font:
    600 13px/1.25 system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    sans-serif;
  color: rgba(15, 23, 42, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Optional smaller second line if you want it later */
.globalResultSub {
  margin-top: 3px;
  font:
    400 12px/1.2 system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    sans-serif;
  color: rgba(15, 23, 42, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chips: lighter */
.globalChip {
  padding: 3px 8px;
  border-radius: 999px;
  font: 500 11px/1 system-ui;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(15, 23, 42, 0.04);
  color: rgba(15, 23, 42, 0.6);
}
/* Separator line between groups (optional if you like more structure) */
.globalDivider {
  height: 1px;
  background: rgba(15, 23, 42, 0.06);
}

.globalGroupHdr {
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}
.globalGroupHdr:first-child {
  border-top: none;
}

/* Live Data Viewer (ldv) */
.ldv-root {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}
.ldv-hdr {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.ldv-sel {
  background: #10151f;
  color: #fff;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 8px 10px;
}
.ldv-metric {
  min-width: 260px;
  max-width: 420px;
  width: 50%;
}
.ldv-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ldv-btn {
  background: #151a24;
  color: #fff;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.ldv-btn:hover {
  filter: brightness(1.06);
}
.ldv-preset.active {
  background: #0b2636;
  border-color: #14557a;
}
.ldv-range {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.ldv-input {
  background: #10151f;
  color: #fff;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 8px 10px;
}
.ldv-btn.ldv-ghost {
  background: transparent;
  border-color: #2a2a2a;
}
.ldv-btn.ldv-ghost:hover {
  background: #0b2636;
}
.ldv-chartWrap {
  position: relative;
  flex: 1;
  min-height: 240px;
  border: 1px solid #1f2633;
  border-radius: 12px;
  background: #0f131b;
  overflow: hidden;
}
.ldv-chartWrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.ldv-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(2px);
}
.ldv-spin {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #0ea5e9;
  animation: ldvspin 0.9s linear infinite;
}
.ldv-msg {
  color: #cfd7e3;
  font:
    600 12px/1.2 system-ui,
    sans-serif;
}
.ldv-empty {
  margin: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #1c2432;
  color: #e5eefc;
  border: 1px solid #263041;
}
@keyframes ldvspin {
  to {
    transform: rotate(360deg);
  }
}

/* Popup shell (if missing) */
#popupMask {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9999;
}

#popupMask .popup {
  width: min(1100px, 92vw);
  height: 90vh;

  background: #121212;
  color: #fff;

  border-radius: 14px;
  border: 1px solid #222;
  box-shadow: 0 25px 60px rgba(0,0,0,0.45);

  display: flex;
  flex-direction: column;
}

#popupMask .popupBody {
  flex: 1;
  overflow-y: auto;   /* THIS enables scrolling */
  overflow-x: hidden;
}

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

#popupMask .popupHdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #222;
  background: #111;
}

#popupMask .popupBody {
  padding: 12px;
  overflow: auto;
}

#popupMask .x {
  background: #1f1f1f;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
}
#popupMask .x:hover {
  background: #0b2636;
}
#popupMask .popupHdr .ttl {
  font:
    900 14px/1.1 system-ui,
    sans-serif;
  letter-spacing: 0.2px;
}

#popupMask .popupHdr {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04),
    rgba(255, 255, 255, 0.01)
  );
}

#popupMask {
  animation: ldvFade 140ms ease;
}
#popupMask .popup {
  animation: ldvPop 160ms ease;
  transform-origin: 50% 30%;
}

@keyframes ldvFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes ldvPop {
  from {
    transform: translateY(6px) scale(0.985);
  }
  to {
    transform: translateY(0) scale(1);
  }
}

.ldv-presets {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 6px;
}
.ldv-btn {
  border-radius: 10px;
}

#popupMask .popupHdr {
  position: sticky;
  top: 0;
  z-index: 2;
}

/* ===== Live Data open: blur background ===== */
body.ldv-open #viewer {
  filter: blur(6px) saturate(0.9) brightness(0.85);
  transform: scale(1.01);
  transition:
    filter 160ms ease,
    transform 160ms ease;
}

/* keep dock slightly softened too (optional) */
body.ldv-open #metricsDock {
  filter: blur(2px);
  opacity: 0.88;
  transition:
    filter 160ms ease,
    opacity 160ms ease;
}

/* smooth back to normal */
#viewer,
#metricsDock {
  transition:
    filter 160ms ease,
    transform 160ms ease,
    opacity 160ms ease;
}

#popupMask {
  animation: ldvFade 140ms ease;
}
#popupMask .popup {
  animation: ldvPop 160ms ease;
  transform-origin: 50% 30%;
}

@keyframes ldvFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes ldvPop {
  from {
    transform: translateY(8px) scale(0.985);
  }
  to {
    transform: translateY(0) scale(1);
  }
}

/* ===== Utilization modal sizing ===== */
.utilPopup {
  width: min(1100px, 92vw);
  height: 82vh;
  display: flex;
  flex-direction: column;
}

/* on small screens, go full-screen (good UX on phones) */
@media (max-width: 700px) {
  .utilPopup {
    width: 96vw;
    height: 92vh;
  }
}

/* blur background when utilization modal open */
body.util-open #viewer {
  filter: blur(6px) saturate(0.9) brightness(0.85);
  transform: scale(1.01);
  transition:
    filter 160ms ease,
    transform 160ms ease;
}
body.util-open #metricsDock {
  filter: blur(2px);
  opacity: 0.88;
  transition:
    filter 160ms ease,
    opacity 160ms ease;
}

/* ===== Utilization UI ===== */
.utilRoot {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}

.utilRow {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.utilSel,
.utilInput {
  background: #10151f;
  color: #fff;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 8px 10px;
}

.utilBtn {
  background: #151a24;
  color: #fff;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.utilBtn:hover {
  filter: brightness(1.06);
}
.utilBtn.ghost {
  background: transparent;
}

.utilKpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 10px;
}
@media (max-width: 900px) {
  .utilKpis {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

.utilCard {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(17, 24, 39, 0.55);
  border-radius: 12px;
  padding: 10px 12px;
}
.utilCard .k {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  font-size: 12px;
}
.utilCard .v {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
  font-size: 18px;
  margin-top: 4px;
}

.utilChartWrap {
  position: relative;
  flex: 1;
  min-height: 260px;
  border: 1px solid #1f2633;
  border-radius: 12px;
  background: #0f131b;
  overflow: hidden;
}
.utilChartWrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.utilTabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}
.utilTab {
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.utilTab.active {
  background: rgba(5, 30, 85, 0.774);
  border-color: rgba(255, 255, 255, 0.22);
}

.utilChartWrap {
  padding-bottom: 10px; /* add */
  box-sizing: border-box; /* add */
}

.utilChartHelper {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  text-align: center;
  margin-top: 6px;
  letter-spacing: 0.2px;
}

.utilTableWrap {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.utilTableTop {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.utilTableTitle {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
}

.utilTableScroll {
  max-height: 420px;
  overflow: auto;
}

.utilTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.utilTable th,
.utilTable td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.88);
  text-align: left;
}

.utilTable th {
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: rgba(8, 12, 18, 0.92);
  backdrop-filter: blur(8px);
}

.utilTable td.num,
.utilTable th.num {
  text-align: right;
}

.st-ok {
  color: rgba(255, 255, 255, 0.8);
}
.st-under {
  color: rgba(255, 210, 120, 0.95);
}
.st-over {
  color: rgba(255, 130, 130, 0.95);
}

.utilRowClickable {
  cursor: pointer;
}
.utilRowClickable:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* Heatmap */
.utilHeatWrap {
  position: relative;
}
.utilHeatTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.utilHeatTitle {
  color: #fff;
  font-weight: 600;
  opacity: 0.95;
}
.utilHeatControls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.utilHeatLabel {
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
}
.utilHeatLegend .hmBar {
  width: 180px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(56, 189, 248, 0.18),
    rgba(14, 165, 233, 0.45),
    rgba(37, 99, 235, 0.72),
    rgba(29, 78, 216, 0.92)
  );
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}

.utilHeatGridWrap {
  position: relative;
  border-radius: 12px;
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.utilHeatGrid {
  position: relative;
  min-width: 520px;
}
.hmTable {
  display: flex;
  flex-direction: column;
}
.hmRow {
  display: grid;
  grid-template-columns: 90px repeat(6, minmax(64px, 1fr));
}
.hmCell {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  color: #fff;
}
.hmCorner,
.hmHeadCell {
  position: sticky;
  top: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  z-index: 2;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
}
.hmCorner {
  left: 0;
  z-index: 3;
}
.hmHour {
  position: sticky;
  left: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.25);
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
}
.hmVal {
  cursor: pointer;
  background:
    linear-gradient(
      180deg,
      rgba(56, 189, 248, calc(var(--hmA, 0.10) * 0.75)),
      rgba(37, 99, 235, var(--hmA, 0.10))
    );
  transition:
    transform 0.06s ease,
    filter 0.12s ease,
    box-shadow 0.12s ease;
}

.hmVal:hover {
  transform: scale(1.01);
  filter: brightness(1.08);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
}

.utilHeatTip {
  position: absolute;
  max-width: 240px;
  white-space: pre-line;
  pointer-events: none;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.92);
  font-size: 12px;
  z-index: 20;
}

.utilHeatNote {
  color: rgba(255, 255, 255, 0.65);
  font-size: 12px;
  margin-top: 8px;
}

.utilHeatDetails {
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
}
.utilHeatDetailsTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.utilHeatDetailsTitle {
  color: #fff;
  opacity: 0.9;
  font-weight: 600;
}
.utilHeatDetailsBody {
  padding: 10px 12px;
  max-height: 260px;
  overflow: auto;
}
.hmItem {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.hmItemMain {
  color: #fff;
  opacity: 0.92;
}
.hmItemSub {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  margin-top: 2px;
}

/* UTIL modal: allow inner scrolling on small screens */
.utilTableScroll {
  overflow: visible;
  max-height: none;
}

/* Root should not force the page to grow */
.utilRoot {
  min-height: 0;
}
.utilPanel {
  min-height: 0;
}

.utilTableWrap {
  min-height: 0;
}

.utilHeatTitleRow {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.utilHeatTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.utilPopup {
  max-height: 92vh;
}

#utilBody {
  min-height: 0;
}

/* ===== Util modal: make the modal body the only vertical scroll area ===== */
#utilMask {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9999;
}

#utilMask .popup,
#utilMask .utilPopup {
  width: min(1100px, 92vw);
  height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#utilBody,
#utilMask .popupBody {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* let content grow naturally inside the scrolling modal body */
.utilRoot,
.utilPanel,
.utilHeatWrap,
.utilTableWrap {
  min-height: 0;
  flex: 0 0 auto;
}

/* remove inner table scrolling so the modal itself handles vertical scroll */
.utilTableScroll {
  max-height: none;
  overflow: visible;
}