:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-light: #eff6ff;
  --side: #0f172a;
  --side-hover: #1e293b;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f6f8fb;
  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% 0%, #1e3a8a 0%, #0f172a 55%, #020617 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 18px;
  padding: 40px 36px 32px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.login-logo {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #7c3aed); font-size: 28px; margin-bottom: 20px;
}
.login-card h1 { font-size: 24px; letter-spacing: .5px; }
.login-card .sub { color: var(--muted); margin-top: 6px; margin-bottom: 26px; font-size: 13px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: #334155; margin-bottom: 7px; font-weight: 600; }
.input, .select, .textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--border); border-radius: 9px;
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
.textarea { resize: vertical; min-height: 76px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 9px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .06s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; padding: 12px; font-size: 15px; }
.btn.ghost { background: #fff; color: #334155; border-color: var(--border); }
.btn.ghost:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #047857; }
.alert {
  padding: 10px 13px; border-radius: 9px; font-size: 13px; margin-bottom: 14px;
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
}
.alert.ok { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert.warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }

/* ---------- 主框架 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--side); color: #cbd5e1; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand {
  padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 11px;
}
.brand .mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #7c3aed); font-size: 19px;
}
.brand .t { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: .5px; }
.brand .s { font-size: 11px; color: #64748b; margin-top: 1px; }
.nav { padding: 14px 10px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  cursor: pointer; color: #94a3b8; font-size: 14px; margin-bottom: 3px; transition: all .13s;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--side-hover); color: #e2e8f0; }
.nav-item.on { background: linear-gradient(90deg, rgba(37,99,235,.9), rgba(37,99,235,.55)); color: #fff; font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; }
.side-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.07); font-size: 11.5px; color: #475569; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 26px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .h { font-size: 16px; font-weight: 700; }
.topbar .r { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-light);
  color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.content { padding: 24px 26px 40px; flex: 1; }
.page { max-width: 1280px; }

/* ---------- 卡片 ---------- */
.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden;
}
.card-hd { padding: 16px 20px; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-hd h2 { font-size: 15px; font-weight: 700; }
.card-hd .desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.card-bd { padding: 20px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::after {
  content: ''; position: absolute; right: -20px; top: -20px; width: 74px; height: 74px;
  border-radius: 50%; background: var(--brand-light); opacity: .8;
}
.stat .k { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.stat .v { font-size: 27px; font-weight: 800; letter-spacing: -.5px; position: relative; }
.stat.ok .v { color: var(--ok); }
.stat.warn .v { color: var(--warn); }
.stat.danger .v { color: var(--danger); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; padding: 11px 14px; background: #f8fafc; color: #475569;
  font-weight: 600; font-size: 12.5px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; letter-spacing: .3px; font-weight: 600; }
.badge {
  display: inline-block; padding: 2.5px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
}
.badge.active { background: #ecfdf5; color: #047857; }
.badge.unused { background: #eff6ff; color: #1d4ed8; }
.badge.expired { background: #fef2f2; color: #b91c1c; }
.badge.disabled { background: #f1f5f9; color: #64748b; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 54px 20px; text-align: center; color: var(--muted); }
.empty .ico { font-size: 38px; opacity: .35; margin-bottom: 12px; }

/* ---------- 发码结果 ---------- */
.codes-box {
  background: #0f172a; border-radius: 10px; padding: 16px 18px; margin-top: 4px;
  font-family: ui-monospace, Consolas, monospace; font-size: 14px; color: #7dd3fc;
  line-height: 2.1; max-height: 300px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex;
  align-items: center; justify-content: center; z-index: 1000; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 620px;
  max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.modal-hd { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-hd h3 { font-size: 16px; }
.modal-bd { padding: 20px 22px; overflow-y: auto; }
.modal-ft { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.x-btn { background: none; border: none; font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1; padding: 4px; }
.x-btn:hover { color: var(--text); }

/* ---------- 提示条 ---------- */
.toast-host { position: fixed; top: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: #0f172a; color: #fff; padding: 11px 17px; border-radius: 10px; font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,.24); animation: tin .2s ease-out; max-width: 380px;
}
.toast.ok { background: #059669; }
.toast.err { background: #dc2626; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.loading-row { padding: 40px; text-align: center; color: var(--muted); }

.list-item {
  display: flex; justify-content: space-between; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid #f1f5f9; font-size: 13.5px;
}
.list-item:last-child { border-bottom: none; }
.list-item .l { color: var(--muted); }
.list-item .r { text-align: right; }

@media (max-width: 760px) {
  .sidebar { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}
