:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1c2029;
  --line: #262b36;
  --txt: #e6e9ef;
  --muted: #8b93a7;
  --acc: #2f81f7;
  --green: #3fb950;
  --amber: #d29922;
  --orange: #f0883e;
  --red: #f85149;
  --cyan: #39c5cf;
  --purple: #a371f7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--txt);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(15, 17, 21, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; letter-spacing: .3px; }
.logo { color: var(--cyan); font-size: 18px; }

.ctrl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.sel, .input {
  background: var(--panel2);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  max-width: 240px;
}
.sel:focus, .input:focus { border-color: var(--acc); }

.btn {
  background: var(--panel2);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover { border-color: var(--acc); }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #fff; }
.btn.ghost { background: transparent; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.status.online .dot { background: var(--green); box-shadow: 0 0 8px rgba(63, 185, 80, .6); }
.status.offline .dot { background: var(--red); box-shadow: 0 0 8px rgba(248, 81, 73, .6); }

/* ---------- 布局 ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 18px 60px; }

.block { margin-bottom: 26px; }
.block-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.block-head h2 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .5px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.bad { color: var(--red); }
.center { text-align: center; padding: 30px 0; }
.hidden { display: none !important; }
.grow { flex: 1; }
.r { text-align: right; }

.banner {
  margin: 12px 18px 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(248, 81, 73, .1);
  border: 1px solid rgba(248, 81, 73, .4);
  color: #ffb4ae;
  font-size: 13px;
}

/* ---------- 卡片 ---------- */
.cat { margin-bottom: 16px; }
.cat-title {
  font-size: 12px; color: var(--muted); letter-spacing: 1px;
  text-transform: uppercase; margin: 0 0 8px; font-weight: 600;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.cards-empty { padding: 24px 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
}
.card .name {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .val {
  font-size: 24px; font-weight: 600; line-height: 1.25;
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.card .unit { font-size: 12px; color: var(--muted); margin-left: 3px; font-weight: 400; }
.card .bar { height: 4px; border-radius: 3px; background: #262b36; margin-top: 8px; overflow: hidden; }
.card .bar > i { display: block; height: 100%; border-radius: 3px; transition: width .4s ease; }
.card .sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

.t-green { color: var(--green); }
.t-amber { color: var(--amber); }
.t-orange { color: var(--orange); }
.t-red { color: var(--red); }
.t-cyan { color: var(--cyan); }
.t-purple { color: var(--purple); }

/* ---------- 图表 ---------- */
.chart { width: 100%; height: 380px; }
.tabs { display: flex; gap: 6px; }
.tab {
  background: var(--panel2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.tab.active { background: rgba(47, 129, 247, .16); color: var(--acc); border-color: var(--acc); }

.picker { margin-bottom: 10px; }
.picker-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--panel2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: var(--acc); }
.chip.on { background: rgba(47, 129, 247, .18); border-color: var(--acc); color: #9dc9ff; }
.chip.ghost { color: var(--muted); }

.picker-body {
  margin-top: 10px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  max-height: 240px; overflow: auto;
}
.pb-group { margin-bottom: 12px; }
.pb-group:last-child { margin-bottom: 0; }
.pb-title { font-size: 11px; color: var(--muted); margin-bottom: 6px; letter-spacing: .5px; }
.pb-items { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 表格 ---------- */
.tablewrap {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; overflow: auto; max-height: 420px;
}
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.tbl th { position: sticky; top: 0; background: var(--panel2); color: var(--muted); font-weight: 500; text-align: left; z-index: 1; }
.tbl td { font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { font-weight: 600; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #262b36; color: var(--muted); }

.foot { text-align: center; font-size: 12px; padding-top: 10px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 22px; width: 100%; max-width: 420px;
}
.modal-box h3 { margin: 0 0 8px; font-size: 16px; }
.modal-box label { display: block; margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.modal-box .input { width: 100%; max-width: none; margin-top: 4px; font-size: 13px; padding: 8px 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- 进程占用排行 ---------- */
.proclist { padding: 4px 0 8px; }
.proc-row {
  display: grid;
  grid-template-columns: 26px minmax(120px, 220px) 1fr 78px 96px;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.proc-row:last-child { border-bottom: 0; }
.proc-rank { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.proc-name {
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.proc-name .cnt { color: var(--muted); font-size: 11px; margin-left: 5px; }
.proc-bar { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; }
.proc-bar > i { display: block; height: 100%; border-radius: 4px; transition: width .5s ease; }
.proc-cpu {
  text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 600;
}
.proc-mem { text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.proc-empty { padding: 18px 0; font-size: 13px; }

@media (max-width: 640px) {
  .chart { height: 300px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .card .val { font-size: 20px; }
  .proc-row { grid-template-columns: 22px minmax(88px, 1fr) 1fr 62px 74px; gap: 8px; }
}
