/* ================================================================
   弹窗激活码管理系统 · 后台样式
   ================================================================ */
:root {
    --brand: #4f46e5;
    --brand-2: #7c3aed;
    --brand-soft: #eef2ff;
    --ink: #111827;
    --ink-2: #374151;
    --muted: #6b7280;
    --muted-2: #9ca3af;
    --line: #e8ebf2;
    --line-2: #f1f3f8;
    --bg: #f5f6fa;
    --card: #ffffff;
    --green: #059669;
    --amber: #d97706;
    --red: #dc2626;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .04);
    --shadow: 0 8px 24px -12px rgba(16, 24, 40, .18);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: #4338ca; }
code { font-family: var(--mono); font-size: .92em; background: #f3f4f6; padding: 1px 5px; border-radius: 5px; color: #4b5563; }

/* ---------------- 布局 ---------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: #fff;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 22px 20px 18px;
}
.brand-logo {
    width: 34px; height: 34px; flex: 0 0 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    display: grid; place-items: center;
    font-size: 17px;
    box-shadow: 0 6px 14px -6px rgba(99, 102, 241, .9);
}
.brand b { display: block; font-size: 14.5px; letter-spacing: -.01em; line-height: 1.2; }
.brand small { display: block; font-size: 11px; color: var(--muted-2); letter-spacing: .06em; text-transform: uppercase; margin-top: 2px; }

.nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 700; color: var(--muted-2); letter-spacing: .08em; padding: 14px 10px 6px; text-transform: uppercase; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    height: 40px; padding: 0 11px;
    border-radius: 9px;
    color: var(--ink-2);
    font-size: 13.5px;
    font-weight: 500;
    transition: .15s;
}
.nav-item svg { width: 17px; height: 17px; opacity: .62; flex: 0 0 17px; }
.nav-item:hover { background: #f7f8fc; color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.nav-item .nav-count {
    margin-left: auto; font-size: 11.5px; font-weight: 600;
    background: #f3f4f6; color: var(--muted); padding: 1px 7px; border-radius: 99px;
}
.nav-item.active .nav-count { background: #fff; color: var(--brand); }

.sidebar-foot {
    margin-top: auto;
    padding: 14px 20px 18px;
    font-size: 11.5px;
    color: var(--muted-2);
    border-top: 1px solid var(--line-2);
}
.sidebar-foot a { color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 62px;
    flex: 0 0 62px;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 14px;
    padding: 0 26px;
    position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip {
    display: flex; align-items: center; gap: 7px;
    font-size: 13px; color: var(--ink-2); font-weight: 500;
    padding: 4px 10px 4px 4px; border-radius: 99px; background: #f6f7fb;
}
.user-avatar {
    width: 24px; height: 24px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff; font-size: 11px; font-weight: 700;
    display: grid; place-items: center;
}

.page { padding: 26px; max-width: 1280px; width: 100%; }

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.page-desc { margin: 5px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.6; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 卡片 ---------------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card + .card { margin-top: 18px; }
.card-head {
    display: flex; align-items: center; gap: 12px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--line-2);
}
.card-head h2 { margin: 0; font-size: 14px; font-weight: 700; }
.card-head .sub { font-size: 12.5px; color: var(--muted); }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* ---------------- 按钮 ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 36px; padding: 0 14px;
    border-radius: 9px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 13.5px; font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: .16s;
    line-height: 1;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    box-shadow: 0 6px 16px -7px rgba(79, 70, 229, .8);
}
.btn-primary:hover { color: #fff; filter: brightness(1.06); box-shadow: 0 9px 22px -8px rgba(79, 70, 229, .9); }
.btn-ghost { background: #fff; border-color: #e5e7eb; color: var(--ink-2); }
.btn-ghost:hover { border-color: #c7d2fe; color: var(--brand); background: #fafbff; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--red); }
.btn-danger:hover { background: #fef2f2; color: #b91c1c; border-color: #fca5a5; }
.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-soft:hover { background: #e0e7ff; color: #4338ca; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 44px; padding: 0 22px; font-size: 14.5px; border-radius: 11px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-link { background: none; border: 0; color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.btn-link.danger { color: var(--red); }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted-2); margin-top: 5px; line-height: 1.6; }
.input, .select, .textarea {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 9px;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    background: #fff;
    outline: none;
    transition: .16s;
}
.input:focus, .select:focus, .textarea:focus { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(165, 180, 252, .25); }
.textarea { min-height: 110px; resize: vertical; line-height: 1.65; }
.textarea.mono { font-family: var(--mono); font-size: 13px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline .input { flex: 1; }
.check { display: flex; gap: 9px; align-items: flex-start; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: .15s; background: #fff; }
.check:hover { border-color: #dbe2f0; background: #fcfdff; }
.check input { margin: 2px 0 0; accent-color: var(--brand); width: 15px; height: 15px; }
.check b { display: block; font-size: 13.5px; font-weight: 600; }
.check span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.check.on { border-color: #c7d2fe; background: #fafbff; }

.color-input {
    width: 100%; height: 42px; padding: 4px 6px;
    border: 1px solid #e5e7eb; border-radius: 9px;
    background: #fff; cursor: pointer;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 0; border-radius: 6px; }
.color-input::-moz-color-swatch { border: 0; border-radius: 6px; }

.switch { position: relative; display: inline-block; width: 38px; height: 21px; flex: 0 0 38px; vertical-align: middle; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch span { position: absolute; inset: 0; background: #d1d5db; border-radius: 99px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .22); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(17px); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    text-align: left;
    font-size: 11.5px; font-weight: 700;
    color: var(--muted); letter-spacing: .05em; text-transform: uppercase;
    padding: 11px 16px;
    background: #fbfcfe;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfdff; }
.table .col-tight { width: 42px; }
.table input[type=checkbox] { accent-color: var(--brand); width: 15px; height: 15px; cursor: pointer; }
.table .main-cell { font-weight: 600; color: var(--ink); }
.table .sub-cell { font-size: 12px; color: var(--muted-2); margin-top: 2px; }
.table .num { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.table .actions-cell { text-align: right; white-space: nowrap; }
.table .actions-cell form { display: inline; }
.table .actions-cell .btn { margin-left: 4px; }

.code-chip {
    display: inline-flex; align-items: center;
    font-family: var(--mono);
    font-size: 13px; letter-spacing: .04em;
    background: #f8f9fc;
    border: 1px solid var(--line);
    color: #312e81;
    padding: 3px 8px; border-radius: 7px;
    cursor: pointer;
    transition: .15s;
}
.code-chip:hover { background: var(--brand-soft); border-color: #c7d2fe; }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11.5px; font-weight: 600;
    padding: 2px 8px; border-radius: 99px;
    white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge-green { background: #ecfdf5; color: #047857; }
.badge-blue { background: #eef2ff; color: #4338ca; }
.badge-gray { background: #f3f4f6; color: #6b7280; }
.badge-amber { background: #fffbeb; color: #b45309; }
.badge-red { background: #fef2f2; color: #b91c1c; }
.badge-plain::before { display: none; }

/* ---------------- 统计 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; box-shadow: var(--shadow-sm);
    position: relative; overflow: hidden;
}
.stat::after {
    content: ""; position: absolute; right: -18px; top: -18px;
    width: 76px; height: 76px; border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, .12), transparent 70%);
}
.stat-label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; font-weight: 600; color: var(--muted-2); letter-spacing: 0; margin-left: 3px; }
.stat-foot { font-size: 12px; color: var(--muted-2); margin-top: 4px; }

/* ---------------- 提示条 ---------------- */
.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 14px; border-radius: 11px;
    font-size: 13.5px; line-height: 1.6;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert b { font-weight: 700; }
.alert-info { background: #f5f7ff; border-color: #e0e7ff; color: #3730a3; }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-err { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert .x { margin-left: auto; cursor: pointer; opacity: .5; font-size: 16px; line-height: 1; background: none; border: 0; color: inherit; }

/* ---------------- 空状态 ---------------- */
.empty { padding: 54px 20px; text-align: center; color: var(--muted); }
.empty .ico { font-size: 34px; opacity: .35; margin-bottom: 10px; }
.empty h3 { margin: 0 0 6px; font-size: 15px; color: var(--ink-2); }
.empty p { margin: 0 0 16px; font-size: 13px; }

/* ---------------- 分页 ---------------- */
.pager { display: flex; align-items: center; gap: 6px; padding: 14px 18px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.pager .info { font-size: 12.5px; color: var(--muted); margin-right: auto; }
.pager a, .pager span.cur {
    min-width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 8px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
    border: 1px solid var(--line); color: var(--ink-2); background: #fff;
}
.pager a:hover { border-color: #c7d2fe; color: var(--brand); background: #fafbff; }
.pager span.cur { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager span.gap { border: 0; background: none; color: var(--muted-2); }

/* ---------------- 代码块 ---------------- */
.code-block {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    position: relative;
}
.code-block .tag { color: #7dd3fc; }
.code-block .attr { color: #c4b5fd; }
.code-block .str { color: #86efac; }

.copy-bar { display: flex; gap: 8px; align-items: center; margin-top: 10px; }

/* ---------------- 编辑页两栏 ---------------- */
.edit-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 18px; align-items: start; }
.sticky-col { position: sticky; top: 78px; }
.preview-frame {
    width: 100%; height: 420px; border: 0;
    background: #f1f5f9;
    border-radius: 0 0 var(--radius) var(--radius);
    display: block;
}
.tabs { display: flex; gap: 4px; padding: 4px; background: #f4f5f9; border-radius: 10px; }
.tabs button {
    flex: 1; border: 0; background: none; font: inherit; font-size: 13px; font-weight: 600;
    color: var(--muted); padding: 7px 6px; border-radius: 7px; cursor: pointer; transition: .15s;
}
.tabs button.on { background: #fff; color: var(--brand); box-shadow: var(--shadow-sm); }

/* ---------------- 登录 ---------------- */
.auth {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background:
        radial-gradient(1000px 500px at 12% -10%, #e0e7ff 0, transparent 60%),
        radial-gradient(900px 500px at 100% 110%, #fce7f3 0, transparent 55%),
        #f7f8fc;
}
.auth-card {
    width: 100%; max-width: 396px;
    background: #fff; border: 1px solid var(--line);
    border-radius: 18px; padding: 34px 30px 28px;
    box-shadow: 0 24px 60px -30px rgba(30, 27, 75, .4), var(--shadow-sm);
}
.auth-logo {
    width: 46px; height: 46px; border-radius: 13px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: grid; place-items: center; color: #fff; font-size: 21px;
    box-shadow: 0 10px 22px -10px rgba(99, 102, 241, .95);
    margin-bottom: 18px;
}
.auth-card h1 { margin: 0 0 6px; font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.auth-card p.sub { margin: 0 0 24px; font-size: 13.5px; color: var(--muted); }
.auth-card .btn { width: 100%; height: 44px; font-size: 14.5px; margin-top: 4px; }
.auth-foot { margin-top: 20px; text-align: center; font-size: 12px; color: var(--muted-2); line-height: 1.7; }

/* ---------------- 落地页 ---------------- */
.landing {
    background:
        radial-gradient(900px 480px at 15% -5%, #e0e7ff 0, transparent 55%),
        radial-gradient(800px 480px at 95% 100%, #fae8ff 0, transparent 55%),
        #f7f8fc;
    min-height: 100vh;
}
.landing-wrap { max-width: 880px; margin: 0 auto; padding: 72px 24px 60px; text-align: center; }
.landing-badge {
    display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .06em;
    color: var(--brand); background: #fff; border: 1px solid #e0e7ff;
    padding: 5px 12px; border-radius: 99px; margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.landing h1 { margin: 0 0 14px; font-size: 38px; letter-spacing: -.035em; font-weight: 800; line-height: 1.2; }
.landing-sub { margin: 0 auto 38px; max-width: 640px; font-size: 15px; line-height: 1.85; color: var(--muted); }
.landing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; text-align: left; margin-bottom: 38px; }
.landing-card {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow-sm);
}
.landing-card h3 { margin: 12px 0 6px; font-size: 14.5px; }
.landing-card p { margin: 0; font-size: 13px; line-height: 1.7; color: var(--muted); }
.landing-ico {
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--brand-soft); color: var(--brand);
    display: grid; place-items: center; font-size: 13px; font-weight: 800;
}
.landing-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.landing-foot { margin-top: 34px; font-size: 12.5px; color: var(--muted-2); }

/* ---------------- 杂项 ---------------- */
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.hidden { display: none !important; }
.sep { height: 1px; background: var(--line-2); margin: 18px 0; }

.toast {
    position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(12px);
    background: #111827; color: #fff; font-size: 13.5px; font-weight: 500;
    padding: 11px 18px; border-radius: 10px; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .5);
    opacity: 0; pointer-events: none; transition: .22s; z-index: 9999;
    display: flex; align-items: center; gap: 8px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.help-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.9; color: var(--muted); }
.help-list b { color: var(--ink-2); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .edit-grid { grid-template-columns: 1fr; }
    .sticky-col { position: static; }
}
@media (max-width: 820px) {
    .shell { flex-direction: column; }
    .sidebar {
        width: 100%; flex: none; height: auto; position: sticky; top: 0; z-index: 30;
        border-right: 0; border-bottom: 1px solid var(--line);
    }
    .brand { padding: 14px 16px 10px; }
    .nav { flex-direction: row; overflow-x: auto; padding: 0 12px 10px; gap: 6px; }
    .nav-label { display: none; }
    .nav-item { height: 36px; padding: 0 12px; white-space: nowrap; }
    .nav-item .nav-count { display: none; }
    .sidebar-foot { display: none; }
    .topbar { position: static; padding: 0 16px; height: 54px; flex-basis: 54px; }
    .page { padding: 16px; }
    .row, .row-3 { grid-template-columns: 1fr; }
    .landing-grid { grid-template-columns: 1fr; }
    .landing h1 { font-size: 28px; }
    .landing-wrap { padding: 44px 18px 40px; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-value { font-size: 22px; }
}
