/* SmartValue Cloud panel — leans on common.css for the brand mark, page
   nav, conn-pill, and card hull. The header layout itself lives per-page
   in each page's own CSS (matching flow.css / history.css) — duplicated
   here so the brand sits left and refresh+pill sit right on the same row. */
header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 24px;
}
@media (max-width: 640px) {
  header { gap: 12px; margin-bottom: 14px; align-items: center; }
}


.cloud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  letter-spacing: 0.02em;
  /* .card-head is uppercase by default (common.css); the pill should be
     mixed-case so capitalized labels like "Online · Normal" render as
     written. */
  text-transform: none;
}
.cloud-pill.good { color: #6ee7b7; border-color: rgba(110,231,183,0.35); background: rgba(16,185,129,0.10); }
.cloud-pill.bad  { color: #fca5a5; border-color: rgba(248,113,113,0.35); background: rgba(248,113,113,0.10); }
.cloud-pill.loading { color: #fcd34d; border-color: rgba(252,211,77,0.35); background: rgba(245,158,11,0.10); }

.card-head-meta {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
}

/* ============= status card ============= */
.cloud-status-card { margin-bottom: 16px; }
.cloud-status-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.cloud-status-row:last-of-type { border-bottom: none; }
.cloud-label { color: var(--text-dim); }
.cloud-value { color: var(--text); font-weight: 500; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; }

.hidden { display: none !important; }

/* ============= analysis & range cards ============= */
.cloud-analysis-card,
.cloud-range-card { margin-bottom: 16px; }


.card-desc {
  margin: 6px 0 14px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.5;
}

.cloud-controls {
  display: flex;
  gap: 10px;
  margin: 12px 0;
  flex-wrap: wrap;
  align-items: center;
  position: relative;   /* anchor for popover */
}

.select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  min-width: 120px;
}
.select:focus { outline: none; border-color: var(--batt-soft); }

.cloud-chart {
  width: 100%;
  height: 360px;
  background: rgba(0,0,0,0.18);
  border-radius: 10px;
  overflow: hidden;
}
.cloud-chart canvas { max-width: 100% !important; }

/* ---------- multi-select button + popover ---------- */
.multi-select-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.01em;
}
.multi-select-btn:hover { background: rgba(255,255,255,0.08); }
.multi-select-btn[aria-expanded="true"] {
  background: rgba(122,255,191,0.08);
  border-color: rgba(122,255,191,0.4);
}
.multi-select-btn svg { width: 14px; height: 14px; }

/* `position: absolute` anchored to document.body (cloud.js relocates the
   popover there on first open). We can't use position:fixed here because
   tracking the trigger button on scroll via a JS handler always lags the
   browser's native scroll paint by one frame, and we can't keep it
   inside a .card because `.card { backdrop-filter: blur(...) }` creates
   both a stacking context AND a containing block for fixed descendants
   — z-index gets trapped. Sitting position:absolute on body gives us:
     • viewport-level z-index (no .card ancestor → no trapped context)
     • free scrolling with the page (no JS update on scroll → no lag)
   cloud.js computes top/left in document coordinates (rect + scrollY). */
.multi-select-popover {
  position: absolute;
  z-index: 100;
  min-width: 280px;
  max-width: 360px;
  max-height: 60vh;
  overflow-y: auto;
  background: #181c26;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 8px 6px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}
.ms-group { padding: 4px 0 6px; }
.ms-heading {
  padding: 6px 12px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.ms-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background-color .12s;
}
.ms-row:hover { background: rgba(255,255,255,0.04); }
.ms-row.disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.ms-row input[type="checkbox"] {
  appearance: none;
  width: 16px; height: 16px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  position: relative;
  flex: 0 0 auto;
}
.ms-row input[type="checkbox"]:checked {
  background: #7affbf;
  border-color: #7affbf;
}
.ms-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-bottom: 2px solid #0d1018;
  border-right: 2px solid #0d1018;
  transform: rotate(40deg) translate(-1px, -1px);
  width: 4px; height: 8px;
  border-top: none; border-left: none;
  left: 4px; top: 1px;
}
.ms-row input[type="checkbox"]:disabled { cursor: not-allowed; }
.ms-text {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex: 1;
  gap: 10px;
}
.ms-name { color: var(--text); }
.ms-unit {
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  color: var(--text-dim);
  letter-spacing: -0.01em;
}
.ms-foot {
  margin-top: 4px;
  padding: 8px 12px 4px;
  font-size: 11.5px;
  color: var(--text-dim);
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ---------- legend ---------- */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
  min-height: 22px;
}
.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* ---------- range presets ---------- */
.range-presets {
  display: inline-flex;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 0;
}
.range-preset-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 0.02em;
}
.range-preset-btn:hover { color: var(--text); }
.range-preset-btn.active {
  background: rgba(122,255,191,0.12);
  color: #7affbf;
}

@media (max-width: 600px) {
  .cloud-controls { gap: 8px; }
  .cloud-controls > .multi-select-btn,
  .cloud-controls > .select { flex: 1 1 100%; }
  .multi-select-popover { left: 0; right: 0; max-width: none; }
  .cloud-chart { height: 280px; }
  .cloud-status-row { font-size: 13px; gap: 12px; flex-wrap: wrap; }
}
