/* hzpanel - 深色管理面板 */
:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #1c2129;
  --border: #30363d;
  --fg: #e6edf3;
  --fg-dim: #8b949e;
  --accent: #58a6ff;
  --accent2: #2f81f7;
  --green: #3fb950;
  --red: #f85149;
  --orange: #d29922;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
}
.hidden { display: none !important; }

/* ===== 登录页 ===== */
.login-wrap {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% -20%, #1f3a5f 0%, var(--bg) 55%);
}
.login-card {
  width: 340px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 36px 32px; text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
.login-logo { font-size: 28px; font-weight: 800; letter-spacing: 1px; }
.login-logo span { color: var(--accent); }
.login-sub { color: var(--fg-dim); margin: 6px 0 26px; font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 14px; margin-bottom: 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--fg); font-size: 14px; outline: none;
}
.login-card input:focus { border-color: var(--accent2); }
.login-card button {
  width: 100%; padding: 11px; background: var(--accent2); color: #fff;
  border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-card button:hover { background: #1f6feb; }
.login-card button:disabled { opacity: .6; cursor: not-allowed; }
.login-err { color: var(--red); margin-top: 12px; font-size: 13px; min-height: 18px; }

/* ===== 布局 ===== */
.layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 168px; background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: width .2s ease; overflow: hidden;
}
body.sidebar-hidden .sidebar { width: 0; border-right: none; }
.logo { font-size: 20px; font-weight: 800; padding: 18px 20px 14px; letter-spacing: 1px; }
.logo span { color: var(--accent); }
.nav { flex: 1; padding: 4px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 8px; cursor: pointer; color: var(--fg-dim);
  margin-bottom: 2px; user-select: none;
}
.nav-item:hover { background: var(--bg3); color: var(--fg); }
.nav-item.active { background: rgba(47,129,247,.15); color: var(--accent); font-weight: 600; }
.nav-ico { font-size: 16px; width: 20px; text-align: center; }
.side-foot { padding: 10px; border-top: 1px solid var(--border); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--bg2);
}
.top-stats { display: flex; gap: 8px; }
.top-badge {
  padding: 4px 10px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; font-size: 12px; color: var(--fg); white-space: nowrap;
}
.top-badge.hot { border-color: #f85149; color: #f85149; }
.page-title { font-size: 17px; font-weight: 700; }
.sysinfo { color: var(--fg-dim); font-size: 12px; text-align: right; line-height: 1.5; }
.view { display: none; flex: 1; min-height: 0; padding: 16px 20px; }
.view.active { display: flex; flex-direction: column; }

/* ===== 通用控件 ===== */
.btn {
  padding: 7px 14px; background: var(--bg3); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  font-size: 13px; white-space: nowrap;
}
.btn:hover { border-color: var(--fg-dim); }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.primary:hover { background: #1f6feb; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.block { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.spacer { flex: 1; }
.sel {
  padding: 7px 10px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none;
}
.ai-result { max-height: 60vh; overflow-y: auto; line-height: 1.7; font-size: 13px; }
.ai-result code { background: var(--bg3); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.codeblock { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; margin: 8px 0; overflow: hidden; }
.codeblock-head { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; background: var(--bg2); border-bottom: 1px solid var(--border); font-size: 12px; color: var(--fg-dim); }
.codeblock pre { margin: 0; padding: 10px; overflow-x: auto; font-size: 12px; line-height: 1.5; }
.host-tag {
  padding: 4px 10px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; font-size: 12px; color: var(--accent2); white-space: nowrap;
}
.path-input {
  padding: 7px 12px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none;
  flex: 1; min-width: 120px;
}
.path-input:focus { border-color: var(--accent2); }
.lbl { display: block; color: var(--fg-dim); font-size: 12px; margin: 12px 0 6px; }
.chk { display: flex; align-items: center; gap: 8px; color: var(--fg-dim); font-size: 12px; margin: 12px 0 4px; cursor: pointer; }
.chk input { accent-color: var(--accent2); width: 15px; height: 15px; }
.badge {
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--bg3); color: var(--fg-dim); border: 1px solid var(--border);
}
.badge.on { background: rgba(63,185,80,.15); color: var(--green); border-color: var(--green); }
.badge.off { background: rgba(248,81,73,.12); color: var(--red); border-color: var(--red); }

/* ===== 卡片 ===== */
.card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; margin-bottom: 14px;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

/* ===== 终端 ===== */
.term-toolbar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap;
}
.term-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; }
.term-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.term-tab {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; cursor: pointer; color: var(--fg-dim);
}
.term-tab .tab-dot { width: 8px; height: 8px; border-radius: 50%; background: #6e7681; flex-shrink: 0; }
.term-tab .tab-dot.on { background: #3fb950; box-shadow: 0 0 5px rgba(63, 185, 80, .7); }
.term-tab .tab-dot.off { background: #6e7681; }
.term-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.term-tab .tab-close { font-size: 11px; opacity: .7; padding: 0 2px; }
.term-tab .tab-close:hover { opacity: 1; }
.term-boxes { flex: 1; min-height: 0; position: relative; }
.term-box {
  display: none; position: absolute; inset: 0;
  background: #0d1117; border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; padding: 6px;
}
.term-box.active { display: block; }
.term-toolbar select {
  padding: 7px 10px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px; min-width: 220px;
}
.term-status { color: var(--fg-dim); font-size: 13px; }
.term-status.on { color: var(--green); }

/* ===== 文件 ===== */
.file-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.file-table-wrap { flex: 1; min-height: 0; overflow: auto; }
.file-table { width: 100%; border-collapse: collapse; }
.file-table th, .file-table td {
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border);
  font-size: 13px; white-space: nowrap;
}
.file-table th { color: var(--fg-dim); font-weight: 600; position: sticky; top: 0; background: var(--bg2); }
.file-table tr:hover td { background: var(--bg3); }
.file-table .name-cell { cursor: pointer; }
.file-table .name-cell:hover { color: var(--accent); }
.file-table .dir-ico { margin-right: 6px; }
.row-op { display: flex; gap: 6px; }
.row-op .btn { padding: 3px 9px; font-size: 12px; }

/* ===== 防火墙 ===== */
.fw-tip { color: var(--orange); font-size: 12px; margin-top: 8px; line-height: 1.6; }
.fw-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===== AI ===== */
.ai-layout { display: flex; gap: 16px; flex: 1; min-height: 0; }
.ai-chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ai-quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 12px; background: var(--bg3); border: 1px solid var(--border); border-bottom: none; border-radius: 12px 12px 0 0; }
.quick-label { color: var(--fg-dim); font-size: 12px; }
.codeblock { position: relative; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; margin: 8px 0; }
.codeblock-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 10px; background: var(--bg3); border-bottom: 1px solid var(--border); border-radius: 8px 8px 0 0; color: var(--fg-dim); font-size: 11px; }
.codeblock pre { padding: 10px 12px; margin: 0; overflow-x: auto; font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; }
.codeblock .btn { padding: 2px 10px; font-size: 11px; }
.chat-box {
  flex: 1; min-height: 0; overflow-y: auto; background: var(--bg2);
  border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.chat-empty { color: var(--fg-dim); text-align: center; margin-top: 60px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.msg.user { align-self: flex-end; background: #1f6feb; color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--bg3); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.err { align-self: flex-start; background: rgba(248,81,73,.12); color: var(--red); border: 1px solid var(--red); }
.chat-input-row { display: flex; gap: 8px; margin-top: 10px; }
.chat-input-row textarea {
  flex: 1; padding: 10px 12px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
  resize: none; outline: none; font-family: inherit; line-height: 1.5;
}
.ai-settings { width: 320px; flex-shrink: 0; overflow-y: auto; }
.host-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.host-list-item .del { color: var(--red); cursor: pointer; padding: 2px 6px; }
.host-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

/* 主机管理弹窗 */
.host-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.host-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px;
}
.host-item-name { font-weight: 600; font-size: 14px; }
.host-item-ops { display: flex; gap: 6px; align-items: center; }
.host-item .badge { font-size: 11px; padding: 2px 8px; }
.host-item-sub { color: var(--fg-dim); font-size: 12px; margin-top: 3px; }
.btn.sm { padding: 4px 12px; font-size: 12px; }
.host-add {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px;
}
.f-label { color: var(--fg-dim); font-size: 12px; margin: 10px 0 5px; }
.f-label:first-child { margin-top: 0; }
.f-input {
  width: 100%; padding: 9px 12px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  outline: none; box-sizing: border-box;
}
.f-input:focus { border-color: var(--accent2); }
.f-input::placeholder { color: var(--fg-dim); opacity: .7; }
.f-row { display: flex; gap: 10px; }
.f-row > div { flex: 1; }
.f-tip { color: var(--fg-dim); font-size: 11px; margin-top: 10px; line-height: 1.6; }

/* ===== 监控 ===== */
.mon-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 13px; color: var(--fg-dim); }
.mon-hint { font-size: 12px; color: var(--fg-dim); opacity: .8; }
.probe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.probe-loading { grid-column: 1 / -1; text-align: center; color: var(--fg-dim); padding: 40px 0; font-size: 13px; }
.probe-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.probe-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.probe-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px rgba(63, 185, 80, .8); flex-shrink: 0; }
.probe-name { font-weight: 700; font-size: 14px; }
.probe-name.remote { color: var(--accent2); }
.probe-up { font-size: 11px; color: var(--fg-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.probe-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.probe-label { width: 34px; font-size: 12px; color: var(--fg-dim); flex-shrink: 0; }
.probe-bar { flex: 1; height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.probe-fill { height: 100%; border-radius: 3px; background: var(--green); transition: width .5s ease; }
.probe-fill.warn { background: var(--yellow); }
.probe-fill.crit { background: var(--red); }
.probe-val { width: 42px; text-align: right; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.probe-spark { width: 100px; height: 28px; flex-shrink: 0; }
.mini-chart { width: 100%; height: 28px; }
.probe-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; }
.probe-net { color: var(--fg-dim); white-space: nowrap; }
.probe-net .dim { opacity: .7; }
.probe-load { color: var(--fg-dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.probe-err { color: #f85149; }
@media (max-width: 768px) {
  .probe-grid { grid-template-columns: 1fr; }
  .probe-spark { display: none; }
}
.mon-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 14px;
}
.mon-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; position: relative; overflow: hidden;
}
.mon-label { color: var(--fg-dim); font-size: 12px; margin-bottom: 6px; }
.mon-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.mon-value small { font-size: 13px; color: var(--fg-dim); font-weight: 400; }
.mon-chart { width: 100%; height: 50px; display: block; }
.mon-chart polyline { fill: none; stroke: var(--accent2); stroke-width: 1.5; }

/* ===== 系统管理 ===== */
.sys-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px;
}
.sys-item {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px;
}
.sys-k { color: var(--fg-dim); font-size: 11px; margin-bottom: 4px; }
.sys-v { font-size: 13px; font-weight: 600; word-break: break-all; }
.task-log {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px;
  max-height: 300px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
  color: var(--fg); line-height: 1.5;
}

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  width: min(720px, 92vw); max-height: 85vh; background: var(--bg2);
  border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column;
  box-shadow: 0 12px 48px rgba(0,0,0,.6);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-close { background: none; border: none; color: var(--fg-dim); font-size: 16px; cursor: pointer; }
.modal-close:hover { color: var(--fg); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-body textarea {
  width: 100%; min-height: 320px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font-family: "SFMono-Regular", Consolas, monospace; font-size: 12.5px; line-height: 1.6;
  resize: vertical; outline: none;
}
.modal-body .form-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.modal-body input[type=text], .modal-body input[type=password] {
  padding: 8px 12px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none;
}
.modal-body input:focus { border-color: var(--accent2); }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-dim); }

/* ===== 移动端 ===== */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .nav-txt, .logo span { display: none; }
  .logo { font-size: 16px; padding: 16px 0; text-align: center; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .nav-ico { width: auto; font-size: 20px; }
  .side-foot .nav-txt { display: none; }
  .ai-layout { flex-direction: column; }
  .ai-settings { width: 100%; }
  .sysinfo { display: none; }
  .view { padding: 12px; }
}
