:root {
  --bg: #0b1220;
  --bg2: #0e1729;
  --card: #131c2e;
  --card-hover: #17233c;
  --border: #1e2a44;
  --border-light: #2c3f66;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-faint: #64748b;
  --blue: #38bdf8;
  --cyan: #22d3ee;
  --green: #34d399;
  --yellow: #fbbf24;
  --orange: #fb923c;
  --red: #f87171;
  --violet: #a78bfa;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #12203a 0%, var(--bg) 45%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #26354f; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #33486b; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 11px 24px;
  background: rgba(10, 16, 29, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(56, 189, 248, 0.06), 0 8px 24px rgba(0, 0, 0, 0.25);
}
.topbar .brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 16.5px; font-weight: 700; letter-spacing: 0.4px;
  color: #f8fafc;
}
.brand-icon {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, #0ea5e9, #06b6d4);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px; font-weight: 800;
  line-height: 1; text-align: center;
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.45);
}
.topbar .hostname { color: var(--text-dim); font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .user-box {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-dim); font-size: 13px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #22d3ee);
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.25);
}
.clock { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer;
  font-size: 13px; line-height: 1.4; white-space: nowrap;
  transition: all 0.15s ease;
}
.btn:hover { background: var(--card-hover); border-color: var(--border-light); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, #0ea5e9, #06b6d4);
  border: none; color: #fff; font-weight: 600;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.3);
}
.btn.primary:hover { filter: brightness(1.12); box-shadow: 0 4px 16px rgba(14, 165, 233, 0.4); }
.btn.danger { color: var(--red); border-color: rgba(248, 113, 113, 0.35); }
.btn.danger:hover { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.5); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }

/* ---------- 布局 ---------- */
main { padding: 22px 24px 48px; max-width: 1440px; margin: 0 auto; }

/* 区块标题（页面级） */
.section-title {
  display: flex; align-items: center; gap: 10px;
  margin: 28px 0 14px; font-size: 16px; font-weight: 700; color: #f1f5f9;
}
.section-title .dot {
  width: 9px; height: 9px; border-radius: 3px;
  background: linear-gradient(135deg, #0ea5e9, #22d3ee);
  box-shadow: 0 0 8px rgba(14, 165, 233, 0.55);
}
.section-title .hint { margin-left: auto; font-size: 12px; color: var(--text-faint); font-weight: 400; }

.grid { display: grid; gap: 14px; }
.grid.overview { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid.charts { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }

/* ---------- 卡片 ---------- */
.card {
  background: linear-gradient(180deg, #141e32 0%, #111a2b 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover { border-color: var(--border-light); box-shadow: 0 6px 26px rgba(0, 0, 0, 0.42); }
.card .card-body { padding: 14px 16px; }

/* ---------- 概览卡片 ---------- */
.ov-card { padding: 16px; position: relative; }
.ov-card::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(160px 90px at 90% -10%, rgba(56, 189, 248, 0.08), transparent 70%);
  pointer-events: none;
}
.ov-card .label { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.ov-card .value { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.ov-card .sub { font-size: 12px; color: var(--text-faint); margin-top: 6px; }
.ov-card .gauge-wrap { display: flex; align-items: center; gap: 14px; }
.ov-card .gauge-info { flex: 1; }
.bar { height: 6px; border-radius: 3px; background: #1e2a44; margin-top: 10px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.bar.green > div { background: linear-gradient(90deg, #34d399, #10b981); }
.bar.blue > div { background: linear-gradient(90deg, #38bdf8, #0284c7); }
.bar.yellow > div { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.bar.red > div { background: linear-gradient(90deg, #f87171, #dc2626); }
.mini-tag { font-size: 11px; padding: 2px 7px; border-radius: 5px; background: #1a2740; color: var(--text-dim); }

/* ---------- 图表 ---------- */
.chart { width: 100%; height: 280px; }

/* ---------- 统计卡（域名/代理页） ---------- */
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-card {
  background: linear-gradient(180deg, #141e32 0%, #111a2b 100%);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 18px; min-width: 118px;
  position: relative; overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); }
.stat-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, #0ea5e9, #22d3ee); opacity: 0.75;
}
.stat-card .n { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat-card .t { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; white-space: nowrap; }
th {
  color: var(--text-faint); font-weight: 600; font-size: 12px;
  background: #101a2e; position: sticky; top: 0; z-index: 2;
  border-bottom: 1px solid var(--border-light);
  letter-spacing: 0.02em;
}
th:first-child { padding-left: 16px; }
td:first-child { padding-left: 16px; }
td { border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.012); }
tbody tr:hover td { background: rgba(14, 165, 233, 0.06); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: var(--font-mono); font-size: 12px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.pill.ok { background: rgba(52, 211, 153, 0.14); color: var(--green); }
.pill.warn { background: rgba(251, 191, 36, 0.14); color: var(--yellow); }
.pill.bad { background: rgba(248, 113, 113, 0.14); color: var(--red); }
.pill.info { background: rgba(56, 189, 248, 0.14); color: var(--blue); }
.use-badge { display: inline-block; min-width: 52px; padding: 3px 8px; border-radius: 6px; text-align: center; font-weight: 700; font-size: 12px; }
.use-low { background: rgba(52, 211, 153, 0.14); color: var(--green); }
.use-mid { background: rgba(251, 191, 36, 0.14); color: var(--yellow); }
.use-high { background: rgba(248, 113, 113, 0.16); color: var(--red); }

/* ---------- 系统信息 ---------- */
.sys-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0; }
.sys-item { padding: 11px 16px; border-bottom: 1px solid var(--border); }
.sys-item:nth-last-child(-n+4) { border-bottom: none; }
.sys-item .k { font-size: 11px; color: var(--text-faint); margin-bottom: 4px; }
.sys-item .v { font-size: 13px; color: var(--text); word-break: break-all; }

/* ---------- 状态条 ---------- */
.status-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; font-size: 12px; color: var(--text-dim);
  border-bottom: 1px solid var(--border); background: #101a2e;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, 0.8); animation: pulse-dot 2s infinite; }
.status-dot.err { background: var(--red); box-shadow: 0 0 8px rgba(248, 113, 113, 0.8); animation: none; }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; } 50% { opacity: 0.55; }
}

/* ---------- 空态 ---------- */
.empty-tip { text-align: center; color: var(--text-faint); padding: 44px 0; font-size: 13px; }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 8, 16, 0.72); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
}
.modal-mask.show { display: flex; animation: fade-in 0.18s ease; }
.modal-mask.show .modal { animation: slide-up 0.22s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal {
  width: 460px; max-width: 92vw; max-height: 86vh; overflow-y: auto;
  background: linear-gradient(180deg, #141e32 0%, #10192a 100%);
  border: 1px solid var(--border-light);
  border-radius: 14px; box-shadow: var(--shadow-lg);
}
.modal .modal-head {
  display: flex; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 700;
}
.modal .modal-head .close { margin-left: auto; cursor: pointer; color: var(--text-faint); font-size: 22px; line-height: 1; padding: 2px 6px; border-radius: 6px; transition: 0.15s; }
.modal .modal-head .close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.modal .modal-body { padding: 18px 20px; }
.modal .modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.field input[type="text"], .field input[type="password"], .field select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #0f1930; color: var(--text);
  font-size: 13px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15); }
.field .hint { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.hint-inline { font-size: 11px; color: var(--text-faint); font-weight: 400; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }

.msg { padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; display: none; }
.msg.err { display: block; background: rgba(248, 113, 113, 0.12); color: var(--red); border: 1px solid rgba(248,113,113,0.3); }
.msg.ok { display: block; background: rgba(52, 211, 153, 0.12); color: var(--green); border: 1px solid rgba(52,211,153,0.3); }

/* ---------- 用户列表 ---------- */
.user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px; border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-row .uname { font-weight: 600; }
.user-row .umeta { color: var(--text-faint); font-size: 12px; }
.user-row .ops { margin-left: auto; display: flex; gap: 8px; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1000px 500px at 30% -10%, #12203a 0%, var(--bg) 50%);
  padding: 20px;
}
.login-card {
  width: 380px; max-width: 94vw;
  background: linear-gradient(180deg, #141e32 0%, #10192a 100%);
  border: 1px solid var(--border-light);
  border-radius: 16px; padding: 36px 32px;
  box-shadow: var(--shadow-lg);
  animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-card h1 { font-size: 19px; font-weight: 800; }
.login-card .desc { color: var(--text-dim); font-size: 13px; margin-bottom: 26px; }
.login-card .btn.primary { width: 100%; justify-content: center; padding: 11px; font-size: 14px; margin-top: 4px; }

/* ---------- 域名/代理页组件 ---------- */
.top-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.top-actions .spacer { flex: 1; }
.type-pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.type-proxy { background: rgba(56,189,248,.15); color: var(--blue); }
.type-static { background: rgba(52,211,153,.15); color: var(--green); }
.type-redirect { background: rgba(251,191,36,.15); color: var(--yellow); }
.hint-box {
  margin-top: 18px; padding: 14px 16px; border-radius: 10px; font-size: 12px; line-height: 1.9;
  background: rgba(56,189,248,.05); border: 1px solid rgba(56,189,248,.16); color: var(--text-dim);
}
.hint-box b { color: var(--blue); }
.switch { position: relative; width: 38px; height: 20px; cursor: pointer; display: inline-block; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; border-radius: 20px; background: #1e2a44; transition: .2s; }
.switch .knob { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #94a3b8; top: 3px; left: 3px; transition: .2s; }
.switch input:checked + .track { background: rgba(52,211,153,.4); }
.switch input:checked + .track + .knob { left: 21px; background: var(--green); }
.domain-link { color: var(--blue); text-decoration: none; }
.domain-link:hover { text-decoration: underline; }
.link-btn { background:none; border:none; color:var(--blue); cursor:pointer; font-size:12px; padding:2px 0; }
.link-btn:hover { text-decoration:underline; }

/* 代理页 */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn {
  padding: 10px 20px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 700;
  border: 1px solid var(--border); background: var(--card); color: var(--text-dim);
  display: flex; align-items: center; gap: 8px; transition: all .15s ease;
}
.tab-btn:hover { border-color: var(--blue); color: var(--blue); transform: translateY(-1px); }
.tab-btn.active {
  background: rgba(56,189,248,.12); border-color: var(--blue); color: var(--blue);
  box-shadow: 0 0 0 3px rgba(56,189,248,.1), 0 4px 14px rgba(56,189,248,.15);
}
.tab-btn .cnt { background: rgba(148,163,184,.15); border-radius: 20px; padding: 0 8px; font-size: 12px; }
.tab-btn.active .cnt { background: var(--blue); color: #fff; }
.proto-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-socks5 { background: #38bdf8; }
.dot-mtproto { background: #34d399; }
.dot-vmess { background: #fbbf24; }
.traffic-up { color: var(--green); }
.traffic-down { color: var(--blue); }
.link-text {
  max-width: 460px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-dim);
}
.copy-box { display: flex; gap: 8px; align-items: center; }
.copy-box .link-text { flex: 1; max-width: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .grid.charts { grid-template-columns: 1fr; }
  main { padding: 14px; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar .hostname { display: none; }
  .topbar .btn { padding: 6px 10px; font-size: 12px; }
  .section-title { font-size: 15px; }
  .section-title .hint { display: none; }
  .stat-card { min-width: 96px; padding: 10px 14px; }
  .stat-card .n { font-size: 18px; }
}
@media (max-width: 480px) {
  .topbar .user-box { display: none; }
  th, td { padding: 8px 8px; }
  th:first-child, td:first-child { padding-left: 10px; }
  .ov-card .value { font-size: 22px; }
  .tab-btn { padding: 8px 14px; font-size: 13px; }
}
