/* ===== 通用 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #eaf3fc;
  --card: #ffffff;
  --ink: #1d3a5f;
  --sub: #7c9dbf;
  --line: #d7e9fb;
  --dark: #2b86d6;
  --dark-2: rgba(255, 255, 255, 0.18);
  --blue: #2f8fe8;
  --green: #07c160;
  --qq: #1296db;
}
body {
  font-family: "Microsoft YaHei", -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; }

/* ===== 水印层（透明背景 + 斜向重复品牌字） ===== */
.watermark {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.watermark span {
  position: absolute;
  color: rgba(100, 116, 139, 0.14);
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  transform: rotate(-28deg);
  user-select: none;
}

/* ===== 登录页 ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}
.login-card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 10px 34px rgba(15, 23, 42, 0.08);
  width: 100%;
  max-width: 400px;
  padding: 40px 32px 30px;
}
.login-logo {
  width: 64px; height: 64px;
  border-radius: 16px;
  object-fit: cover;
  display: block;
  margin: 0 auto 16px;
  background: var(--dark);
}
.login-title { text-align: center; font-size: 22px; font-weight: 700; }
.login-sub { text-align: center; color: var(--sub); font-size: 13px; margin-top: 6px; }
.oauth-row { display: flex; gap: 12px; margin: 26px 0 22px; }
.oauth-btn {
  flex: 1;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; color: #374151;
}
.oauth-btn .dot { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; }
.dot.qq { background: var(--qq); }
.dot.wx { background: var(--green); }
.dot.zfb { background: var(--blue); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--sub); font-size: 12px; margin-bottom: 22px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.role-tabs {
  display: flex; background: #f3f4f6; border-radius: 12px; padding: 4px; margin-bottom: 20px;
}
.role-tab {
  flex: 1; text-align: center; padding: 10px 0; border-radius: 10px;
  font-size: 14px; color: #6b7280; background: transparent;
}
.role-tab.active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 2px 8px rgba(15,23,42,0.08); }
.field {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; font-size: 15px; margin-bottom: 16px; background: #fff; color: var(--ink);
}
.field::placeholder { color: #9ca3af; }
.login-btn {
  width: 100%; background: var(--blue); color: #fff; border-radius: 12px;
  padding: 15px 0; font-size: 16px; font-weight: 600;
}
.login-btn:disabled { opacity: .6; }
.login-foot { text-align: center; color: var(--sub); font-size: 12px; margin-top: 22px; }
.login-msg { text-align: center; font-size: 13px; margin-top: 14px; min-height: 18px; }
.login-msg.err { color: #ef4444; }
.login-msg.ok { color: var(--green); }

/* ===== 控制台布局 ===== */
.admin-shell { display: flex; min-height: 100vh; position: relative; z-index: 1; }
.sidebar {
  width: 230px; background: linear-gradient(180deg, #2b86d6 0%, #43a9ee 100%); color: #eaf4ff;
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; }
.side-brand img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; }
.side-brand .name { font-size: 15px; font-weight: 600; }
.side-brand .role { font-size: 11px; color: #d6ecff; }
.side-menu { flex: 1; overflow-y: auto; padding: 8px 12px; }
.side-menu .mi {
  display: flex; align-items: center; gap: 10px; padding: 12px 12px;
  border-radius: 10px; font-size: 14px; color: #eaf4ff; margin-bottom: 2px;
}
.side-menu .mi.active, .side-menu .mi:hover { background: rgba(255,255,255,0.22); color: #fff; }
.side-menu .mi .ic { width: 18px; text-align: center; }
.side-foot { padding: 16px 18px; border-top: 1px solid rgba(255,255,255,0.15); }
.balance-card { background: rgba(255,255,255,0.18); border-radius: 12px; padding: 14px; }
.balance-card .label { font-size: 12px; color: #d6ecff; }
.balance-card .val { font-size: 22px; font-weight: 700; color: #fff; margin-top: 4px; }
.side-user { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; font-size: 13px; }
.side-user .logout { color: #f87171; cursor: pointer; }

.main { flex: 1; margin-left: 230px; padding: 0 26px 30px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; margin: 8px 0 4px; background: rgba(255,255,255,.72); border: 1px solid rgba(255,255,255,.7); border-radius: 14px; backdrop-filter: blur(6px); box-shadow: 0 3px 12px rgba(15,55,95,.06); }
.topbar .tb-left { display: flex; align-items: center; gap: 14px; font-size: 18px; font-weight: 600; }
.topbar .icon-btn { width: 34px; height: 34px; border-radius: 9px; background: #fff; display: flex; align-items: center; justify-content: center; color: #6b7280; }

.welcome-card {
  background: #fff; border-radius: 18px; padding: 28px 30px; margin-bottom: 22px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 4px 18px rgba(15,23,42,0.05); position: relative; overflow: hidden;
}
.welcome-card .tag { font-size: 12px; letter-spacing: 2px; color: #9ca3af; }
.welcome-card h2 { font-size: 26px; margin: 10px 0 8px; }
.welcome-card p { color: #9ca3af; font-size: 14px; }
.welcome-balance { background: #ecfdf3; color: #16a34a; border-radius: 14px; padding: 18px 26px; text-align: center; }
.welcome-balance .label { font-size: 12px; }
.welcome-balance .val { font-size: 24px; font-weight: 700; margin-top: 4px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.stat-card { background: #fff; border-radius: 16px; padding: 22px; box-shadow: 0 4px 18px rgba(15,23,42,0.05); }
.stat-card .s-label { color: #9ca3af; font-size: 13px; }
.stat-card .s-val { font-size: 26px; font-weight: 700; margin-top: 8px; }
.stat-card .s-action { color: var(--blue); font-size: 13px; margin-top: 8px; }

.content-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.panel { background: #fff; border-radius: 16px; padding: 22px; box-shadow: 0 4px 18px rgba(15,23,42,0.05); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-head h3 { font-size: 16px; }
.panel-head .more { color: var(--blue); font-size: 13px; }
.site-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-top: 1px solid #f1f5f9; }
.site-row .domain { font-size: 15px; }
.badge { background: #ecfdf3; color: #16a34a; border-radius: 8px; font-size: 12px; padding: 3px 10px; }
.site-row .time { color: #9ca3af; font-size: 12px; }
.quick-list .qi { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid #f1f5f9; font-size: 14px; }
.quick-list .qi .ic { width: 34px; height: 34px; border-radius: 10px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
}

/* ===== 表单与按钮 ===== */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin: 16px 0; }
.form-grid label { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: #6b7280; }
.field, .form-grid input, .form-grid select, .form-grid textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; font-size: 15px; background: #fff; color: var(--ink);
}
.form-grid textarea { resize: vertical; font-family: inherit; }
.btn-primary {
  background: var(--blue); color: #fff; border-radius: 12px; padding: 12px 22px;
  font-size: 15px; font-weight: 600;
}
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { background: #f1f5f9; color: var(--ink); border-radius: 9px; padding: 7px 14px; font-size: 13px; }
.hint { color: var(--sub); font-size: 12px; margin-top: 12px; }
.empty { color: var(--sub); font-size: 13px; padding: 24px 0; text-align: center; }
.msg-list.tall { max-height: 460px; }
.notice-img { width: 90px; height: 60px; object-fit: cover; border-radius: 8px; }
.chk { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); }
.chk input { width: auto; }

/* ===== 表格 ===== */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 13px 12px; border-bottom: 1px solid #f1f5f9; }
.tbl th { color: #9ca3af; font-weight: 500; font-size: 13px; }
.tbl td { color: #374151; }

/* ===== 弹窗 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-mask[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 18px; width: 100%; max-width: 420px; box-shadow: 0 18px 50px rgba(15,23,42,.2); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 22px 0; }
.modal-head h3 { font-size: 17px; }
.modal-close { font-size: 24px; color: #9ca3af; cursor: pointer; line-height: 1; }
.modal-body { padding: 18px 22px 24px; }

/* ===== 等级卡片 ===== */
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 10px; }
.level-card { border-radius: 16px; padding: 22px; background: #f8fafc; }
.level-card h3 { font-size: 16px; margin-bottom: 8px; }
.level-card p { color: #6b7280; font-size: 13px; }
.level-card.lv3 { border-left: 4px solid #7c3aed; }
.level-card.lv2 { border-left: 4px solid #1677ff; }
.level-card.lv1 { border-left: 4px solid #07c160; }

/* ===== 客服消息 ===== */
.msg-list { display: flex; flex-direction: column; gap: 14px; max-height: 320px; overflow-y: auto; padding: 6px 0; }
.msg { display: flex; flex-direction: column; max-width: 70%; }
.msg.self { align-self: flex-end; }
.msg.other { align-self: flex-start; }
.msg .bubble { background: #f1f5f9; border-radius: 14px; padding: 11px 14px; font-size: 14px; line-height: 1.5; }
.msg.self .bubble { background: var(--blue); color: #fff; }
.msg .mt { font-size: 11px; color: #9ca3af; margin-top: 4px; }
.msg.self .mt { text-align: right; }
.msg-img { max-width: 180px; border-radius: 10px; margin-top: 6px; display: block; cursor: pointer; }
.msg-emoji { font-size: 20px; }
.msg-input { display: flex; gap: 10px; margin-top: 16px; }
.msg-input input { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; font-size: 15px; }

/* ===== 设置块 ===== */
.settings-block { margin-top: 22px; padding-top: 18px; border-top: 1px solid #f1f5f9; }
.settings-block h3 { font-size: 15px; margin-bottom: 4px; }

@media (max-width: 760px) {
  .sidebar { width: 74px; }
  .side-brand .name, .side-brand .role, .side-menu .mi { font-size: 0; }
  .side-menu .mi .ic { font-size: 18px; }
  .main { margin-left: 74px; padding: 0 14px 24px; }
  .form-grid, .level-grid, .stat-grid { grid-template-columns: 1fr; }
}

/* ===== AI 巡总站 ===== */
.ai-scan-mask { position: fixed; inset: 0; background: rgba(234,243,252,.94); z-index: 80; display: flex; align-items: center; justify-content: center; }
.ai-scan { position: relative; width: 240px; height: 240px; display: flex; align-items: center; justify-content: center; }
.ai-ring { position: absolute; inset: 0; border-radius: 50%; border: 5px solid #d7e9fb; border-top-color: #2f8fe8; border-right-color: #43a9ee; animation: aiSpin 1.1s linear infinite; }
.ai-core { text-align: center; }
.ai-brand { font-size: 22px; font-weight: 700; color: #1d3a5f; }
.ai-sub { margin-top: 8px; font-size: 15px; color: #2f8fe8; letter-spacing: 4px; }
.ai-scan-close { position: absolute; bottom: -56px; left: 50%; transform: translateX(-50%); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 22px; color: var(--ink); font-size: 14px; }
@keyframes aiSpin { to { transform: rotate(360deg); } }

/* ===== 充值页 ===== */
.recharge-wrap { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.recharge-qr { flex: 0 0 auto; }
.recharge-qr img { width: 240px; max-width: 100%; border-radius: 16px; border: 1px solid var(--line); display: block; }
.recharge-side { flex: 1 1 220px; }
.recharge-side h3 { font-size: 20px; color: #1d3a5f; margin-bottom: 10px; }

/* ===== 套餐详情 ===== */
.detail-row { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px dashed #eef2f7; }
.detail-row .detail-k { flex: 0 0 96px; color: #64748b; font-size: 14px; }
.detail-row .detail-v { flex: 1; font-size: 14px; color: var(--ink); word-break: break-all; }

@media (max-width: 760px) {
  .recharge-wrap { flex-direction: column; align-items: flex-start; }
  .recharge-qr img { width: 220px; }
}

/* ===== 后台统一背景图（管理员 / 代理；登录页不生效） ===== */
body.role-admin .admin-shell,
body.role-agent .admin-shell {
  position: relative;
  background-color: transparent;
  background-image: linear-gradient(135deg, rgba(240, 247, 255, 0.58), rgba(223, 238, 255, 0.42));
}
body.role-admin .admin-shell::before,
body.role-agent .admin-shell::before {
  content: "";
  position: fixed;
  inset: -18px;
  z-index: -1;
  background: url('./admin-bg.jpg') center 10% / cover no-repeat;
  filter: blur(5px) saturate(.96) brightness(.9);
  opacity: .62;
  pointer-events: none;
}
.sidebar { box-shadow: 8px 0 30px rgba(8, 35, 64, .13); }
.panel { background: rgba(255,255,255,.94); backdrop-filter: blur(8px); }
.btn-danger { background: #fee2e2; color: #c62828; }

/* ===== IP 地图 ===== */
.ipmap-intro {
  color: #486685; font-size: 13px; line-height: 1.9; margin: -4px 0 16px;
  padding: 12px 14px; border: 1px solid rgba(120, 176, 225, .35); border-radius: 12px;
  background: rgba(236, 246, 255, .7);
}
.ipmap-intro strong { color: #1d5d99; }
.ipmap-shell { display: grid; grid-template-columns: minmax(0, 1fr) 306px; gap: 16px; align-items: start; }
.ipmap-map-card {
  background: #071727; border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 34px rgba(4, 24, 45, .22);
  border: 1px solid rgba(95, 170, 240, .22);
}
.ipmap-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: linear-gradient(90deg, rgba(10, 35, 60, .98), rgba(12, 48, 80, .94));
  border-bottom: 1px solid rgba(95, 170, 240, .18); color: #cfeaff; font-size: 12px;
}
.ipmap-status { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ipmap-count { color: #7fb7e8; }
.ipmap-bar .btn-sm { background: rgba(255,255,255,.1); color: #d8efff; border: 1px solid rgba(140,200,255,.22); }
.ipmap-canvas-wrap {
  position: relative; width: 100%; aspect-ratio: 2 / 1; overflow: hidden;
  background: #071727; cursor: crosshair;
}
.ipmap-canvas-wrap canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
}
#ipmFx { cursor: crosshair; touch-action: manipulation; }
.ipmap-tip {
  display: none; position: absolute; z-index: 3; pointer-events: none;
  background: rgba(5, 20, 36, .92); color: #cfe9ff; border: 1px solid rgba(120, 190, 255, .35);
  border-radius: 8px; padding: 5px 9px; font-size: 12px; white-space: nowrap;
}
.ipmap-hint {
  position: absolute; left: 14px; bottom: 12px; z-index: 2;
  color: rgba(190, 225, 255, .72); font-size: 11px; background: rgba(5, 20, 36, .55);
  border: 1px solid rgba(120, 190, 255, .18); border-radius: 8px; padding: 4px 9px; pointer-events: none;
}
.ipmap-foot {
  padding: 9px 14px; color: #8fb7d8; font-size: 11px; display: flex; align-items: center; gap: 7px;
  background: rgba(6, 25, 43, .96); border-top: 1px solid rgba(95, 170, 240, .12);
}
.ipmap-foot .dot-user, .ipmap-foot .dot-target, .ipmap-foot .dot-mark {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.ipmap-foot .dot-user { background: #2f8fe8; }
.ipmap-foot .dot-target { background: #ff5470; margin-left: 7px; }
.ipmap-foot .dot-mark { background: #38dcb4; margin-left: 7px; }
.ipmap-side { display: flex; flex-direction: column; gap: 12px; }
.ipmap-card {
  background: rgba(255,255,255,.95); border: 1px solid rgba(176, 208, 238, .5);
  border-radius: 14px; padding: 14px; box-shadow: 0 6px 18px rgba(15, 55, 95, .06);
}
.ipmap-card-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700; color: #1e3f61; margin-bottom: 10px;
}
.ipmap-mini {
  background: #eef6ff; color: #2f6fa8; border: 1px solid #cfe5fa; border-radius: 7px;
  padding: 3px 8px; font-size: 11px; cursor: pointer;
}
.ipmap-mini:hover { background: #def0ff; }
.ipmap-del { color: #c54a4a; border-color: #f4cccc; background: #fff2f2; }
.ipmap-ip {
  font-family: Consolas, monospace; font-size: 15px; color: #0b68b4; font-weight: 700;
  word-break: break-all; margin-bottom: 6px;
}
.ipmap-loc { font-size: 13px; color: #31536f; margin-bottom: 4px; }
.ipmap-coord { font-size: 11px; color: #7b98b3; word-break: break-all; }
.ipmap-note { font-size: 11px; color: #a06c2a; line-height: 1.6; margin-top: 7px; }
.ipmap-target-name { font-size: 14px; font-weight: 700; color: #173e61; line-height: 1.5; margin-bottom: 5px; }
.ipmap-distance {
  margin: 10px 0 12px; padding: 10px; border-radius: 10px; text-align: center;
  background: linear-gradient(135deg, #eef8ff, #e3f1ff); border: 1px solid #cde7fb;
  color: #5b7f9e; font-size: 12px;
}
.ipmap-distance b { display: inline-block; color: #0b68b4; font-size: 17px; margin-left: 5px; vertical-align: -1px; }
.ipmap-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.ipmap-actions .btn-sm { flex: 1; min-width: 72px; padding: 8px 8px; }
.ipmap-actions #ipmLaunchBtn { flex: 1 0 100%; order: -1; padding: 10px 8px; font-weight: 700; background: linear-gradient(135deg, #ff6a4d, #e6344f); color: #fff; box-shadow: 0 4px 12px rgba(230, 52, 79, .25); }
.ipmap-actions .btn-sm:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }
.ipmap-list { display: flex; flex-direction: column; gap: 7px; max-height: 180px; overflow-y: auto; }
.ipmap-list-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 8px; border-radius: 9px; background: #f5faff; }
.ipmap-list-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ipmap-list-main b { font-size: 12px; color: #234764; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.ipmap-list-main small { font-size: 10px; color: #8aa4bd; }
.ipmap-empty { color: #9db3c8; font-size: 11px; padding: 8px 4px; }
.ipmap-shake { animation: ipmapShake .34s ease; }
@keyframes ipmapShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, -1px); }
  80% { transform: translate(2px, 1px); }
}

@media (max-width: 1080px) {
  .ipmap-shell { grid-template-columns: 1fr; }
  .ipmap-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ipmap-side .ipmap-card:first-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .ipmap-side { grid-template-columns: 1fr; }
  .ipmap-bar { flex-wrap: wrap; }
  .ipmap-status { flex: 1 1 100%; }
  .ipmap-foot { font-size: 10px; flex-wrap: wrap; }
}
