/* ==================================================================
   Lua 网络验证控制台 — 白蓝工作台 / 午夜蓝夜间模式
   ================================================================== */
* { box-sizing: border-box; }
html, body { height: 100%; }
:root {
  color-scheme: light;
  --bg: #f3f7ff;
  --panel: #ffffff;
  --panel-2: #eaf1ff;
  --line: #d6e2f5;
  --line-2: #adc5e8;
  --text: #172b4d;
  --muted: #536987;
  --muted-2: #7184a0;
  --accent: #2563eb;
  --teal: #168f83;
  --warn: #a96600;
  --danger: #c53046;
  --violet: #6846c7;
  --radius: 14px;
  --shadow: 0 24px 60px rgba(30, 64, 120, .12);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b16;
  --panel: #0f172b;
  --panel-2: #121c36;
  --line: #1e2a4a;
  --line-2: #2a3a63;
  --text: #e9eefc;
  --muted: #8b97b8;
  --muted-2: #66739a;
  --accent: #5b8cff;
  --teal: #33d6a6;
  --warn: #ffb020;
  --danger: #ff5d6c;
  --violet: #a78bfa;
  --shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(91, 140, 255, .12), transparent 60%),
    radial-gradient(800px 520px at 100% 110%, rgba(51, 214, 166, .08), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.sub { color: var(--muted); font-size: 12px; }
.strong { font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 12px; letter-spacing: .2px; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 404px; padding: 34px 30px 26px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: rise .35s ease both;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 26px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 13px; flex: 0 0 44px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 21px; color: #fff;
  background: linear-gradient(135deg, #5b8cff, #8b5cf6);
  box-shadow: 0 10px 26px rgba(91, 140, 255, .38);
}
.brand h1 { margin: 0; font-size: 16px; letter-spacing: .3px; }
.brand p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.brand.small { margin-bottom: 22px; padding: 2px 6px; }
.brand.small .brand-mark { width: 34px; height: 34px; flex-basis: 34px; font-size: 16px; border-radius: 10px; }
.brand.small h1 { font-size: 13.5px; }
.brand.small p { font-size: 11px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea, .input {
  width: 100%; padding: 11px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  outline: none; transition: border-color .18s, box-shadow .18s;
}
.field textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 140, 255, .15);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error {
  margin: 2px 0 12px; padding: 9px 12px; border-radius: 9px; font-size: 12.5px;
  color: var(--danger); background: rgba(197, 48, 70, .08); border: 1px solid rgba(197, 48, 70, .22);
}
.login-foot { margin: 18px 0 0; text-align: center; font-size: 11.5px; color: var(--muted-2); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); font-size: 13px; cursor: pointer;
  transition: transform .12s, background .18s, border-color .18s, opacity .18s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.btn.primary {
  border: none; color: #fff;
  background: linear-gradient(135deg, #2563eb, #4c80f1);
  box-shadow: 0 8px 20px rgba(91, 140, 255, .3);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(91, 140, 255, .08); }
.btn.danger { color: var(--danger); border-color: rgba(197, 48, 70, .4); background: rgba(197, 48, 70, .08); }
.btn.danger:hover { background: rgba(255, 93, 108, .16); }
.btn.block { width: 100%; padding: 11px 16px; }
.btn.tiny { padding: 4px 9px; font-size: 11.5px; border-radius: 7px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; border-radius: 9px;
  color: var(--muted); cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: rgba(91, 140, 255, .1); color: var(--text); }

/* ---------------- 布局 ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 236px; z-index: 40;
  display: flex; flex-direction: column; padding: 20px 14px 16px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-right: 1px solid var(--line);
}
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--muted); font-size: 13.5px; transition: .16s;
}
.nav a .ico { width: 18px; text-align: center; font-size: 14px; opacity: .9; }
.nav a:hover { color: var(--text); background: rgba(91, 140, 255, .07); }
.nav a.active {
  color: var(--accent); background: linear-gradient(90deg, rgba(37, 99, 235, .14), rgba(37, 99, 235, .03));
  box-shadow: inset 2px 0 0 var(--accent);
}
.side-foot { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid var(--line); }
.side-admin { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; word-break: break-all; }
.side-foot .btn { width: 100%; }
.theme-switch { margin-top: 8px; border-color: #1d3f78; color: #dceaff; background: #102b55; }
.theme-switch:hover { background: #19427d; border-color: #4b83d5; }

.main { flex: 1; min-width: 0; margin-left: 236px; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px;
  background: color-mix(in srgb, var(--panel) 90%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.page-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .2px; }
.page-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.select-wrap { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.select-wrap select {
  padding: 7px 10px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); outline: none; font-size: 12.5px; min-width: 128px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #5b8cff, #8b5cf6);
  box-shadow: 0 6px 16px rgba(91, 140, 255, .3);
}
.menu-btn { display: none; }
.view { width: 100%; max-width: 1580px; margin: 0 auto; padding: 22px 26px 56px; }
.backdrop { display: none; }

/* ---------------- 卡片 / 网格 ---------------- */
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.two { grid-template-columns: 1.35fr 1fr; }
.grid.two-even { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat {
  position: relative; overflow: hidden; padding: 16px 18px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: var(--radius);
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c, var(--accent)); }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { margin: 7px 0 5px; font-size: 26px; font-weight: 700; letter-spacing: -.6px; line-height: 1.35; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.stat .sub { font-size: 11.5px; color: var(--muted-2); }
.stat .spark { position: absolute; right: 14px; top: 14px; font-size: 17px; opacity: .35; }

/* ---------------- 图表 ---------------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.bars { display: flex; align-items: flex-end; gap: 7px; height: 156px; padding-top: 8px; }
.bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.bar-stack { width: 100%; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bar { width: 8px; max-width: 13px; min-height: 2px; border-radius: 4px 4px 2px 2px; transition: height .3s ease; }
.bar-label { font-size: 10px; color: var(--muted-2); white-space: nowrap; }
.bars.dense { gap: 3px; height: 96px; }
.bars.dense .bar { width: 100%; max-width: 9px; border-radius: 3px 3px 1px 1px; }
.bars.dense .bar-label { display: none; }
.chart-empty { height: 150px; display: flex; align-items: center; justify-content: center; color: var(--muted-2); font-size: 12.5px; }

.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { position: relative; width: 148px; height: 148px; border-radius: 50%; flex: 0 0 148px; }
.donut::after { content: ""; position: absolute; inset: 19px; border-radius: 50%; background: var(--panel); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1; }
.donut-center b { font-size: 24px; letter-spacing: -.5px; }
.donut-center span { font-size: 11px; color: var(--muted); margin-top: 2px; }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 132px; }
.donut-legend li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 12.5px; color: var(--muted); }
.donut-legend li b { margin-left: auto; color: var(--text); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }

.rank-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed rgba(30, 42, 74, .8); }
.rank-item:last-child { border-bottom: none; }
.rank-no { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--muted); background: var(--panel-2); }
.rank-item:nth-child(1) .rank-no { color: #ffd166; }
.rank-body { flex: 1; min-width: 0; }
.rank-body .top { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.rank-track { height: 5px; border-radius: 3px; background: var(--panel-2); margin-top: 6px; overflow: hidden; }
.rank-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--teal)); }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.kv > div { padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.kv .k { font-size: 11px; color: var(--muted); }
.kv .v { margin-top: 4px; font-size: 15px; font-weight: 600; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 12.8px; min-width: 760px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  padding: 11px 12px; text-align: left; white-space: nowrap;
  font-size: 11.5px; font-weight: 500; color: var(--muted);
  background: var(--panel-2); border-bottom: 1px solid var(--line);
}
tbody td { padding: 10px 12px; border-bottom: 1px solid rgba(30, 42, 74, .55); vertical-align: middle; }
tbody tr:hover { background: rgba(91, 140, 255, .055); }
tbody tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; }
td.actions .btn { margin-right: 4px; }
td.actions .btn:last-child { margin-right: 0; }
.table-note { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 12.5px; }
.online-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); margin-right: 6px; box-shadow: 0 0 0 3px rgba(51, 214, 166, .16); }

/* ---------------- 徽章 ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.ok { color: #08766a; background: rgba(22, 143, 131, .1); }
.badge.blue { color: #1d4ed8; background: rgba(37, 99, 235, .1); }
.badge.warn { color: #854d00; background: rgba(169, 102, 0, .1); }
.badge.danger { color: #a61b32; background: rgba(197, 48, 70, .1); }
.badge.violet { color: #5631ad; background: rgba(104, 70, 199, .1); }
.badge.muted { color: var(--muted); background: rgba(83, 105, 135, .1); }
:root[data-theme="dark"] .badge.ok { color: #4ade80; }
:root[data-theme="dark"] .badge.blue { color: #7ea6ff; }
:root[data-theme="dark"] .badge.warn { color: #ffc861; }
:root[data-theme="dark"] .badge.danger { color: #ff8d97; }
:root[data-theme="dark"] .badge.violet { color: #c0aeff; }

/* ---------------- 筛选 / 分页 ---------------- */
.filter-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 13px; }
.filter-row select, .filter-row input {
  padding: 8px 11px; border-radius: 9px; background: var(--panel);
  border: 1px solid var(--line); outline: none; font-size: 12.5px; min-width: 130px;
}
.filter-row input { min-width: 220px; flex: 1; max-width: 340px; }
.filter-row select:focus, .filter-row input:focus { border-color: var(--accent); }
.pager { display: flex; align-items: center; gap: 9px; justify-content: flex-end; margin-top: 14px; font-size: 12px; color: var(--muted); }

/* ---------------- 标签页 ---------------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 12.8px;
  color: var(--muted); background: transparent; border: 1px solid transparent;
}
.tab:hover { color: var(--text); background: rgba(91, 140, 255, .07); }
.tab.active { color: var(--accent); background: rgba(37, 99, 235, .1); border-color: rgba(37, 99, 235, .3); }

/* ---------------- 弹层 ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; padding: 20px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 7, 15, .72); backdrop-filter: blur(6px);
  animation: fade .16s ease both;
}
.modal {
  width: 100%; max-width: 580px; max-height: 88vh; overflow: auto;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line-2); border-radius: 18px;
  box-shadow: var(--shadow); animation: pop .18s ease both;
}
.modal-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 17px 20px; background: var(--panel-2); border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 14.5px; }
.modal-body { padding: 20px; }
.modal-foot {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 14px 20px; background: var(--panel); border-top: 1px solid var(--line);
}
.modal .field-row.three { grid-template-columns: repeat(3, 1fr); }
.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin: 4px 0 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.confirm-text { margin: 2px 0 4px; color: var(--muted); line-height: 1.7; font-size: 13px; }
.code-block {
  margin: 10px 0 0; padding: 12px 14px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px; line-height: 1.7; word-break: break-all; white-space: pre-wrap;
}
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row .input { flex: 1; }
.help { font-size: 11.5px; color: var(--muted-2); margin: 6px 0 0; line-height: 1.6; }

/* ---------------- 提示 ---------------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  min-width: 200px; max-width: 360px; padding: 11px 15px;
  border-radius: 10px; font-size: 12.8px; line-height: 1.5;
  background: var(--panel-2); border: 1px solid var(--line-2);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .4);
  animation: slide .22s ease both;
}
.toast.ok { border-left: 3px solid var(--teal); }
.toast.err { border-left: 3px solid var(--danger); }
.toast.out { animation: fadeOut .25s ease both; }

/* ---------------- 加载 / 空状态 ---------------- */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 70px 0; color: var(--muted); font-size: 13px; }
.spin { width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(91, 140, 255, .25); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.error-box { padding: 18px; border-radius: 12px; border: 1px solid rgba(197, 48, 70, .3); background: rgba(197, 48, 70, .07); color: var(--danger); font-size: 13px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.empty .big { font-size: 26px; display: block; margin-bottom: 8px; opacity: .5; }

/* ---------------- 动画 ---------------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(6px); } }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .grid.two, .grid.two-even, .grid.three { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-btn { display: grid; }
  .backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(4, 7, 15, .6); backdrop-filter: blur(2px); }
  .view { padding: 18px 16px 44px; }
  .topbar { padding: 12px 16px; }
  .select-wrap span { display: none; }
  .page-head p { display: none; }
  .filter-row input { min-width: 100%; }
}
@media (max-width: 560px) {
  .field-row, .modal .field-row.three { grid-template-columns: 1fr; }
  .grid.two, .grid.three { gap: 12px; }
  .stat .value { font-size: 23px; }
}

/* ---------------- 代理端 ---------------- */
.balance-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 13px; border-radius: 999px; font-size: 12.5px;
  color: var(--teal); background: rgba(22, 143, 131, .09);
  border: 1px solid rgba(22, 143, 131, .24);
}
.balance-pill b { color: var(--text); font-size: 13.5px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.product-card {
  display: flex; flex-direction: column; gap: 12px; padding: 18px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: 14px;
}
.product-card h4 { margin: 0; font-size: 15px; }
.product-card .meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.product-price { font-size: 24px; font-weight: 700; color: var(--teal); letter-spacing: -.5px; }
.product-price small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.product-buy { display: flex; gap: 8px; align-items: center; margin-top: auto; }
.product-buy input {
  width: 78px; padding: 8px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.notice {
  padding: 12px 14px; border-radius: 10px; line-height: 1.7; font-size: 12.5px;
  color: var(--muted); background: rgba(37, 99, 235, .07);
  border: 1px solid rgba(37, 99, 235, .22);
}
