:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2330;
  --line: #222c3a;
  --text: #d6dee9;
  --muted: #7b8a9c;
  --dim: #556273;
  --accent: #2fbd84;
  --accent-dim: rgba(47, 189, 132, .12);
  --blue: #4a9eea;
  --warn: #d99b3c;
  --danger: #dd5f5f;
  --radius: 8px;

  /* 面板类色值（浅色主题会整组替换） */
  --thead: #12171f;
  --line-2: #1a212c;
  --hover: #1a212b;
  --tag-bg: #1d2531;
  --btn-hover: #232c3b;
  --btn-hover-border: #2e3a4d;
  --accent-hover: #35cf92;
  --input-bg: #0f141b;
  --on-accent: #06120c;
  --icon-bg: #1d2735;
  --code-bg: #1a212b;
  --mask: rgba(4, 8, 13, .72);
  --shadow: 0 20px 60px rgba(0, 0, 0, .5);
  --focus-ring: #2f4a63;
  --thumb: #2a3444;
  --thumb-hover: #3a4658;
  --chip-on-bg: #1d3348;
  --chip-on-fg: #8fc0ef;
  --chip-on-bd: #2c4a66;
}

/* 日间主题 */
html[data-theme="light"] {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel-2: #ffffff;
  --line: #dde3ec;
  --line-2: #e9eef5;
  --text: #1c2430;
  --muted: #5b6878;
  --dim: #8d99a8;
  --accent: #0f9d63;
  --accent-hover: #12b473;
  --accent-dim: rgba(15, 157, 99, .10);
  --blue: #1f6fe0;
  --warn: #b56a10;
  --danger: #d33f3f;
  --thead: #f7f9fc;
  --hover: #f4f7fb;
  --tag-bg: #eef2f7;
  --btn-hover: #eef2f7;
  --btn-hover-border: #cfd8e4;
  --input-bg: #ffffff;
  --on-accent: #ffffff;
  --icon-bg: #eef3fb;
  --code-bg: #eef2f7;
  --mask: rgba(20, 28, 40, .42);
  --shadow: 0 12px 36px rgba(20, 30, 50, .14);
  --focus-ring: #7fb0ea;
  --thumb: #c8d2e0;
  --thumb-hover: #b0bccd;
  --chip-on-bg: #e4efff;
  --chip-on-fg: #1a5fa8;
  --chip-on-bd: #bcd7f5;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono {
  font-family: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
  font-size: 12.5px;
}

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

.topbar {
  height: 52px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .3px;
}

.brand .mark {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, #2fbd84, #1f8f63);
  display: grid; place-items: center;
  font-size: 12px; color: #06120c; font-weight: 800;
}

.topbar .spacer { flex: 1; }

.topbar .who {
  color: var(--muted);
  font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.topbar .who b { color: var(--text); font-weight: 500; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px; }

/* ---------------- 通用 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
  font-family: inherit;
  white-space: nowrap;
}
.btn:hover { background: var(--btn-hover); border-color: var(--btn-hover-border); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: rgba(221,95,95,.35); }
.btn.danger:hover { background: rgba(221,95,95,.1); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

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

.panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.panel-hd .title { color: var(--text); font-weight: 500; font-size: 13.5px; }

/* ---------------- 统计 ---------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v {
  font-size: 24px; font-weight: 600; margin-top: 3px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.5px;
}
.stat .v.green { color: var(--accent); }

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

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 18px;
  background: var(--thead);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 11px 18px;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--hover); }
td.right, th.right { text-align: right; }

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

/* ---------------- 标签 ---------------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 20px;
  background: var(--tag-bg);
  color: var(--muted);
}
.tag.live { background: var(--accent-dim); color: var(--accent); }
.tag.fail { background: rgba(221,95,95,.12); color: var(--danger); }

.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.tag.live .dot { animation: pulse 1.8s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

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

.modal-mask {
  position: fixed; inset: 0;
  background: var(--mask);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-mask.show { display: flex; }

.modal {
  width: 440px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* 字段多的大弹窗 */
.modal.wide { width: 600px; }
.modal h3 {
  flex: 0 0 auto;
  margin: 0;
  padding: 16px 20px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.modal .body {
  flex: 1 1 auto;
  padding: 18px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.modal .foot {
  flex: 0 0 auto;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--thead);
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}
.field input, .field select {
  width: 100%;
  padding: 8px 11px;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.field input:focus, .field select:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px rgba(74,158,234,.1);
}

.row2 { display: grid; grid-template-columns: 1fr 100px; gap: 10px; }

/* 等宽两列：用于并排两个下拉/输入，压缩弹窗高度 */
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) {
  .cols2 { grid-template-columns: 1fr; }
}

.err-msg {
  color: var(--danger);
  font-size: 12.5px;
  min-height: 18px;
  margin-bottom: 6px;
}

/* ---------------- 滚动条 ---------------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--thumb);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--thumb-hover); }

/* 资产在线状态 */
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.st.on { color: var(--accent); }
.st .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); display: inline-block; }
.st.on .dot { background: var(--accent); box-shadow: 0 0 6px rgba(47,189,132,.45); }

/* 网段扫描 */
.bar { height: 6px; background: var(--thead); border-radius: 4px; overflow: hidden; }
#sc-bar { height: 100%; width: 0; background: #3fb950; transition: width .3s; }
#sc-result { max-height: 210px; overflow-y: auto; margin-top: 4px; }
.scan-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.scan-row:last-child { border-bottom: none; }
.scan-row .mono { flex: 1; }
