:root {
  --bg: #0f1420;
  --panel: #172033;
  --panel-2: #1e2942;
  --border: #2a3552;
  --text: #e6ecf7;
  --muted: #8b9ab5;
  --primary: #3b82f6;
  --primary-hover: #2f6fe0;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 26px; }
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; }
.sub { margin: 0; font-size: 12px; color: var(--muted); }

.badge {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-warn { background: rgba(245, 158, 11, .15); color: var(--warn); border: 1px solid rgba(245, 158, 11, .35); }
.badge-ok { background: rgba(34, 197, 94, .15); color: var(--ok); border: 1px solid rgba(34, 197, 94, .35); }
.badge-err { background: rgba(239, 68, 68, .15); color: var(--danger); border: 1px solid rgba(239, 68, 68, .35); }

/* ---------- 标签页 ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- 布局 ---------- */
main { padding: 20px 24px 48px; max-width: 1240px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.card h2 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: #c7d4ea; }
.card h2:not(:first-child) { margin-top: 22px; }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }

input[type="text"], input[type="password"], input[type="file"], select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
input[type="file"] { padding: 6px 8px; }
input:focus, select:focus { outline: none; border-color: var(--primary); }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 160px; }

.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
.check input { width: auto; margin: 0; }

.form-grid { display: flex; flex-direction: column; }
.form-grid .row > label { margin-bottom: 12px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }

/* ---------- 按钮 ---------- */
.btn {
  padding: 9px 18px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: #26334f; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 500; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(239, 68, 68, .4); background: rgba(239, 68, 68, .08); }
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, .18); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ---------- 提示 / 元信息 ---------- */
.meta { color: var(--muted); font-size: 12px; margin: -6px 0 10px; min-height: 18px; }
.meta code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; color: #9dd0ff; }

.hint { margin: 0 0 14px; padding-left: 20px; color: var(--muted); font-size: 12.5px; }
.hint li { margin-bottom: 4px; }

.chipinfo {
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 14px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}
.chipinfo.connected { color: var(--ok); border-color: rgba(34, 197, 94, .3); }

/* ---------- 进度条 ---------- */
.progress-wrap { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.progress { flex: 1; height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #3b82f6, #22d3ee); transition: width .15s; }
.progress-text { font-size: 12px; color: var(--muted); min-width: 42px; text-align: right; font-family: ui-monospace, monospace; }

/* ---------- 日志终端 ---------- */
.terminal {
  background: #0a0e17;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 12px;
  margin: 0 0 10px;
  height: 260px;
  overflow-y: auto;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #a8c4a8;
  white-space: pre-wrap;
  word-break: break-all;
}
.terminal .err { color: #ff8a8a; }
.terminal .info { color: #8ab4ff; }
.terminal .ok { color: #6ee7a0; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tbody tr:hover { background: rgba(59, 130, 246, .06); }
td .tag { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--panel-2); font-size: 11.5px; }
td.empty, .empty-row td { color: var(--muted); text-align: center; padding: 24px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; color: var(--muted); }

/* ---------- 参数键值 ---------- */
.kv-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.param-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.param-row { display: flex; gap: 8px; align-items: center; }
.param-row input { margin: 0; }
.param-row .k { flex: 0 0 34%; }
.param-row .v { flex: 1; }
.param-row .del { flex: 0 0 auto; padding: 7px 11px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f2a44;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(239, 68, 68, .5); }
.toast.ok { border-color: rgba(34, 197, 94, .5); }

/* ---------- 顶栏右侧链接 / 登录页 ---------- */
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.tlink {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}
.tlink:hover { text-decoration: underline; }

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-wrap { width: 100%; max-width: 380px; }

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px;
}

.login-head { text-align: center; margin-bottom: 22px; }
.login-head .logo { font-size: 32px; }
.login-head h1 { margin: 6px 0 2px; font-size: 18px; font-weight: 600; }

.btn-block { width: 100%; margin-top: 6px; }

.login-foot { text-align: center; margin: 14px 0 0; }
