/* ============ 设计变量 ============ */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e6e8ec;
  --line-strong: #d5d8de;
  --text: #1c2230;
  --text-2: #4c5567;
  --muted: #8b93a5;
  --accent: #4f46e5;
  --accent-600: #4338ca;
  --accent-soft: #eef0ff;
  --green: #10b981;
  --red: #e5484d;
  --amber: #f59e0b;
  --term-bg: #0f1219;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(19, 24, 38, .05);
  --shadow-md: 0 8px 24px rgba(19, 24, 38, .09);
  --shadow-lg: 0 24px 60px rgba(19, 24, 38, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ============ 启动占位 ============ */
.boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  z-index: 90;
}
.boot-logo svg { animation: pulse 1.6s ease-in-out infinite; border-radius: 10px; }
.boot-text { color: var(--muted); font-size: 13px; }
@keyframes pulse {
  0%, 100% { opacity: .55; transform: scale(.97); }
  50% { opacity: 1; transform: scale(1); }
}

/* ============ 登录页 ============ */
.auth-view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 480px at 15% -10%, #e6e9ff 0%, rgba(230, 233, 255, 0) 60%),
    radial-gradient(700px 420px at 110% 110%, #e2f6f0 0%, rgba(226, 246, 240, 0) 55%),
    var(--bg);
  z-index: 80;
  overflow: auto;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px 30px 26px;
  box-shadow: var(--shadow-md);
  animation: rise .35s ease-out;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand svg { border-radius: 9px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.auth-card h2 { font-size: 19px; margin: 0 0 6px; }
.auth-sub { margin: 0 0 22px; font-size: 13px; color: var(--muted); line-height: 1.6; }

/* ============ 表单元素 ============ */
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 6px;
}
.field > span em {
  font-style: normal;
  font-weight: 400;
  font-size: 11.5px;
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 9px 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; font-family: var(--mono); font-size: 12px; line-height: 1.5; }
.field input::placeholder,
.field textarea::placeholder { color: #b3b9c7; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.field-tip {
  display: block;
  font-style: normal;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 5px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  margin: 4px 0 6px;
  cursor: pointer;
  user-select: none;
}
.check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.form-error {
  color: var(--red);
  font-size: 12.5px;
  margin: 10px 0 0;
  min-height: 0;
  line-height: 1.5;
}
.form-error:empty { display: none; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .06s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: #fafbfc; border-color: #c6cad4; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(79, 70, 229, .25);
}
.btn.primary:hover { background: var(--accent-600); border-color: var(--accent-600); }

.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: #eef0f4; color: var(--text); }

.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--red); }
.btn.danger-ghost:hover { background: #fdecec; }

.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.tiny { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; height: 40px; margin-top: 8px; font-size: 14px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
  flex: none;
}
.icon-btn:hover { background: #eef0f4; color: var(--text); }
.icon-btn.danger:hover { background: #fdecec; color: var(--red); }

/* ============ 主框架 ============ */
.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  height: 54px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand-sm { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; letter-spacing: .2px; }
.brand-sm svg { border-radius: 6px; }
.topbar-right { display: flex; align-items: center; gap: 6px; }

.user-chip {
  font-size: 12.5px;
  color: var(--text-2);
  background: #f2f3f6;
  border-radius: 20px;
  padding: 5px 11px;
  margin-right: 4px;
}

.workspace { flex: 1; display: flex; min-height: 0; }

/* ============ 侧边栏 ============ */
.sidebar {
  width: 306px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.side-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px 0;
}
.side-tab {
  flex: 1;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.side-tab:hover { color: var(--text); background: #f5f6f8; }
.side-tab.active { color: var(--accent); background: var(--accent-soft); }

.side-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tab-panel { display: flex; flex-direction: column; min-height: 0; flex: 1; }

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px;
}
.side-title { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; }

.search-wrap { padding: 0 14px 8px; }
.search {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: #f7f8fa;
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.search:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }

.host-list,
.cmd-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 12px;
  min-height: 0;
}

.host-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .14s, border-color .14s;
}
.host-item:hover { background: #f7f8fb; border-color: var(--line); }
.host-item.active { background: var(--accent-soft); border-color: #dcdffb; }

.host-avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(140deg, #6366f1, #4f46e5);
  letter-spacing: .3px;
}

.host-main { flex: 1; min-width: 0; }
.host-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
}
.host-name-txt {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.host-meta {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.host-acts { display: flex; gap: 1px; opacity: 0; transition: opacity .15s; }
.host-item:hover .host-acts { opacity: 1; }

.cmd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  transition: background .14s;
}
.cmd-item:hover { background: #f7f8fb; }
.cmd-main { flex: 1; min-width: 0; }
.cmd-label { font-size: 13px; font-weight: 500; }
.cmd-code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.cmd-acts { display: flex; opacity: 0; transition: opacity .15s; }
.cmd-item:hover .cmd-acts { opacity: 1; }

.empty-hint {
  padding: 8px 18px 18px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.65;
}

.side-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
}
.side-foot svg { flex: none; color: var(--green); }

/* ============ 会话标签栏（多 VPS） ============ */
.session-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 6px;
  min-width: 0;
}

.session-tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.session-tabs::-webkit-scrollbar { height: 4px; }
.session-tabs::-webkit-scrollbar-thumb { background: #d7dbe3; border-radius: 4px; }

.st-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
  max-width: 236px;
  min-width: 132px;
  height: 42px;
  padding: 0 6px 0 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.st-tab:hover { border-color: var(--line-strong); background: #fbfbfd; }
.st-tab.active {
  background: var(--accent-soft);
  border-color: #c9cdf8;
  box-shadow: 0 1px 2px rgba(79, 70, 229, .1);
}
.st-tab.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -3px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.st-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: #c9cedb;
}
.st-tab.online .st-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(16, 185, 129, .14); }
.st-tab.connecting .st-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(245, 158, 11, .14); animation: blink 1s infinite; }
.st-tab.offline .st-dot { background: var(--red); box-shadow: 0 0 0 3px rgba(229, 72, 77, .12); }

.st-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.st-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.st-tab.offline .st-name { color: var(--text-2); }
.st-sub {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.st-tab.offline .st-sub { color: #c08a8b; }

.st-idx {
  font-family: var(--mono);
  font-size: 10px;
  color: #b3b9c7;
  flex: none;
  min-width: 8px;
  text-align: center;
}
.st-tab.active .st-idx { color: #8f8ae0; }

.st-close {
  width: 20px;
  height: 20px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
}
.st-tab:hover .st-close,
.st-tab.active .st-close { opacity: 1; }
.st-close:hover { background: #fdecec; color: var(--red); }

.session-sum {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 2px;
  font-size: 12px;
  color: var(--text-2);
}
.ss-item { display: inline-flex; align-items: center; gap: 4px; }
.ss-lb { font-size: 11px; color: var(--muted); }
.ss-item b { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.ss-dot { width: 6px; height: 6px; border-radius: 50%; background: #c9cedb; }
.ss-item.online .ss-dot { background: var(--green); }
.ss-item.connecting .ss-dot { background: var(--amber); }
.ss-item.offline .ss-dot { background: var(--red); }
.ss-item.online b { color: var(--text); }
.ss-item.connecting b { color: var(--amber); }
.ss-item.offline b { color: var(--red); }
.ss-total {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: #f2f3f6;
  border-radius: 20px;
  padding: 3px 8px;
}
.session-sum .btn.tiny { height: 26px; }

/* ============ 终端区 ============ */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 14px 12px 14px;
  gap: 0;
}

.term-bar {
  height: 38px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 0 6px;
  gap: 12px;
}
.term-title { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); min-width: 0; }
.term-title #term-title {
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c9cedb;
  flex: none;
  transition: background .2s, box-shadow .2s;
}
.dot.connecting { background: var(--amber); box-shadow: 0 0 0 3px rgba(245, 158, 11, .15); animation: blink 1s infinite; }
.dot.online { background: var(--green); box-shadow: 0 0 0 3px rgba(16, 185, 129, .16); }
.dot.offline { background: var(--red); box-shadow: 0 0 0 3px rgba(229, 72, 77, .14); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.term-badge {
  font-size: 11px;
  color: var(--green);
  background: rgba(16, 185, 129, .1);
  border-radius: 20px;
  padding: 2px 8px;
}
.term-actions { display: flex; gap: 4px; flex: none; }

.term-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--term-bg);
  border-radius: 13px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid #1b2230;
}

/* 多会话：每个会话一块独立的 xterm 面板，切标签只换显示 */
.term-deck {
  position: absolute;
  inset: 0;
}

.term-pane {
  position: absolute;
  inset: 0;
  padding: 12px 6px 12px 14px;
  visibility: hidden;
}
.term-pane.active { visibility: visible; }

/* xterm 细节微调 */
.term-pane .xterm-viewport { background: transparent !important; }
.term-pane .xterm-viewport::-webkit-scrollbar { width: 9px; }
.term-pane .xterm-viewport::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .14);
  border-radius: 8px;
}
.term-pane .xterm-viewport::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .26); }

/* 侧栏里的会话状态标记 */
.host-live {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.5;
  border-radius: 20px;
  vertical-align: 1px;
  white-space: nowrap;
}
.host-live.online { color: #0f7a55; background: rgba(16, 185, 129, .12); }
.host-live.connecting { color: #9a6410; background: rgba(245, 158, 11, .14); }
.host-live.offline { color: #a33b3f; background: rgba(229, 72, 77, .1); }

/* 欢迎页 */
.welcome {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(520px 300px at 50% 0%, rgba(79, 70, 229, .22), rgba(15, 18, 25, 0) 70%),
    var(--term-bg);
  z-index: 2;
}
.welcome-inner { max-width: 420px; text-align: center; color: #cbd2e0; }
.welcome-inner h2 { color: #f2f5fb; font-size: 20px; margin: 0 0 8px; font-weight: 600; }
.welcome-inner p { margin: 0 0 20px; font-size: 13px; line-height: 1.7; color: #98a2b8; }
.welcome-actions { display: flex; gap: 10px; justify-content: center; margin-bottom: 24px; }
.welcome-actions .btn:not(.primary) {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .14);
  color: #dbe1ee;
}
.welcome-actions .btn:not(.primary):hover { background: rgba(255, 255, 255, .11); }

.welcome-tips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}
.welcome-tips li {
  font-size: 12px;
  color: #8d97ad;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 9px;
  padding: 8px 12px;
  line-height: 1.6;
}
.welcome-tips b { color: #d6dceb; font-weight: 600; }

/* ============ 快捷命令栏 ============ */
.quickbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 2px 0;
  min-height: 42px;
}
.qb-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  flex: none;
}
.qb-label svg { color: var(--amber); }

.chips {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.chips::-webkit-scrollbar { height: 5px; }
.chips::-webkit-scrollbar-thumb { background: #d7dbe3; border-radius: 4px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  flex: none;
}
.chip:hover {
  color: var(--accent);
  border-color: #c7caf7;
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.chip:active { transform: none; }
.chip .chip-cmd {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip:hover .chip-cmd { color: #7a74e8; }

/* ============ 实时监控 ============ */
.metrics {
  flex: none;
  margin: 2px 0 10px;
  padding: 8px 10px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow-sm);
  animation: rise .22s ease-out;
}
.metrics.folded { padding-bottom: 8px; }
.metrics.folded .metrics-grid { display: none; }

.metrics-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 24px;
  margin-bottom: 6px;
}
.metrics.folded .metrics-head { margin-bottom: 0; }
.mh-left,
.mh-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mh-left { flex: 1 1 0; overflow: hidden; }
.mh-right { flex: none; }
.mh-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: #c9cedb;
  transition: background .2s, box-shadow .2s;
}
.mh-dot.live { background: var(--green); box-shadow: 0 0 0 3px rgba(16, 185, 129, .14); }
.mh-dot.paused { background: var(--amber); box-shadow: 0 0 0 3px rgba(245, 158, 11, .14); }
.mh-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: .3px;
  flex: none;
}
.mh-host {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mh-time { font-family: var(--mono); font-size: 11px; color: #a9b0bf; flex: none; }
.mh-select {
  height: 24px;
  padding: 0 3px;
  font-family: inherit;
  font-size: 11.5px;
  color: var(--text-2);
  background: #f7f8fa;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  flex: none;
}
.mh-select:focus { border-color: var(--accent); background: #fff; }
.mh-right .icon-btn { width: 24px; height: 24px; border-radius: 6px; }

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr .82fr 1fr 1.58fr;
  gap: 8px;
}

.m-card {
  min-width: 0;
  padding: 8px 10px 7px;
  background: #fbfbfd;
  border: 1px solid #edeff4;
  border-radius: 10px;
  transition: border-color .18s, background .18s;
}
.m-card:hover { border-color: var(--line-strong); background: #fff; }

.m-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; min-width: 0; }
.m-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--muted);
  text-transform: uppercase;
  flex: none;
}
/* 网卡名保持小写，不做大写转换 */
#l-net { text-transform: none; letter-spacing: .2px; }
.m-val {
  min-width: 0;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .25s;
}

.m-mid { height: 26px; display: flex; align-items: center; margin: 2px 0 3px; }
.m-spark { display: block; width: 100%; height: 26px; }

.m-bar {
  width: 100%;
  height: 6px;
  background: #e9ebf1;
  border-radius: 4px;
  overflow: hidden;
}
.m-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #6d67ea, var(--accent));
  transition: width .4s cubic-bezier(.4, 0, .2, 1), background .3s;
}

.m-sub {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.35;
  color: #6f788c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 阈值配色：健康 → 偏高 → 危险 */
.m-card[data-lvl="warn"] .m-val { color: var(--amber); }
.m-card[data-lvl="warn"] .m-bar i { background: linear-gradient(90deg, #fbbf24, var(--amber)); }
.m-card[data-lvl="crit"] .m-val { color: var(--red); }
.m-card[data-lvl="crit"] .m-bar i { background: linear-gradient(90deg, #f2777a, var(--red)); }
.m-card[data-lvl="off"] .m-val { color: var(--muted); font-weight: 500; }
.m-card[data-lvl="off"] .m-bar i { background: #d7dbe3; }

/* 采集异常提示 */
.metrics.error .m-card[data-lvl] { opacity: .55; }

#btn-metrics.on {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #dcdffb;
}

/* ============ 弹窗 ============ */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(17, 21, 31, .38);
  backdrop-filter: blur(2px);
  animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 22px 24px 20px;
  animation: pop .2s cubic-bezier(.2, .9, .3, 1);
}
.modal-card.narrow { max-width: 400px; }
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.confirm-body {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-2);
  word-break: break-word;
}
.confirm-body code {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11.5px;
  background: #f3f4f7;
  border-radius: 5px;
  padding: 1px 6px;
  word-break: break-all;
}

/* ============ Toast ============ */
.toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 210px;
  max-width: 340px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
  animation: slideIn .22s ease-out;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
.toast.leaving { animation: slideOut .2s ease-in forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes slideOut { to { opacity: 0; transform: translateX(16px); } }

/* ============ 响应式 ============ */
@media (max-width: 1080px) {
  .metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metrics-grid .m-net { grid-column: span 2; }
  .mh-time { display: none; }
}

@media (max-width: 860px) {
  .sidebar { width: 252px; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .side-foot { display: none; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics-grid .m-net { grid-column: span 2; }
  .st-tab { max-width: 190px; min-width: 118px; }
  .ss-total { display: none; }
}

@media (max-width: 680px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .workspace { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); max-height: 42vh; }
  .main { padding: 10px; }
  .term-wrap { min-height: 58vh; }
  .welcome-tips { display: none; }
  .topbar-right .user-chip { display: none; }
  .mh-time { display: none; }
  .st-sub { display: none; }
  .st-tab { height: 36px; min-width: 96px; }
  .session-sum .btn.tiny { display: none; }
}
