/* 弹幕游戏平台：平台端 / 用户端 / 登录页共用样式 */
:root {
  --primary: #7c3aed;
  --primary-d: #6d28d9;
  --primary-l: #f3edff;
  --bg: #f4f5fa;
  --card: #fff;
  --text: #1f2330;
  --muted: #6b7280;
  --line: #e7e8ef;
  --side: #1d1b2e;
  --side-2: #2a2742;
  --green: #16a34a;
  --orange: #ea7a0c;
  --red: #dc2626;
  --blue: #2563eb;
  --gray: #6b7280;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 50, .05), 0 2px 10px rgba(20, 20, 50, .05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.warn-text { color: var(--orange); }
.danger-text { color: var(--red); }
.ok-text { color: var(--green); }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 16px; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.side { width: 220px; flex: none; background: var(--side); color: #cfcbe6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand b { display: block; color: #fff; font-size: 17px; letter-spacing: 1px; }
.brand b::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: linear-gradient(135deg, #a78bfa, #f97316); margin-right: 8px; vertical-align: 1px; }
.brand span { font-size: 12px; color: #8f8aad; margin-left: 18px; }
.menu { padding: 10px 0; flex: 1; overflow-y: auto; }
.menu a { display: flex; align-items: center; gap: 10px; padding: 11px 22px; color: #cfcbe6; text-decoration: none; border-left: 3px solid transparent; }
.menu a:hover { background: var(--side-2); color: #fff; }
.menu a.active { background: var(--side-2); color: #fff; border-left-color: #a78bfa; }
.menu .ico { width: 18px; text-align: center; opacity: .85; }
.side-foot { padding: 14px 20px; font-size: 12px; color: #77729a; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 10; }
.topbar .title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar .who { color: var(--muted); }
.topbar .who b { color: var(--text); font-weight: 500; }
.content { padding: 22px 24px 40px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 20px; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title h3 { font-size: 15px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; border-top: 3px solid var(--primary); }
.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 24px; font-weight: 600; margin-top: 6px; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.orange { border-top-color: var(--orange); }
.stat.green { border-top-color: var(--green); }
.stat.blue { border-top-color: var(--blue); }
.stat.red { border-top-color: var(--red); }

.notice { background: var(--primary-l); color: #4c2a93; border-radius: 8px; padding: 10px 14px; font-size: 13px; line-height: 1.7; }
.notice.warn { background: #fff4e5; color: #8a4b05; }
.notice.danger { background: #fdecec; color: #8f1d1d; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); background: #fafafd; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:nth-child(even) td { background: #fbfbfe; }
.tbl tbody tr:hover td { background: #f6f2ff; }
.tbl tr.hl td { background: #fff6e8 !important; }
.tbl tr.click { cursor: pointer; }
.tbl td.ops { white-space: nowrap; }
.tbl td.ops .btn + .btn { margin-left: 4px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 徽标 ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; line-height: 18px; white-space: nowrap; background: #eef0f4; color: var(--gray); }
.badge.green { background: #e5f6ec; color: #13803c; }
.badge.orange { background: #fff1de; color: #b45309; }
.badge.red { background: #fde8e8; color: #b91c1c; }
.badge.blue { background: #e6efff; color: #1d4ed8; }
.badge.purple { background: var(--primary-l); color: var(--primary-d); }
.badge.gray { background: #eef0f4; color: #4b5563; }

/* ---------- 按钮、表单 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--text); font: inherit; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { border-color: #c9c3e8; background: #faf8ff; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { color: var(--red); border-color: #f2c4c4; }
.btn.danger:hover { background: #fff5f5; }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn.link { border: none; background: none; color: var(--primary); padding: 0 6px; height: auto; }
.btn.link.danger { color: var(--red); }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.input, select.input, textarea.input { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; font: inherit; color: var(--text); background: #fff; outline: none; min-width: 0; }
textarea.input { height: auto; padding: 8px 10px; min-height: 70px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124, 58, 237, .12); }
.input.sm { height: 28px; font-size: 12.5px; }
.form { display: grid; gap: 14px; }
.field label.lbl { display: block; font-size: 13px; color: #374151; margin-bottom: 6px; font-weight: 500; }
.field .input { width: 100%; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.field .req { color: var(--red); margin-left: 2px; }
.form .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #fff; }
.seg button { border: none; background: none; padding: 0 12px; height: 32px; font: inherit; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--primary); color: #fff; }

/* 开关 */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 22px; background: #d1d5db; border-radius: 99px; position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { left: 21px; }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(124, 58, 237, .25); }

/* ---------- 弹窗 ---------- */
.mask { position: fixed; inset: 0; background: rgba(17, 15, 35, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 100; overflow-y: auto; animation: fade .12s; }
.dialog { background: #fff; border-radius: 12px; width: 520px; max-width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.25); display: flex; flex-direction: column; }
.dialog.wide { width: 820px; }
.dialog-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.dialog-head h3 { font-size: 16px; }
.dialog-head .x { border: none; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.dialog-body { padding: 18px 20px; max-height: 70vh; overflow-y: auto; }
.dialog-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 提示 ---------- */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #1f2330; color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); font-size: 13.5px; max-width: 90vw; animation: fade .15s; }
.toast.ok { background: #15803d; }
.toast.err { background: #b91c1c; }
.toast.warn { background: #b45309; }

/* ---------- 空状态、加载 ---------- */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty::before { content: "∅"; display: block; font-size: 28px; color: #c7c9d3; margin-bottom: 6px; }
.loading { text-align: center; padding: 40px 16px; color: var(--muted); }
.loading::before { content: ""; display: inline-block; width: 16px; height: 16px; border: 2px solid #d6d0f0; border-top-color: var(--primary); border-radius: 50%; margin-right: 8px; vertical-align: -3px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 图表 ---------- */
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; width: 100%; height: auto; min-width: 360px; }
.chart .legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.chart .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- 游戏卡片（用户端） ---------- */
.game-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.game-card { display: flex; flex-direction: column; gap: 12px; }
.game-card .gc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.game-card .gc-name { font-size: 18px; font-weight: 600; }
.game-card .gc-desc { color: #4b5563; line-height: 1.6; font-size: 13px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.urlbox { display: flex; gap: 8px; }
.urlbox .input { flex: 1; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: #fafafd; }
ol.steps { margin: 6px 0 0; padding-left: 20px; line-height: 1.8; color: #374151; font-size: 13px; }
.gift-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.gift-list .gi { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.gift-list .gi:last-child { border-bottom: none; }
.gift-list .gi:hover { background: #f6f2ff; }
.gift-list .gi.in { background: #f2fbf5; }
.gift-list .gi .nm { flex: 1; }
.tbl input.input { width: 100%; }
.pre { white-space: pre-wrap; word-break: break-all; }

/* ---------- 登录页 ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #e9ddff 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #ffe6cf 0%, transparent 60%), var(--bg); }
.login-box { width: 380px; max-width: 100%; background: #fff; border-radius: 14px; box-shadow: 0 10px 40px rgba(60, 40, 120, .12); padding: 34px 32px 26px; }
.login-box h1 { font-size: 22px; text-align: center; }
.login-box .sub { text-align: center; color: var(--muted); margin: 8px 0 24px; font-size: 13px; }
.login-box .btn.primary { width: 100%; height: 40px; font-size: 15px; }
.login-box .tips { margin-top: 18px; font-size: 12.5px; color: var(--muted); background: #fafafd; border-radius: 8px; padding: 10px 12px; line-height: 1.8; }

/* ---------- 窄屏 ---------- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; }
  .brand { padding: 12px 16px; display: flex; align-items: baseline; gap: 6px; }
  .brand span { margin-left: 0; }
  .menu { display: flex; overflow-x: auto; padding: 0; }
  .menu a { padding: 10px 14px; border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
  .menu a.active { border-bottom-color: #a78bfa; }
  .side-foot { display: none; }
  .topbar { padding: 0 14px; position: static; }
  .content { padding: 14px; }
  .grid.cols-2, .grid.cols-3, .form .cols { grid-template-columns: 1fr; }
  .game-cards { grid-template-columns: 1fr; }
  .topbar .who span.hide-sm { display: none; }
}
