/* GOST 节点管理系统 · 原型样式
   Notion 风格：低饱和、细边框、克制的层次、以留白代替分隔线 */

:root {
  --bg: #ffffff;
  --side: #f7f7f5;
  --soft: #fafaf9;
  --hover: #efefec;
  --line: #e9e9e5;
  --line-strong: #dedeD8;
  --ink: #30312e;
  --ink-2: #55564f;
  --muted: #85877e;
  --faint: #a8aaa1;

  --green: #42765e;
  --green-bg: #edf4ef;
  --amber: #a97b38;
  --amber-bg: #faf3e5;
  --red: #b65c56;
  --red-bg: #f9edeb;
  --blue: #537793;
  --blue-bg: #edf2f6;
  --gray-bg: #f1f1ee;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 12px 44px rgba(36, 38, 32, 0.09);
  --shadow-sm: 0 1px 2px rgba(36, 38, 32, 0.06);
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- 登录 ---------- */

.login-view {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--soft);
}

.login-view[hidden] { display: none; }

.login-card {
  width: 372px;
  padding: 36px 34px 30px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.login-mark { width: 40px; height: 40px; margin-bottom: 20px; }
.login-mark img { display: block; width: 100%; height: 100%; }

.login-card h1 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.login-card p.sub {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 13px;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}

.input {
  width: 100%;
  padding: 8px 11px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.input:focus {
  border-color: #b9b9b1;
  box-shadow: 0 0 0 3px rgba(48, 49, 46, 0.06);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}

.btn:hover { background: var(--hover); }
.btn:active { background: var(--line); }

.btn-primary {
  color: #fff;
  background: #30312e;
  border-color: #30312e;
}

.btn-primary:hover { background: #43443f; border-color: #43443f; }

.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: #e3c9c6; }

.btn-block { width: 100%; }
.btn-sm { padding: 4px 9px; font-size: 12px; }

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn[hidden] { display: none; }

/* ---------- 布局 ---------- */

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.app[hidden] { display: none; }

.mobile-header, .nav-close, .nav-backdrop { display: none; }

.sidebar {
  width: 234px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--side);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.workspace {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 14px 12px;
  margin: 0;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-sm);
}

.workspace:hover { background: var(--hover); }

.workspace-mark { width: 22px; height: 22px; flex-shrink: 0; }
.workspace-mark img { display: block; width: 100%; height: 100%; }

.workspace-name {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.workspace-tag {
  font-size: 10px;
  color: var(--muted);
  background: var(--gray-bg);
  border-radius: 3px;
  padding: 1px 5px;
  font-weight: 500;
}

.nav { padding: 4px 8px 12px; }

.nav-label {
  padding: 10px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 8px;
  margin-bottom: 1px;
  font-size: 13.5px;
  color: var(--ink-2);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: background 0.1s;
}

.nav-item:hover { background: var(--hover); }

.nav-item.active {
  background: var(--hover);
  color: var(--ink);
  font-weight: 500;
}

.nav-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.62;
}

.nav-item.active .nav-icon { opacity: 0.86; }

.nav-count {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 10px;
  border-top: 1px solid var(--line);
}

.account-wrap { position: relative; }

.account-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.account-trigger:hover, .account-trigger[aria-expanded="true"] {
  background: var(--hover);
}

.account-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--gray-bg);
  font-size: 13px;
  font-weight: 600;
}

.account-name { display: flex; flex-direction: column; line-height: 1.35; }
.account-name strong { font-size: 12.5px; font-weight: 600; }
.account-name small { font-size: 11px; color: var(--muted); }
.account-caret { width: 15px; height: 15px; margin-left: auto; color: var(--muted); }

.account-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 5;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.account-menu[hidden] { display: none; }

.account-menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  text-align: left;
}

.account-menu-item:hover, .account-menu-item:focus-visible {
  background: var(--hover);
  color: var(--ink);
}

/* ---------- 主区 ---------- */

.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  background: var(--bg);
}

.view { display: none; }
.view.active { display: block; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 40px 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.topbar .crumb {
  font-size: 12.5px;
  color: var(--faint);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.body { padding: 26px 40px 72px; }

.view-desc {
  margin: 0 0 26px;
  max-width: 720px;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------- 卡片 / 面板 ---------- */

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.panel-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
}

.panel-head .hint {
  font-size: 12px;
  color: var(--faint);
}

.panel-head .spacer { flex: 1; }

.panel-body { padding: 18px; }

.password-form { display: flex; flex-direction: column; min-height: 0; }
.password-form .modal-body { flex: 1; }

/* 统计卡 */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.stat {
  padding: 15px 18px;
  background: var(--bg);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}

.stat-value {
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: proportional-nums;
  line-height: 1.15;
}

.stat-foot {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--faint);
}

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; }

.list-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.list-toolbar label { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.list-toolbar .list-search { width: min(100%, 340px); }

.list-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.list-pagination .page-count { margin-right: auto; }
.list-pagination .page-size-label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.list-pagination .page-size { width: auto; padding: 3px 6px; font-size: 12px; }

@media (max-width: 600px) {
  .list-toolbar { flex-wrap: wrap; }
  .list-toolbar .list-search { width: 100%; }
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th {
  padding: 9px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--soft); }

td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.mono, .mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

.heartbeat-time {
  width: 110px;
  min-width: 110px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cell-strong { font-weight: 500; }
.cell-sub {
  display: block;
  font-size: 11.5px;
  color: var(--faint);
  margin-top: 1px;
}
.proxy-source-uuid { overflow-wrap: anywhere; }

/* ---------- 徽标 ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 20px;
  white-space: nowrap;
}

.badge .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-ok { color: var(--green); background: var(--green-bg); }

/* 列表 IP 单元格里的双栈标识：只是标记"另有 IPv6"，比行内徽标更小。 */
.stack-badge {
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10.5px;
  vertical-align: 1px;
}

.muted { color: var(--muted); }
.text-strong { font-weight: 600; color: var(--ink); }

/* 确认框里逐条列出的后果。行距比默认松一点，因为每一行都是
   一句完整的话，挤在一起会读漏其中一条。 */
.confirm-line { margin: 0 0 7px; font-size: 13px; line-height: 1.6; }
.badge-warn { color: var(--amber); background: var(--amber-bg); }
.badge-off { color: var(--red); background: var(--red-bg); }
.badge-info { color: var(--blue); background: var(--blue-bg); }
.badge-gray { color: var(--muted); background: var(--gray-bg); }

/* ---------- 小工具 ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}

.chip {
  padding: 4px 11px;
  font-size: 12.5px;
  color: var(--ink-2);
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  transition: background 0.1s;
}

.chip:hover { background: var(--hover); }

.chip.active {
  color: #fff;
  background: #30312e;
  border-color: #30312e;
}

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
}

.kv {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 9px 16px;
  font-size: 13.5px;
}

.kv dt { color: var(--muted); font-size: 12.5px; padding-top: 1px; }
.kv dd { margin: 0; }

.section-note {
  margin: 0 0 16px;
  padding: 11px 14px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--soft);
  border-left: 2px solid var(--line-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.section-note b { font-weight: 600; }

.section-note.warn {
  background: var(--amber-bg);
  border-left-color: var(--amber);
}

.section-note.danger {
  background: var(--red-bg);
  border-left-color: var(--red);
}

.code {
  display: block;
  padding: 11px 13px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: #3d3e39;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre;
}

.code .cmt { color: var(--faint); }
.code .lit { color: var(--blue); }
.config-yaml-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.config-yaml-head .btn { flex-shrink: 0; }
.config-yaml { max-height: 360px; overflow: auto; margin: 8px 0 0; }

.copy-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.copy-row .code { flex: 1; min-width: 0; margin: 0; }

/* 全局节点密钥与各角色安装命令 */
.access-title { font-size: 13.5px; font-weight: 500; margin-bottom: 6px; }
.access-secret { white-space: pre-wrap; overflow-wrap: anywhere; }
.access-warning { margin: 15px 0 18px; }
.access-commands { display: grid; gap: 16px; }
.access-command .code, .install-command {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow-x: visible;
}
.install-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.install-options .chips { margin-bottom: 6px; }
.install-repeat-note { margin-top: 10px; }

/* 进度条 */

.bar {
  height: 4px;
  border-radius: 2px;
  background: var(--gray-bg);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--green);
}

.bar.warn > i { background: var(--amber); }
.bar.off > i { background: var(--red); }

/* ---------- 弹窗 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(36, 38, 32, 0.28);
}

.overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal.wide { max-width: 680px; }

.modal-head {
  display: flex;
  align-items: center;
  padding: 17px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
}

.modal-head .sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--faint);
  font-weight: 400;
}

.modal-close {
  margin-left: auto;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
}

.modal-close:hover { background: var(--hover); }

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--soft);
}

.step {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.step-n {
  width: 21px;
  height: 21px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--gray-bg);
  border-radius: 50%;
}

.step-t { font-size: 13.5px; font-weight: 500; margin-bottom: 4px; }
.step-d { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }

.proxy-test-progress { height: 5px; background: var(--gray-bg); border-radius: 5px; overflow: hidden; }
.proxy-test-progress i {
  display: block; width: 0; height: 100%; border-radius: inherit;
  background: var(--green); transition: width 0.25s ease;
}
.proxy-test-progress.is-error i { background: var(--red); }
.proxy-test-steps { list-style: none; margin: 16px 0 20px; padding: 0; }
.proxy-test-steps li { display: flex; align-items: flex-start; gap: 12px; padding: 9px 0; }
.proxy-test-steps li + li { border-top: 1px solid var(--line); }
.proxy-test-number {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%; font-size: 12px;
  color: var(--muted); background: var(--gray-bg);
}
.proxy-test-steps li > div { min-width: 0; flex: 1; }
.proxy-test-steps strong { display: block; font-size: 13px; font-weight: 500; }
.proxy-test-steps small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.proxy-test-state { flex: none; padding-top: 2px; font-size: 12px; color: var(--muted); }
.proxy-test-steps .is-running .proxy-test-number { background: var(--blue-bg); color: var(--blue); }
.proxy-test-steps .is-running .proxy-test-state { color: var(--blue); }
.proxy-test-steps .is-done .proxy-test-number { background: var(--green-bg); color: var(--green); }
.proxy-test-steps .is-done .proxy-test-state { color: var(--green); }
.proxy-test-steps .is-error .proxy-test-number { background: var(--red-bg); color: var(--red); }
.proxy-test-steps .is-error .proxy-test-state { color: var(--red); }
.proxy-test-output-label { display: block; margin-bottom: 7px; font-size: 12px; color: var(--ink-2); }
.proxy-test-output { display: block; height: 180px; resize: vertical; font-family: var(--mono); font-size: 12px; white-space: pre; }
.proxy-test-error { margin: 10px 0 0; color: var(--red); font-size: 12.5px; overflow-wrap: anywhere; }
.proxy-list-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }

/* 内嵌小表格 */
table.mini th, table.mini td { padding: 7px 10px; font-size: 12.5px; }

/* 节点详情中的独立端点 */
.secret-value { max-width: 190px; min-width: 0; overflow-wrap: anywhere; }

/* 提示气泡 */
.tip {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted var(--faint);
}

/* ---------- 登录附加 ---------- */

.login-hint {
  margin: 12px 0 0;
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--red);
  background: var(--red-bg);
  border-radius: var(--radius-sm);
}

.login-hint[hidden] { display: none; }

.login-foot {
  margin: 18px 0 0;
  font-size: 11.5px;
  color: var(--faint);
  text-align: center;
}

/* ---------- 提示条 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 60;
  transform: translateX(-50%);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toast[hidden] { display: none; }
.toast.err { color: var(--red); border-color: var(--red); background: var(--red-bg); }
.toast.ok { color: var(--green); border-color: var(--green); background: var(--green-bg); }

/* 表格里的次要说明行 */
.cell-note {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--faint);
}

/* 行内按钮组 */
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* 事件日志与其他页面对齐。 */
#view-events .panel { box-shadow: var(--shadow-sm); }
#view-events .event-toolbar { gap: 14px; padding: 16px 20px; }
#view-events .event-toolbar .list-search { width: min(100%, 420px); }
#view-events .event-order-hint { margin-left: auto; font-size: 12px; color: var(--faint); white-space: nowrap; }
#view-events table { table-layout: fixed; min-width: 780px; }
#view-events th, #view-events td { padding-left: 16px; padding-right: 16px; }
#view-events td { padding-top: 14px; padding-bottom: 14px; }
#view-events th:nth-child(1), #view-events td:nth-child(1) { width: 178px; }
#view-events th:nth-child(2), #view-events td:nth-child(2) { width: 90px; }
#view-events th:nth-child(3), #view-events td:nth-child(3) { width: 220px; }
#view-events td:first-child { white-space: nowrap; font-size: 12px; }
#view-events .event-target-title { display: block; font-weight: 500; overflow-wrap: anywhere; }
#view-events .event-target-meta { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
#view-events td:last-child { overflow-wrap: anywhere; line-height: 1.6; }
#view-events .list-pagination { padding: 12px 18px; }
#view-events .event-page-indicator { color: var(--ink-2); white-space: nowrap; }

@media (max-width: 600px) {
  #view-events .event-order-hint { display: none; }
}

/* 代理列表：出口/入口数量多时限高滚动，表头随滚动保持可见。 */
.proxy-list .table-wrap { max-height: 340px; overflow-y: auto; }
.proxy-list thead th { position: sticky; top: 0; z-index: 1; }

/* 流量与连接统计：服务多时限高滚动，表头保持可见。 */
.stat-list .table-wrap { max-height: 340px; overflow-y: auto; }
.stat-list thead th { position: sticky; top: 0; z-index: 1; }

/* 节点表：总览与节点页同一套列；节点与地域分剩余宽度，状态与操作留足位置，不再横向溢出。 */
.node-table { table-layout: fixed; }
.node-table .col-status { width: 170px; }
.node-table .col-map { width: 96px; }
.node-table .col-traffic { width: 112px; }
.node-table .heartbeat-time { width: 104px; min-width: 0; }
.node-table .col-actions { width: 150px; }
.node-table td { overflow: hidden; }
.node-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.node-cell .cell-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.region-cell { color: var(--ink-2); font-size: 12.5px; }
.status-cell .cell-note { max-width: 100%; }
.traffic-cell { font-size: 11.5px; line-height: 1.5; }
.map-cell { font-variant-numeric: tabular-nums; }

/* 平板与手机：导航保留同一套菜单，窄屏通过抽屉打开。 */
@media (max-width: 900px) {
  .app { height: 100dvh; flex-direction: column; }
  .main { min-height: 0; }
  .mobile-header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 10px;
    padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
    border-bottom: 1px solid var(--line);
    background: var(--side);
  }
  .mobile-nav-toggle, .nav-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--ink);
  }
  .mobile-nav-toggle svg { width: 20px; height: 20px; }
  .mobile-brand { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
  .mobile-brand small { font-size: 11px; color: var(--muted); }
  .mobile-brand strong { font-size: 15px; font-weight: 600; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 25;
    width: min(300px, calc(100vw - 48px));
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
  }
  .app.nav-open .sidebar { visibility: visible; transform: translateX(0); box-shadow: var(--shadow); }
  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 24;
    border: 0;
    background: rgba(36, 38, 32, 0.35);
  }
  .nav-backdrop[hidden] { display: none; }
  .app.nav-open .main { overflow: hidden; }
  .nav-close { margin: 10px 14px 0 auto; font-size: 23px; }
  .sidebar .nav-item, .account-trigger, .account-menu-item { min-height: 44px; }
  .sidebar .nav-item { padding: 10px 12px; margin-bottom: 3px; }
  .nav-icon { width: 18px; height: 18px; }
  .sidebar-foot { padding-bottom: 14px; }
  .topbar, .body { padding-left: 24px; padding-right: 24px; }
  .topbar { gap: 12px; padding-top: 14px; padding-bottom: 14px; }
  .topbar h2 { font-size: 20px; }
  .topbar-actions { flex-shrink: 0; }
  .btn, .chip { min-height: 44px; }
  .input { min-height: 44px; font-size: 16px; }
  .list-pagination .page-size { min-height: 44px; font-size: 16px; }
  .modal-close { width: 44px; height: 44px; flex-shrink: 0; font-size: 22px; }
  .modal-head > div { min-width: 0; }
  .modal-head .sub { overflow-wrap: anywhere; }
  .kv { grid-template-columns: 112px minmax(0, 1fr); }
  .kv dd { min-width: 0; overflow-wrap: anywhere; }
  .panel-head { flex-wrap: wrap; }
  .panel-head h3 { flex-shrink: 0; }
  .panel-head .hint { min-width: 0; }
  .step > div:last-child { min-width: 0; flex: 1; }
  .toast { max-width: calc(100vw - 32px); width: max-content; bottom: calc(20px + env(safe-area-inset-bottom)); }
}

/* 业务表格在手机上使用带字段名的卡片；数据与操作不另造一份。 */
@media (max-width: 900px) {
  .mobile-header { padding-left: 12px; padding-right: 12px; }
  .topbar { padding: 14px 16px; flex-wrap: wrap; }
  .topbar .crumb { display: none; }
  .topbar h2 { font-size: 19px; }
  .topbar-actions { gap: 6px; flex-wrap: wrap; }
  .body { padding: 18px 16px calc(32px + env(safe-area-inset-bottom)); }
  .view-desc { margin-bottom: 18px; font-size: 13px; }
  .panel { margin-bottom: 16px; }
  .panel-head { gap: 8px; padding: 12px 14px; }
  .panel-head .hint { flex: 1 1 100%; order: 1; }
  .panel-head .spacer { display: none; }
  .panel-head .badge { margin-left: auto; }
  .panel-head .btn { margin-left: auto; }
  .panel-head .badge + .btn { margin-left: 0; }
  .panel-body { padding: 14px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
  .stat { min-width: 0; padding: 14px; }
  .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat-value { font-size: 24px; }
  .stat-foot { overflow-wrap: anywhere; }
  .body > .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; gap: 8px; margin-bottom: 14px; }
  .body > .chips .chip { flex-shrink: 0; }
  .list-toolbar, #view-events .event-toolbar { align-items: stretch; gap: 8px; padding: 12px 14px; flex-direction: column; }
  .list-toolbar .list-search, #view-events .event-toolbar .list-search { width: 100%; }
  .list-pagination, #view-events .list-pagination { justify-content: space-between; gap: 8px; padding: 12px 14px; }
  .list-pagination .page-count { flex: 1 1 100%; }
  .list-pagination .page-size-label { margin-right: auto; }
  .list-pagination .btn { padding-left: 12px; padding-right: 12px; }
  .kv { grid-template-columns: 88px minmax(0, 1fr); gap: 10px 12px; margin-top: 0; }
  .copy-row { flex-direction: column; align-items: stretch; }
  .copy-row .btn { align-self: stretch; }
  .copy-row .code { flex: auto; }
  .install-options { grid-template-columns: 1fr; }
  .code { max-width: 100%; }
  .secret-value { max-width: none; }
  .proxy-list .table-wrap, .stat-list .table-wrap { max-height: none; overflow: visible; }
  #app table.mobile-table, .overlay table.mobile-table { position: relative; display: block; min-width: 0; width: 100%; table-layout: auto; }
  .mobile-table thead {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .mobile-table tbody { display: block; }
  .mobile-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
  }
  .mobile-table tbody tr:last-child { border-bottom: 0; }
  #app .mobile-table td, .overlay .mobile-table td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .mobile-table td::before { content: attr(data-label); font: 11.5px var(--font); color: var(--muted); }
  .mobile-table td.mobile-wide, .mobile-table td.mobile-actions, .mobile-table td.mobile-empty { grid-column: 1 / -1; }
  #app .mobile-table td.mobile-actions, .overlay .mobile-table td.mobile-actions { padding-top: 12px; border-top: 1px solid var(--line); }
  .mobile-table td.mobile-actions::before, .mobile-table td.mobile-empty::before { display: none; }
  .mobile-table .row-actions, .mobile-table .proxy-list-actions { width: 100%; }
  .mobile-table .row-actions .btn, .mobile-table .proxy-list-actions .btn { flex: 1; }
  #app .mobile-table td.mobile-empty, .overlay .mobile-table td.mobile-empty { display: block; text-align: center; padding: 20px 0; }
  #view-events .event-order-hint { display: none; }
  .overlay { padding: 12px; }
  .overlay:has(.modal.wide) { padding: 0; }
  .modal { max-height: calc(100dvh - 24px); }
  .modal.wide { max-width: none; max-height: 100%; height: 100%; border-radius: 0; }
  .modal-head { flex-shrink: 0; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
  .modal-body { min-height: 0; padding: 16px 14px; }
  .modal.wide .modal-body { flex: 1; }
  .modal-foot { flex-shrink: 0; flex-wrap: wrap; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  .modal-foot > span { display: none; }
  .login-view { padding: 20px 16px; overflow-y: auto; }
  .login-card { width: min(100%, 372px); padding: 28px 24px; margin: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* v2 映射与告警沿用节点表的视觉样式，不用颜色替代状态文字。 */
.mapping-toolbar { flex-wrap: wrap; }
.mapping-filter { width: auto; min-width: 110px; }
.mapping-issue-filter { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.alert-list, .issue-list .table-wrap { max-height: 360px; overflow: auto; }
.alert-list th, .issue-list th { position: sticky; top: 0; z-index: 1; }
.alert-detail { min-width: 200px; max-width: 460px; white-space: normal; overflow-wrap: anywhere; }
.panel-read-error { margin: 0 20px 12px; }
#mappingRows td { overflow-wrap: anywhere; }
#view-settings .kv dd { overflow-wrap: anywhere; }
.config-yaml-head { flex-wrap: wrap; gap: 8px; }
@media (max-width: 900px) {
  .alert-list, .issue-list .table-wrap { max-height: none; overflow: visible; }
  .alert-detail { min-width: 0; max-width: none; }
  .mapping-toolbar .mapping-filter { flex: 1; }
}

/* ---------- 展示优化（.scratch/ui-polish） ---------- */

.title-row { display: flex; align-items: center; gap: 8px; }
.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  cursor: help;
}
.help-tip:hover, .help-tip:focus-visible { color: var(--ink); border-color: var(--muted); }

.ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warn-text { color: var(--amber); }
.link-btn {
  padding: 0;
  font: inherit;
  color: var(--ink);
  background: none;
  border: 0;
  border-bottom: 1px dotted transparent;
  text-align: left;
}
.link-btn:hover { border-bottom-color: currentColor; }
.link-btn.mono { font-family: var(--mono); font-size: 12.5px; }
.btn-ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--hover); }

.stat-attention .stat-value { color: var(--amber); }
.stat-attention .stat-foot { color: var(--amber); }

.alert-panel.is-collapsed .panel-head { border-bottom: 0; }

/* 映射同步：一行状态，失败时追加错误行。 */
.sync-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 12px 18px; background: var(--soft); }
.sync-title { font-size: 13.5px; font-weight: 600; }
.sync-items { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; flex: 1; font-size: 12.5px; color: var(--ink-2); }
.sync-item { display: inline-flex; gap: 6px; white-space: nowrap; }
.sync-label { color: var(--muted); }
.sync-error { flex: 1 1 100%; color: var(--amber); overflow-wrap: anywhere; }
.sync-error b { font-weight: 600; }

.mapping-table { table-layout: fixed; }
.mapping-table .col-port { width: 90px; }
.mapping-table .col-actions { width: 240px; }
.mapping-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.mapping-actions .action-target { margin: 0; }
.exit-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.candidate-list { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.candidate-list .cell-note { margin: 0; }
tr.endpoint-row td { padding-top: 0; background: var(--soft); }
tbody tr.endpoint-row:hover { background: var(--soft); }
.endpoint-list { display: grid; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.endpoint-item { display: flex; align-items: center; gap: 10px; min-width: 0; }
.endpoint-item .spacer { flex: 1; }
.endpoint-kind { width: 64px; flex-shrink: 0; font-size: 12px; color: var(--muted); }
.endpoint-address { overflow-wrap: anywhere; }

/* 设置页 */
.secret-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.secret-text { overflow-wrap: anywhere; margin-right: 4px; }
.field-help { margin: 12px 0 0; font-size: 12px; color: var(--faint); line-height: 1.6; }
.action-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.inline-status { font-size: 12.5px; color: var(--ink-2); }
.install-picker { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.install-picker .chips { margin-bottom: 10px; }

/* 节点详情 */
.modal.node-modal { max-width: 820px; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; margin: 0 0 20px; }
.info-item { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; align-items: baseline; min-width: 0; }
.info-item dt { font-size: 12.5px; color: var(--muted); }
.info-item dd { margin: 0; min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.info-item .cell-note { display: inline; margin-left: 6px; }
.copyable-id { display: inline-flex; align-items: center; gap: 4px; }
.tabs { display: flex; gap: 2px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 7px 12px;
  margin-bottom: -1px;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.tab.tab-warn { color: var(--amber); }
.tab-pane > .panel:last-child { margin-bottom: 0; }
.tab-pane > .empty { padding: 32px 0; }
table.mini .secret-value { white-space: nowrap; }

@media (max-width: 900px) {
  .info-grid { grid-template-columns: minmax(0, 1fr); }
  .mapping-table .col-actions, .mapping-table .col-port { width: auto; }
  .tabs { overflow-x: auto; }
  .tab { flex-shrink: 0; min-height: 44px; }
  .mobile-table td.mobile-detail { grid-column: 1 / -1; }
  .mobile-table td.mobile-detail::before { display: none; }
  #app .mobile-table td.mobile-detail { padding: 0; }
  .endpoint-item { flex-wrap: wrap; }
  .endpoint-item .spacer { display: none; }
  .sync-bar { padding: 12px 14px; }
  .sync-items { flex: 1 1 100%; gap: 6px 16px; }
}

/* ---------- 接口调试 ---------- */

/* 左侧接口目录，右侧说明 / 调试 / 最近调用；窄屏目录换成下拉框。 */
.api-layout { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 28px; align-items: start; }
.api-nav { position: sticky; top: 96px; display: flex; flex-direction: column; gap: 1px; }
.api-nav-group { margin: 14px 0 3px; padding: 0 8px; font-size: 11.5px; color: var(--faint); letter-spacing: 0.02em; }
.api-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 8px;
  font-size: 13.5px;
  color: var(--ink-2);
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}
.api-nav-item:hover { background: var(--hover); }
.api-nav-item.active { background: var(--hover); color: var(--ink); font-weight: 500; }
.api-dir { margin-left: auto; font-size: 11px; font-weight: 400; color: var(--faint); }
.api-nav-select { display: none; }
.api-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 10px; }
.api-head h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.api-path { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.api-direction { font-size: 12px; color: var(--muted); }
.api-doc-file { font-weight: 500; font-size: 13px; }
.api-try-body { display: grid; gap: 14px; }
.api-try-body .debug-result { margin-top: 0; }
.api-confirm-table { margin: 4px 0 12px; }
.api-confirm-table .debug-table-wrap { max-height: 260px; }
.api-try-hint { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.api-editor { min-height: 150px; resize: vertical; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.api-urls { display: grid; gap: 4px; }
.api-url { display: flex; align-items: center; gap: 6px; }
.api-url .mono { font-size: 12.5px; overflow-wrap: anywhere; }
.crypto-form { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 10px 12px; align-items: start; }
.crypto-form label { padding-top: 9px; font-size: 12.5px; color: var(--muted); }
.crypto-form .input { font-size: 12.5px; }
.crypto-input { resize: vertical; }

/* 对接说明（docs/ 下的 Markdown） */
.md { padding: 4px 24px 24px; font-size: 13.5px; line-height: 1.75; color: var(--ink); overflow-wrap: anywhere; }
.md h1 { margin: 14px 0 10px; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.md h2 { margin: 26px 0 10px; padding-top: 16px; font-size: 16px; font-weight: 600; border-top: 1px solid var(--line); scroll-margin-top: 90px; }
.md h3 { margin: 18px 0 8px; font-size: 14px; font-weight: 600; }
.md h4 { margin: 14px 0 6px; font-size: 13.5px; font-weight: 600; }
.md p { margin: 0 0 10px; }
.md a { color: var(--blue); }
.md-list { margin: 0 0 10px; padding-left: 22px; }
.md-list .md-list { margin: 3px 0 0; }
.md-list li + li { margin-top: 3px; }
.md-code { margin: 0 0 12px; }
.md-inline { padding: 1px 5px; font-family: var(--mono); font-size: 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 4px; }
.md-table-wrap { margin: 0 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.md-table th, .md-table td { padding: 7px 12px; font-size: 12.5px; vertical-align: top; overflow-wrap: normal; }
.md-table td:first-child { white-space: nowrap; }
@media (min-width: 901px) {
  /* 说明在自己的滚动区里，接口标题与标签始终可见。 */
  .md { position: relative; max-height: calc(100vh - 280px); min-height: 320px; overflow: auto; }
}
@media (max-width: 900px) {
  .api-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .api-nav { display: none; }
  .api-nav-select { display: block; }
  .md { padding: 4px 16px 18px; }
  .md-table td:first-child { white-space: normal; }
  .crypto-form { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .crypto-form label { padding-top: 0; }
}

.debug-form { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.debug-form label { font-size: 12.5px; color: var(--muted); }
.debug-ips { display: grid; gap: 2px; }
.debug-result { display: grid; gap: 14px; margin-top: 16px; }
.debug-result:empty { display: none; }
.debug-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; font-size: 13px; }
.debug-error { color: var(--red); font-size: 12.5px; overflow-wrap: anywhere; }
.debug-message { min-width: 0; }
.debug-message-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; color: var(--ink-2); }
.debug-message-head .spacer { flex: 1; }
.debug-code { margin: 0; max-height: 280px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-all; }
.debug-table-wrap { max-height: 380px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.debug-detail { display: grid; gap: 14px; }
.debug-kv { margin-bottom: 4px; }
.exchange-peer { max-width: 280px; overflow-wrap: anywhere; }
.exchange-table .col-actions { width: 80px; }
.exchange-table .nowrap { white-space: nowrap; }

/* 云服务商、云实例与节点来源 */
.node-table .col-origin { width: 76px; }
.cloud-table td { overflow-wrap: anywhere; }
.cloud-table .row-actions { flex-wrap: wrap; }
.cloud-form { display: flex; flex-direction: column; min-height: 0; }
.cloud-form .modal-body { flex: 1; }
.cloud-fields { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.cloud-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.cloud-credentials-help { margin: -6px 0 14px; }
.cloud-secret { display: flex; gap: 6px; align-items: center; }
.cloud-secret .input { flex: 1; min-width: 0; }
/* 用文本框加遮罩而不是 password，避免浏览器把云凭据当登录密码自动填充或提示保存。 */
.input.is-masked { -webkit-text-security: disc; }
.cloud-message { margin: 0 0 10px; font-size: 12.5px; line-height: 1.6; color: var(--muted); }
.cloud-message, .cloud-impact, .section-note.is-error { overflow-wrap: anywhere; }
.cloud-message.is-error, .cloud-instance-error { color: var(--red); }
.cloud-instance-error { margin-top: 3px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.section-note.is-error { background: var(--red-bg); border-left-color: var(--red); }
#nodeCloudDetails { margin-bottom: 16px; }
#nodeCloudDetails .info-grid { margin-bottom: 0; }
#cloudInstancePagination[hidden] { display: none; }
@media (min-width: 901px) {
  .node-table:has(.col-origin) { min-width: 850px; }
}

/* 映射 job */
.job-add-form + .job-add-form { margin-top: 12px; }
.job-add-form .input { width: auto; }
.job-add-form #jobUploadVersion, .job-add-form #jobURLVersion { width: 140px; }
.job-url-input { min-width: min(360px, 100%); flex: 1; }
.job-sha-input { width: min(300px, 100%); font-family: var(--mono); font-size: 12px; }
.job-reason { max-width: 420px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.job-version-table .nowrap, .job-exit-table .nowrap, .job-task-table .nowrap { white-space: nowrap; }
.job-node-actions { margin-bottom: 18px; }
.job-version-select { width: auto; min-width: 160px; }
.job-log { margin: 10px 0 0; max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11.5px; }
.job-pane .panel { margin-bottom: 16px; }
