:root {
  --bg: #07080c;
  --bg-2: #0d0f15;
  --bg-3: #141822;
  --panel: #0f121a;
  --panel-2: #161a26;
  --line: #232839;
  --line-2: #2b3147;
  --text: #e7eaf3;
  --text-dim: #9aa3b8;
  --text-soft: #6b7388;
  --accent: #7c5cff;
  --accent-2: #5a3eff;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #60a5fa;

  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  --font-sans: "Space Grotesk", "Manrope", -apple-system, sans-serif;
  --font-body: "Manrope", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
}

* { box-sizing: border-box; }
html, body, #root {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; color: inherit; background: none; border: none; outline: none; }

.app {
  display: flex;
  height: 100vh;
  background:
    radial-gradient(1200px 600px at 80% -10%, #1a1830 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #15192a 0%, transparent 55%),
    var(--bg);
}
.app .sidebar { width: 268px; flex-shrink: 0; transition: width .25s cubic-bezier(.4,0,.2,1), margin-left .25s cubic-bezier(.4,0,.2,1); }
.app.sidebar-collapsed .sidebar { margin-left: -268px; }

/* ─────────── Sidebar ─────────── */

.sidebar {
  background: linear-gradient(180deg, rgba(20,24,36,.95), rgba(13,15,22,.95));
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: grid; place-items: center;
  color: white;
  box-shadow: 0 4px 18px -4px var(--accent);
}
.brand-text { flex: 1; }
.brand-title {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 15px;
}
.brand-sub {
  color: var(--text-soft);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
}
.brand-collapse {
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
}

.sidebar-section {
  padding: 16px 18px 4px;
  display: flex; flex-direction: column; gap: 8px;
}
.section-label {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--text-soft);
  font-size: 10px;
  letter-spacing: 0.12em;
  font-weight: 600;
  text-transform: uppercase;
}
.section-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0;
}

/* Segmented control */
.seg {
  display: grid;
  background: var(--bg-3);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
}
.seg-2 { grid-template-columns: 1fr 1fr; }
.seg-3 { grid-template-columns: 1fr 1fr 1fr; }
/* Six group modes: two rows of three. */
.seg-wrap { grid-template-columns: 1fr 1fr 1fr; }
.seg-wrap button { padding: 6px 4px; font-size: 11.5px; }
.seg button {
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 7px;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 12px;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button.seg-on {
  background: var(--panel-2);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 4px 12px -4px rgba(0,0,0,.5);
}

/* Context list */
.ctx-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 172px;
  overflow-y: auto;
  padding-right: 4px;
}
.ctx-list::-webkit-scrollbar { width: 6px; }
.ctx-list::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
.ctx-list::-webkit-scrollbar-track { background: transparent; }
.ctx-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 12px;
  text-align: left;
  transition: background .15s, color .15s;
}
.ctx-item:hover { background: rgba(255,255,255,.03); color: var(--text); }
.ctx-item.ctx-on {
  background: linear-gradient(90deg, rgba(124,92,255,.18), rgba(124,92,255,.04));
  color: var(--text);
}
.ctx-item.ctx-on::before {
  content: ""; position: absolute; width: 3px; height: 16px;
  background: var(--accent); border-radius: 3px;
  margin-left: -10px;
}
.ctx-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.ctx-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono); font-size: 11px;
}
.ctx-tail {
  font-size: 10px; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 1px 5px; border: 1px solid var(--line);
  border-radius: 4px;
}

/* Slider */
.slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  background: var(--bg-3);
  border-radius: 2px;
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px var(--accent);
}
.slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
  cursor: pointer;
}
.slider:disabled { opacity: .35; }
.slider:disabled::-webkit-slider-thumb { cursor: not-allowed; }
.slider:disabled::-moz-range-thumb { cursor: not-allowed; }

.btn-primary {
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: white;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 12px;
  box-shadow: 0 4px 14px -4px var(--accent), inset 0 1px 0 rgba(255,255,255,.2);
  transition: transform .1s;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.spinning .refresh-icon { animation: spin .6s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-dim);
}
.footer-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.footer-row.dim { color: var(--text-soft); }
.footer-tail { margin-left: auto; }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.dot-ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }

/* ─────────── Main ─────────── */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.header {
  container: header / inline-size;
  display: flex; align-items: center; gap: 20px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(13,15,22,.92);
}

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text-dim);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.spinning .refresh-icon { animation: spin .6s linear infinite; }

/* overflow: last line of defence — the title block clips rather than paints
   under the stat cards if the breakpoints below ever run short. */
.header-title { flex: 1; min-width: 0; overflow: hidden; }
.title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.title-main {
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  /* Shrinks with an ellipsis rather than sliding under the stat cards, but
     keeps a floor so it never collapses to zero width next to the chips. */
  flex-shrink: 1;
  min-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.title-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  padding: 3px 8px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.title-sub {
  color: var(--text-soft);
  font-size: 12px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-stats { display: flex; gap: 10px; flex-shrink: 0; }
.stat {
  width: 150px;
  padding: 7px 12px 8px;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0));
  border: 1px solid var(--line);
}
.stat-label {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--text-soft);
  text-transform: uppercase;
  font-weight: 600;
}
.stat-val { display: flex; align-items: baseline; gap: 5px; margin-top: 3px; white-space: nowrap; }
.stat-num {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-unit {
  font-size: 10.5px;
  color: var(--text-soft);
}
.stat-bar {
  height: 3px;
  background: var(--bg-3);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 7px;
}
.stat-bar-fill { height: 100%; transition: width .3s; border-radius: 2px; }

.header-tools { display: flex; align-items: center; gap: 10px; }
.search {
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px;
  height: 34px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-soft);
  transition: border-color .15s;
}
.search:focus-within { border-color: var(--accent); color: var(--text); }
.search input { width: 160px; font-size: 12px; color: var(--text); }
.search input::placeholder { color: var(--text-soft); }
.search-clear { color: var(--text-soft); font-size: 16px; line-height: 1; padding: 0 4px; }
/* Doubled class so it outranks .search:focus-within — an invalid token only
   exists while the input is focused, which is exactly when it must show red. */
.search.search-invalid,
.search.search-invalid:focus-within { border-color: var(--danger); }

/* Query bar — search box plus its match count, error and hint popovers. */
.query-bar { position: relative; }
.query-bar .search input { width: 250px; font-family: var(--font-mono); font-size: 11.5px; }
.query-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.query-count-none { color: var(--warn); }

.query-pop {
  position: absolute;
  top: 40px; right: 0;
  z-index: 40;
  min-width: 268px;
  padding: 9px 11px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: 0 14px 34px rgba(0,0,0,.55);
}
.query-errors { border-color: var(--danger); }
.query-err { display: flex; gap: 7px; font-size: 11px; color: #fca5a5; }
.query-err + .query-err { margin-top: 4px; }
.query-err code { font-family: var(--font-mono); color: var(--text); flex-shrink: 0; }

/* Hint is advisory only — clicks must reach the input, not this panel. */
.query-hint { pointer-events: none; }
.query-hint-title {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.query-hint-row { display: flex; gap: 10px; font-size: 11px; color: var(--text-soft); line-height: 1.7; }
.query-hint-row code { font-family: var(--font-mono); color: var(--text-dim); width: 132px; flex-shrink: 0; }
.query-hint-foot {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--text-soft);
}

/* ─────────── Grid ─────────── */

.grid-wrap {
  flex: 1;
  overflow: hidden;
  padding: 14px;
  position: relative;
}
.grid {
  position: relative;
  width: 100%; height: 100%;
}
.grid-slot {
  position: absolute;
}

/* Zone / node pool box behind its node cards. Drawn first, so the cards sit
   on top of it; the label band is the ZONE_HEADER strip above them. */
.zone-box {
  position: absolute;
  border: 1px dashed var(--line-2);
  border-radius: 12px;
  background: rgba(255,255,255,.015);
  transition: opacity .18s;
  pointer-events: none;
}
.zone-box.zone-unlabelled { border-style: dotted; background: none; }
.zone-box.is-dim { opacity: .4; }
.zone-head {
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
}
.zone-kind {
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 9.5px;
}
.zone-name { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.zone-unlabelled .zone-name { color: var(--text-dim); font-style: italic; }
.zone-meta { margin-left: auto; display: flex; gap: 8px; color: var(--text-dim); }
.zone-util { font-weight: 600; }

.node-card {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 10px;
  border: 1px solid;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, filter .2s, opacity .18s;
}
.node-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 36px -8px rgba(0,0,0,.6);
  filter: brightness(1.08);
}
.node-card::after {
  /* subtle inner glow */
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  pointer-events: none;
}

.node-header {
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255,255,255,.95);
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
  background: linear-gradient(180deg, rgba(0,0,0,.15), rgba(0,0,0,0));
  position: relative;
  z-index: 2;
}
.node-header-dot {
  width: 7px; height: 7px; border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
  flex-shrink: 0;
}
.node-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500;
}
.node-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.node-util {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Pods + containers */
.pod-box {
  position: absolute;
  border-radius: 4px;
  border: 1px solid;
  overflow: hidden;
  transition: opacity .18s, box-shadow .18s;
}
.pod-label {
  position: absolute; top: 0; left: 0; right: 0;
  height: 12px;
  font-size: 8px;
  color: rgba(255,255,255,.85);
  padding: 0 4px;
  display: flex; align-items: center;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-shadow: 0 1px 1px rgba(0,0,0,.5);
  pointer-events: none;
}
.container-box {
  position: absolute;
  border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
  color: rgba(0,0,0,.85);
  font-weight: 500;
  overflow: hidden;
  padding: 0 3px;
}
.container-box span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 100%;
}

/* Query dim/highlight. The empty free-space block is never a pod, so it is
   deliberately left out of both states. */
.node-card.is-dim { opacity: .32; }
.pod-box.is-dim { opacity: .16; }
.pod-box.is-match {
  z-index: 3;
  box-shadow: 0 0 0 1.5px var(--accent), 0 0 14px -2px var(--accent);
}

.pod-empty {
  position: absolute;
  border-radius: 6px;
  background: repeating-linear-gradient(
    45deg,
    rgba(255,255,255,.04),
    rgba(255,255,255,.04) 4px,
    rgba(255,255,255,.08) 4px,
    rgba(255,255,255,.08) 8px
  );
  border: 1px dashed rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255,255,255,.45);
  letter-spacing: -0.01em;
}

/* Free capacity on a node that refuses pods is not really free. Same 45deg
   recipe as .pod-empty above, dialled up and tinted by severity so a full node
   and an unusable one never look alike. */
.pod-empty.warn-danger, .pod-empty.warn-warn, .pod-empty.warn-info {
  border-style: solid;
}
.pod-empty.warn-danger {
  background: repeating-linear-gradient(
    45deg,
    rgba(239,68,68,.10), rgba(239,68,68,.10) 5px,
    rgba(239,68,68,.28) 5px, rgba(239,68,68,.28) 10px
  );
  border-color: rgba(239,68,68,.55);
  color: rgba(255,255,255,.7);
}
.pod-empty.warn-warn {
  background: repeating-linear-gradient(
    45deg,
    rgba(245,158,11,.10), rgba(245,158,11,.10) 5px,
    rgba(245,158,11,.26) 5px, rgba(245,158,11,.26) 10px
  );
  border-color: rgba(245,158,11,.5);
  color: rgba(255,255,255,.7);
}
.pod-empty.warn-info {
  background: repeating-linear-gradient(
    45deg,
    rgba(96,165,250,.08), rgba(96,165,250,.08) 5px,
    rgba(96,165,250,.2) 5px, rgba(96,165,250,.2) 10px
  );
  border-color: rgba(96,165,250,.45);
  color: rgba(255,255,255,.65);
}

/* Node warning badge, shared by the 2D header and the 3D plate label. */
.node-warn {
  display: inline-flex; align-items: center; gap: 2px;
  flex-shrink: 0;
  line-height: 0;
}
.node-warn-count {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}
.sev-danger { color: var(--danger); }
.sev-warn { color: var(--warn); }
.sev-info { color: var(--info); }

/* ─────────── Overlay ─────────── */

.overlay {
  position: fixed; inset: 0;
  background: rgba(5,7,12,.78);
  display: grid; place-items: center;
  z-index: 100;
  animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.overlay-card {
  width: min(760px, 92vw);
  max-height: 86vh;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 80px -16px rgba(0,0,0,.8);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: slideUp .25s cubic-bezier(.4,0,.2,1);
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.overlay-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}
.overlay-title {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.overlay-sub {
  margin-top: 6px;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-dim);
  font-size: 12px;
}
.status-pill {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.status-ready { background: rgba(16,185,129,.15); color: var(--ok); }
.status-pressure { background: rgba(245,158,11,.15); color: var(--warn); }
.status-scheduling-disabled { background: rgba(239,68,68,.15); color: var(--danger); }
.status-tainted { background: rgba(96,165,250,.15); color: var(--info); }

.overlay-sched {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.ov-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ov-chips-note { font-size: 11px; color: var(--text-soft); }
.taint-rows { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.taint-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
}
.taint-row code {
  font-family: var(--font-mono);
  color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.taint-effect {
  margin-left: auto;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--bg-3);
  color: var(--text-soft);
}
/* PreferNoSchedule is a hint, not a wall — it reads dimmer than the two effects
   that actually keep pods off the node. */
.taint-effect.eff-NoSchedule, .taint-effect.eff-NoExecute {
  background: rgba(96,165,250,.14);
  color: var(--info);
}

.overlay-stats {
  /* auto-fit: GPU and storage stats join CPU/Memory/Pods without leaving
     empty cells that would show the gap colour. */
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.ov-stat { background: var(--panel); padding: 16px 20px; }
.ov-label {
  font-size: 10px;
  color: var(--text-soft);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
}
.ov-val {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--text);
  margin: 6px 0;
}
.ov-val span {
  font-size: 11px;
  color: var(--text-soft);
}
.ov-bar {
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  overflow: hidden;
}
.ov-bar div {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .3s;
}

.overlay-pods {
  flex: 1;
  overflow-y: auto;
  padding: 16px 22px 22px;
}
.ov-section-title {
  font-size: 10px;
  color: var(--text-soft);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 10px;
}
.empty-state {
  padding: 32px;
  text-align: center;
  color: var(--text-soft);
  background: var(--bg-3);
  border-radius: var(--r-md);
  border: 1px dashed var(--line);
}

.pod-rows { display: flex; flex-direction: column; gap: 4px; }
.pod-row {
  display: grid;
  grid-template-columns: 1fr 90px 100px;
  gap: 14px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  align-items: center;
  transition: border-color .15s;
}
.pod-row:hover { border-color: var(--line-2); }
.pod-row-name { min-width: 0; }
.pod-row-name code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pod-row-containers { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.container-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--text-dim);
}
.container-pill.init {
  background: transparent;
  border-style: dashed;
  color: var(--text-soft);
}
.pod-row-stat { text-align: right; }
.pod-row-num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.pod-row-unit {
  font-size: 10px;
  color: var(--text-soft);
  margin-left: 3px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a4060; }
::-webkit-scrollbar-track { background: transparent; }

/* Responsive — the title must never lose. Both the stat tiles and the context
   chip give way before it, and .title-chip never gets a min-width: with
   .title-row{overflow:hidden} that silently paints the title at zero width. */
/* Sized from the header itself, not the viewport, since the sidebar collapses.
   Fixed parts (padding, menu, tools, gaps) take ~614px and the title needs
   ~240px, so four 150px cards fit from 1490px and three from 1330px. An
   extended-resource card makes four; the pod count gives way first. */
@container header (max-width: 1490px) {
  .header-stats.has-ext .stat-pods { display: none; }
}
@container header (max-width: 1330px) {
  .header-stats { display: none; }
}
@media (max-width: 1000px) {
  .title-chip { display: none; }
}
@media (max-width: 760px) {
  .search input { width: 100px; }
  .query-bar .search input { width: 130px; }
}

/* Error Banner */
.error-banner {
  background: rgba(239, 68, 68, 0.16);
  border-bottom: 1px solid var(--danger);
  color: #fca5a5;
  padding: 10px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 12px;
  animation: fadeIn 0.3s;
}
.error-banner span {
  font-weight: 500;
}
.error-banner button {
  background: var(--danger);
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 11px;
  transition: opacity 0.15s, transform 0.1s;
}
.error-banner button:hover {
  opacity: 0.9;
}
.error-banner button:active {
  transform: scale(0.97);
}
/* Informational, not a failure: e.g. a shared link named an unknown context. */
.notice-banner {
  background: rgba(96, 165, 250, 0.12);
  border-bottom-color: var(--info);
  color: #bfdbfe;
}
.notice-banner button {
  background: none;
  color: inherit;
  font-size: 14px;
  padding: 0 6px;
}

.dot-warn {
  background: var(--warn);
  box-shadow: 0 0 6px var(--warn);
}

/* Header live-updates indicator. */
.live-chip { display: inline-flex; align-items: center; gap: 6px; overflow: visible; }
.demo-chip { color: var(--accent); border-color: var(--accent); flex-shrink: 0; }
.full-demo-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.live-live { color: var(--ok); }
.live-live .live-dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.live-reconnecting { color: var(--warn); }
.live-reconnecting .live-dot { background: var(--warn); animation: livePulse 1.2s ease-in-out infinite; }
@keyframes livePulse { 50% { opacity: .25; } }

/* ─────────── 3D Cubes ─────────── */

/* Resource picker is meaningless in 3D — a cube already shows both axes. */
.seg.seg-disabled { opacity: .35; }
.seg.seg-disabled button { cursor: not-allowed; }
/* Resource menu — replaces the two-button toggle once the cluster offers
   extended resources (GPUs, ephemeral storage, hugepages). The trigger reads
   like a .seg, the list reuses the .query-pop popover. */
.res-menu { position: relative; }
.res-trigger {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 9px 11px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 12px; font-weight: 500;
  text-align: left;
  transition: border-color .15s;
}
.res-trigger:hover, .res-trigger-open { border-color: var(--line-2); }
.res-trigger svg:first-child { color: var(--text-dim); flex-shrink: 0; }
.res-caret { margin-left: auto; color: var(--text-soft); flex-shrink: 0; transition: transform .15s; }
.res-trigger-open .res-caret { transform: rotate(180deg); }
.res-item-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-pop {
  top: calc(100% + 6px); left: 0; right: 0;
  min-width: 0;
  padding: 5px;
}
.res-group { padding: 8px 8px 4px; margin: 4px 0 0; border-top: 1px solid var(--line); }
.res-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border-radius: 6px;
  background: none; border: 0;
  color: var(--text-dim);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.res-item .export-hint { margin-left: auto; flex-shrink: 0; }
.res-item:hover { background: var(--bg-3); color: var(--text); }
.res-item-on { color: var(--text); background: var(--bg-3); box-shadow: inset 2px 0 0 var(--accent); }

/* Extended requests on a pod row in the focus overlay. */
.ext-pill {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line-2);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.ext-pill.ext-on { border-color: var(--accent); color: var(--text); }

.seg-note {
  color: var(--text-soft);
  font-size: 10.5px;
  line-height: 1.4;
}

/* Header 2D/3D pill */
.view-pill {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 34px;
  padding: 3px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  flex-shrink: 0;
}
.view-pill button {
  padding: 0 12px;
  height: 26px;
  border-radius: var(--r-pill);
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.view-pill button:hover { color: var(--text); }
.view-pill button.view-on {
  background: var(--panel-2);
  color: var(--text);
}
.view-pill button.view-on.view-3d {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 3px 12px -3px var(--accent);
}

.scene-3d {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, rgba(20,10,60,.5), transparent 70%);
}
.scene-gl { position: absolute; inset: 0; }
.scene-gl canvas { display: block; cursor: grab; }
.scene-gl canvas:active { cursor: grabbing; }
.scene-nogl { display: grid; place-items: center; padding: 24px; color: var(--text-dim); text-align: center; }

/* Sidebar node-health legend. Only mounted when something is wrong. */
.health-rows { display: flex; flex-direction: column; gap: 6px; }
.health-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
}
.health-swatch {
  width: 14px; height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid currentColor;
  background: repeating-linear-gradient(
    45deg,
    transparent, transparent 2px,
    currentColor 2px, currentColor 4px
  );
}
.health-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}

/* Sidebar audit panel: health rows as toggle buttons. */
.audit-row {
  /* The negative margin gives the hover wash room without shifting the text. */
  width: calc(100% + 8px);
  background: none; border: 0; padding: 3px 4px; margin: -3px -4px;
  border-radius: 4px;
  font: inherit; font-size: 11px; text-align: left;
  cursor: pointer;
}
.audit-row:hover { background: rgba(255,255,255,.05); }
.audit-row.audit-on { background: rgba(255,255,255,.08); color: var(--text); }
.audit-swatch {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: currentColor;
}
.audit-clean { font-size: 11px; color: var(--text-soft); }

/* Sidebar topology panel: one row per zone / pool. */
.topo-row.topo-none {
  background: none; border: 0; padding: 0;
  font: inherit; font-size: 11px; text-align: left;
  cursor: default; font-style: italic;
}
.topo-util {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  width: 32px; text-align: right;
}

/* Audit findings on a focus-overlay workload row. */
.pod-row-findings { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.audit-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid currentColor;
  font-size: 10px;
  font-family: var(--font-mono);
  background: rgba(0,0,0,.2);
}
.audit-pill .pod-audit { position: static; filter: none; }

.cube-tip-audit {
  margin-top: 6px; padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  font-family: var(--font-mono);
}

/* Pod audit badge, top-right corner of a 2D pod box. */
.pod-audit {
  position: absolute; top: 1px; right: 2px;
  line-height: 0;
  z-index: 1;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.6));
}

.scene-legend {
  position: absolute;
  left: 18px; bottom: 18px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px 10px 8px;
  background: rgba(8,10,18,.86);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.legend-lines {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--text-dim);
}
.legend-lines .legend-foot {
  margin-top: 3px;
  color: var(--text-soft);
  font-size: 10px;
}

.cube-tip {
  position: fixed;
  z-index: 60;
  padding: 8px 10px;
  background: rgba(4,6,12,.96);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  box-shadow: 0 12px 30px -8px rgba(0,0,0,.8);
  pointer-events: none;
  white-space: nowrap;
}
.cube-tip-name {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  margin-bottom: 4px;
}
.cube-tip-row {
  font-size: 10.5px;
  color: var(--text-soft);
}
.cube-tip-row span {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.cube-tip-foot {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-soft);
}

/* ─────────── Cross-node workload highlighting ─────────── */

/* Class toggles only — the glow and the dim are static rules built off
   --accent, so selecting a workload never recomputes per-pod styles. */

/* outline rather than border-color: PodBox sets its border colour inline.
   z-index 1 lifts a peer over its sibling pods but stays under .node-header
   (z-index 2), so the glow never bleeds across the node name. */
.pod-box.wl-peer {
  outline: 1.5px solid var(--accent);
  outline-offset: -1px;
  box-shadow: 0 0 12px 2px var(--accent);
  z-index: 1;
}
.pod-box.wl-dim {
  opacity: .22;
}
/* Hover preview — same shape, quieter, so it never reads as a pinned pick. */
.pod-box.wl-peer.wl-preview {
  box-shadow: 0 0 7px 1px var(--accent);
}
.pod-box.wl-dim.wl-preview {
  opacity: .55;
}

/* Query scope wins over workload state. Both features set opacity, box-shadow
   and filter on the same elements at equal specificity, so without this the
   later block would simply win: a pod the query ruled out would brighten back
   up, or even pick up a peer glow, the moment a workload was hovered. Query
   dimming means "out of scope"; nothing in scope-less territory glows. */
.pod-box.is-dim.wl-peer,
.pod-box.is-dim.wl-dim {
  opacity: .16;
  outline: none;
  box-shadow: none;
}

/* Header readout for the pinned workload. */
.wl-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 340px;
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 12px -4px var(--accent);
}
.wl-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wl-chip-meta {
  color: var(--text-dim);
  white-space: nowrap;
}
.wl-chip-clear {
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1;
  padding: 0 1px;
}
.wl-chip-clear:hover { color: var(--text); }
.wl-chip-sim {
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 15px;
  padding: 0 6px;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--r-pill);
}
.wl-chip-sim:hover { color: var(--text); background: var(--accent); }

/* Same deal as .title-chip above — give way before the title does. */
@media (max-width: 1000px) {
  .wl-chip { display: none; }
}

/* Export menu — reuses the .query-pop popover. */
.export-menu { position: relative; }
.export-menu .icon-btn:disabled { opacity: .4; cursor: default; }
.icon-btn.icon-btn-on { background: var(--panel-2); color: var(--text); }
.export-pop { min-width: 220px; padding: 7px; }
.export-pop .query-hint-title { padding: 2px 6px 6px; }
.export-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%;
  padding: 7px 8px;
  border-radius: 6px;
  background: none; border: 0;
  color: var(--text);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.export-item:hover:not(:disabled) { background: var(--bg-3); }
.export-item:disabled { color: var(--text-soft); cursor: default; }
.export-hint { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-soft); }
.export-hint-ok { color: var(--ok); }
.export-sep { height: 1px; margin: 5px 4px; background: var(--line); }

/* ─────────── Scheduling simulators ─────────── */

.header-tools .icon-btn:disabled { opacity: .4; cursor: default; }

/* Node outlines while a fit or drain result is shown. Inset, so they never
   change the card's box and the treemap layout stays put. */
.node-card.sim-ok { box-shadow: inset 0 0 0 2px var(--ok), 0 0 18px -6px var(--ok); }
.node-card.sim-fail { box-shadow: inset 0 0 0 2px var(--danger), 0 0 18px -6px var(--danger); }
.node-card.sim-drained { box-shadow: inset 0 0 0 2px var(--text-soft); opacity: .55; }
.sim-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
}
.sim-badge-ok { background: rgba(16,185,129,.18); color: var(--ok); }
.sim-badge-fail { background: rgba(239,68,68,.18); color: var(--danger); }
.sim-badge-drained { background: var(--bg-3); color: var(--text-dim); }
.sim-badge-hyp { background: transparent; color: var(--text-dim); border: 1px dashed var(--text-soft); }

/* Hypothetical nodes: only in the shown simulation, so drawn as dashed ghosts.
   The card's inline background and border colour lose to these. */
.node-card.is-hypothetical {
  border-style: dashed;
  border-width: 1.5px !important;
  border-color: var(--text-soft) !important;
  background: transparent !important;
}
.node-card.is-hypothetical.sim-ok { border-color: var(--ok) !important; box-shadow: 0 0 18px -6px var(--ok); }
.node-card.is-hypothetical.sim-fail { border-color: var(--danger) !important; box-shadow: 0 0 18px -6px var(--danger); }
.node-card.is-hypothetical .pod-empty { background: transparent; }

.sim-strip {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 22px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  border-bottom: 1px solid;
}
.sim-strip-ok { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.35); }
.sim-strip-fail { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.35); }
.sim-strip-kind { color: var(--text-soft); text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
.sim-strip-legend { margin-left: auto; display: flex; gap: 6px; }

.overlay-head-tools { display: flex; align-items: center; gap: 8px; }
.sim-drain-btn { padding: 8px 12px; white-space: nowrap; }
.btn-primary:disabled { opacity: .6; cursor: default; transform: none; }

/* The fit form grows with every hypothetical node row, so a simulator card
   scrolls as a whole, header pinned, rather than only its result pane. */
.overlay-card.sim-card { overflow-y: auto; }
.sim-card > * { flex-shrink: 0; }
.sim-card > .overlay-pods { flex: none; overflow: visible; }
.sim-card > .overlay-head { position: sticky; top: 0; z-index: 1; background: var(--panel); }

.sim-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.sim-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sim-wide { grid-column: 1 / -1; }
.sim-field input {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  padding: 8px 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.sim-field input:focus { outline: none; border-color: var(--accent); }
.sim-field input::placeholder { color: var(--text-soft); }
.sim-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.sim-error { font-size: 11px; color: var(--danger); margin-right: auto; }
.sim-note { font-size: 11px; color: var(--text-dim); margin-right: auto; }
.sim-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.sim-preset {
  font: inherit;
  font-size: 11.5px;
  color: var(--text-dim);
  padding: 5px 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  cursor: pointer;
}
.sim-preset:hover { color: var(--text); border-color: var(--line-2); }
.sim-preset-on { color: var(--text); border-color: var(--accent); background: var(--panel-2); }

.sim-summary {
  font-size: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid;
}
.sim-summary-ok { color: var(--ok); border-color: rgba(16,185,129,.35); background: rgba(16,185,129,.08); }
.sim-summary-fail { color: var(--danger); border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.08); }

.sim-row-ok { border-left: 3px solid var(--ok); }
.sim-row-fail { border-left: 3px solid var(--danger); }
.sim-reasons {
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  margin-top: 5px;
  font-size: 11px;
  color: var(--danger);
}
.sim-reasons-ok { color: var(--ok); font-family: var(--font-mono); }
.sim-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: rgba(245,158,11,.15);
  color: var(--warn);
}
.sim-group + .sim-group { margin-top: 16px; }
.sim-skipped { display: flex; flex-direction: column; gap: 4px; }
.sim-report-head { display: flex; align-items: baseline; justify-content: space-between; }
.sim-link { font-size: 11px; color: var(--text-dim); background: none; border: 0; cursor: pointer; }
.sim-link:hover { color: var(--text); }
.sim-caveat { margin-top: 14px; font-size: 10.5px; color: var(--text-soft); line-height: 1.5; }

.sim-summary-neutral { color: var(--text-dim); border-color: var(--line-2); background: var(--bg-2); }
.sim-row-warn { border-left: 3px solid var(--warn); }
.sim-reasons-warn { color: var(--warn); }
.sim-row-click { cursor: pointer; }
.sim-step {
  font-size: 9.5px;
  min-width: 16px;
  padding: 0 5px;
  text-align: center;
  border-radius: var(--r-pill);
  background: rgba(16,185,129,.18);
}
.sim-muted { color: var(--text-soft); }
.sim-template {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  margin-bottom: 12px;
  font-size: 11px;
  color: var(--text-dim);
}
.sim-template code { color: var(--text); }
.sim-nested { margin: 0 0 4px 18px; }
.sim-tag-hyp { background: transparent; color: var(--text-dim); border: 1px dashed var(--text-soft); }

/* "+ Add nodes" rows: a template or a custom shape, times a count. */
.sim-extra { gap: 8px; }
.sim-extra-entry { display: flex; flex-direction: column; gap: 6px; }
.sim-extra-row { display: flex; align-items: center; gap: 8px; }
.sim-extra-row select {
  flex: 1; min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  padding: 7px 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.sim-extra-row select:focus { outline: none; border-color: var(--accent); }
.sim-field .sim-extra-count { width: 70px; }
.sim-extra-times { color: var(--text-soft); font-size: 12px; }
.sim-extra-shape { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding-left: 12px; }
.sim-extra-add { align-self: flex-start; }
.sim-extra-add:disabled { opacity: .5; cursor: default; }
.sim-rerun { margin: 0 -22px 12px; border-top: 1px solid var(--line); padding-top: 12px; padding-bottom: 12px; }

/* Offers the pending pods simulation; a button styled as a chip. */
.pending-chip {
  flex-shrink: 0;
  color: var(--warn);
  border-color: rgba(245,158,11,.45);
  cursor: pointer;
}
.pending-chip:hover { color: var(--text); background: rgba(245,158,11,.18); }

@media (max-width: 760px) {
  .sim-form { grid-template-columns: 1fr; }
}
