/* 蓝白色调后台样式 */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff4ff;
  --primary-soft: #dbe7ff;
  --bg: #f4f7fc;
  --card: #ffffff;
  --border: #e3e9f3;
  --text: #1e293b;
  --text-2: #475569;
  --text-3: #94a3b8;
  --success: #16a34a;
  --success-bg: #ecfdf3;
  --warning: #d97706;
  --warning-bg: #fff7e6;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(37, 99, 235, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 224px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; border-bottom: 1px solid var(--border); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); position: relative; flex-shrink: 0; }
.brand-mark::after { content: ""; position: absolute; inset: 9px; border: 2px solid #fff; border-radius: 3px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; }
.brand-text small { color: var(--text-3); font-size: 12px; }
.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav-group { color: var(--text-3); font-size: 12px; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: 2px 0; border-radius: 8px;
  color: var(--text-2); text-decoration: none; transition: background .15s, color .15s;
}
.nav a::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); opacity: .5; }
.nav a:hover { background: var(--primary-light); color: var(--primary); }
.nav a.active { background: var(--primary); color: #fff; }
.nav a.active::before { background: #fff; opacity: 1; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 10;
}
.page-title { font-size: 17px; font-weight: 600; }
.top-right { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.top-user { padding: 0 10px; border-right: 1px solid var(--border); margin-right: 4px; }
.content { padding: 22px 24px 40px; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); gap: 10px; flex-wrap: wrap; }
.card-title { font-weight: 600; font-size: 15px; }
.card-sub { color: var(--text-3); font-size: 12px; margin-left: 8px; font-weight: normal; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1280px) { .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-2 { grid-template-columns: 1fr; } }

.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; right: -18px; top: -18px; width: 70px; height: 70px; border-radius: 50%; background: var(--primary-light); }
.stat-label { color: var(--text-2); font-size: 13px; position: relative; z-index: 1; }
.stat-value { font-size: 24px; font-weight: 600; margin-top: 8px; color: var(--text); position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--text-3); font-size: 12px; margin-top: 6px; position: relative; z-index: 1; }
.stat.primary { background: linear-gradient(135deg, #3b82f6, #1d4ed8); border-color: transparent; }
.stat.primary .stat-label, .stat.primary .stat-sub { color: rgba(255, 255, 255, .8); }
.stat.primary .stat-value { color: #fff; }
.stat.primary::after { background: rgba(255, 255, 255, .12); }

/* ---------- 工具栏 / 表单 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.input, .select, .textarea {
  height: 34px; padding: 0 11px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
  font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.textarea { height: auto; min-height: 90px; padding: 8px 11px; resize: vertical; width: 100%; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.w-sm { width: 140px; } .input.w-md { width: 200px; } .input.w-lg { width: 280px; }
.input.full, .select.full { width: 100%; }

.btn {
  height: 34px; padding: 0 15px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text);
  cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .15s; white-space: nowrap; font-family: inherit;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
.btn-text { border-color: transparent; background: transparent; color: var(--text-2); padding: 0 10px; }
.btn-text:hover { background: var(--primary-light); border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 6px; }
.btn-link { border: none; background: none; color: var(--primary); cursor: pointer; padding: 0 4px; font-size: 13px; font-family: inherit; }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }
.btn-block { width: 100%; height: 40px; font-size: 15px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: none; background: transparent; height: 32px; padding: 0 13px; cursor: pointer; color: var(--text-2); font-size: 13px; font-family: inherit; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--primary); color: #fff; }

.form-row { margin-bottom: 15px; }
.form-row > label:not(.switch):not(.check) { display: block; margin-bottom: 6px; color: var(--text-2); font-size: 13px; }
.form-row .hint { color: var(--text-3); font-size: 12px; margin-top: 5px; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.inline { display: flex; align-items: center; gap: 10px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 11px; background: #cbd5e1; position: relative; transition: background .2s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:disabled + .track { opacity: .5; }
.switch .switch-text { color: var(--text-2); font-size: 13px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text-2); }
.check input { accent-color: var(--primary); width: 15px; height: 15px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { background: #f8fafd; color: var(--text-2); font-weight: 500; font-size: 13px; }
.table tbody tr:hover { background: #f8fbff; }
.table td.wrap { white-space: normal; word-break: break-all; min-width: 160px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .ops { display: flex; gap: 4px; }
.table tr.clickable { cursor: pointer; }
.empty { padding: 42px 0; text-align: center; color: var(--text-3); }
.muted { color: var(--text-3); }
.mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 12.5px; }
.amount { color: var(--primary); font-weight: 600; font-variant-numeric: tabular-nums; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 12px 16px; color: var(--text-2); font-size: 13px; }
.pager .btn { height: 28px; min-width: 32px; padding: 0 8px; font-size: 13px; }
.pager .btn.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; background: #f1f5f9; color: var(--text-2); gap: 5px; }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.blue { background: var(--primary-light); color: var(--primary); }
.badge.green { background: var(--success-bg); color: var(--success); }
.badge.orange { background: var(--warning-bg); color: var(--warning); }
.badge.red { background: var(--danger-bg); color: var(--danger); }
.badge.gray { background: #f1f5f9; color: var(--text-3); }

/* ---------- 弹窗 / 提示 ---------- */
.mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .38); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 60px 16px; overflow-y: auto; animation: fade .15s; }
.dialog { background: #fff; border-radius: 12px; width: 520px; max-width: 100%; box-shadow: 0 20px 60px rgba(15, 23, 42, .2); animation: rise .18s; }
.dialog.wide { width: 860px; }
.dialog-head { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.dialog-title { font-size: 16px; font-weight: 600; }
.dialog-close { border: none; background: none; cursor: pointer; width: 30px; height: 30px; border-radius: 6px; position: relative; }
.dialog-close::before, .dialog-close::after { content: ""; position: absolute; left: 8px; top: 14px; width: 14px; height: 2px; background: var(--text-3); }
.dialog-close::before { transform: rotate(45deg); } .dialog-close::after { transform: rotate(-45deg); }
.dialog-close:hover { background: #f1f5f9; }
.dialog-body { padding: 20px 22px; max-height: calc(100vh - 220px); overflow-y: auto; }
.dialog-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }

.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary); padding: 10px 18px; border-radius: 8px; box-shadow: 0 8px 24px rgba(15, 23, 42, .12); color: var(--text); animation: rise .2s; max-width: 480px; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

.notice { background: var(--primary-light); border: 1px solid var(--primary-soft); color: var(--primary-dark); padding: 10px 14px; border-radius: 8px; font-size: 13px; line-height: 1.6; margin-bottom: 14px; }
.notice.warn { background: var(--warning-bg); border-color: #fde3b5; color: #92400e; }
.secret-box { background: #f8fafd; border: 1px dashed var(--primary); border-radius: 8px; padding: 12px; font-family: Consolas, monospace; word-break: break-all; font-size: 13px; }
.qr { display: block; margin: 6px auto 12px; width: 200px; height: 200px; border: 1px solid var(--border); border-radius: 8px; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 10px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; word-break: break-all; }

/* ---------- 图表 ---------- */
.chart { width: 100%; height: 280px; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .grid-line { stroke: #eef2f8; stroke-width: 1; }
.chart .tick { fill: var(--text-3); font-size: 11px; }
.chart .line { fill: none; stroke-width: 2.2; }
.chart .area { opacity: .12; }
.chart .dot { stroke: #fff; stroke-width: 2; }
.legend { display: flex; gap: 18px; color: var(--text-2); font-size: 12.5px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 24px 120px 1fr 90px; align-items: center; gap: 10px; font-size: 13px; }
.bar-rank { width: 22px; height: 22px; border-radius: 6px; background: #f1f5f9; color: var(--text-2); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.bar-rank.top { background: var(--primary); color: #fff; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: #eef2f8; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb); border-radius: 4px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

/* ---------- 登录页 ---------- */
.login-page { min-height: 100vh; display: flex; background: linear-gradient(135deg, #eef4ff 0%, #f8fbff 50%, #e6efff 100%); }
.login-side { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 60px 8vw; color: var(--text); position: relative; overflow: hidden; }
.login-side::before { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: radial-gradient(circle, rgba(37, 99, 235, .14), transparent 70%); left: -120px; bottom: -160px; }
.login-side h1 { font-size: 34px; margin: 0 0 14px; font-weight: 700; color: #0f2a6b; position: relative; }
.login-side p { color: var(--text-2); font-size: 15px; line-height: 1.8; max-width: 440px; margin: 0; position: relative; }
.login-points { margin-top: 28px; display: flex; flex-direction: column; gap: 12px; position: relative; }
.login-points div { display: flex; align-items: center; gap: 10px; color: var(--text-2); }
.login-points div::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--primary); }
.login-panel { width: 460px; display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: 100%; background: #fff; border-radius: 16px; padding: 36px 34px; box-shadow: 0 20px 50px rgba(37, 99, 235, .12); border: 1px solid var(--border); }
.login-card h2 { margin: 0 0 6px; font-size: 22px; }
.login-card .sub { color: var(--text-3); margin-bottom: 26px; font-size: 13px; }
.login-card .input { height: 42px; width: 100%; font-size: 15px; }
.login-card .form-row { margin-bottom: 18px; }
.login-err { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 8px; }
.code-input { letter-spacing: 8px; text-align: center; font-family: Consolas, monospace; font-size: 20px !important; }
@media (max-width: 900px) { .login-side { display: none; } .login-panel { width: 100%; } }
