:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2430;
  --text-2: #6b7686;
  --line: #e6eaf0;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.12);
  --warn: #f59e0b;
  --danger: #ef4444;
  --ok: #10b981;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

/* 顶栏 */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  padding: 4px 2px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-dot {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

.status {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-2);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.6s ease-in-out infinite;
}

.badge.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.badge.error .dot {
  background: var(--danger);
  animation: none;
}

.badge.ok {
  background: rgba(16, 185, 129, 0.12);
  color: var(--ok);
}

.badge.ok .dot {
  background: var(--ok);
  animation: none;
}

.badge.paused {
  background: var(--line);
  color: var(--text-2);
}

.badge.paused .dot {
  background: var(--text-2);
  animation: none;
}

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

.updated {
  font-variant-numeric: tabular-nums;
}

/* 控制栏 */
.ctrl-btn,
.ctrl-select {
  font-family: inherit;
  font-size: 12px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.ctrl-btn {
  padding: 0 12px;
  font-weight: 600;
}

.ctrl-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.ctrl-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.ctrl-btn.active:hover {
  color: #fff;
}

.ctrl-select {
  padding: 0 6px;
  outline: none;
}

/* 卡片网格 */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card-wide {
  grid-column: span 2;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

.card-head h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.hint {
  font-size: 12px;
  color: var(--text-2);
}

/* 环形进度 */
.ring-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
}

.ring {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}

.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--line);
  stroke-width: 10;
}

.ring-fg {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.5s ease, stroke 0.3s ease;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ring-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.kv span {
  color: var(--text-2);
}

.kv b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.mem-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-2);
}

/* 每核负载条 */
.bars {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}

.bar-row {
  display: grid;
  grid-template-columns: 26px 1fr 40px;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-2);
}

.bar-row b {
  text-align: right;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.bar-track {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  width: 0;
  transition: width 0.4s ease, background 0.3s ease;
}

/* 网络 */
.net-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 6px;
}

.net-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 10px;
}

.net-label {
  font-size: 13px;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.arrow {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.arrow.down { background: rgba(37, 99, 235, 0.12); color: var(--primary); }
.arrow.up { background: rgba(245, 158, 11, 0.15); color: var(--warn); }

.net-rate {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.net-total {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
}

.net-total b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* 磁盘列表 */
.disk-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.disk-item {
  display: grid;
  grid-template-columns: 150px 1fr 64px;
  align-items: center;
  gap: 12px;
}

.disk-item .name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.disk-item .name small {
  display: block;
  font-weight: 400;
  color: var(--text-2);
  font-size: 11px;
  margin-top: 2px;
}

.disk-item .pct {
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* 温度 */
.temp-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.temp-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.temp-item span {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}

.temp-item b {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.empty {
  color: var(--text-2);
  font-size: 13px;
  padding: 8px 0;
}

/* 系统信息 */
.sys-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sys-list li {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.sys-list span { color: var(--text-2); }

.sys-list b {
  font-weight: 600;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

.foot {
  margin-top: 22px;
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
}

/* 趋势图 */
.trend {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.trend-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-2);
  margin-bottom: 4px;
}

.trend-range {
  font-variant-numeric: tabular-nums;
}

.trend-svg {
  display: block;
  width: 100%;
  height: 56px;
  background: var(--bg);
  border-radius: 8px;
  overflow: visible;
}

.trend-line {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-line.cpu { stroke: var(--primary); }
.trend-line.mem { stroke: var(--ok); }
.trend-line.recv { stroke: var(--primary); }
.trend-line.sent { stroke: var(--warn); }

.legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend .trend-range {
  margin-left: 4px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.rec { background: var(--primary); }
.legend-dot.sent { background: var(--warn); }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .card-wide { grid-column: span 1; }
  body { padding: 16px; }
}
