:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-soft: #eef0ff;
    --green: #22b573;
    --green-soft: #e7f8ef;
    --danger: #e5484d;
    --danger-soft: #fdecec;
    --orange: #f59e0b;
    --text: #1f2330;
    --text-2: #626977;
    --line: #e8eaf1;
    --bg: #f5f6fa;
    --radius: 14px;
    --shadow: 0 6px 24px rgba(31, 35, 48, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
table { border-collapse: collapse; width: 100%; }

/* ------------------------------- 布局 ------------------------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 224px; flex: 0 0 224px; background: #171a29; color: #c9cede;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 22px 20px 18px; }
.brand strong { display: block; color: #fff; font-size: 15px; }
.brand small { display: block; color: #7f879c; font-size: 12px; }
.brand-logo {
    width: 36px; height: 36px; border-radius: 10px; flex: 0 0 36px;
    background: linear-gradient(135deg, #7f83ff, #5b5ef0); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.brand-logo.big { width: 54px; height: 54px; flex: 0 0 54px; border-radius: 16px; font-size: 24px; margin: 0 auto 12px; }
.nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
    color: #a9b0c4; padding: 10px 14px; border-radius: 10px; font-size: 14px; transition: .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: linear-gradient(135deg, #6f73f7, #5a5df0); color: #fff; }
.sidebar-foot {
    padding: 16px 20px; border-top: 1px solid rgba(255, 255, 255, .08);
    display: flex; justify-content: space-between; font-size: 13px; color: #8d94a8;
}
.sidebar-foot a { color: #b9bfd2; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 14px; background: #fff;
    padding: 16px 26px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 18px; flex: 1; }
.menu-btn { display: none; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 9px; font-size: 16px; }
.content { padding: 24px 26px 60px; }
.topbar-actions { display: flex; gap: 10px; }

/* ------------------------------- 组件 ------------------------------- */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title h2 { font-size: 16px; }
.card-title .sub { color: var(--text-2); font-size: 13px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid var(--line); background: #fff; color: var(--text);
    padding: 8px 16px; border-radius: 9px; font-size: 14px; cursor: pointer;
    transition: .15s; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--danger); border-color: #f3c8ca; background: #fff; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.flash-success { background: var(--green-soft); color: #12805a; }
.flash-error { background: var(--danger-soft); color: #b4252a; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-card .label { color: var(--text-2); font-size: 13px; }
.stat-card .num { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: .5px; }
.stat-card.purple .num { color: var(--primary); }
.stat-card.green .num { color: var(--green); }
.stat-card.orange .num { color: var(--orange); }

.table-wrap { overflow-x: auto; }
.table th {
    text-align: left; font-size: 13px; color: var(--text-2); font-weight: 500;
    padding: 10px 12px; background: #fafbfe; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid #f1f2f7; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fcfcff; }
.muted { color: var(--text-2); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; }
.badge-on { background: var(--green-soft); color: #12805a; }
.badge-off { background: #f0f1f5; color: #7c8394; }
.badge-hot { background: #fff3e0; color: #c97a09; }

.thumb { width: 46px; height: 46px; border-radius: 9px; object-fit: cover; background: #f0f1f6; display: block; }
.thumb.placeholder { display: flex; align-items: center; justify-content: center; color: #b4b9c7; font-size: 12px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 13px; color: var(--text-2); }
.field > span .req { color: var(--danger); }
.field input[type=text], .field input[type=password], .field input[type=number], .field select, .field textarea {
    border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; font-size: 14px;
    font-family: inherit; color: var(--text); background: #fff; width: 100%; outline: none; transition: .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); }
.field textarea { min-height: 110px; resize: vertical; line-height: 1.8; }
.field .hint { font-size: 12px; color: #9aa0b0; }
.radio-line { display: flex; gap: 18px; align-items: center; padding-top: 4px; }
.radio-line label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
.check-line { display: flex; gap: 20px; align-items: center; }
.check-line label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }

.upload-row { display: flex; gap: 10px; }
.upload-preview { margin-top: 8px; }
.upload-preview img { max-width: 160px; max-height: 120px; border-radius: 10px; border: 1px solid var(--line); }
.form-actions { display: flex; gap: 12px; padding-top: 8px; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-bar select, .filter-bar input {
    border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; font-size: 14px; background: #fff;
}
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding-top: 16px; flex-wrap: wrap; }
.pager a, .pager span {
    padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 13px; color: var(--text);
}
.pager .current { background: var(--primary); border-color: var(--primary); color: #fff; }

.empty { text-align: center; padding: 46px 10px; color: #9aa0b0; }

/* 统计图 */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 10px 0 0; }
.bars .bar-wrap { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.bars .bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, #8b8eff, #6164f0); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .bar-label { font-size: 11px; color: #9aa0b0; white-space: nowrap; }

/* 登录页 */
.login-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(1200px 600px at 20% 0%, #e7e9ff, #f6f7fb 60%);
    padding: 20px;
}
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 20px; box-shadow: 0 20px 60px rgba(40, 44, 80, .12); padding: 34px 30px 24px; }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand h1 { font-size: 20px; margin-bottom: 4px; }
.login-brand p { margin: 0; color: var(--text-2); font-size: 13px; }
.login-foot { text-align: center; color: #a6acbb; font-size: 12px; margin: 18px 0 0; }

.code-box { background: #1e2233; color: #d7dcf0; border-radius: 10px; padding: 14px 16px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.8; overflow-x: auto; white-space: pre; }
.steps { counter-reset: step; padding-left: 0; list-style: none; margin: 0; }
.steps li { position: relative; padding: 0 0 18px 38px; }
.steps li::before {
    counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0;
    width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
    font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}
.steps li:last-child { padding-bottom: 0; }
.steps li strong { display: block; margin-bottom: 3px; }
.steps li p { margin: 0; color: var(--text-2); }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tag { background: #f4f5fa; border-radius: 6px; padding: 3px 9px; font-size: 12px; color: var(--text-2); font-family: ui-monospace, Menlo, Consolas, monospace; }
.alert { border-radius: 10px; padding: 12px 14px; font-size: 13px; background: #fff7e6; color: #9a6408; margin-bottom: 16px; }

@media (max-width: 1000px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
}
@media (max-width: 820px) {
    .sidebar { position: fixed; left: -240px; z-index: 50; transition: left .2s; height: 100vh; }
    .sidebar.open { left: 0; box-shadow: 20px 0 60px rgba(0,0,0,.25); }
    .menu-btn { display: inline-block; }
    .content { padding: 16px 14px 50px; }
    .topbar { padding: 12px 14px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .num { font-size: 22px; }
    .card { padding: 16px; }
}
