:root {
  --bg: #0b0f14; --panel: #121820; --panel2: #18212b; --line: #243040; --text: #e6edf3; --muted: #8b9bb0;
  --ok: #34d399; --warn: #fbbf24; --bad: #f87171; --accent: #60a5fa;
  --w-runners: #fb923c; --w-qwen: #c084fc; --w-stillroom: #2dd4bf; --w-other: #64748b;
  --cols: 1; --hdr: 48px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; }
button:hover { border-color: var(--accent); }
header { height: var(--hdr); display: flex; align-items: center; gap: 16px; padding: 0 14px;
  border-bottom: 1px solid var(--line); }
header h1 { font-size: 16px; margin: 0; letter-spacing: .04em; }
.spacer { flex: 1; }
#summary { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); }
#summary b { color: var(--text); font-variant-numeric: tabular-nums; }
.conn { color: var(--muted); }
.conn.ok::before, .conn.bad::before { content: ""; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 6px; background: var(--ok); }
.conn.bad::before { background: var(--bad); }

/* Hosts side by side (up to 3 per row). Each host is a column of 4 cells: header, CPU, GPU, details. Cells of
   different hosts share rows, so the top graphs align and never scroll; only the details cell scrolls. */
#grid { display: flex; flex-direction: column; gap: 12px; padding: 10px; height: calc(100vh - var(--hdr)); overflow-y: auto; }
.chunk { flex: 1 0 auto; display: grid; gap: 6px 12px; grid-auto-flow: column;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: auto auto minmax(200px, 1fr); }
.chunk:only-child { flex: 1 1 0; min-height: 0; }
.cell { min-width: 0; min-height: 0; }
.cell.offline { opacity: .55; }
.hh { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 10px; }
.hh h2 { font-size: 15px; margin: 0; }
.hh .meta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.offline .dot { background: var(--bad); }
.hh .forget { margin-left: auto; padding: 1px 8px; }
/* CPU and GPU share one compact band so the workloads below get the room. */
.hw2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.hw2.solo { grid-template-columns: minmax(0, 1fr); }
.hw2 > section { background: var(--panel); padding: 6px 10px; }
.hw2 h3 { margin-bottom: 2px; }
.hw2 .big .n { font-size: 22px; }
.hw2 .spark { height: 24px; margin-top: 2px; }
.hw2 .cores { height: 20px; margin-top: 3px; }
.hw2 .kv { margin-top: 2px; }
.hw2 .gpuname { margin-bottom: 0; }
.hw2 table { margin-top: 2px; }
.hw2 td { padding: 1px 6px 1px 0; }
.hd { overflow-y: auto; container-type: inline-size; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.hdi { display: grid; gap: 10px; padding: 8px; grid-template-columns: minmax(0, 1fr); align-content: start; }
@container (min-width: 760px) { .wcards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  #grid { height: auto; overflow: visible; }
  .chunk { grid-template-rows: auto auto 320px; }
}

section { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
section.grow { flex: 1; min-height: 120px; overflow-y: auto; }
h3 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  display: flex; align-items: center; gap: 8px; }
h3 .sub { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 400; }

.big { display: flex; align-items: baseline; gap: 10px; }
.big .n { font-size: 30px; font-weight: 650; font-variant-numeric: tabular-nums; }
.big .u { color: var(--muted); }
.spark { width: 100%; height: 38px; display: block; margin-top: 4px; }
.cores { display: flex; gap: 2px; height: 34px; align-items: flex-end; margin-top: 6px; }
.cores i { flex: 1; min-width: 2px; background: var(--ok); border-radius: 1px; opacity: .85; }
.bar { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; margin: 3px 0 2px; }
.bar > b { display: block; height: 100%; background: var(--ok); }
.bar.warn > b { background: var(--warn); } .bar.bad > b { background: var(--bad); }
.kv { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 12px; margin-top: 4px; }
.kv b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.gpu + .gpu { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 8px; }
.gpuname { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.alert { color: var(--bad); font-size: 12px; margin: 4px 0; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11px; padding: 2px 6px 4px 0; }
td { padding: 3px 6px 3px 0; border-top: 1px solid var(--line); white-space: nowrap; }
td.l { white-space: normal; word-break: break-all; }
td.r, th.r { text-align: right; }
.chip { display: inline-block; padding: 0 7px; border-radius: 9px; font-size: 11px; color: #0b0f14;
  background: var(--w-other); }
.chip.runners { background: var(--w-runners); } .chip.qwen { background: var(--w-qwen); }
.chip.stillroom { background: var(--w-stillroom); }
.pill { display: inline-block; padding: 0 7px; border-radius: 9px; font-size: 11px; border: 1px solid var(--line); }
.pill.busy { color: var(--warn); border-color: var(--warn); } .pill.idle { color: var(--muted); }
.pill.up { color: var(--ok); border-color: var(--ok); } .pill.down { color: var(--bad); border-color: var(--bad); }
.pill.degraded { color: var(--warn); border-color: var(--warn); }
.item { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; }
.item .t { font-weight: 600; } .item .d { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.item .r { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { color: var(--muted); font-style: italic; }
.wl-h { display: flex; align-items: center; gap: 6px; margin: 8px 0 2px; font-weight: 600; }
.wl-h:first-child { margin-top: 0; }

/* Workload gauges */
.gauge { height: 7px; background: var(--panel2); border-radius: 4px; overflow: hidden; min-width: 40px; }
.gauge > b { display: block; height: 100%; background: var(--w-other); min-width: 1px; }
.gauge.w-runners > b { background: var(--w-runners); } .gauge.w-qwen > b { background: var(--w-qwen); }
.gauge.w-stillroom > b { background: var(--w-stillroom); }
.grp + .grp { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.ghead { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.gnums { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.gnums b { color: var(--text); font-weight: 600; }
.trio { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; margin-bottom: 4px; }
.trio small { color: var(--muted); font-size: 11px; display: block; margin-bottom: 2px; }
.urow { display: grid; grid-template-columns: minmax(80px, 38%) 1fr auto; gap: 8px; align-items: center; padding: 2px 0; }
.uname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uval { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Workload cards */
.wcards { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.wcard { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--w-other));
  border-radius: 8px; padding: 8px 10px; min-width: 0; }
.whead { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.whead .d, .job .d { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.job { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.jl { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.jl .r { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.jl2 { color: var(--muted); font-size: 12px; margin: 2px 0 3px; overflow-wrap: anywhere; }
.job .gauge { height: 8px; }
.wcard.dim { opacity: .75; }
.wcard.dim .whead b, .wcard.dim .chip { filter: grayscale(1); }
#login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 5; }
#login[hidden] { display: none; }
#loginForm { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px;
  width: min(360px, 90vw); display: grid; gap: 10px; }
#loginForm h2 { margin: 0; } #loginForm p { margin: 0; color: var(--muted); }
#loginForm input { font: inherit; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); }
.err { color: var(--bad) !important; min-height: 1.2em; }
