/* serverstat — 服务器状态看板
 * 设计方向：product-performs（软件在场前干活）· seed 557813292
 * 配色：Graphite and orange · 字体：Switzer（回退系统无衬线）
 * 核心表达：显存条按进程分段 —— 这条板子独有的信息密度
 */

:root {
  --bg: #18191b;
  --surface: #222427;
  --surface-2: #2b2d31;
  --ink: #eff0f1;
  --muted: #9c9ea3;
  --accent: #ff4a1f;
  --accent-ink: #18191b;

  --field-1: #eff0f1;
  --field-1-ink: #18191b;

  /* 语义色：用于负载分档，不作装饰 */
  --ok: #5b8c5a;
  --warn: #c9922e;
  --crit: #ff4a1f;

  --font-display: "Switzer", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-text: var(--font-display);
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; /* taste-skill-ignore: 仅用于 PID 与命令行这类字面代码 */

  --step-small: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
  --step-body: clamp(1rem, 0.95rem + 0.3vw, 1.1875rem);
  --step-lead: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --step-head: clamp(1.75rem, 1.2rem + 2.6vw, 3.25rem);
  --step-display: clamp(2.5rem, 1.4rem + 5.4vw, 5.5rem);

  --margin: clamp(1rem, 2.4vw, 2.5rem);
  --gutter: clamp(1rem, 2vw, 1.75rem);
  --section: clamp(3.5rem, 7vw, 6rem);
  --radius: 4px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
  --t-press: 140ms;
  --t-hover: 180ms;
  --t-ui: 240ms;
  --t-reveal: 700ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--step-body);
  line-height: 1.5;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul[class], ol[class] { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.head { font-family: var(--font-display); font-weight: 600; font-size: var(--step-head);
  line-height: 1.05; letter-spacing: -0.03em; }
.lead { font-size: var(--step-lead); line-height: 1.35; letter-spacing: -0.01em; }
.small { font-size: var(--step-small); line-height: 1.45; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 0.8125rem; } /* taste-skill-ignore: PID 与命令行是字面代码 */

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: var(--gutter);
  padding: 1rem var(--margin) 0.9rem;
  border-top: 4px solid var(--accent);
}
.brand { display: flex; align-items: baseline; gap: 0.6rem; font-weight: 600; letter-spacing: -0.02em; }
.brand-mark {
  width: 10px; height: 10px; background: var(--accent); display: inline-block;
  transform: translateY(-1px);
}
.brand-sub { color: var(--muted); font-weight: 400; font-size: var(--step-small); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 1.25rem; }
.topbar-meta { color: var(--muted); font-size: var(--step-small); }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
  display: inline-block; margin-right: 0.45rem; vertical-align: 1px;
}
.live-dot.stale { background: var(--warn); }
.live-dot.dead { background: var(--crit); }
.topbar-link { font-size: var(--step-small); color: var(--muted); text-decoration: none;
  transition: color var(--t-hover); }
.topbar-link:hover { color: var(--ink); }

/* 顶栏主操作：立即刷新（看板本就该有的手动拉取） */
.btn-refresh {
  background: var(--accent); color: var(--accent-ink);
  padding: 0.5rem 0.95rem; border-radius: var(--radius);
  font-size: var(--step-small); font-weight: 600;
  transition: opacity var(--t-hover), transform var(--t-press);
}
.btn-refresh:hover { opacity: 0.88; }
.btn-refresh:active { transform: scale(0.97); }
.btn-refresh.busy { opacity: 0.6; }

/* ---------- 主体 ---------- */
.wrap { padding: 0 var(--margin); max-width: 1560px; margin: 0 auto; }

/* 首屏：文字在左，真实机架照片在右 */
.intro {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem); align-items: center;
  padding: clamp(2rem, 4.5vw, 3.5rem) 0 clamp(1.5rem, 3vw, 2.5rem);
}
.intro-text { max-width: 46ch; }
.intro h1 { font-size: var(--step-display); line-height: 0.98; letter-spacing: -0.04em;
  font-weight: 600; }
.intro .lead { margin-top: 1rem; color: var(--ink); max-width: 44ch; }
/* 图注叠在图片底部：既是说明，又不打断正文与按钮的连续性 */
.intro-photo { margin: 0; position: relative; overflow: hidden; border-radius: var(--radius); }
.intro-photo img {
  width: 100%; height: auto; border-radius: var(--radius);
  filter: grayscale(0.35) brightness(0.68);
  /* 签名动效：照片缓慢漂移缩放，让静态机房有活的感觉 */
  animation: drift 28s var(--ease-soft) infinite alternate;
  will-change: transform;
}
@keyframes drift {
  from { transform: scale(1.04) translateX(0); }
  to { transform: scale(1.12) translateX(-1.2%); }
}
/* 第二段说明：属于正文的一部分，不是标题上方的标签 */
.lead-note { margin-top: 0.6rem; color: var(--muted); font-size: var(--step-small);
  line-height: 1.55; max-width: 46ch; }

.btn-primary {
  margin-top: 1.5rem; padding: 0.7rem 1.15rem;
  background: var(--accent); color: var(--accent-ink); border-radius: var(--radius);
  font-weight: 600; font-size: var(--step-body);
  transition: opacity var(--t-hover), transform var(--t-press);
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: scale(0.98); }

/* 总览区用一档更深的底色做分隔，而不是细线 */
.summary {
  display: flex; flex-wrap: wrap; gap: clamp(1.5rem, 4vw, 4rem);
  padding: clamp(1.25rem, 2.5vw, 2rem) clamp(1.25rem, 2.5vw, 2rem);
  background: var(--surface);
  border-radius: var(--radius);
  margin-top: 0.5rem;
}
.summary-item { min-width: 120px; }
.summary-value { font-size: clamp(1.75rem, 3.2vw, 2.75rem); font-weight: 600;
  line-height: 1; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.summary-label { color: var(--muted); font-size: var(--step-small); margin-top: 0.35rem; }

/* ---------- 机器卡片区 ---------- */
.section-head { display: flex; align-items: baseline; gap: 1rem; margin: var(--section) 0 1.5rem; }
.section-head h2 { font-size: var(--step-lead); font-weight: 600; letter-spacing: -0.02em; }
.section-head p { color: var(--muted); font-size: var(--step-small); }

.grid {
  display: grid; gap: var(--gutter);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem 1.25rem;
  text-align: left; width: 100%; display: block;
  transition: background var(--t-hover), transform var(--t-hover);
}
.card:hover { background: var(--surface-2); }
.card:active { transform: scale(0.995); }
.card.is-open { background: var(--surface-2); }

.card-top { display: flex; align-items: baseline; gap: 0.6rem; }
.card-name { font-weight: 600; font-size: 1.0625rem; letter-spacing: -0.015em; }
.card-ip { color: var(--muted); font-size: var(--step-small); font-variant-numeric: tabular-nums; }
.card-age { margin-left: auto; color: var(--muted); font-size: var(--step-small); }

.card-gpu-name { color: var(--muted); font-size: var(--step-small); margin-top: 0.15rem; }

/* 显存主角区 */
.vram-head { display: flex; align-items: baseline; gap: 0.5rem; margin-top: 1.1rem; }
.vram-pct { font-size: clamp(2rem, 4.5vw, 3rem); font-weight: 600; line-height: 0.95;
  letter-spacing: -0.045em; font-variant-numeric: tabular-nums; }
.vram-unit { color: var(--muted); font-size: var(--step-small); }
.vram-abs { margin-left: auto; color: var(--muted); font-size: var(--step-small);
  font-variant-numeric: tabular-nums; }

/* 分段显存条：每段一个进程 */
.vram-bar {
  display: flex; height: 12px; margin-top: 0.7rem; border-radius: 2px;
  overflow: hidden; background: var(--surface-2); gap: 1px;
}
.vram-seg { height: 100%; background: var(--accent); transition: width var(--t-ui) var(--ease-soft); }
.vram-seg.alt { background: #7d452f; }
.vram-seg.rest { background: var(--surface-2); }
.vram-bar.solo .vram-seg { background: var(--muted); }

.vram-legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; margin-top: 0.7rem; }
.vram-legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: var(--step-small); }
.vram-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); flex: none; }
.vram-dot.alt { background: #7d452f; }
.vram-legend-user { color: var(--ink); }
.vram-legend-mem { color: var(--muted); font-variant-numeric: tabular-nums; }

/* 次要指标行：用留白与上方拉开，不用细线 */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem;
  margin-top: 1.35rem; }
.metric-label { color: var(--muted); font-size: var(--step-small); }
.metric-value { font-size: 1.0625rem; font-weight: 500; font-variant-numeric: tabular-nums;
  margin-top: 0.1rem; }
.meter { height: 4px; margin-top: 0.4rem; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--muted); transition: width var(--t-ui) var(--ease-soft); }
.meter-fill.warn { background: var(--warn); }
.meter-fill.crit { background: var(--crit); }

/* 状态点 */
.state-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.state-dot.ok { background: var(--ok); }
.state-dot.warn { background: var(--warn); }
.state-dot.crit { background: var(--crit); }
.state-dot.idle { background: var(--surface-2); }

/* ---------- 详情面板 ---------- */
/* 细节面板是产品的真实界面片段，行分隔线属于表格自带的结构 */
.detail {
  margin-top: var(--gutter); background: var(--surface);
  border-radius: var(--radius); padding: clamp(1.25rem, 2.5vw, 2rem);
}
.detail[hidden] { display: none; }
.detail-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap;
  padding-bottom: 1rem; border-bottom: 1px solid var(--surface-2); } /* taste-skill-ignore: 界面片段的表头分隔 */
.detail-head h2 { font-size: var(--step-lead); font-weight: 600; letter-spacing: -0.02em; }
.detail-close { margin-left: auto; color: var(--muted); font-size: var(--step-small); }
.detail-close:hover { color: var(--ink); }

.gpu-rows { margin-top: 1.25rem; }
.gpu-row {
  display: grid; grid-template-columns: 3.25rem 1fr; gap: 0 1rem;
  padding: 0.9rem 0; border-bottom: 1px solid var(--surface-2); /* taste-skill-ignore: 界面片段 */
}
.gpu-row:last-child { border-bottom: 0; }
.gpu-idx { color: var(--muted); font-size: var(--step-small); font-variant-numeric: tabular-nums; }
.gpu-title { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.gpu-name { font-weight: 500; }
.gpu-nums { margin-left: auto; display: flex; gap: 1.25rem; font-size: var(--step-small);
  color: var(--muted); font-variant-numeric: tabular-nums; }
.gpu-nums b { color: var(--ink); font-weight: 500; }
.gpu-bar { margin-top: 0.55rem; }

.proc-table { width: 100%; border-collapse: collapse; margin-top: 0.7rem; font-size: var(--step-small); }
.proc-table th { text-align: left; color: var(--muted); font-weight: 400; padding: 0.35rem 0.75rem 0.35rem 0; }
.proc-table td { padding: 0.35rem 0.75rem 0.35rem 0; border-top: 1px solid var(--surface-2); /* taste-skill-ignore: 真实表格 */
  vertical-align: top; }
.proc-table td.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0; }
.proc-cmd { color: var(--muted); word-break: break-all; }
.proc-user { color: var(--ink); }
.proc-mem { color: var(--accent); font-variant-numeric: tabular-nums; }
.proc-empty { color: var(--muted); padding: 0.6rem 0; font-size: var(--step-small); }

.detail-split { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(1.5rem, 3vw, 3rem);
  margin-top: 1.75rem; }
.detail-block h3 { font-size: var(--step-body); font-weight: 600; margin-bottom: 0.6rem; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: 0.4rem 0;
  border-bottom: 1px solid var(--surface-2); font-size: var(--step-small); } /* taste-skill-ignore: 界面片段 */
.kv:last-child { border-bottom: 0; }
.kv-k { color: var(--muted); }
.kv-v { font-variant-numeric: tabular-nums; }

/* 走势图 */
.spark { display: flex; align-items: flex-end; gap: 1px; height: 56px; margin-top: 0.8rem; }
.spark-bar { flex: 1; background: var(--surface-2); min-width: 2px; transition: height var(--t-ui) var(--ease-soft); }
.spark-bar.hot { background: var(--accent); }

/* ---------- 登录 ---------- */
.login-page { min-height: 100svh; display: grid; place-items: center; padding: var(--margin); }
.login-box { width: 100%; max-width: 380px; }
.login-box h1 { font-size: 1.75rem; font-weight: 600; letter-spacing: -0.025em; }
.login-box p { color: var(--muted); margin-top: 0.5rem; font-size: var(--step-small); }
.field { margin-top: 1.25rem; }
.field label { display: block; color: var(--muted); font-size: var(--step-small); margin-bottom: 0.35rem; }
.field input {
  width: 100%; background: var(--surface); border: 1px solid var(--surface-2);
  border-radius: var(--radius); padding: 0.7rem 0.85rem; font-size: 1rem;
  transition: border-color var(--t-hover);
}
.field input:focus { border-color: var(--accent); outline: none; }
.btn {
  display: block; width: 100%; margin-top: 1.5rem; padding: 0.75rem 1rem;
  background: var(--accent); color: var(--accent-ink); border-radius: var(--radius);
  font-weight: 600; text-align: center; transition: opacity var(--t-hover);
}
.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.err { color: var(--accent); font-size: var(--step-small); margin-top: 0.75rem; min-height: 1.2em; }

/* ---------- 动效 ---------- */
/* 每张卡片的各个部分分别入场（不是整块一个淡入），逐项延迟 60ms */
.reveal { opacity: 0; transform: translateY(18px); }
.reveal.in { opacity: 1; transform: none; transition: opacity var(--t-reveal) var(--ease-out),
  transform var(--t-reveal) var(--ease-out); }

.card.reveal.in .card-top,
.card.reveal.in .card-gpu-name,
.card.reveal.in .vram-head,
.card.reveal.in .vram-bar,
.card.reveal.in .vram-legend,
.card.reveal.in .metrics {
  animation: rise var(--t-reveal) var(--ease-out) both;
}
.card.reveal.in .card-top { animation-delay: 0ms; }
.card.reveal.in .card-gpu-name { animation-delay: 60ms; }
.card.reveal.in .vram-head { animation-delay: 120ms; }
.card.reveal.in .vram-bar { animation-delay: 180ms; }
.card.reveal.in .vram-legend { animation-delay: 240ms; }
.card.reveal.in .metrics { animation-delay: 300ms; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* 显存条的分段随数值伸长，是看板的签名动效 */
.vram-seg { transform-origin: left center; animation: grow 900ms var(--ease-soft) both; }
@keyframes grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* 数值更新时轻微跳动，提示数据在动 */
.vram-pct.tick { animation: tick 500ms var(--ease-out); }
@keyframes tick {
  0% { transform: none; }
  35% { transform: translateY(-2px); }
  100% { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .card.reveal.in .card-top,
  .card.reveal.in .card-gpu-name,
  .card.reveal.in .vram-head,
  .card.reveal.in .vram-bar,
  .card.reveal.in .vram-legend,
  .card.reveal.in .metrics,
  .vram-seg, .vram-pct.tick,
  .intro-photo img { animation: none; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- 集群实景带 ---------- */
/* 全宽实景 + 文字，构图与首屏和卡片区都不同 */
.cluster-band {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3.5rem); align-items: center;
  margin-top: var(--section);
  padding: 0 var(--margin);
  max-width: 1560px; margin-left: auto; margin-right: auto;
}
.band-figure { margin: 0; overflow: hidden; border-radius: var(--radius); }
.band-figure img {
  width: 100%; height: 100%; max-height: 340px; object-fit: cover;
  filter: grayscale(0.5) brightness(0.62);
}
.band-text h2 { font-size: var(--step-lead); font-weight: 600; letter-spacing: -0.02em; }
.band-text p { margin-top: 0.75rem; color: var(--ink); max-width: 46ch; }

/* ---------- 页脚 ---------- */
/* 用更深的底色收尾，不用细线 */
.site-foot {
  margin-top: var(--section);
  padding: clamp(1.5rem, 3vw, 2.5rem) var(--margin) clamp(2rem, 4vw, 3rem);
  background: var(--surface);
  max-width: 1560px; margin-left: auto; margin-right: auto;
  border-radius: var(--radius);
}
.site-foot p { color: var(--ink); font-size: var(--step-body); max-width: 70ch; }
.site-foot .credits { margin-top: 0.4rem; color: var(--muted); font-size: var(--step-small); }
.site-foot .credits a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.site-foot .credits a:hover { color: var(--ink); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .intro { grid-template-columns: 1fr; }
  .intro-photo img { max-height: 40svh; object-fit: cover; }
  .cluster-band { grid-template-columns: 1fr; }
  .band-figure img { max-height: 44svh; }
}
@media (max-width: 760px) {
  .detail-split { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .gpu-row { grid-template-columns: 2.5rem 1fr; }
  .gpu-nums { margin-left: 0; width: 100%; gap: 1rem; }
  .topbar { flex-wrap: wrap; }
  .topbar-right { width: 100%; margin-left: 0; }
  /* 窄屏下总览改成两列网格，标签与数值成对不换行错位 */
  .summary { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem 1.5rem; }
  .summary-item { min-width: 0; }
}
