:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #e5e9f1;
  --line-soft: #eef1f7;
  --text: #1a2233;
  --text-2: #4b5566;
  --muted: #7b8494;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.mono { font-family: "Cascadia Mono", Consolas, "Courier New", monospace; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
code { background: #eef2f9; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* ---------- 品牌 ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(140deg, #3b82f6, #1e40af);
  color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .5px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, .25);
}
.brand b { display: block; font-size: 14.5px; letter-spacing: .2px; }
.brand span { display: block; font-size: 10.5px; color: var(--muted); letter-spacing: .1em; }
.brand.big .logo { width: 42px; height: 42px; border-radius: 12px; font-size: 19px; }
.brand.big h1 { margin: 0; font-size: 20px; }
.brand.big p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); letter-spacing: .1em; }

/* ---------- 登录 ---------- */
.login-wrap {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 15% 0%, #dbe7ff 0%, transparent 60%),
    radial-gradient(700px 400px at 95% 100%, #e6ecff 0%, transparent 55%),
    #f4f6fa;
  z-index: 50;
}
.login-card {
  width: 360px; background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 28px 28px 22px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .1);
}
.login-card .brand { margin-bottom: 22px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.field input {
  width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 11px; font-size: 14px; font-family: inherit; outline: none;
  background: #fbfcfe; transition: .15s;
}
.field input:focus { background: #fff; border-color: #93b4fb; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.login-err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin: 10px 0 0; text-align: center; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 56px; flex: none; display: flex; align-items: center; gap: 12px;
  padding: 0 18px; background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(8px);
}
.conn-state { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.conn-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.conn-state.bad i { background: var(--danger); }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }

/* ---------- 布局 ---------- */
#app { flex: 1; min-height: 0; display: flex; flex-direction: column; }
main { flex: 1; min-height: 0; display: flex; }
.view { flex: 1; min-width: 0; padding: 20px 22px; display: flex; flex-direction: column; }
#view-devices { overflow: auto; }
#view-term, #view-files { padding: 14px 16px 16px; overflow: hidden; }

.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.page-head h2 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

.bar {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 4px 2px 12px;
}
.dev-title { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.dev-title b { font-size: 14px; font-weight: 600; }
.dev-title span { font-size: 11.5px; color: var(--muted); }

/* ---------- 卡片与表格 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card.grow { flex: 1; min-height: 0; overflow: auto; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th {
  text-align: left; font-weight: 500; font-size: 11.5px; color: var(--muted);
  padding: 10px 14px; background: #fafbfd; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; white-space: nowrap; z-index: 1;
}
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #fafcff; }
.tbl .right { text-align: right; }
.tbl.compact td, .tbl.compact th { padding: 8px 10px; font-size: 12.5px; }

.host b { font-weight: 500; }
.host span { display: block; font-size: 11px; color: var(--muted); font-family: Consolas, monospace; margin-top: 2px; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .13); }
.dot.off { background: #c3cad8; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; line-height: 18px;
  background: #eef2f9; color: var(--text-2);
}
.badge.ok { background: #e8f7ee; color: #0f8a45; }
.badge.wait { background: #fff4e5; color: #b45309; }
.badge.err { background: #fdecec; color: #c02626; }

.empty { padding: 46px 20px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.9; }

/* ---------- 按钮 ---------- */
.btn {
  height: 34px; padding: 0 13px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--text-2);
  font-family: inherit; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: #c9d3e6; background: #fbfcff; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eef2f9; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #fdecec; border-color: #f7c6c6; }
.btn.block { width: 100%; height: 38px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.select {
  height: 32px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  font-family: inherit; font-size: 12.5px; color: var(--text-2); padding: 0 8px; cursor: pointer;
}

/* ---------- 终端 ---------- */
.term-wrap {
  flex: 1; min-height: 0; background: #0d1117; border: 1px solid #1c2430;
  border-radius: var(--radius); overflow: hidden; padding: 8px 6px 6px 8px;
}
#xterm { width: 100%; height: 100%; }
.xterm .xterm-viewport { background: transparent !important; }

/* ---------- 文件 ---------- */
.pathbar {
  flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  padding: 0 2px 10px; font-size: 12.5px; min-height: 26px;
}
.crumb {
  border: 0; background: transparent; font-family: inherit; font-size: 12.5px;
  color: var(--primary); cursor: pointer; padding: 3px 5px; border-radius: 5px;
}
.crumb:hover { background: #e8effd; }
.crumb.sep { color: #b6bfcd; cursor: default; padding: 3px 1px; }
.crumb.cur { color: var(--text); font-weight: 500; cursor: default; }
.crumb.cur:hover { background: transparent; }

.fname { display: flex; align-items: center; gap: 8px; }
.fname .ico {
  width: 22px; height: 22px; border-radius: 5px; display: grid; place-items: center;
  font-size: 11px; font-weight: 600; flex: none;
}
.ico.dir { background: #fff6e0; color: #b7791f; }
.ico.file { background: #eef2f9; color: #64748b; }
.ico.txt { background: #e8f7ee; color: #0f8a45; }
.fname a { color: var(--text); text-decoration: none; cursor: pointer; }
.fname a:hover { color: var(--primary); text-decoration: underline; }

.statusline { flex: none; padding: 8px 2px 0; font-size: 12px; color: var(--muted); min-height: 26px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .42);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 24px;
}
.modal-card {
  background: #fff; border-radius: 12px; width: 640px; max-width: 100%;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .25); padding: 18px 20px;
  display: flex; flex-direction: column; max-height: 86vh;
}
.modal-card.small { width: 380px; }
.modal-card.wide { width: 900px; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 14.5px; }
.modal-head .x {
  margin-left: auto; border: 0; background: transparent; font-size: 20px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.modal-head .x:hover { background: #f1f4f9; color: var(--text); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; line-height: 1.6; }
.row-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.input {
  height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px;
  font-family: inherit; font-size: 13px; outline: none; flex: 1;
}
.input.num { width: 90px; flex: none; }
.input:focus { border-color: #93b4fb; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
#edit-text {
  flex: 1; min-height: 380px; resize: none; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px;
  line-height: 1.55; outline: none; background: #fbfcfe;
}
#edit-text:focus { background: #fff; border-color: #93b4fb; }

.progress { height: 8px; border-radius: 20px; background: #eef1f7; overflow: hidden; margin: 6px 0 10px; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #60a5fa, #2563eb); transition: width .15s; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #1f2937; color: #fff; font-size: 13px; padding: 10px 16px;
  border-radius: 9px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); z-index: 80;
  max-width: 80vw;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #15803d; }

@media (max-width: 860px) {
  .tbl th:nth-child(3), .tbl td:nth-child(3),
  .tbl th:nth-child(4), .tbl td:nth-child(4) { display: none; }
}
