/* 素笺 Sujian — home page. Tokens come from sujian-base.css. */

:root {
  --hm-off: #cfcfc8;
  --hm-past: #d7d7d0;
  --hm-card-line: #e6e6e1;
  --hm-hover: #f6f6f2;
}

:root[data-theme="dark"] {
  --hm-off: #3c3d39;
  --hm-past: #34352f;
  --hm-card-line: #2a2b28;
  --hm-hover: #1d1e1b;
}

.hm-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.hm-body [hidden] { display: none !important; }

/* Public column switches from the admin settings (config.columns). */
body[data-hide~="cpu"] [data-col="cpu"],
body[data-hide~="memory"] [data-col="memory"],
body[data-hide~="disk"] [data-col="disk"],
body[data-hide~="upload"] [data-col="upload"],
body[data-hide~="download"] [data-col="download"],
body[data-hide~="packet_loss"] [data-col="packet_loss"],
body[data-hide~="total_transfer"] [data-col="total_transfer"],
body[data-hide~="bandwidth"] [data-col="bandwidth"] {
  display: none !important;
}

/* ------------------------------------------------------------------ header */

.hm-topbar { min-width: 0; }

.hm-brandwrap {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hm-brandwrap .sj-brand {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}

.hm-brandwrap .sj-brand:hover { color: var(--sj-text); }

.sj-live .sj-dot { width: 6px; height: 6px; }
.sj-live.is-wait { color: var(--sj-faint); }
.sj-live.is-wait .sj-dot { background: var(--sj-faint); }
.sj-live.is-off .sj-dot { width: 7px; height: 7px; }
.sj-live:not(.is-off):not(.is-wait) .sj-dot { animation: hm-pulse 2.4s ease-in-out infinite; }

@keyframes hm-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.hm-search input::-webkit-search-cancel-button { cursor: pointer; }
.hm-search:focus-within { border-color: var(--sj-faint); }

.hm-theme-btn .hm-ico-moon { display: none; }
:root[data-theme="dark"] .hm-theme-btn .hm-ico-sun { display: none; }
:root[data-theme="dark"] .hm-theme-btn .hm-ico-moon { display: block; }

/* -------------------------------------------------------------------- main */

.hm-main {
  flex: 1 0 auto;
  padding-top: 32px;
  padding-bottom: 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Summary */
.hm-summary {
  display: flex;
  align-items: flex-end;
  gap: 48px;
}

.hm-online,
.hm-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.hm-online { flex-shrink: 0; }

.hm-sum-label {
  font-size: 13px;
  color: var(--sj-muted);
}

.hm-stat .hm-sum-label { font-size: 13px; }

.hm-online-num {
  font-size: 48px;
  letter-spacing: -0.03em;
  line-height: 1;
}

.hm-online-total {
  font-size: 22px;
  color: var(--sj-faint);
}

.hm-sum-sub {
  font-size: 12.5px;
  color: var(--sj-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hm-sum-sub.sj-crit { color: var(--sj-crit-ink); }

/* The offline count is a quick filter toggle. */
.hm-offline-btn {
  align-self: flex-start;
  margin: 0;
  padding: 1px 0;
  border: 0;
  border-bottom: 1px dashed transparent;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.hm-offline-btn:not(:disabled):hover { border-bottom-color: currentColor; }
.hm-offline-btn:disabled { cursor: default; }
.hm-offline-btn.is-active {
  padding: 1px 8px;
  border: 0;
  border-radius: 999px;
  background: var(--sjd-crit-soft, rgba(192, 57, 43, 0.1));
}

.hm-stats {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  border-left: 1px solid var(--sj-line);
}

.hm-stat {
  flex: 1 1 0;
  padding: 2px 22px;
  border-left: 1px solid var(--sj-line-soft);
}

.hm-stat:first-child { border-left: 0; }
.hm-stat .hm-sum-sub { font-size: 12.5px; }

.hm-stat-val {
  font-size: 26px;
  line-height: 1.25;
  white-space: nowrap;
}

.hm-stat-unit {
  font-size: 13px;
  color: var(--sj-muted);
}

/* Toolbar */
.hm-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 6px 0;
  border-top: 1px solid var(--sj-line);
  border-bottom: 1px solid var(--sj-line);
}

.hm-regions {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.hm-region-btn {
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--sj-radius-sm);
  background: transparent;
  color: var(--sj-text-2);
  font-family: var(--sj-mono);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.hm-region-btn.is-all { font-family: var(--sj-font); }
.hm-region-btn:hover { background: var(--sj-surface-2); color: var(--sj-text); }
.hm-region-btn .sj-flag { margin-right: 8px; }
.hm-region-btn .hm-count { color: var(--sj-faint); }

.hm-region-btn.is-active,
.hm-region-btn.is-active:hover {
  background: var(--sj-invert-bg);
  color: var(--sj-invert-text);
}

.hm-region-btn.is-active .hm-count { color: inherit; opacity: 0.7; }

.hm-meta {
  flex-shrink: 0;
  margin: 0 8px 0 12px;
  font-size: 12px;
  color: var(--sj-faint);
  white-space: nowrap;
}

.hm-views { flex-shrink: 0; }

.sj-segmented .hm-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hm-view-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.sj-segmented .hm-view-btn:not(.is-active):hover { color: var(--sj-text); }

/* Notice and empty state */
.hm-notice {
  padding: 10px 14px;
  border: 1px solid var(--sj-line);
  border-left: 3px solid var(--sj-crit);
  border-radius: 10px;
  background: var(--sj-surface);
  color: var(--sj-text-2);
  font-size: 13px;
}

.hm-notice.is-soft { border-left-color: var(--sj-warn); }

.hm-empty {
  padding: 56px 16px;
  text-align: center;
  color: var(--sj-muted);
  font-size: 14px;
}

.hm-empty p { margin: 0 0 14px; overflow-wrap: anywhere; }

.hm-empty-btn {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--sj-line);
  border-radius: var(--sj-radius-sm);
  background: var(--sj-surface);
  color: var(--sj-text-2);
  cursor: pointer;
}

.hm-empty-btn:hover { color: var(--sj-text); border-color: var(--sj-faint); }

/* View switching (set pre-paint on <html>) */
:root[data-view="list"] .hm-grid,
:root[data-view="grouped"] .hm-grid { display: none; }
:root:not([data-view="list"]) .hm-list-wrap { display: none; }
:root:not([data-view="grouped"]) .hm-groups { display: none; }
.hm-list-wrap.is-empty,
.hm-groups.is-empty { display: none; }

/* ------------------------------------------------------------------- cards */

.hm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.hm-grid:empty { display: none; }

.hm-card {
  display: block;
  min-width: 0;
  padding: 22px;
  background: var(--sj-surface);
  border: 1px solid var(--hm-card-line);
  border-radius: var(--sj-radius);
  color: var(--sj-text);
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

a.hm-card:not(.is-static):hover {
  color: var(--sj-text);
  border-color: var(--sj-line);
  box-shadow: 0 1px 0 var(--sj-line), 0 6px 18px -12px rgba(27, 27, 24, 0.25);
}

.hm-card-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hm-card.is-offline .hm-card-body { opacity: 0.6; }

.hm-card-top {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.hm-card-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.hm-card-head .hm-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hm-region {
  flex-shrink: 0;
  font-size: 12.5px;
  color: var(--sj-muted);
  white-space: nowrap;
}

.sj-flag:empty { display: none; }

.hm-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
  font-size: 13px;
}

.hm-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--sj-text-2);
  white-space: nowrap;
}

.hm-status.is-off { color: var(--sj-crit-ink); }

.hm-sdot {
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--sj-ok);
  border: 2px solid var(--sj-ok);
}

.hm-status.is-off .hm-sdot {
  background: transparent;
  border-color: var(--sj-crit);
}

.hm-tags {
  display: contents;
}

.hm-tags .sj-tag {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hm-metrics {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.hm-metric {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 108px;
  align-items: center;
  gap: 12px;
}

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

.hm-mval {
  min-width: 56px;
  font-size: 15px;
  text-align: right;
  white-space: nowrap;
}

.hm-delta { font-size: 12px; color: var(--sj-muted); }
.hm-delta.sj-warn { color: var(--sj-warn); }
.hm-pct { color: var(--sj-faint); }
.sj-track > span.is-off { background: var(--hm-off); }
.hm-card .sj-track,
.hm-list .sj-track { height: 4px; }

.hm-net {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--sj-line-soft);
  border-bottom: 1px solid var(--sj-line-soft);
}

.hm-net-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.hm-rate {
  font-size: 20px;
  white-space: nowrap;
}

.hm-arrow { font-size: 12px; }

.hm-unit {
  font-size: 12px;
  color: var(--sj-muted);
}

.hm-cum {
  font-size: 12.5px;
  color: var(--sj-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hm-probe {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.hm-probe-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--sj-muted);
}

.hm-probe-head b {
  font-weight: 400;
  font-size: 15px;
  color: var(--sj-text);
}

.hm-list .c-lat b,
.hm-list .c-loss b { font-weight: 400; font-size: 14px; color: var(--sj-text); }

.hm-probe-head b.sj-faint,
.hm-list b.sj-faint { color: var(--sj-faint); }
.hm-probe-head b.sj-warn,
.hm-list b.sj-warn { color: var(--sj-warn); }
.hm-probe-head b.sj-crit,
.hm-list b.sj-crit { color: var(--sj-crit); }

.hm-strip {
  display: flex;
  gap: 2px;
  height: 18px;
}

.hm-strip i {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 2px;
  background: var(--sj-track);
}

.hm-strip i.is-ok { background: var(--sj-ok); }
.hm-strip i.is-warn { background: var(--sj-warn); }
.hm-strip i.is-crit { background: var(--sj-crit); }
.hm-strip i.is-past { background: var(--hm-past); }
.hm-strip { cursor: default; }

/* Instant probe tooltip (see bindStripTooltip in home.js). */
.hm-tip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  max-width: 280px;
  padding: 8px 10px;
  border: 1px solid var(--sj-line);
  border-radius: 8px;
  background: var(--sj-surface);
  box-shadow: 0 6px 20px -8px rgba(0, 0, 0, 0.35);
  color: var(--sj-text);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-line;
  pointer-events: none;
}
.hm-tip[hidden] { display: none; }

/* Loading skeleton */
.hm-skel-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 360px;
}

.hm-skel {
  display: block;
  height: 10px;
  border-radius: 4px;
  background: var(--sj-surface-2);
  animation: hm-skel 1.4s ease-in-out infinite;
}

.hm-skel.w60 { width: 60%; height: 14px; }
.hm-skel.w35 { width: 35%; }
.hm-skel.w90 { width: 90%; height: 6px; }
.hm-skel.h28 { height: 36px; margin: 6px 0; }
.hm-skel.h14 { height: 14px; margin-top: auto; }

@keyframes hm-skel {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* -------------------------------------------------------------------- list */

.hm-list-wrap {
  background: var(--sj-surface);
  border: 1px solid var(--hm-card-line);
  border-radius: var(--sj-radius);
  overflow: hidden;
}

.hm-list {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.hm-list th {
  height: 44px;
  padding: 0 10px;
  border-bottom: 1px solid var(--sj-line);
  color: var(--sj-muted);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.hm-list td {
  height: 56px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--sj-line-soft);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hm-list th:first-child,
.hm-list td:first-child { padding-left: 18px; }
.hm-list th:last-child,
.hm-list td:last-child { padding-right: 18px; }
.hm-list tbody tr:last-child td { border-bottom: 0; }

.hm-row { cursor: pointer; }
.hm-row:hover td { background: var(--hm-hover); }
/* Node detail closed to guests: rows and cards are not links. */
.hm-row.is-static { cursor: default; }
.hm-row.is-static:hover td { background: transparent; }
.hm-row.is-offline td > * { opacity: 0.6; }
.hm-skel-row { cursor: default; }
.hm-skel-row td { height: 56px; }

.hm-list .c-region { width: 76px; }
.hm-list .c-status { width: 80px; color: var(--sj-text-2); font-size: 13px; }
.hm-list .c-num { width: 100px; }
.hm-list .c-rate { width: 130px; }
.hm-list .c-total { width: 104px; }
.hm-list .c-lat { width: 76px; }
.hm-list .c-loss { width: 68px; }
.hm-list .c-strip { width: 140px; }

.hm-node-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hm-row-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
  min-width: 0;
  color: var(--sj-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
}

.hm-row-link:hover { color: var(--sj-ok); }
.hm-row-link .hm-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-row .hm-status { gap: 0; }

.hm-list td.c-node .hm-tags {
  display: flex;
  gap: 4px;
  flex: 0 100 auto;
  min-width: 0;
  overflow: hidden;
}

.hm-list td.c-node .sj-tag { font-size: 11.5px; flex-shrink: 1; min-width: 0; }

.hm-list .c-region { font-size: 13px; color: var(--sj-muted); }

.hm-list td.c-num .hm-mval {
  display: block;
  min-width: 0;
  text-align: left;
  margin-bottom: 6px;
  font-size: 14px;
}

.hm-list td.c-num .sj-track { width: 100%; max-width: 84px; }
.hm-cell-label { display: none; }
.hm-list .c-rate .hm-unit { font-size: 12px; }
.hm-list .c-rate > span:first-child { font-size: 11px; }

.hm-list td.c-total {
  font-size: 13px;
  color: var(--sj-text-2);
  line-height: 1.5;
}

.hm-list td.c-total > span { display: block; }
.hm-list td.c-total .sj-up,
.hm-list td.c-total .sj-down { font-size: 10px; }
.hm-list .hm-strip { height: 14px; }

/* ----------------------------------------------------------------- grouped */

.hm-groups {
  background: var(--sj-surface);
  border: 1px solid var(--hm-card-line);
  border-radius: var(--sj-radius);
  overflow: hidden;
}

.hm-group + .hm-group { border-top: 1px solid var(--sj-line); }

.hm-ghead {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  height: 48px;
  padding: 0 20px;
  background: var(--sj-surface-2);
  border-bottom: 1px solid var(--sj-line-soft);
  font-size: 14px;
  color: var(--sj-muted);
}

.hm-gtitle {
  font-size: 15px;
  font-weight: 500;
  color: var(--sj-text);
  white-space: nowrap;
}

.hm-gcount { white-space: nowrap; }
.hm-gcount b { font-weight: 500; color: var(--sj-text); }

.hm-gbw {
  display: inline-flex;
  gap: 16px;
  font-size: 14px;
  color: var(--sj-text-2);
  white-space: nowrap;
}

.hm-gbw .sj-up,
.hm-gbw .sj-down { font-size: 11px; }

.hm-grow {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  height: 44px;
  padding: 0 20px;
  border-bottom: 1px solid var(--sj-line-soft);
  color: var(--sj-text);
  text-decoration: none;
  font-size: 14px;
}

.hm-gbody .hm-grow:last-child { border-bottom: 0; }
a.hm-grow:not(.is-static):hover { background: var(--hm-hover); color: var(--sj-text); }
.hm-grow.is-offline > * { opacity: 0.55; }

.hm-glegend {
  height: 38px;
  font-size: 13px;
  color: var(--sj-muted);
  border-bottom: 1px solid var(--sj-line);
}

.hm-grow > span { flex-shrink: 0; white-space: nowrap; }
.hm-grow .g-dot { width: 7px; display: inline-flex; }
.hm-grow .g-dot .hm-status { gap: 0; }

.hm-grow .g-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  font-size: 14px;
}

.hm-grow .g-use {
  width: 108px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hm-grow .g-use .hm-mval {
  width: 54px;
  min-width: 0;
  font-size: 14px;
}

.hm-grow .g-use .sj-track { width: 44px; flex-shrink: 0; }
.hm-glegend .g-use { padding-left: 0; }
.hm-grow .g-rate { width: 124px; }
.hm-grow .g-rate > span:first-child { font-size: 11px; }
.hm-grow .g-rate .hm-unit { font-size: 12px; }
.hm-grow .g-lat { width: 72px; text-align: right; }
.hm-grow .g-loss { width: 60px; text-align: right; }
.hm-grow .g-up { width: 72px; text-align: right; color: var(--sj-text-2); font-size: 13px; }

.hm-grow b {
  font-weight: 400;
  font-size: 14px;
  color: var(--sj-text);
}

.hm-grow b.sj-faint { color: var(--sj-faint); }
.hm-grow b.sj-warn { color: var(--sj-warn); }
.hm-grow b.sj-crit { color: var(--sj-crit); }
.hm-grow.hm-skel-row { display: flex; }

/* -------------------------------------------------------------- responsive */

@media (min-width: 1440px) {
  .hm-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
  }
  .hm-card { padding: 18px; }
  .hm-metric { gap: 8px; }
}

@media (max-width: 1199px) {
  .hm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hm-summary { gap: 32px; }
  .hm-stat { padding: 2px 16px; }
  .hm-list .c-strip,
  .hm-list .c-status { display: none; }
  .hm-list .c-rate { width: 124px; }
}

@media (max-width: 1099px) {
  .hm-list .c-total { display: none; }
}

@media (max-width: 1099px) {
  .hm-grow .g-rate { width: 108px; }
  .hm-grow .g-use { width: 62px; }
  .hm-grow .g-use .sj-track { display: none; }
}

@media (max-width: 699px) {
  .hm-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 899px) {
  .hm-grow .g-use { width: 58px; }
  .hm-grow .g-use .sj-track { display: none; }
  .hm-main { padding-top: 24px; gap: 20px; }

  .hm-summary {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
  }

  .hm-online-num { font-size: 44px; }

  .hm-stats {
    flex-wrap: wrap;
    row-gap: 18px;
    border-left: 0;
    border-top: 1px solid var(--sj-line-soft);
    padding-top: 16px;
  }

  .hm-stat {
    flex: 1 1 calc(50% - 1px);
    padding: 0 0 0 16px;
  }

  .hm-stat:nth-child(odd) { border-left: 0; padding-left: 0; }
}

@media (max-width: 759px) {
  .hm-topbar {
    height: auto;
    min-height: 60px;
    flex-wrap: wrap;
    row-gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .hm-brandwrap { order: 1; }
  .hm-theme-btn { order: 2; }
  .hm-search { order: 3; flex: 1 1 100%; width: 100%; }

  .hm-toolbar { flex-wrap: wrap; gap: 6px; }
  .hm-toolbar .hm-regions { flex: 1 1 100%; }
  .hm-toolbar .hm-views { margin-left: auto; }
  .hm-grow,
  .hm-ghead { padding: 0 14px; gap: 10px; }
  .hm-grow { font-size: 13.5px; }
  .hm-grow .g-rate,
  .hm-glegend .g-rate { display: none; }

  .hm-regions {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
  }

  .hm-regions::-webkit-scrollbar { display: none; }
  .hm-meta { margin-left: 4px; }

  /* List view collapses rows into compact 3-column blocks. */
  .hm-list thead { display: none; }
  .hm-list,
  .hm-list tbody { display: block; }

  .hm-list tr.hm-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "node node region"
      "cpu mem disk"
      "up down lat";
    gap: 10px 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--sj-line-soft);
  }

  .hm-list tbody tr:last-child { border-bottom: 0; }
  .hm-list tr.hm-skel-row { display: block; }

  .hm-list td,
  .hm-list tbody tr:last-child td {
    height: auto;
    padding: 0 !important;
    border: 0;
    background: none !important;
  }

  .hm-list td.c-node { grid-area: node; }
  .hm-list td.c-region { grid-area: region; width: auto; text-align: right; }
  .hm-list td.c-num[data-col="cpu"] { grid-area: cpu; }
  .hm-list td.c-num[data-col="memory"] { grid-area: mem; }
  .hm-list td.c-num[data-col="disk"] { grid-area: disk; }
  .hm-list td.c-rate[data-col="upload"] { grid-area: up; }
  .hm-list td.c-rate[data-col="download"] { grid-area: down; }
  .hm-list td.c-lat { grid-area: lat; width: auto; }
  .hm-list td.c-num,
  .hm-list td.c-rate { width: auto; }
  .hm-list .c-loss,
  .hm-list .c-status,
  .hm-list .c-total,
  .hm-list .c-strip { display: none !important; }

  .hm-list td.c-node .hm-tags { display: none; }

  .hm-cell-label {
    display: inline;
    margin-right: 6px;
    font-size: 11.5px;
    color: var(--sj-muted);
  }

  .hm-list td.c-num .hm-mval { display: inline; }
  .hm-list .hm-delta { display: none; }
  .hm-list td.c-num .sj-track { margin-top: 5px; max-width: none; }
  .hm-list td.c-rate { font-size: 12.5px; }
}

@media (max-width: 599px) {
  .hm-grid { grid-template-columns: minmax(0, 1fr); }
  .hm-gbw { display: none !important; }
  .hm-grow .g-use[data-col="disk"],
  .hm-grow .g-up { display: none; }
  .hm-grow,
  .hm-ghead { gap: 8px; }
  .hm-grow .g-name { font-size: 13.5px; }
  .hm-grow .g-use { width: 46px; }
  .hm-grow .g-use .hm-mval { width: auto; font-size: 13px; }
  .hm-grow .g-lat { width: 50px; }
  .hm-grow .g-loss { width: 40px; }
  .hm-grow b { font-size: 13px; }
  .hm-card { padding: 18px; }
  .hm-online-num { font-size: 40px; }
  .hm-stat-val { font-size: 22px; }
  .sj-footer-inner { gap: 8px 16px; padding-top: 10px; padding-bottom: 10px; }
}

@media (max-width: 379px) {
  .hm-grow .g-use[data-col="memory"] { display: none; }
}

/* Phones: the summary becomes a compact card stack. */
@media (max-width: 599px) {
  .hm-summary { gap: 10px; }

  /* Online count on the left, offline quick filter as a pill on the right. */
  .hm-online {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "label pill" "num pill";
    align-items: center;
    row-gap: 6px;
    column-gap: 12px;
    padding: 16px 16px 14px;
    border: 1px solid var(--sj-line);
    border-radius: var(--sj-radius);
    background: var(--sj-surface);
  }
  .hm-online > .hm-sum-label { grid-area: label; }
  .hm-online-num { grid-area: num; font-size: 40px; }
  .hm-online-total { font-size: 20px; }
  .hm-online .hm-offline-btn {
    grid-area: pill;
    align-self: center;
    justify-self: end;
    padding: 7px 12px;
    border: 0;
    border-radius: 999px;
    background: color-mix(in srgb, currentColor 12%, transparent);
    font-size: 13px;
    line-height: 1.2;
  }
  .hm-online .hm-offline-btn:not(:disabled):hover { border-bottom: 0; }
  .hm-online .hm-offline-btn.is-active {
    padding: 7px 12px;
    background: var(--sj-crit);
    color: #ffffff;
  }

  /* Four stats as a 2x2 grid of small cards. */
  .hm-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding-top: 0;
    border: 0;
  }
  .hm-stat,
  .hm-stat:nth-child(odd) {
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--sj-line);
    border-radius: 12px;
    background: var(--sj-surface);
  }
  .hm-stat .hm-sum-label { font-size: 12px; }
  .hm-stat-val { font-size: 21px; line-height: 1.2; }
  .hm-stat-unit { font-size: 12px; }
  .hm-stat .hm-sum-sub { font-size: 11.5px; }

  /* Regions scroll on their own row; count + view switch share the next. */
  .hm-toolbar {
    gap: 10px 8px;
    padding: 10px 0;
  }
  .hm-toolbar .hm-meta { margin: 0; font-size: 12.5px; color: var(--sj-muted); }
}

/* ------------------------------------------------------------ detail drawer */

html.hm-drawer-lock,
html.hm-drawer-lock body { overflow: hidden; }

.hm-drawer { position: fixed; inset: 0; z-index: 80; }
.hm-drawer[hidden] { display: none; }

.hm-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 18, 16, 0.32);
  opacity: 0;
  transition: opacity 0.26s ease;
}

.hm-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(80vw, calc(100vw - 72px));
  background: var(--sj-bg);
  border-left: 1px solid var(--sj-line);
  box-shadow: -24px 0 48px -24px rgba(0, 0, 0, 0.35);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hm-drawer.is-open .hm-drawer-backdrop { opacity: 1; }
.hm-drawer.is-open .hm-drawer-panel { transform: translateX(0); }

.hm-drawer-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--sj-bg);
}

/* Collapse tab on the drawer's outer (left) edge. */
.hm-drawer-handle {
  position: absolute;
  top: 50%;
  left: -40px;
  width: 40px;
  height: 64px;
  margin-top: -32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--sj-line);
  border-right: 0;
  border-radius: 12px 0 0 12px;
  background: var(--sj-surface);
  color: var(--sj-text-2);
  box-shadow: -8px 0 16px -10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}
.hm-drawer-handle:hover { color: var(--sj-text); background: var(--sj-surface-2); }
.hm-drawer-handle svg { width: 20px; height: 20px; }

@media (max-width: 700px) {
  .hm-drawer-panel { width: 100vw; border-left: 0; }
  .hm-drawer-handle {
    top: 10px;
    left: 10px;
    z-index: 1;
    width: 36px;
    height: 36px;
    margin-top: 0;
    border: 1px solid var(--sj-line);
    border-radius: 999px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hm-drawer-backdrop,
  .hm-drawer-panel { transition: none; }
}
