:root {
  --bg: #0e1116;
  --bg2: #151b23;
  --card: #171e27;
  --line: #263140;
  --fg: #dbe4ee;
  --muted: #7d8fa3;
  --acc: #4a9eff;
  --ok: #33c175;
  --warn: #f0a742;
  --err: #ef4a5a;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.55 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
code, pre, textarea, input, select, .mono { font-family: var(--mono); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--err); font-size: 12px; min-height: 16px; }
a { color: var(--acc); }

/* ---------- 登录 ---------- */
.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 32px 30px; width: 340px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 18px 60px rgba(0,0,0,.5);
}
.login-card .logo { font-size: 20px; font-weight: 700; }
.login-card input { padding: 10px 12px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 14px; align-items: center;
  padding: 10px 18px; background: var(--bg2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.tag {
  font-size: 11px; background: #203040; color: #8fc2ff; border: 1px solid #2c4257;
  padding: 1px 7px; border-radius: 20px; margin-left: 6px; font-weight: 400;
}
.top-status { font-size: 12px; color: var(--muted); }
.top-status b.on { color: var(--ok); } .top-status b.off { color: var(--err); }
.tabs { display: flex; gap: 4px; }
.tab {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 7px 13px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.tab:hover { color: var(--fg); background: #1d2733; }
.tab.active { background: #1e3busy; background: #1c2b3a; color: #cfe6ff; border-color: #2b4761; }
.top-right { display: flex; gap: 6px; align-items: center; }

/* ---------- 统计 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 10px; padding: 14px 18px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat .n { font-size: 24px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat.ok .n { color: var(--ok); } .stat.warn .n { color: var(--warn); } .stat.info .n { color: var(--acc); }

/* ---------- 面板 ---------- */
.panel { padding: 14px 18px 40px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 14px;
}
.card h3 { margin: 4px 0 10px; font-size: 13px; color: #a9c1d8; letter-spacing: .3px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.toolbar .left { display: flex; gap: 8px; align-items: center; }
.toolbar input { width: 260px; }

/* ---------- 按钮 / 控件 ---------- */
.btn {
  background: #22303f; color: var(--fg); border: 1px solid #33475c; border-radius: 8px;
  padding: 7px 12px; cursor: pointer; font-size: 13px;
}
.btn:hover { background: #2a3c4f; }
.btn.primary { background: #1d5a9f; border-color: #2b79c9; color: #fff; }
.btn.primary:hover { background: #236ab8; }
.btn.danger { background: #46212a; border-color: #6c3140; }
.btn.danger:hover { background: #5a2833; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  background: #0e141b; color: var(--fg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; font-size: 13px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #35597c; }
.field { margin-bottom: 8px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.chk { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.chk input { width: auto; }
.row { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.row.wrap { flex-wrap: wrap; }
.row input, .row select { width: auto; }

/* ---------- 表格 ---------- */
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  border-bottom: 1px solid var(--line); padding: 8px 9px; white-space: nowrap;
}
table.grid td { border-bottom: 1px solid #1d2530; padding: 9px; vertical-align: top; }
table.grid tbody tr:hover { background: #1a222c; }
td.empty { color: var(--muted); text-align: center; padding: 22px; }
.w-ck { width: 30px; } .w-act { width: 170px; }
.mono-id { font-family: var(--mono); font-weight: 600; }
.sub { color: var(--muted); font-size: 11px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.off { background: #4a5663; }
.badge {
  font-size: 11px; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--line);
  background: #1b2530; color: #9fb3c8; white-space: nowrap;
}
.badge.win { border-color: #2f5f8a; color: #8fc7ff; }
.badge.linux { border-color: #4c6b2f; color: #bfe08a; }
.badge.grey { color: var(--muted); }
.os { display: flex; gap: 6px; align-items: center; }

/* ---------- 待接受 ---------- */
.pending {
  background: #242013; border: 1px solid #4a4126; border-radius: 10px;
  padding: 10px 14px; margin-bottom: 12px;
}
.pending .p-item { display: flex; gap: 10px; align-items: center; padding: 4px 0; flex-wrap: wrap; }
.pending b { color: var(--warn); }

/* ---------- 执行命令 ---------- */
.run-grid { display: grid; grid-template-columns: 330px 1fr; gap: 14px; align-items: start; }
.sys-grid { display: grid; grid-template-columns: 340px 1fr; gap: 14px; align-items: start; }
.card.grow { min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: #1a2836; border: 1px solid #2b4257; color: #b7d3ee; border-radius: 6px;
  padding: 3px 8px; font-size: 12px; cursor: pointer; font-family: var(--mono);
}
.chip:hover { background: #22394f; }

/* ---------- 结果 ---------- */
.results { margin-top: 12px; min-width: 0; }
.res-host { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.res-head {
  padding: 7px 12px; background: #1a2230; cursor: pointer; display: flex;
  justify-content: space-between; align-items: center; font-size: 13px;
}
.res-head .ok { color: var(--ok); } .res-head .bad { color: var(--err); }
.res-host pre {
  margin: 0; padding: 11px 13px; background: #0b0f14; white-space: pre-wrap;
  word-break: break-word; font-size: 12.5px; max-height: 460px; overflow: auto;
}
.raw-out { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #0b0f14; white-space: pre-wrap; font-size: 12px; }
.spin { display: inline-block; animation: r 1s linear infinite; }
@keyframes r { to { transform: rotate(360deg); } }

/* ---------- 代码块 ---------- */
.codebox { position: relative; }
.codebox pre {
  background: #0b0f14; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 90px 12px 13px; margin: 0; white-space: pre-wrap; word-break: break-all; font-size: 12.5px;
}
.codebox .copy { position: absolute; top: 8px; right: 8px; }
ul.tips { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; }
ul.tips li { margin: 4px 0; }
.join-form { display: grid; grid-template-columns: 1fr 120px 150px auto; gap: 10px; align-items: end; }
.btn-field { display: flex; align-items: flex-end; }

/* ---------- 抽屉 ---------- */
.drawer {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex;
  justify-content: flex-end; z-index: 50;
}
.drawer-body {
  background: var(--bg2); width: min(760px, 96vw); height: 100%; overflow: auto;
  border-left: 1px solid var(--line); padding: 16px 18px;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv td { padding: 5px 8px; border-bottom: 1px solid #1d2530; }
.kv td:first-child { color: var(--muted); width: 190px; }
.removed { margin-top: 10px; color: var(--muted); }
.removed summary { cursor: pointer; font-size: 12px; }
#removedList { font-size: 12px; padding: 6px 0; }

/* ---------- toast ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast {
  background: #1c2b3a; border: 1px solid #2f5273; color: #d6e8fa; padding: 9px 14px;
  border-radius: 8px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: fade .2s ease-out;
}
.toast.bad { background: #3a1c22; border-color: #74323f; color: #ffd7dd; }
.toast.ok { background: #16321f; border-color: #2e6b45; color: #cfe9d8; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 1050px) {
  .run-grid, .sys-grid, .join-form { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: 1fr auto; }
  .tabs { grid-column: 1 / -1; overflow-x: auto; }
}
