:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e3e8ee;
  --text: #1f2937;
  --text-2: #6b7280;
  --primary: #2f6fed;
  --primary-dark: #2459c4;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
  --mono: 'Cascadia Code', Consolas, 'SF Mono', Menlo, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }

/* 登录 */
.view-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #eef3fb, #f8fafc); }
.login-card { width: min(92vw, 360px); background: var(--surface); border-radius: 16px; box-shadow: 0 12px 40px rgba(16,24,40,.12); padding: 32px 28px; }
.login-logo { font-size: 22px; font-weight: 800; letter-spacing: .2px; }
.login-sub { color: var(--text-2); margin: 6px 0 22px; font-size: 13px; }

/* 布局 */
.view-main { display: flex; min-height: 100vh; }
.sidebar { width: 208px; background: #111827; color: #e5e7eb; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 800; font-size: 17px; padding: 6px 10px 18px; color: #fff; }
.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: block; padding: 10px 12px; border-radius: 8px; color: #cbd5e1; text-decoration: none; cursor: pointer; font-weight: 500; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; color: #9ca3af; font-size: 13px; }
.main { flex: 1; padding: 26px 30px; max-width: 1080px; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 18px; }

/* 卡片 / 统计 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card-title { font-weight: 700; font-size: 15px; margin-bottom: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stat-num { font-size: 28px; font-weight: 800; }
.stat-label { color: var(--text-2); margin-top: 4px; font-size: 13px; }
.muted-list { padding-left: 18px; color: var(--text-2); line-height: 1.9; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-2); }
.input, select.input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; color: var(--text); outline: none; }
.input:focus { border-color: var(--primary); }
.form-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px; }
.form-msg { margin-top: 12px; font-size: 13px; color: var(--success); }
.form-msg.error { color: var(--danger); }

/* 按钮 */
.btn { border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; transition: .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border: 1.5px solid var(--border); color: var(--text-2); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 工具栏 / 表格 */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.quick-grant-card { border-left: 4px solid var(--primary); }
.quick-grant { display: grid; grid-template-columns: 1.2fr 1.8fr auto; gap: 14px; align-items: end; }
.quick-grant-btns label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-2); }
@media (max-width: 860px) {
  .quick-grant { grid-template-columns: 1fr; }
}
.table-wrap { padding: 8px 14px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; padding: 10px 8px; border-bottom: 1.5px solid var(--border); }
.table td { padding: 11px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.tier-tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tier-none { background: #f3f4f6; color: #6b7280; }
.tier-personal { background: #ecfdf5; color: #047857; }
.tier-pplus { background: #eff6ff; color: #1d4ed8; }
.tier-free, .tier-premium { background: #fefce8; color: #a16207; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 12px 0 4px; color: var(--text-2); font-size: 13px; }

/* 生成器 */
.gen-result { margin-top: 18px; background: #f8fafc; border: 1.5px dashed var(--border); border-radius: 10px; padding: 16px; text-align: center; }
.gen-label { font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.gen-code { font-size: 26px; font-weight: 700; letter-spacing: 4px; color: var(--primary); font-family: var(--mono); margin-bottom: 10px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: min(94vw, 560px); max-height: 86vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; position: sticky; top: 0; background: #fff; }
.modal-close { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--text-2); line-height: 1; }
.modal-body { padding: 18px 20px 22px; }
.ent-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.ent-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.ent-name { font-weight: 600; font-size: 14px; }
.ent-status { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.ent-actions { display: flex; gap: 6px; flex: none; }

/* Toast */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; z-index: 99; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
@media (max-width: 720px) {
  .sidebar { width: 72px; padding: 14px 8px; }
  .brand { font-size: 0; padding: 6px 4px 14px; }
  .brand::first-letter { font-size: 17px; }
  .nav-item { text-align: center; padding: 10px 4px; font-size: 12px; }
  .sidebar-foot span { display: none; }
  .main { padding: 18px 14px; }
}
