* { box-sizing: border-box; }
:root {
  --sidebar-bg: #111622;
  --sidebar-hover: #1c2436;
  --sidebar-active: #2563eb;
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
}
html, body { margin: 0; padding: 0; height: 100%; font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }
[hidden] { display: none !important; }

.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 20% 20%, #1e293b 0%, #0b101b 70%); padding: 24px; }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; padding: 30px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); display: flex; flex-direction: column; gap: 16px; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand h1 { margin: 0; font-size: 19px; }
.auth-brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.brand-badge { width: 42px; height: 42px; border-radius: 11px; background: linear-gradient(135deg, #2563eb, #3b82f6); color: #fff; font-weight: 800; font-size: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-badge.sm { width: 34px; height: 34px; font-size: 16px; border-radius: 9px; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 224px; background: var(--sidebar-bg); color: #cbd5e1; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 18px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar-header strong { display: block; color: #fff; font-size: 15px; }
.sidebar-header small { color: #94a3b8; font-size: 11px; }
.nav-list { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.nav-btn { width: 100%; text-align: left; border: 0; background: transparent; color: #cbd5e1; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; display: flex; align-items: center; gap: 10px; transition: .15s; }
.nav-btn:hover { background: var(--sidebar-hover); color: #fff; }
.nav-btn.active { background: rgba(37, 99, 235, .24); color: #60a5fa; font-weight: 600; box-shadow: inset 3px 0 0 #3b82f6; }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.07); display: flex; flex-direction: column; gap: 8px; }
.admin-identity { font-size: 12px; color: #94a3b8; word-break: break-all; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 58px; background: #fff; border-bottom: 1px solid var(--border); padding: 0 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.topbar h2 { margin: 0; font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.toast { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; padding: 5px 12px; border-radius: 999px; font-size: 12px; }
.toast.err { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.page-body { padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 18px; max-width: 1320px; width: 100%; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; box-shadow: 0 1px 3px rgba(15, 23, 42, .04); }
.card-title { margin: 0 0 14px; font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-sub { margin: -8px 0 14px; font-size: 12px; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 14px; }
.stat-box { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.stat-box .label { font-size: 12px; color: var(--muted); }
.stat-box .val { font-size: 26px; font-weight: 800; margin-top: 6px; color: var(--text); }
.stat-box .val.ok { color: var(--ok); }
.stat-box .val.blue { color: var(--primary); }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #334155; font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 11px; font-size: 13.5px; font-family: inherit; color: var(--text); background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea { resize: vertical; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.inline-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }

.btn { border: 1px solid #cbd5e1; background: #fff; color: #1e293b; border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer; font-weight: 500; transition: .15s; white-space: nowrap; }
.btn:hover { background: #f8fafc; border-color: #94a3b8; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: #fff; border-color: #fca5a5; color: var(--danger); }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.15); color: #e2e8f0; }
.btn.ghost:hover { background: rgba(255,255,255,.12); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.full { width: 100%; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #f8fafc; color: #475569; font-weight: 600; white-space: nowrap; }
tr:hover td { background: #f8fafc; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.admin { background: #ede9fe; color: #6d28d9; }
.badge.staff { background: #dbeafe; color: #1d4ed8; }
.badge.vip3, .badge.vip2, .badge.vip1 { background: #fef3c7; color: #b45309; }
.badge.free { background: #f1f5f9; color: #64748b; }
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.warn { background: #ffedd5; color: #c2410c; }
.badge.err { background: #fee2e2; color: #b91c1c; }

.qr-upload-box { width: 148px; height: 148px; border: 1.5px dashed #cbd5e1; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; background: #f8fafc; overflow: hidden; position: relative; }
.qr-upload-box img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.qr-upload-box span { color: var(--muted); font-size: 12px; text-align: center; padding: 8px; }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.alert.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert.info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-card { width: 100%; max-width: 580px; max-height: 90vh; overflow-y: auto; background: #fff; border-radius: 14px; padding: 22px 24px; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.code-box { font-family: Consolas, monospace; background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; font-size: 12.5px; max-height: 220px; overflow: auto; white-space: pre-wrap; }
