:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1d212a;
  --line: #262b36;
  --fg: #e6e9ef;
  --fg-dim: #8b93a5;
  --cpu: #4f9cf9;
  --mem: #a78bfa;
  --swap: #f472b6;
  --disk: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI",
        "Noto Sans CJK SC", "Microsoft YaHei", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(15, 17, 21, .85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 16px; margin: 0; letter-spacing: .5px; }

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 0 0 rgba(248, 113, 113, .6);
  transition: background .3s;
}
.dot.live {
  background: var(--disk);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.host {
  color: var(--fg-dim);
  font-size: 13px;
  flex: 1;
  min-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.host b { color: var(--fg); font-weight: 600; }

.controls { display: flex; gap: 8px; }
.controls button, .controls select {
  background: var(--panel-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.controls button:hover, .controls select:hover { border-color: #3a4152; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  min-width: 0;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .4px;
  color: var(--fg-dim);
  text-transform: uppercase;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.card h2 .hint { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 12px; }

/* ---------- 仪表盘 ---------- */
.gauges {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.gauge { display: flex; align-items: center; gap: 16px; }

.ring { position: relative; width: 104px; height: 104px; flex: 0 0 104px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring .track { stroke: #232833; }
.ring .value {
  stroke: var(--cpu);
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset .45s ease, stroke .45s ease;
}
[data-accent="mem"] .ring .value { stroke: var(--mem); }
[data-accent="swap"] .ring .value { stroke: var(--swap); }
[data-accent="disk"] .ring .value { stroke: var(--disk); }

.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.ring-label b { font-size: 22px; font-variant-numeric: tabular-nums; }
.ring-label span { font-size: 11px; color: var(--fg-dim); }

.meta { min-width: 0; }
.meta-main {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta-sub {
  font-size: 12px;
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 图表 ---------- */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card { display: flex; flex-direction: column; }
canvas { width: 100%; height: 180px; display: block; }

.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--fg-dim); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- CPU 核心 ---------- */
.cores {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 8px;
}
.core { text-align: center; }
.core .bar {
  height: 56px;
  background: #232833;
  border-radius: 6px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.core .fill {
  width: 100%;
  background: linear-gradient(180deg, var(--cpu), #2f6fbf);
  transition: height .4s ease, background .4s ease;
}
.core .fill.warn { background: linear-gradient(180deg, var(--warn), #b57f10); }
.core .fill.bad  { background: linear-gradient(180deg, var(--bad), #a83a3a); }
.core .label { font-size: 10px; color: var(--fg-dim); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ---------- 表格 ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--fg-dim); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
td .mono { font-variant-numeric: tabular-nums; }

.bar-mini {
  height: 6px;
  border-radius: 3px;
  background: #232833;
  overflow: hidden;
  min-width: 56px;
  display: inline-block;
  width: 100%;
  vertical-align: middle;
}
.bar-mini > i { display: block; height: 100%; background: var(--disk); transition: width .4s; }
.bar-mini > i.warn { background: var(--warn); }
.bar-mini > i.bad  { background: var(--bad); }

.cmd { display: block; color: var(--fg-dim); font-size: 11px; max-width: 380px;
       overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 温度 ---------- */
.temps { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.temp-item { background: var(--panel-2); border-radius: 10px; padding: 12px; }
.temp-item b { font-size: 20px; font-variant-numeric: tabular-nums; }
.temp-item span { display: block; font-size: 11px; color: var(--fg-dim);
                  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--fg-dim); font-size: 13px; padding: 4px 0; }

/* ---------- 页脚 ---------- */
footer {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 20px 32px;
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--fg-dim);
}
.error { color: var(--bad); }

@media (max-width: 1080px) {
  .gauges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .gauges { grid-template-columns: 1fr; }
  .gauge { flex-direction: row; }
  main { padding: 14px 12px 30px; }
  .topbar { padding: 10px 12px; }
}
