:root {
  --bg: #0d1117;
  --bg2: #151b23;
  --bg3: #1c242e;
  --line: #263140;
  --fg: #e6edf3;
  --muted: #8b98a5;
  --accent: #4da3ff;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
body {
  font: 14px/1.5 -apple-system, "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.tiny { font-size: 11.5px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }

/* 登录 */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 360px; text-align: center; }
.logo { font-size: 44px; }
.login h1 { font-size: 22px; margin: 6px 0 2px; letter-spacing: .5px; }
.login input { width: 100%; margin: 18px 0 10px; }
.err { color: var(--bad); font-size: 12.5px; min-height: 18px; margin-top: 8px; }

/* 基础控件 */
input, textarea, select {
  width: 100%; background: var(--bg2); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: inherit; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; line-height: 1.5; }
.btn {
  border: 1px solid var(--line); background: var(--bg3); color: var(--fg);
  border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.xs { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; margin-top: 10px; }
.btn.danger { color: var(--bad); border-color: #4a2326; }
.btn:disabled { opacity: .5; }
.icon {
  background: transparent; border: none; color: var(--muted); font-size: 18px;
  padding: 6px 8px; cursor: pointer; line-height: 1;
}
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.chk input { width: auto; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: rgba(13, 17, 23, .92);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  padding-top: calc(10px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand b { font-size: 15px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); }
.dot.off { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.tag { font-size: 11px; color: var(--muted); background: var(--bg3); border: 1px solid var(--line); padding: 1px 7px; border-radius: 20px; }

/* 导航 */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--bg);
  position: sticky; top: calc(45px + env(safe-area-inset-top)); z-index: 19;
}
.tabs::-webkit-scrollbar { display: none; }
.tabbtn {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 20px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.tabbtn.active { background: var(--bg3); color: var(--fg); border-color: var(--line); }

main { padding: 12px; max-width: 980px; margin: 0 auto; }
.view { display: flex; flex-direction: column; gap: 12px; }

/* 卡片 */
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.card-head b { font-size: 14px; }
details.card > summary { cursor: pointer; color: var(--accent); font-size: 13.5px; }
details.card[open] > summary { margin-bottom: 10px; }

/* 指标 */
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 14px; }
@media (max-width: 520px) { .grid4 { grid-template-columns: repeat(2, 1fr); } }
.metric { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.metric span { font-size: 11.5px; color: var(--muted); }
.metric b { font-size: 20px; font-variant-numeric: tabular-nums; }
.metric small { color: var(--muted); font-size: 10.5px; }
.bar { height: 4px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .4s; }
.bar i.hot { background: var(--warn); }
.bar i.crit { background: var(--bad); }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 3px 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 500; text-align: right; overflow: hidden; text-overflow: ellipsis; }
.rowline { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.rowline input { flex: 1; min-width: 120px; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 20px; background: var(--bg3); color: var(--muted); }
.badge.ok { color: #06210c; background: var(--good); }
.badge.bad { color: #2b0b0b; background: var(--bad); }

/* 表格 */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11.5px; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 5px 6px; border-bottom: 1px solid rgba(38, 49, 64, .5); }
.tbl tr:last-child td { border-bottom: none; }
.tbl td:last-child { text-align: right; }

/* 终端 */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { background: var(--bg3); border: 1px solid var(--line); color: var(--muted); border-radius: 20px; padding: 4px 10px; font-size: 12px; white-space: nowrap; cursor: pointer; font-family: ui-monospace, Menlo, monospace; }
.console {
  background: #05080c; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; margin: 0; font-family: ui-monospace, Menlo, monospace;
  font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-all;
  max-height: 46vh; overflow: auto; color: #c8d6e5;
}

/* 文件 */
.file-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.frow { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid rgba(38, 49, 64, .6); cursor: pointer; font-size: 13px; }
.frow:last-child { border-bottom: none; }
.frow:active { background: var(--bg3); }
.frow .ico { width: 18px; text-align: center; }
.frow .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow .sz { color: var(--muted); font-size: 11px; }
.frow.dir .nm { color: var(--accent); }

/* 列表项 */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 12px; }
.item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.item-head b { font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.item-meta { color: var(--muted); font-size: 11.5px; display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.acts { display: flex; gap: 6px; flex-wrap: wrap; }

/* 表单 */
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.form label input, .form label select { color: var(--fg); }
.grow { flex: 1; }

/* 进度 */
.prog { height: 6px; background: var(--bg3); border-radius: 4px; overflow: hidden; margin: 6px 0; }
.prog i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* 弹层 */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--bg3); border: 1px solid var(--line); color: var(--fg);
  padding: 9px 16px; border-radius: 22px; font-size: 13px; z-index: 99; max-width: 86vw;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.toast.bad { border-color: #6b2222; color: #ffb4b4; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 100; display: flex; align-items: flex-end; justify-content: center; padding: 12px; }
.modal-box { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 760px; max-height: 82vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.modal-box pre { margin: 0; padding: 12px; overflow: auto; font-size: 12px; font-family: ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-all; }

/* 故障检测 */
.health-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; }
.hrow { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 1.5; }
.hdot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--muted); }
.hdot.ok { background: var(--good); }
.hdot.warn { background: #e0a526; }
.hdot.bad { background: var(--bad); box-shadow: 0 0 6px var(--bad); }
.hname { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.hdetail { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hms, .hts { flex: none; color: var(--muted); font-size: 11px; }
