:root {
  --bg: #0b0f17;
  --bg2: #111827;
  --card: #161e2e;
  --card2: #1c2740;
  --line: #243050;
  --txt: #e8edf7;
  --sub: #8b98b8;
  --acc: #4f8cff;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --radius: 18px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow-x: hidden; overflow-x: clip; }
body {
  background: var(--bg);
  color: var(--txt);
  font: 15px/1.5 -apple-system, "PingFang SC", "Noto Sans SC", "Helvetica Neue", sans-serif;
  overscroll-behavior-y: none;
  touch-action: pan-y;   /* 只允许纵向平移，禁止左右拖动 */
  width: 100%;
}
.hidden { display: none !important; }
/* 全局隐藏滚动条（仍可正常滚动） */
::-webkit-scrollbar { width: 0; height: 0; display: none; }
* { scrollbar-width: none; -ms-overflow-style: none; }
input, select, button { font: inherit; color: inherit; }

/* 登录 */
.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card .logo { font-size: 52px; }
.login-card h1 { font-size: 24px; margin: 12px 0 4px; }
.login-card .sub { color: var(--sub); margin-bottom: 28px; }
.login-card input { width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); margin-bottom: 14px; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: rgba(11,15,23,.82); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; }
.icon-btn { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 7px 11px; }

/* 概览统计 */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 14px 16px 0; }
.stat-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.stat-box .num { font-size: 22px; font-weight: 700; }
.stat-box .lbl { font-size: 12px; color: var(--sub); }

/* 服务器列表 */
.server-list { padding: 12px 16px 90px; display: flex; flex-direction: column; gap: 12px; }
.server-card {
  background: linear-gradient(160deg, var(--card), var(--card2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; position: relative; overflow: hidden;
}
.server-card.offline { opacity: .55; }
.sc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--sub); flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--red); }
.sc-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-host { color: var(--sub); font-size: 13px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--bg2); border: 1px solid var(--line); color: var(--sub); max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge.err { color: var(--red); border-color: var(--red); }
.sc-bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.sc-bar .top { display: flex; justify-content: space-between; font-size: 12px; color: var(--sub); margin-bottom: 4px; }
.sc-bar .val { color: var(--txt); font-weight: 600; }
.bar { height: 7px; background: var(--bg2); border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 6px; background: var(--acc); transition: width .5s; }
.bar i.hot { background: linear-gradient(90deg, var(--yellow), var(--red)); }
.sc-foot { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--sub); }
.sc-foot > span { min-width: 0; overflow-wrap: anywhere; }
.stats-row > *, .sc-bars > *, .grid2 > *, .row2 > * { min-width: 0; }
.server-card, .card, .gpu-item, .disk-item, .proc-row { min-width: 0; }

/* 详情 */
#detailView { padding: 0 16px 20px; }
.detail-head { padding: 16px 2px; }
.back-btn { background: none; border: none; color: var(--acc); font-size: 16px; margin-bottom: 8px; }
.detail-name { font-size: 22px; font-weight: 700; }
.detail-host { color: var(--sub); font-size: 13px; margin: 2px 0 10px; overflow-wrap: anywhere; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { font-size: 12px; color: var(--sub); background: var(--card); border: 1px solid var(--line); padding: 4px 10px; border-radius: 20px; overflow-wrap: anywhere; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card h2 { font-size: 15px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.alert { background: rgba(248,113,113,.12); border: 1px solid var(--red); color: var(--red); border-radius: 12px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px; }
.mini-btn { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; font-size: 12px; color: var(--sub); }

/* GPU 卡片 */
.gpu-item { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.gpu-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.gpu-name { font-size: 13px; font-weight: 600; }
.gpu-util { font-size: 18px; font-weight: 700; color: var(--acc); }
.gpu-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--sub); margin-top: 8px; }

/* 环形指示 */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .card { margin-bottom: 14px; }
.ring-wrap { display: flex; justify-content: center; padding: 6px 0 10px; }
.ring {
  width: 92px; height: 92px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--acc) calc(var(--p,0) * 1%), var(--bg2) 0);
  position: relative;
}
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--card); }
.ring span { position: relative; font-weight: 700; font-size: 17px; }
.mini { font-size: 12px; color: var(--sub); text-align: center; }

/* 磁盘 */
.disk-item { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.disk-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.disk-sub { font-size: 12px; color: var(--sub); margin-top: 8px; }

/* 进程 */
.proc-list { font-size: 13px; }
.proc-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.proc-row:last-child { border: none; }
.proc-row .pid { color: var(--sub); width: 52px; flex: none; }
.proc-row .cmd { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proc-row .mem { color: var(--acc); flex: none; }
.proc-empty { color: var(--sub); text-align: center; padding: 8px 0; }
h3.proc-sub { font-size: 13px; color: var(--sub); margin: 10px 0 4px; }

/* 电源 */
.danger-zone { border-color: rgba(248,113,113,.4); }
.power-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.delay-row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; color: var(--sub); font-size: 13px; }
.delay-row select { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }

/* 按钮 */
.btn { border: none; border-radius: 14px; padding: 13px 18px; font-weight: 600; cursor: pointer; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--acc); color: #fff; }
.btn.warn { background: rgba(251,191,36,.15); color: var(--yellow); border: 1px solid var(--yellow); }
.btn.danger { background: rgba(248,113,113,.15); color: var(--red); border: 1px solid var(--red); }
.btn.ghost { background: var(--bg2); color: var(--sub); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.fab {
  position: fixed; right: 20px; bottom: calc(28px + env(safe-area-inset-bottom, 0px)); width: 56px; height: 56px;
  border-radius: 50%; border: none; background: var(--acc); color: #fff;
  font-size: 26px; box-shadow: 0 8px 24px rgba(79,140,255,.4); z-index: 15;
}

/* 抽屉 & 弹层 */
.drawer-mask, .confirm-mask { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; backdrop-filter: blur(2px); }
.drawer {
  position: fixed; top: 0; right: 0; width: 78vw; max-width: 320px; height: 100vh;
  background: var(--bg2); border-left: 1px solid var(--line); z-index: 41;
  padding: 22px 18px; transform: translateX(105%); transition: transform .25s;
  display: flex; flex-direction: column; gap: 16px;
}
.drawer.open { transform: translateX(0); }
.drawer h2 { font-size: 17px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; color: var(--sub); font-size: 14px; }
.switch-row select { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.hint { color: var(--sub); font-size: 12px; margin-top: auto; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--bg2); border-radius: 22px 22px 0 0; padding: 12px 18px 26px;
  transform: translateY(105%); transition: transform .28s;
  max-height: 92vh; overflow-y: auto;
}
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 42px; height: 4px; background: var(--line); border-radius: 4px; margin: 4px auto 14px; }
.sheet h2 { font-size: 17px; margin-bottom: 14px; }
.sheet input { width: 100%; padding: 13px 15px; border-radius: 13px; border: 1px solid var(--line); background: var(--card); margin-bottom: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.test-result { font-size: 13px; min-height: 20px; margin-top: 8px; color: var(--sub); }
.test-result.ok { color: var(--green); }
.test-result.bad { color: var(--red); }

.confirm-mask { display: flex; align-items: center; justify-content: center; z-index: 50; }
.confirm-box { width: 84vw; max-width: 340px; background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; padding: 22px 18px; }
.confirm-box h3 { font-size: 17px; margin-bottom: 8px; }
.confirm-box p { color: var(--sub); font-size: 14px; margin-bottom: 18px; }

/* 长按编辑菜单 */
.ctx-menu {
  position: fixed; z-index: 60; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.ctx-menu button { display: block; width: 100%; padding: 12px 22px; background: none; border: none; text-align: left; }
.ctx-menu button.del { color: var(--red); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: #000c; color: #fff; padding: 10px 20px; border-radius: 24px;
  font-size: 13px; z-index: 70; pointer-events: none;
  max-width: 86vw; text-align: center; overflow-wrap: anywhere;
}
