/* ==========================================================
   脚本群控后台 - 通用样式（浅色主题 / 全设备自适应）
   ========================================================== */
:root {
    --primary: #2563eb;
    --primary-d: #1d4ed8;
    --primary-l: #eff6ff;
    --ok: #16a34a;
    --ok-l: #ecfdf5;
    --warn: #f59e0b;
    --warn-l: #fffbeb;
    --err: #dc2626;
    --err-l: #fef2f2;
    --text: #0f172a;
    --text2: #475569;
    --text3: #94a3b8;
    --bd: #e2e8f0;
    --bg: #f1f5f9;
    --card: #ffffff;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
    --shadow-lg: 0 10px 30px rgba(15,23,42,.12);
    --fs-scale: 1;   /* 全站字号缩放系数（后台可调，14px 为基准） */
    --sb-w: min(calc(226px * var(--fs-scale)), 380px);   /* 侧边栏宽度：随字号等比变宽（封顶 380px，温和增长） */
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    overflow-x: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: calc(14px * var(--fs-scale));
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
code, pre, .mono {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ---------------- 布局 ---------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sb-w);
    flex: 0 0 var(--sb-w);
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 60;
    transition: transform .25s ease;
    will-change: transform;
}
.sidebar .brand {
    padding: 18px 20px;
    font-size: calc(16px * var(--fs-scale));
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0;
}
.sidebar .brand .dot {
    width: 26px; height: 26px; border-radius: 8px;
    background: linear-gradient(135deg,#3b82f6,#8b5cf6);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: calc(13px * var(--fs-scale)); color: #fff; flex: none;
}
.sidebar .brand .brand-logo {
    height: 26px; width: 26px; border-radius: 8px; object-fit: cover; flex: none;
    background: #fff; padding: 2px; box-sizing: border-box;
}
.sidebar nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 10px; scrollbar-width: thin; scrollbar-color: transparent transparent; }
/* 侧边栏滚动条：默认隐藏，鼠标移入/滚动时才显示细条 */
.sidebar nav::-webkit-scrollbar { width: 6px; height: 6px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; transition: background .2s; }
.sidebar nav:hover { scrollbar-color: rgba(255,255,255,.28) transparent; }
.sidebar:hover nav::-webkit-scrollbar-thumb,
.sidebar nav:hover::-webkit-scrollbar-thumb,
.sidebar nav:focus-within::-webkit-scrollbar-thumb { background: rgba(255,255,255,.28); }
.sidebar nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.45); }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px;
    color: #cbd5e1; margin-bottom: 3px;
    font-size: calc(14px * var(--fs-scale)); white-space: nowrap;
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.sidebar nav a.on { background: var(--primary); color: #fff; }
.sidebar nav a .ic { width: 18px; text-align: center; opacity: .9; flex: none; }
.sidebar .sb-foot {
    padding: 12px 16px; font-size: calc(12px * var(--fs-scale)); color: #64748b;
    border-top: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

/* ---------------- 侧边栏底部用户信息框（三行：邮箱 / 头像+等级+退出 / 设备+到期） ---------------- */
.sidebar .sb-user {
    display: flex; flex-direction: column; gap: 9px;
    padding: 12px; margin: 12px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 12px;
    flex-shrink: 0;
}
.sidebar .sb-user-email {
    color: #f8fafc; font-size: calc(13px * var(--fs-scale)); font-weight: 600;
    overflow-wrap: anywhere; word-break: break-word;
}
.sidebar .sb-user-row2 {
    display: flex; align-items: center; gap: 8px;
}
.sidebar .sb-user-av {
    width: 34px; height: 34px; border-radius: 50%; flex: none;
    overflow: hidden; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff; font-size: calc(15px * var(--fs-scale)); font-weight: 700; text-transform: uppercase;
}
.sidebar .sb-user-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar .sb-user-role { flex: 1; min-width: 0; }
.sidebar .sb-user-role .tag { transform: scale(.92); transform-origin: left center; }
.sidebar .sb-user-sub {
    font-size: calc(11px * var(--fs-scale)); color: #94a3b8;
    overflow-wrap: anywhere; word-break: break-word;
}
.sidebar .sb-user-logout {
    flex: none; margin-left: auto; height: 30px; padding: 0 10px; border-radius: 9px;
    display: inline-flex; align-items: center; gap: 4px;
    background: rgba(255,255,255,.08); color: #cbd5e1; font-size: calc(12px * var(--fs-scale));
    text-decoration: none; white-space: nowrap;
}
.sidebar .sb-user-logout:hover { background: rgba(239,68,68,.18); color: #fca5a5; text-decoration: none; }

/* ---------------- 侧边栏余额卡片（黑金配色） ---------------- */
.sidebar .sb-balance {
    margin: 0 12px 10px; padding: 14px 16px;
    background: linear-gradient(135deg, #15130f 0%, #241d10 55%, #3a2c12 100%);
    border: 1px solid rgba(212, 175, 55, .38);
    border-radius: 12px;
    color: #f3e3b3;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(212, 175, 55, .15);
}
.sidebar .sb-bal-row {
    display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
    margin-bottom: 10px;
}
.sidebar .sb-bal-label { font-size: calc(12px * var(--fs-scale)); color: rgba(240, 201, 107, .78); }
.sidebar .sb-bal-amount {
    font-size: calc(22px * var(--fs-scale)); font-weight: 700; letter-spacing: .5px;
    color: #f2cd6b;
    text-shadow: 0 1px 8px rgba(212, 175, 55, .35);
}
.sidebar .sb-bal-actions {
    display: flex; gap: 8px;
}
.sidebar .sb-bal-btn {
    flex: 1; text-align: center;
    padding: 6px 0; border-radius: 8px;
    font-size: calc(12px * var(--fs-scale)); font-weight: 600; color: #f2cd6b;
    background: rgba(212, 175, 55, .08);
    border: 1px solid rgba(212, 175, 55, .45);
    text-decoration: none;
    transition: background .15s, color .15s;
}
.sidebar .sb-bal-btn:hover { background: rgba(212, 175, 55, .18); text-decoration: none; }
.sidebar .sb-bal-btn.pri {
    background: linear-gradient(135deg, #f7dd8f, #d4af37);
    color: #1a1408;
    border-color: transparent;
    font-weight: 700;
}
.sidebar .sb-bal-btn.pri:hover { background: linear-gradient(135deg, #ffe9a8, #e0bb43); }

/* ---------------- 侧边栏分组导航 ---------------- */
.sidebar nav .sb-group {
    margin-bottom: 10px;
}
.sidebar nav .sb-label {
    font-size: calc(11px * var(--fs-scale)); font-weight: 600; letter-spacing: .06em;
    color: #64748b; text-transform: uppercase;
    padding: 10px 12px 4px;
}
.sidebar nav a.sb-logout {
    margin-top: 10px;
    color: #94a3b8;
}
.sidebar nav a.sb-logout:hover {
    background: rgba(220,38,38,.15); color: #fca5a5;
}
/* 总后台底部：管理员行 + 右侧退出按钮（复用用户后台 .sb-user-logout 样式） */
.sidebar .sb-admin-row {
    display: flex; align-items: center; gap: 8px;
    color: #e2e8f0; margin-bottom: 4px;
}
.sidebar .sb-admin-row .sb-admin-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 自动刷新控件（侧边栏底部） ---------------- */
.sidebar .sb-auto {
    background: rgba(255,255,255,.06);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 8px 12px 4px;
    display: flex; flex-direction: column; gap: 8px;
    border: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}
.sidebar .sb-auto .auto-row { display: flex; align-items: center; gap: 10px; }
.sidebar .sb-auto .auto-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sidebar .sb-auto .auto-label { font-size: calc(13px * var(--fs-scale)); font-weight: 500; color: rgba(255,255,255,.9); }
.sidebar .sb-auto select.inp { font-size: calc(12px * var(--fs-scale)); padding: 5px 8px; width: auto; min-width: 72px; }
/* Toggle switch */
.sidebar .sb-auto .switch {
    position: relative; display: inline-block;
    width: 36px; height: 20px; flex-shrink: 0;
}
.sidebar .sb-auto .switch input { opacity: 0; width: 0; height: 0; }
.sidebar .sb-auto .slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #94a3b8; border-radius: 999px;
    transition: background .2s;
}
.sidebar .sb-auto .slider::before {
    content: ''; position: absolute;
    height: 14px; width: 14px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.sidebar .sb-auto .switch input:checked + .slider { background: var(--primary, #3b82f6); }
.sidebar .sb-auto .switch input:checked + .slider::before { transform: translateX(16px); }
.sidebar .sb-auto .switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(59,130,246,.25); }
.sidebar .sb-auto .auto-tip { font-size: calc(11px * var(--fs-scale)); opacity: .7; color: rgba(255,255,255,.75); }

.main {
    flex: 1; min-width: 0;
    margin-left: var(--sb-w);
    display: flex; flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--bd);
    padding: 0 20px;
    height: 58px;
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 50;
    flex-shrink: 0;
}
.topbar .t-title { font-size: calc(17px * var(--fs-scale)); font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar #autoBox { display: inline-flex; align-items: center; gap: 6px; }
.topbar #autoSec { min-width: 80px; }
.burger {
    display: none;
    background: none; border: 0; font-size: calc(22px * var(--fs-scale)); cursor: pointer;
    padding: 6px 10px; color: var(--text); line-height: 1;
    min-width: 40px; min-height: 40px;           /* 触摸友好 */
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;     /* 去除移动端点击高亮 */
}
.burger:hover { background: #f1f5f9; }
.burger:active { background: #e2e8f0; }

.content { padding: 20px; flex: 1; }

/* ---------------- 卡片 ---------------- */
.card {
    background: var(--card);
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.card-hd {
    padding: 14px 18px;
    border-bottom: 1px solid var(--bd);
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-hd h3 { font-size: calc(15px * var(--fs-scale)); }
.card-hd .spacer { flex: 1; }
.card-bd { padding: 18px; }

/* ---------------- 统计卡 ---------------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat {
    background: #fff;
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}
.stat .lb { color: var(--text3); font-size: calc(12px * var(--fs-scale)); }
.stat .vl { font-size: calc(24px * var(--fs-scale)); font-weight: 700; line-height: 1.3; }
.stat.g .vl { color: var(--ok); }
.stat.r .vl { color: var(--err); }
.stat.b .vl { color: var(--primary); }
.stat.o .vl { color: var(--warn); }

/* ---------------- 按钮 ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid var(--bd); background: #fff; color: var(--text);
    padding: 7px 14px; border-radius: 8px; cursor: pointer;
    font-size: calc(13px * var(--fs-scale)); font-family: inherit; line-height: 1.5;
    white-space: nowrap; transition: all .15s;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.pri { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.pri:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { background: #15803d; }
.btn.warn { background: var(--warn, #d97706); border-color: var(--warn, #d97706); color: #fff; }
.btn.warn:hover { background: #b45309; }
.btn.dan { background: var(--err); border-color: var(--err); color: #fff; }
.btn.dan:hover { background: #b91c1c; }
.btn.sm { padding: 4px 10px; font-size: calc(12px * var(--fs-scale)); }
.btn.lg { padding: 10px 18px; font-size: calc(15px * var(--fs-scale)); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-grp { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 表单 ---------------- */
.form-row { margin-bottom: 14px; }
.form-row label {
    display: block; margin-bottom: 6px; font-size: calc(13px * var(--fs-scale));
    color: var(--text2); font-weight: 500;
}
.inp, select.inp, textarea.inp {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--bd); border-radius: 8px;
    font-size: calc(14px * var(--fs-scale)); font-family: inherit;
    background: #fff; color: var(--text);
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.inp:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.inp[readonly] { background: #f8fafc; color: var(--text2); }
.inp-grp { display: flex; gap: 8px; }
.inp-grp .inp { flex: 1; }
.hint { font-size: calc(12px * var(--fs-scale)); color: var(--text3); margin-top: 5px; }

/* ---------------- 开关 / 单选 ---------------- */
.toggle {
    display: inline-flex; border: 1px solid var(--bd); border-radius: 8px;
    overflow: hidden; background: #f8fafc;
}
.toggle label {
    padding: 7px 18px; cursor: pointer; font-size: calc(13px * var(--fs-scale)); color: var(--text2);
    border-right: 1px solid var(--bd); margin: 0; white-space: nowrap; transition: all .15s;
}
.toggle label:last-child { border-right: 0; }
.toggle input { display: none; }
.toggle input:checked + span { color: #fff; }
.toggle label.on { background: var(--primary); color: #fff; }

.seg {
    display: inline-flex; flex-wrap: wrap; gap: 6px;
}
.seg label {
    padding: 6px 14px; border: 1px solid var(--bd); border-radius: 999px;
    cursor: pointer; font-size: calc(13px * var(--fs-scale)); color: var(--text2);
    background: transparent; margin: 0; transition: all .15s;
    display: inline-flex; align-items: center;
}
.seg input { display: none; }
.seg label > span {
    display: inline-block; padding: 6px 14px; margin: -6px -14px; border-radius: 999px;
    transition: background .15s, color .15s;
}
/* 选中态：靠 :checked + span 直接上色，不依赖 JS 加 .on（多选 / 单选通用） */
.seg input:checked + span,
.seg label.on > span {
    background: var(--primary-l); color: var(--primary-d); font-weight: 500;
    box-shadow: 0 0 0 1px var(--primary) inset;
}

/* ---------------- 表格 ---------------- */
.tw { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tb { width: 100%; border-collapse: collapse; }
table.tb th, table.tb td {
    padding: 8px 10px; text-align: left;
    border-bottom: 1px solid var(--bd); vertical-align: middle;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
table.tb th {
    background: #f8fafc; font-size: calc(12px * var(--fs-scale)); color: var(--text2);
    font-weight: 600;
}
table.tb tbody tr:hover { background: #f8fafc; }
table.tb td .ops { display: flex; gap: 5px; flex-wrap: nowrap; }
table.tb td .ops .btn.sm { padding: 3px 8px; font-size: calc(12px * var(--fs-scale)); }
.num { font-variant-numeric: tabular-nums; }

/* 与 .tb 同款，用于未命名表格（customcfg / invite 等） */
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td {
    padding: 8px 10px; text-align: left;
    border-bottom: 1px solid var(--bd); vertical-align: middle;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
table.tbl th {
    background: #f8fafc; font-size: calc(12px * var(--fs-scale)); color: var(--text2);
    font-weight: 600;
}
table.tbl tbody tr:hover { background: #f8fafc; }
table.tbl td .ops { display: flex; gap: 5px; flex-wrap: nowrap; }
table.tbl td .ops .btn.sm { padding: 3px 8px; font-size: calc(12px * var(--fs-scale)); }

/* 自定义配置变量表列宽 */
.cc-th-name { width: 18%; }
.cc-th-type { width: 12%; }
.cc-th-content { width: 30%; }
.cc-th-default { width: 15%; }
.cc-th-order { width: 12%; }
.cc-th-ops { width: 13%; }

/* ---------------- 徽标 ---------------- */
.tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px; border-radius: 999px; font-size: calc(12px * var(--fs-scale)); font-weight: 500;
    white-space: nowrap;
}
.tag.g { background: var(--ok-l); color: #15803d; }
.tag.r { background: var(--err-l); color: #b91c1c; }
.tag.b { background: var(--primary-l); color: var(--primary-d); }
.tag.o { background: var(--warn-l); color: #b45309; }
.tag.n { background: #f1f5f9; color: var(--text2); }
.dotg { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dotg.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.dotg.off { background: var(--text3); }

/* ---------------- 提示条 ---------------- */
.alert {
    padding: 11px 15px; border-radius: 8px; margin-bottom: 14px;
    font-size: calc(13.5px * var(--fs-scale)); border: 1px solid transparent;
}
.alert.ok { background: var(--ok-l); color: #15803d; border-color: #bbf7d0; }
.alert.err { background: var(--err-l); color: #b91c1c; border-color: #fecaca; }
.alert.info { background: var(--primary-l); color: var(--primary-d); border-color: #bfdbfe; }
.alert.warn { background: var(--warn-l); color: #b45309; border-color: #fde68a; }

/* ---------------- 工具条 ---------------- */
.toolbar {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    padding: 12px 18px; border-bottom: 1px solid var(--bd);
}
.toolbar .inp, .toolbar select.inp { width: auto; min-width: 130px; }
.toolbar .grow { flex: 1; min-width: 140px; }
.toolbar #sort { min-width: 120px; }
/* 设备列表工具栏：「新建标签」按钮与「按编号排序」下拉等高对齐、同尺寸 */
.toolbar #sort, .toolbar #btnTagAdd { height: 40px; }
.toolbar #btnTagAdd { padding: 0 14px; font-size: calc(14px * var(--fs-scale)); border-radius: 8px; }
.batch-bar {
    display: none; padding: 10px 18px;
    background: var(--primary-l); border-bottom: 1px solid #bfdbfe;
    gap: 8px; flex-wrap: wrap; align-items: center; font-size: calc(13px * var(--fs-scale));
}
.batch-bar.show { display: flex; }

/* ---------------- 分页 ---------------- */
.pager { display: flex; gap: 6px; align-items: center; padding: 14px 18px; flex-wrap: wrap; }
.pager .btn { padding: 4px 11px; }
.pager .info { color: var(--text3); font-size: calc(12.5px * var(--fs-scale)); }

/* ---------------- 空状态 ---------------- */
.empty { text-align: center; padding: 46px 20px; color: var(--text3); }
.empty .big { font-size: calc(38px * var(--fs-scale)); margin-bottom: 8px; opacity: .45; }

/* ---------------- 登录页 ---------------- */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(135deg,#eef2ff 0%,#f1f5f9 45%,#ecfeff 100%);
}
.auth-box {
    width: 100%; max-width: 420px;
    background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
    padding: 32px 30px;
}
.auth-box .logo { text-align: center; margin-bottom: 22px; }
.auth-box .logo .dot {
    width: 46px; height: 46px; border-radius: 13px; margin: 0 auto 10px;
    background: linear-gradient(135deg,#3b82f6,#8b5cf6);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: calc(21px * var(--fs-scale)); font-weight: 700;
}
.auth-box .logo .logo-img {
    display: block; margin: 0 auto 10px;
    max-width: 180px; max-height: 52px; object-fit: contain;
    border-radius: 10px;
}
.auth-box h2 { font-size: calc(20px * var(--fs-scale)); text-align: center; margin-bottom: 4px; }
.auth-box .sub { text-align: center; color: var(--text3); font-size: calc(13px * var(--fs-scale)); margin-bottom: 22px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: calc(13px * var(--fs-scale)); }
.text-c { text-align: center; }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--bd); padding: 0 18px; flex-wrap: wrap; }
.tab {
    padding: 11px 16px; cursor: pointer;
    border-bottom: 2px solid transparent; color: var(--text2); font-size: calc(14px * var(--fs-scale));
    background: none; border-top: 0; border-left: 0; border-right: 0; font-family: inherit;
}
.tab.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.pane { display: none; }
.pane.on { display: block; }

/* ---------------- 网格表单 ---------------- */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 24px; }

/* ---------------- Toast ---------------- */
#toast {
    position: fixed; left: 50%; bottom: 34px;
    transform: translateX(-50%) translateY(20px);
    background: #0f172a; color: #fff;
    padding: 11px 22px; border-radius: 999px; font-size: calc(13.5px * var(--fs-scale));
    opacity: 0; pointer-events: none; transition: all .25s;
    z-index: 9999; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 弹窗 ---------------- */
.mask {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.5);
    display: none; align-items: center; justify-content: center;
    z-index: 900; padding: 16px;
}
.mask.show { display: flex; }
.modal {
    background: #fff; border-radius: 14px;
    width: 100%; max-width: 460px; max-height: 90vh;
    overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-hd { padding: 16px 20px; border-bottom: 1px solid var(--bd); font-weight: 600; display: flex; align-items: center; }
.modal-hd .spacer { flex: 1; }
.modal-bd { padding: 20px; }
.modal-ft { padding: 14px 20px; border-top: 1px solid var(--bd); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.x { background: none; border: 0; font-size: calc(22px * var(--fs-scale)); cursor: pointer; color: var(--text3); line-height: 1; }

/* ---------------- 支付方式弹窗 ---------------- */
.pay-amt { font-size: calc(15px * var(--fs-scale)); font-weight: 600; color: var(--text); margin-bottom: 14px; }
.pay-list { display: flex; flex-direction: column; gap: 10px; }
.pay-opt {
    display: flex; align-items: center; gap: 12px; text-align: left;
    width: 100%; padding: 12px 14px; border: 1px solid var(--bd); border-radius: 12px;
    background: #fff; cursor: pointer; transition: border-color .15s, background .15s;
}
.pay-opt:hover { border-color: var(--primary); background: var(--primary-l); }
.pay-ic {
    width: 38px; height: 38px; border-radius: 10px; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: calc(16px * var(--fs-scale)); font-weight: 700;
}
.pay-ic.wx  { background: #07c160; }
.pay-ic.ali { background: #1677ff; }
.pay-ic.qq  { background: #12a5db; }
.pay-ic.bal { background: linear-gradient(135deg,#3b82f6,#8b5cf6); }
.pay-name { font-weight: 600; color: var(--text); }
.pay-sub { margin-left: auto; font-size: calc(12px * var(--fs-scale)); color: var(--text3); }

/* ---------------- 联系站长二维码 ---------------- */
.qr-wrap { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
/* 两个二维码：强制横排（不换行）+ 放大一倍（400px） */
.qr-wrap.qr-2 { flex-wrap: nowrap; }
.qr-wrap.qr-1 .qr-box { flex: 0 1 400px; max-width: 400px; }
.qr-wrap.qr-2 .qr-box { flex: 1 1 0; max-width: 400px; min-width: 0; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.qr-img {
    width: 100%; aspect-ratio: 1/1; max-width: 400px;
    border-radius: 12px; overflow: hidden;
    background: #f8fafc; border: 1px solid var(--bd);
    display: flex; align-items: center; justify-content: center;
}
.qr-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.qr-name { font-weight: 600; font-size: calc(18px * var(--fs-scale)); padding: 6px 16px; border-radius: 999px; }
.qr-name.wx { background: rgba(7,193,96,.12); color: #07c160; }
.qr-name.qq { background: rgba(18,150,219,.12); color: #1296db; }
/* 手机端：二维码自动换行单列 */
@media (max-width: 560px) {
    .qr-wrap.qr-2 { flex-wrap: wrap; }
    .qr-wrap .qr-box, .qr-wrap.qr-2 .qr-box { flex: 1 1 100%; max-width: 320px; margin: 0 auto; }
}

/* 管理端上传二维码预览：自适应，不超出表单宽度 */
.qr-preview {
    margin-top: 8px; max-width: 220px; width: 100%;
    border-radius: 10px; overflow: hidden;
    border: 1px solid var(--bd); background: #f8fafc;
    aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center;
}
.qr-preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* 站点 Logo / Favicon 预览：宽幅自适应（Logo 通常非正方形，不用 1:1 裁切） */
.logo-preview {
    margin-top: 10px; max-width: 260px; width: 100%; min-height: 48px;
    border-radius: 10px; overflow: hidden;
    border: 1px solid var(--bd); background: #f8fafc;
    display: flex; align-items: center; justify-content: center; padding: 8px;
}
.logo-preview img { max-width: 100%; max-height: 120px; width: auto; height: auto; object-fit: contain; display: block; }

/* 账号设置页：头像预览 */
.av-prev {
    width: 72px; height: 72px; border-radius: 50%; flex: none;
    overflow: hidden; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg,#3b82f6,#8b5cf6); color: #fff;
    border: 1px solid var(--bd);
}
.av-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av-prev .av-letter { font-size: calc(28px * var(--fs-scale)); font-weight: 700; text-transform: uppercase; }

/* ---------------- 美化文件选择框（选择文件 / 选择图片） ---------------- */
.file-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--primary); color: #fff; font-size: calc(13px * var(--fs-scale)); line-height: 1;
    padding: 9px 14px; border-radius: 8px; cursor: pointer;
    transition: background .15s; user-select: none; white-space: nowrap;
}
.file-btn:hover { background: var(--primary-d); color: #fff; }
/* .file-btn 是 <label>，会被 .form-row label 的默认样式（color:var(--text2) / margin 等）
   以更高优先级覆盖 → 这里用更高优先级锁定：白字、无下边距 */
.form-row label.file-btn,
.file-box .file-btn { color: #fff; margin-bottom: 0; font-weight: 600; }
.file-btn .fi { font-size: calc(14px * var(--fs-scale)); line-height: 1; }
/* 真实 file input 视觉隐藏，点击 label 即触发选择 */
.file-btn input[type="file"] {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); border: 0; background: none;
}
.file-name {
    font-size: calc(13px * var(--fs-scale)); color: var(--text2); max-width: 220px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------------- Token 展示 ---------------- */
.token-box {
    display: flex; gap: 10px; align-items: center;
    background: #0f172a; color: #e2e8f0;
    padding: 16px 18px; border-radius: 10px;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: calc(19px * var(--fs-scale)); letter-spacing: 2px; flex-wrap: break-word;
}
.token-box .t { flex: 1; word-break: break-all; min-width: 200px; }

/* ---------------- 进度条 ---------------- */
.bar { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

/* ---------------- 其它辅助 ---------------- */
.muted { color: var(--text3); }
.small { font-size: calc(12.5px * var(--fs-scale)); }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.rowline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
/* ---------------- 复选框 / 单选按钮 美化（.chkline / .cb / 表格内） ---------------- */
.chkline, .cb {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: calc(13px * var(--fs-scale)); color: var(--text2); margin-right: 14px;
    cursor: pointer; user-select: none; white-space: nowrap;
    padding: 6px 10px; border-radius: 8px;
    transition: background .12s;
}
.chkline:hover, .cb:hover { background: rgba(37,99,235,.06); }
.chkline input[type="checkbox"],
.chkline input[type="radio"],
.cb input[type="checkbox"] {
    appearance: none; -webkit-appearance: none;
    width: 20px; height: 20px; flex: none;
    border: 2px solid #cbd5e1; border-radius: 6px;
    background: #fff; cursor: pointer;
    display: inline-grid; place-content: center;
    transition: all .15s; margin: 0;
}
.chkline input[type="radio"],
.cb input[type="radio"] { border-radius: 50%; }
.chkline input[type="checkbox"]:checked,
.chkline input[type="radio"]:checked,
.cb input[type="checkbox"]:checked,
.cb input[type="radio"]:checked {
    border-color: var(--primary); background: var(--primary);
}
.chkline input[type="checkbox"]:checked::before,
.cb input[type="checkbox"]:checked::before {
    content: ""; width: 5px; height: 10px; border: solid #fff;
    border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.chkline input[type="radio"]:checked::before,
.cb input[type="radio"]:checked::before {
    content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff;
}

/* 表格内复选框也放大并统一主题色 */
table.tb td input[type="checkbox"] {
    appearance: none; -webkit-appearance: none;
    width: 18px; height: 18px;
    border: 2px solid #cbd5e1; border-radius: 5px; background: #fff;
    display: inline-grid; place-content: center; cursor: pointer;
    transition: all .15s; margin: 0; vertical-align: middle;
}
table.tb td input[type="checkbox"]:checked {
    border-color: var(--primary); background: var(--primary);
}
table.tb td input[type="checkbox"]:checked::before {
    content: ""; width: 5px; height: 9px; border: solid #fff;
    border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--bd); font-size: calc(13.5px * var(--fs-scale)); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text3); }

/* ---------------- 购买套餐 / 设备额度 ---------------- */
.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    align-items: stretch;
}
.plan {
    position: relative;
    display: flex; flex-direction: column;
    background: var(--card);
    border: 1px solid var(--bd);
    border-radius: 14px;
    padding: 20px 16px 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.plan::before {
    content: ''; position: absolute; left: 0; top: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
}
.plan:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #cbd5e1; }
.plan .p-ic {
    width: 42px; height: 42px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: calc(22px * var(--fs-scale)); margin-bottom: 10px;
    background: var(--primary-l);
}
.plan .pn { font-size: calc(15px * var(--fs-scale)); font-weight: 600; color: var(--text); }
.plan .pp {
    margin: 6px 0 2px;
    font-size: calc(30px * var(--fs-scale)); font-weight: 800; color: var(--text);
    line-height: 1.1; letter-spacing: -.5px;
    font-variant-numeric: tabular-nums;
}
.plan .pp .cur { font-size: calc(16px * var(--fs-scale)); font-weight: 600; vertical-align: 3px; margin-right: 1px; color: var(--text2); }
.plan .pd {
    flex: 1; margin: 4px 0 14px;
    color: var(--text2); font-size: calc(13px * var(--fs-scale)); line-height: 1.75;
}
.plan .pd .tag { margin-top: 4px; }
.plan .btn { width: 100%; }
.plan.off { opacity: .72; }
.plan.off::before { background: #cbd5e1; }
.plan.off .p-ic { background: #f1f5f9; }

.qty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-top: 14px;
    align-items: stretch;
}
.qty-box {
    display: flex; flex-direction: column; gap: 10px;
    background: var(--card);
    border: 1px solid var(--bd);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--shadow);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.qty-box:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #cbd5e1; }
.qty-box .qn { font-size: calc(14px * var(--fs-scale)); font-weight: 600; color: var(--text); }
.qty-box .qp {
    font-size: calc(22px * var(--fs-scale)); font-weight: 800; color: var(--text);
    font-variant-numeric: tabular-nums;
}
.qty-box .qp .qo {
    font-size: calc(13px * var(--fs-scale)); font-weight: 500; color: var(--text3);
    text-decoration: line-through; margin-left: 6px;
}
.qty-box .btn { width: 100%; }

/* 购买页设备卡：数量 / 时长 选择器（紧凑可点选） */
.qty-grid#devQty { grid-template-columns: repeat(3, 1fr); gap: 10px; }
.qty-box.mini {
    flex-direction: row; justify-content: center; align-items: center;
    padding: 12px 10px; cursor: pointer; gap: 0;
}
.qty-box.mini .qn { font-size: calc(15px * var(--fs-scale)); }
.qty-box.mini.active {
    border-color: var(--primary); background: var(--primary-l);
    box-shadow: none; transform: none; color: var(--primary-d); font-weight: 600;
}
.seg#devDur { display: flex; width: 100%; }
.seg#devDur .seg-btn {
    flex: 1 1 0; justify-content: center; text-align: center; min-width: 0;
    padding: 10px 8px; border: 1px solid var(--bd); border-radius: 10px;
    cursor: pointer; font-size: calc(13px * var(--fs-scale)); color: var(--text2); background: #fff;
    display: inline-flex; flex-direction: column; gap: 3px; transition: all .15s;
}
.seg#devDur .seg-btn .seg-sub { font-size: calc(11px * var(--fs-scale)); color: var(--text3); }
.seg#devDur .seg-btn.active {
    background: var(--primary-l); border-color: var(--primary);
    color: var(--primary-d); font-weight: 600;
}
.seg#devDur .seg-btn.active .seg-sub { color: var(--primary-d); opacity: .8; }

/* 购买页提示条（与系统提示条区分，做柔和蓝底） */
.card .hint.note {
    background: var(--primary-l);
    border: 1px solid #bfdbfe;
    color: var(--primary-d);
    border-radius: 10px;
    padding: 12px 14px;
    line-height: 1.75;
}

/* 购买页：支付方式 / 自动续费 的卡片式单选 & 复选 */
.radio-i, .chk-i {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--bd);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font-size: calc(14px * var(--fs-scale));
    color: var(--text2);
    transition: border-color .15s, background .15s, color .15s;
    user-select: none;
}
.radio-i:hover, .chk-i:hover { border-color: #cbd5e1; }
.radio-i input, .chk-i input { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; }
.radio-i:has(input:checked), .chk-i:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-l);
    color: var(--primary-d);
    font-weight: 600;
}

/* ---------------- 自适应 ---------------- */
@media (max-width: 1100px) {
    :root { --sb-w: min(calc(212px * var(--fs-scale)), 340px); }
}
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    /* 移动端打开侧边栏时加遮罩层防止内容穿透点击 */
    .sidebar.open ~ .main::before {
        content: '';
        position: fixed; inset: 0; background: rgba(0,0,0,.35);
        z-index: 55;
    }
    .main { margin-left: 0 !important; }
    .burger { display: block; }
    .topbar { padding: 0 14px; height: 52px; }
    .content { padding: 12px 10px; }
    .card-bd { padding: 14px; }
    .toolbar { padding: 10px 12px; }
    .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .stat { padding: 10px 11px; }
    .auth-box { padding: 26px 20px; }

    /* 手机端表格：横向滚动容器加阴影提示 */
    .tw {
        border: 1px solid var(--bd);
        border-radius: var(--radius);
        margin-bottom: 16px;
        -webkit-overflow-scrolling: touch;
    }

    /* 工具栏手机端纵向排列 */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .toolbar .inp, .toolbar select.inp {
        width: 100% !important; min-width: 0; flex: none;
    }
    .toolbar .grow { width: 100%; flex: none; }

    /* 卡片标题栏适配 */
    .card-hd { padding: 12px 14px; flex-wrap: wrap; gap: 6px; }
    .card-hd h3 { font-size: calc(14px * var(--fs-scale)); }

    /* 批量操作栏 */
    .batch-bar { padding: 10px 12px; }

    /* 分页 */
    .pager { padding: 12px; justify-content: center; }

    /* Token 展示 */
    .token-box { padding: 12px 14px; font-size: calc(15px * var(--fs-scale)); letter-spacing: 1px; }

    /* 表单行间距 */
    .form-row { margin-bottom: 12px; }
}
@media (max-width: 560px) {
    .stats { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .stat { padding: 8px 9px; }
    .stat .vl { font-size: calc(17px * var(--fs-scale)); }
    .topbar .t-title { font-size: calc(15px * var(--fs-scale)); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .btn { padding: 8px 13px; font-size: calc(13px * var(--fs-scale)); min-height: 40px; }   /* 触摸友好 */
    .btn.sm { min-height: 34px; padding: 5px 10px; }
    .btn.lg { min-height: 46px; padding: 11px 18px; }
    .toolbar .inp, .toolbar select.inp { width: 100%; min-width: 0; flex: 1 1 100%; }
    .token-box { font-size: calc(14px * var(--fs-scale)); }
    .grid2 { gap: 0; }
    .modal { max-width: 100%; margin: 8px; border-radius: 12px; }
    .modal-hd { padding: 14px 16px; }
    .modal-bd { padding: 16px; }
    .modal-ft { padding: 12px 16px; }

    /* 顶部栏紧凑布局 */
    .topbar { gap: 8px; }
    .topbar .t-title { font-size: calc(14px * var(--fs-scale)); }

    /* 总后台顶栏：自动刷新控件在手机端换行 */
    .topbar #autoBox,
    .topbar #autoSec,
    .topbar .btn[onclick*="reload"] {
        font-size: calc(12px * var(--fs-scale));
        padding: 4px 8px;
    }

    /* 统计卡片更紧凑 */
    .stat .lb { font-size: calc(11px * var(--fs-scale)); }
    .stat .vl { font-size: calc(18px * var(--fs-scale)); }

    /* 表格最小宽度缩小，减少横向滚动距离 */
    table.tb { min-width: 520px; }
    table.tb th, table.tb td { padding: 9px 10px; font-size: calc(13px * var(--fs-scale)); }

    /* 登录框全宽 */
    .auth-box { padding: 22px 18px; border-radius: 14px; }
    .auth-box h2 { font-size: calc(18px * var(--fs-scale)); }

    /* Tabs 横向可滚动 */
    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; padding: 0 12px; }
    .tab { padding: 10px 14px; font-size: calc(13px * var(--fs-scale)); white-space: nowrap; }

    /* KV 列表（服务器资源） */
    .kv { padding: 9px 0; font-size: calc(13px * var(--fs-scale)); }

    /* 进度条高度增加，方便触控查看 */
    .bar { height: 10px; }

    /* 提示条 */
    .alert { padding: 10px 13px; font-size: calc(13px * var(--fs-scale)); border-radius: 8px; }

    /* 空状态 */
    .empty { padding: 36px 16px; }
    .empty .big { font-size: calc(32px * var(--fs-scale)); }

    /* 购买套餐 / 设备额度：手机端单列，方便点按与阅读 */
    .plan-grid, .qty-grid { grid-template-columns: 1fr; }
}

/* ---------------- 2K / 高分屏适配：弹窗与图片整体放大 ---------------- */
@media (min-width: 1920px) {
    /* 全局弹窗字体/间距放大 */
    .modal-hd { padding: 20px 24px; font-size: calc(17px * var(--fs-scale)); }
    .modal-bd { padding: 24px; }
    .modal-ft { padding: 16px 24px; }
    .pay-opt { padding: 16px 18px; }
    .pay-ic { width: 46px; height: 46px; font-size: calc(19px * var(--fs-scale)); }
    .pay-name { font-size: calc(16px * var(--fs-scale)); }
    .pay-amt { font-size: calc(17px * var(--fs-scale)); }

    /* 各业务弹窗单独放大（覆盖 inline style） */
    #contactMask .modal { max-width: 1180px; }
    #rechargeMask .modal,
    #rechargePayMask .modal,
    #payMask .modal { max-width: 600px; }

    /* 联系站长 / 上传预览 二维码放大 */
    #contactMask .qr-img,
    #contactMask .qr-wrap .qr-box { max-width: 560px; }
    #contactMask .qr-wrap.qr-1 .qr-box { flex: 0 1 560px; }
    #contactMask .qr-wrap.qr-2 .qr-box { flex: 1 1 0; max-width: 560px; }
    #contactMask .qr-name { font-size: calc(20px * var(--fs-scale)); }
    .logo-preview img { max-height: 180px; }

    /* 充值弹窗金额输入更大一点 */
    #rechargeMask .inp[type="number"]#rechargeAmt { font-size: calc(20px * var(--fs-scale)); padding: 16px 18px; }
}

/* ---------------- 全站字体大小控件（用户后台显示设置 / 总后台网站设置） ---------------- */
.fs-wrap { display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.fs-ctrl { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.fs-ctrl input[type="range"] {
    flex: 1 1 220px; min-width: 160px; max-width: 380px;
    height: 6px; accent-color: var(--primary); cursor: pointer;
}
.fs-num { display: inline-flex; align-items: center; gap: 6px; }
.fs-num input[type="number"] {
    width: 78px; text-align: center; padding: 8px 6px;
    border: 1px solid var(--bd); border-radius: 8px; font-size: calc(15px * var(--fs-scale));
    font-family: inherit; color: var(--text); background: #fff; outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.fs-num input[type="number"]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.fs-btn {
    width: 36px; height: 36px; border: 1px solid var(--bd); background: #fff;
    border-radius: 8px; cursor: pointer; color: var(--text2); font-size: calc(18px * var(--fs-scale)); line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s, border-color .15s;
}
.fs-btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.fs-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
