:root {
  --bg: #07090f;
  --bg-2: #0b0f19;
  --panel: rgba(17, 22, 36, 0.72);
  --panel-2: rgba(22, 28, 46, 0.7);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #e8ecf5;
  --text-2: #a6b0c6;
  --text-3: #6f7a93;
  --brand: #7c5cff;
  --brand-2: #20d3c2;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --info: #60a5fa;
  --radius: 16px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --font: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.5; overflow-x: hidden;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* 背景 */
.bg-orb { position: fixed; border-radius: 50%; filter: blur(90px); opacity: 0.55; pointer-events: none; z-index: 0; }
.orb-a { width: 620px; height: 620px; left: -220px; top: -260px; background: radial-gradient(circle at 30% 30%, #7c5cff, transparent 65%); animation: drift 26s ease-in-out infinite alternate; }
.orb-b { width: 560px; height: 560px; right: -200px; bottom: -240px; background: radial-gradient(circle at 60% 60%, #20d3c2, transparent 65%); animation: drift 30s ease-in-out infinite alternate-reverse; }
@keyframes drift { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(60px, 40px, 0) scale(1.08); } }
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.35;
  background-image: linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: radial-gradient(ellipse at 50% 0%, #000 30%, transparent 80%);
}
.glass {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); box-shadow: var(--shadow);
}
.view { position: relative; z-index: 1; }

/* 品牌 */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 8px 24px rgba(124, 92, 255, 0.35);
}
.brand.compact .brand-mark { width: 32px; height: 32px; border-radius: 10px; font-size: 16px; }
.brand-name { font-weight: 700; letter-spacing: 0.2px; font-size: 18px; }
.brand.compact .brand-name { font-size: 15px; }
.brand-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }

/* 登录 */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; padding: 32px 30px 24px; animation: rise 0.5s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.login-card form { margin-top: 26px; display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field span { font-size: 12px; color: var(--text-2); }
.field input, textarea, select, .note-input, #f-q {
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, textarea:focus, select:focus, .note-input:focus, #f-q:focus { border-color: rgba(124,92,255,0.7); box-shadow: 0 0 0 3px rgba(124,92,255,0.18); }
.form-error { color: var(--bad); font-size: 12.5px; min-height: 16px; }
.login-foot { margin-top: 18px; text-align: center; color: var(--text-3); font-size: 12px; }

/* 按钮 */
.btn {
  border: 1px solid var(--line-2); background: rgba(255,255,255,0.05); color: var(--text); border-radius: 10px; padding: 9px 14px; cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s, opacity .15s; white-space: nowrap; font-weight: 500;
}
.btn:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.22); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, #7c5cff, #5b8cff); border-color: transparent; color: #fff; box-shadow: 0 8px 20px rgba(124,92,255,.32); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.accent { background: linear-gradient(135deg, #20d3c2, #3ba7ff); border-color: transparent; color: #04121a; font-weight: 600; box-shadow: 0 8px 20px rgba(32,211,194,.28); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(248,113,113,.5); color: #fecaca; }
.btn.ok { border-color: rgba(52,211,153,.5); color: #bbf7d0; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.xs { padding: 3px 8px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }

/* 顶栏 */
.topbar {
  position: sticky; top: 12px; z-index: 5; margin: 12px 20px 0; padding: 10px 16px; display: flex; align-items: center; gap: 18px; border-radius: 14px;
}
.sys { display: flex; gap: 14px; align-items: center; color: var(--text-2); font-size: 12.5px; flex: 1; flex-wrap: wrap; }
.sys-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); box-shadow: 0 0 0 3px rgba(255,255,255,.05); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(52,211,153,.18); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px rgba(248,113,113,.18); }
.dot.busy { background: var(--warn); box-shadow: 0 0 0 3px rgba(251,191,36,.18); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-name { font-weight: 600; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-2); }
.chip.admin { color: #e9d5ff; border-color: rgba(167,139,250,.55); background: rgba(124,92,255,.15); }

/* 布局 */
.layout { position: relative; z-index: 1; padding: 20px; display: grid; gap: 18px; max-width: 1500px; margin: 0 auto; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat { padding: 16px 18px; }
.stat-k { color: var(--text-3); font-size: 12px; }
.stat-v { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-v.accent { color: #c4b5fd; } .stat-v.ok { color: var(--ok); } .stat-v.warn { color: var(--warn); }
.stat-s { color: var(--text-3); font-size: 12px; margin-top: 2px; }

.entries { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.entry { padding: 20px 20px 16px; position: relative; overflow: hidden; }
.entry::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: linear-gradient(90deg, var(--brand), transparent); opacity: .8; }
.entry[data-mode="kick"]::before { background: linear-gradient(90deg, var(--brand-2), transparent); }
.entry-head { display: flex; gap: 14px; align-items: flex-start; }
.entry-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; font-weight: 700; flex: none; }
.entry-icon.full { background: rgba(124,92,255,.18); color: #c4b5fd; border: 1px solid rgba(124,92,255,.35); }
.entry-icon.kick { background: rgba(32,211,194,.14); color: #99f6e4; border: 1px solid rgba(32,211,194,.35); }
.entry h2 { margin: 0; font-size: 18px; }
.entry p { margin: 4px 0 0; color: var(--text-2); font-size: 12.5px; line-height: 1.55; }
.entry-form { margin-top: 14px; display: grid; gap: 10px; }
.entry-form textarea { width: 100%; resize: vertical; min-height: 120px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.entry-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.select { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 12.5px; }
.select select { padding: 8px 10px; }
.note-input { flex: 1; min-width: 160px; padding: 8px 10px; }
.entry-result { font-size: 12.5px; color: var(--text-2); display: grid; gap: 4px; }
.entry-result .ok { color: var(--ok); } .entry-result .bad { color: var(--bad); } .entry-result .warn { color: var(--warn); }
.entry-result ul { margin: 2px 0 0; padding-left: 18px; }

/* 台账 */
.ledger { padding: 16px 18px 12px; }
.ledger-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.ledger-title { display: flex; align-items: baseline; gap: 10px; }
.ledger-title h2 { margin: 0; font-size: 18px; }
.ledger-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ledger-tools select, .ledger-tools input { padding: 7px 10px; font-size: 12.5px; }
#f-q { width: 240px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 6px 12px; cursor: pointer; color: var(--text-2); font-size: 12.5px; }
.seg button.on { background: rgba(124,92,255,.22); color: #fff; }
.table-wrap { margin-top: 12px; overflow: auto; border-radius: 12px; border: 1px solid var(--line); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 1100px; }
.table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--text-3); background: rgba(255,255,255,.03); padding: 10px 12px; position: sticky; top: 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.05); vertical-align: top; font-size: 13px; }
.table tbody tr { transition: background .12s; cursor: pointer; }
.table tbody tr:hover { background: rgba(255,255,255,.035); }
.table tbody tr.row-new { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: rgba(124,92,255,.22); } to { background: transparent; } }
.th-actions { text-align: right !important; }
.td-actions { text-align: right; white-space: nowrap; }
.td-actions .btn { margin-left: 4px; }
.email { font-family: var(--mono); font-size: 12.5px; }
.note-cell { max-width: 380px; color: var(--text-2); font-size: 12.5px; white-space: normal; word-break: break-all; }
.mode-tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: 600; letter-spacing: .2px; }
.mode-tag.full { background: rgba(124,92,255,.18); color: #c4b5fd; }
.mode-tag.kick { background: rgba(32,211,194,.14); color: #99f6e4; }
.mb-tag { font-size: 11px; color: var(--text-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; font-weight: 500; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.queued { color: #cbd5e1; background: rgba(148,163,184,.12); border-color: rgba(148,163,184,.3); }
.pill.running { color: #c4b5fd; background: rgba(124,92,255,.14); border-color: rgba(124,92,255,.4); }
.pill.running::before { animation: pulse 1.2s infinite; }
.pill.kick_ok { color: #99f6e4; background: rgba(32,211,194,.12); border-color: rgba(32,211,194,.4); }
.pill.refund_sent { color: #93c5fd; background: rgba(96,165,250,.12); border-color: rgba(96,165,250,.4); }
.pill.needs_info { color: #fde68a; background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.45); }
.pill.refunded { color: #86efac; background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.45); }
.pill.denied { color: #fca5a5; background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.45); }
.pill.failed { color: #fda4af; background: rgba(251,113,133,.12); border-color: rgba(251,113,133,.45); }
.pill.rejected { color: #d6d3d1; background: rgba(168,162,158,.12); border-color: rgba(168,162,158,.4); }
.tiny { font-size: 11px; color: var(--text-3); }
.empty { padding: 36px; text-align: center; color: var(--text-3); }
.pager { display: flex; justify-content: flex-end; gap: 6px; padding: 10px 2px 0; align-items: center; color: var(--text-3); font-size: 12.5px; }

/* 抽屉 */
.drawer { position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(520px, 94vw); z-index: 20; display: flex; flex-direction: column; animation: slide .25s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 16px 18px 10px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 2px 0 0; font-size: 15px; font-family: var(--mono); word-break: break-all; }
.drawer-body { padding: 14px 18px 18px; overflow: auto; display: grid; gap: 14px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; word-break: break-all; }
.d-note { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; white-space: pre-wrap; color: var(--text-2); }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.timeline { display: grid; gap: 8px; }
.tl { display: grid; grid-template-columns: 14px 1fr; gap: 10px; align-items: start; font-size: 12.5px; }
.tl i { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; background: var(--text-3); }
.tl.done i { background: var(--ok); } .tl.now i { background: var(--brand); box-shadow: 0 0 0 3px rgba(124,92,255,.22); } .tl.bad i { background: var(--bad); }
.tl b { font-weight: 600; } .tl .tiny { display: block; }

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(3,5,10,.55); display: grid; place-items: center; padding: 20px; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card { width: 100%; max-width: 760px; max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 18px; overflow: auto; display: grid; gap: 12px; }
.modal-body form { display: grid; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.users-table td, .users-table th { padding: 8px 10px; }
.users-table { min-width: 0; }
.modal-card.wide { max-width: 1080px; }

/* Toast */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 40; display: grid; gap: 8px; }
.toast { padding: 10px 14px; border-radius: 10px; background: rgba(20,26,40,.92); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 13px; animation: rise .25s ease-out; max-width: 420px; }
.toast.ok { border-color: rgba(52,211,153,.5); } .toast.bad { border-color: rgba(248,113,113,.55); } .toast.warn { border-color: rgba(251,191,36,.5); }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .entries { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { margin: 8px 8px 0; flex-wrap: wrap; }
  .layout { padding: 12px 8px; }
  .stats { grid-template-columns: 1fr 1fr; }
  #f-q { width: 100%; }
}
