:root {
    --primary: #0b6bcb;
    --primary-dark: #084f96;
    --primary-soft: #e8f1fc;
    --accent: #0e9f6e;
    --danger: #dc2626;
    --warning: #d97706;
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --radius: 12px;
    --shadow: 0 8px 30px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }

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

.sidebar {
    width: 236px;
    flex: 0 0 236px;
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand-mark {
    width: 34px; height: 34px; border-radius: 9px;
    background: linear-gradient(135deg, #2f80ed, #0e9f6e);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px;
}
.brand-text { line-height: 1.25; }
.brand-text strong { display: block; color: #fff; font-size: 15px; font-weight: 600; }
.brand-text span { font-size: 11px; color: #94a3b8; }

.site-switcher { padding: 14px 16px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.site-switcher label { display: block; font-size: 11px; color: #94a3b8; margin-bottom: 6px; letter-spacing: .04em; }
.site-switcher select {
    width: 100%; padding: 8px 10px; border-radius: 8px;
    background: #1e293b; color: #e2e8f0; border: 1px solid #334155; font-size: 13px;
}

.nav-group { padding: 14px 0 6px; }
.nav-group-title { padding: 4px 20px 8px; font-size: 11px; color: #64748b; letter-spacing: .08em; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 18px; margin: 2px 10px; border-radius: 9px;
    color: #cbd5e1; font-size: 13.5px;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: rgba(47, 128, 237, .18); color: #fff; box-shadow: inset 3px 0 0 #60a5fa; }
.nav-item .ico { width: 18px; text-align: center; opacity: .8; font-size: 14px; }
.nav-item .dot {
    margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: #dc2626; color: #fff; font-size: 11px;
    display: inline-flex; align-items: center; justify-content: center;
}

.sidebar-foot { margin-top: auto; padding: 16px 18px 18px; border-top: 1px solid rgba(255, 255, 255, .06); font-size: 12px; }
.sidebar-foot a { display: block; color: #94a3b8; padding: 5px 0; }
.sidebar-foot a:hover { color: #fff; }

.main { margin-left: 236px; 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 24px; position: sticky; top: 0; z-index: 15;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; }
.topbar .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-chip {
    display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px;
    border-radius: 20px; background: #f8fafc; border: 1px solid var(--border); font-size: 13px;
}
.avatar {
    width: 26px; height: 26px; border-radius: 50%; background: var(--primary);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 12px; text-transform: uppercase;
}

.content { padding: 22px 24px 40px; width: 100%; max-width: 1360px; }

/* ---------------- 通用组件 ---------------- */
.card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .hint { font-size: 12px; color: var(--muted); }
.card-body { padding: 20px; }
.card-body.tight { padding: 12px 16px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); background: #fbfcfe; display: flex; gap: 10px; align-items: center; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
    background: var(--primary); color: #fff; font-size: 13.5px; cursor: pointer;
    transition: .16s ease; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #f8fafc; color: var(--primary); border-color: #cbd5e1; }
.btn-soft { background: var(--primary-soft); color: var(--primary-dark); }
.btn-soft:hover { background: #dbeafe; color: var(--primary-dark); }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; color: #991b1b; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px 9px; }

.input, .select, .textarea {
    width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 9px;
    font-size: 13.5px; font-family: inherit; color: var(--text); background: #fff; transition: .16s;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11, 107, 203, .12);
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.65; }
.select { height: 38px; }
.input-sm { padding: 6px 10px; font-size: 12.5px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: #374151; margin-bottom: 6px; font-weight: 500; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field .req { color: var(--danger); }
.form-grid { display: grid; gap: 0 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.links-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
@media (max-width: 1200px) {
    .links-layout { grid-template-columns: 1fr; gap: 18px 0; }
}
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 6px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    text-align: left; padding: 11px 16px; background: #f8fafc; color: #475569;
    font-weight: 500; font-size: 12.5px; white-space: nowrap; border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fcfdff; }
.table .actions { display: flex; gap: 6px; white-space: nowrap; }
.cell-main { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.thumb-sm { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #f1f5f9; flex: 0 0 44px; }
.cell-title { font-weight: 500; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ---------------- 素材库 ---------------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; margin-top: 16px; }
.media-item { display: flex; flex-direction: column; overflow: hidden; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.media-thumb { position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; overflow: hidden; font: inherit; background: #f1f5f9; border: 0; cursor: zoom-in; }
.media-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .2s ease; }
.media-thumb:hover img { transform: scale(1.03); }
.media-thumb:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.media-thumb-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; background: rgba(15,23,42,.38); opacity: 0; transition: opacity .18s ease; }
.media-thumb:hover .media-thumb-hint, .media-thumb:focus-visible .media-thumb-hint { opacity: 1; }
.media-meta { padding: 12px; }
.media-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--text); }
.media-preview { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; padding: 24px; }
.media-preview[hidden] { display: none; }
.media-preview-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.72); }
.media-preview-dialog { position: relative; z-index: 1; display: flex; flex-direction: column; width: min(880px, 100%); max-height: 90vh; overflow: hidden; background: #fff; border-radius: 16px; box-shadow: 0 24px 70px rgba(15,23,42,.35); }
.media-preview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.media-preview-head strong { display: block; font-size: 15px; }
.media-preview-close { padding: 0 6px; font-size: 26px; line-height: 1.1; color: var(--muted); background: transparent; border: 0; cursor: pointer; }
.media-preview-close:hover { color: var(--text); }
.media-preview-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; background: #f8fafc; }
.media-preview-body img { display: block; max-width: 100%; max-height: 64vh; object-fit: contain; border-radius: 4px; }
.media-preview-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
body.media-preview-open { overflow: hidden; }

.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 12px; white-space: nowrap; }
.badge-green { background: #ecfdf5; color: #047857; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-red { background: #fef2f2; color: #b91c1c; }
.badge-blue { background: var(--primary-soft); color: var(--primary-dark); }
.badge-amber { background: #fffbeb; color: #b45309; }

.empty { padding: 54px 20px; text-align: center; color: var(--muted); }
.empty h3 { margin: 0 0 8px; font-size: 15px; color: var(--text); }
.empty p { margin: 0 0 16px; font-size: 13px; }

.pager { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 16px; flex-wrap: wrap; }
.pager a, .pager span {
    min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: #fff;
    font-size: 13px; color: var(--text);
}
.pager a:hover { border-color: var(--primary); color: var(--primary); }
.pager .active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager .disabled { color: #cbd5e1; }

/* ---------------- 数据看板 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 18px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card::after {
    content: ""; position: absolute; right: -30px; top: -30px; width: 80px; height: 80px;
    border-radius: 50%; background: var(--primary-soft); opacity: .6;
}
.stat-label { font-size: 12.5px; color: var(--muted); position: relative; z-index: 1; }
.stat-value { font-size: 28px; font-weight: 700; margin: 6px 0 2px; letter-spacing: -.02em; position: relative; z-index: 1; }
.stat-foot { font-size: 12px; color: var(--muted); position: relative; z-index: 1; }
.stat-foot .up { color: var(--accent); } .stat-foot .down { color: var(--danger); }

.chart-box { padding: 8px 8px 0; }
.chart-canvas { width: 100%; height: 260px; display: block; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.quick-item {
    display: flex; flex-direction: column; gap: 4px; padding: 16px;
    border: 1px dashed #dbe3ef; border-radius: 10px; background: #fbfdff; color: var(--text);
}
.quick-item:hover { border-color: var(--primary); color: var(--primary); }
.quick-item .q-ico { font-size: 18px; }
.quick-item b { font-size: 13.5px; font-weight: 600; }
.quick-item span { font-size: 12px; color: var(--muted); }

.checklist { display: flex; flex-direction: column; gap: 10px; }
.check-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.check-item .mark {
    width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center;
    justify-content: center; font-size: 12px; background: #f1f5f9; color: #94a3b8;
}
.check-item.done .mark { background: #ecfdf5; color: #047857; }
.check-item a { margin-left: auto; font-size: 12px; }

/* ---------------- 提示 ---------------- */
.flash { margin-bottom: 14px; padding: 12px 16px; border-radius: 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.flash-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.flash-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

.alert { padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.alert-info { background: #eff6ff; color: #1d4ed8; }
.alert-warn { background: #fffbeb; color: #92400e; }
.alert-danger { background: #fef2f2; color: #b91c1c; }

/* ---------------- 标签页 ---------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
    padding: 10px 16px; border-radius: 9px 9px 0 0; font-size: 13.5px; color: var(--muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; background: #fff; }

/* ---------------- 图片字段 ---------------- */
.image-field { display: flex; gap: 10px; align-items: flex-start; }
.image-preview {
    width: 96px; height: 96px; border-radius: 9px; border: 1px dashed #cbd5e1;
    background: #f8fafc center/cover no-repeat; flex: 0 0 96px;
    display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 12px;
}
.image-field .grow { display: flex; flex-direction: column; gap: 8px; }
.image-field .row { gap: 8px; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin-top: 10px; }
.image-item {
    position: relative; aspect-ratio: 1 / 1; border: 1px solid #e2e8f0; border-radius: 9px;
    background: #f8fafc; overflow: hidden;
}
.image-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-remove {
    position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 50%;
    background: rgba(15, 23, 42, .72); color: #fff; font-size: 14px; line-height: 20px;
    cursor: pointer; padding: 0;
}
.image-remove:hover { background: #b91c1c; }

/* ---------------- 编辑器（设计器） ---------------- */
.editor-body { margin: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; background: #0f172a; }
.editor-topbar {
    height: 56px; background: #0f172a; color: #e2e8f0; display: flex; align-items: center;
    justify-content: space-between; padding: 0 16px; gap: 12px; border-bottom: 1px solid #1e293b; flex: 0 0 56px;
}
.editor-topbar .left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.editor-topbar .left a { color: #94a3b8; font-size: 13px; }
.editor-topbar .left a:hover { color: #fff; }
.editor-topbar .page-name { color: #fff; font-weight: 600; font-size: 14px; }
.editor-topbar .right { display: flex; align-items: center; gap: 10px; }
.save-state { font-size: 12px; color: #94a3b8; }
.save-state.ok { color: #34d399; }
.save-state.err { color: #f87171; }
.btn-light { background: #1e293b; color: #e2e8f0; border: 1px solid #334155; }
.btn-light:hover { background: #263449; color: #fff; }
.btn-primary-editor { background: #2f80ed; color: #fff; }
.btn-primary-editor:hover { background: #1c6fd6; color: #fff; }

.editor-shell { flex: 1; display: flex; min-height: 0; }
.editor-left {
    width: 230px; flex: 0 0 230px; background: #111c2e; color: #cbd5e1;
    display: flex; flex-direction: column; border-right: 1px solid #1e293b; min-height: 0;
}
.editor-panel-title {
    padding: 12px 14px; font-size: 12px; color: #94a3b8; border-bottom: 1px solid #1e293b;
    display: flex; align-items: center; justify-content: space-between;
}
.editor-pages { padding: 8px; overflow-y: auto; max-height: 200px; }
.page-link {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
    font-size: 13px; color: #cbd5e1;
}
.page-link:hover { background: #1a2739; color: #fff; }
.page-link.active { background: #1c3350; color: #fff; }
.page-link .home-tag { font-size: 10px; background: #14532d; color: #86efac; padding: 1px 5px; border-radius: 4px; }
.editor-blocks { flex: 1; overflow-y: auto; padding: 8px; }
.block-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
    font-size: 12.5px; color: #cbd5e1; cursor: pointer; border: 1px solid transparent;
}
.block-item:hover { background: #1a2739; }
.block-item.active { background: #1c3350; border-color: #2f80ed; color: #fff; }
.block-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-item .ops { display: flex; gap: 2px; opacity: 0; }
.block-item:hover .ops, .block-item.active .ops { opacity: 1; }
.block-item .mini { background: none; border: 0; color: #94a3b8; cursor: pointer; padding: 2px 4px; font-size: 11px; }
.block-item .mini:hover { color: #fff; }

.editor-canvas { flex: 1; min-width: 0; background: #eef2f7; position: relative; }
.canvas-frame { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
.canvas-badge {
    position: absolute; left: 14px; top: 12px; z-index: 2; background: rgba(15, 23, 42, .72);
    color: #fff; font-size: 11.5px; padding: 4px 10px; border-radius: 20px; pointer-events: none;
}

.editor-right {
    width: 330px; flex: 0 0 330px; background: #fff; border-left: 1px solid var(--border);
    display: flex; flex-direction: column; min-height: 0;
}
.editor-right-head {
    padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
    justify-content: space-between;
}
.editor-right-head b { font-size: 14px; }
.editor-props { flex: 1; overflow-y: auto; padding: 16px; }
.editor-props .field { margin-bottom: 14px; }
.editor-props .field label { font-size: 12.5px; }
.prop-empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.editor-add-btn { padding: 12px; border-top: 1px solid var(--border); background: #fbfcfe; }

.prop-list { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.prop-list-item { border-bottom: 1px solid var(--border); padding: 10px; background: #fbfcfe; }
.prop-list-item:last-child { border-bottom: 0; }
.prop-list-item .head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.prop-list-item .head b { font-size: 12px; color: var(--muted); }
.prop-list-item .inputs { display: grid; gap: 6px; }
.prop-list-item .inputs input, .prop-list-item .inputs textarea {
    padding: 7px 9px; font-size: 12.5px; border-radius: 7px; border: 1px solid #d1d5db; width: 100%;
}
.prop-list-add { padding: 8px; }

/* 添加区块弹层 */
.modal-mask {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 40;
    display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
    width: 640px; max-width: 100%; max-height: 80vh; background: #fff; border-radius: 14px;
    overflow: hidden; display: flex; flex-direction: column;
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head b { font-size: 15px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.block-group-title { font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.block-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.block-choice {
    border: 1px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer;
    background: #fbfcfe; text-align: left; font-family: inherit;
}
.block-choice:hover { border-color: var(--primary); background: #f3f8ff; color: var(--primary); }
.block-choice b { display: block; font-size: 13px; margin-bottom: 3px; }
.block-choice span { font-size: 11.5px; color: var(--muted); }

/* ---------------- 模板卡片 ---------------- */
.template-filters { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-bottom: 16px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.template-category-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.template-filter { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; font: inherit; font-size: 12.5px; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; transition: .16s; }
.template-filter:hover { color: var(--primary); border-color: var(--primary); }
.template-filter.active { color: var(--primary-dark); background: var(--primary-soft); border-color: var(--primary); }
.template-filter-count { min-width: 18px; padding: 1px 5px; text-align: center; font-size: 11px; color: var(--muted); background: #fff; border-radius: 999px; }
.template-filter-tip { align-self: center; margin-left: 2px; }
.template-category-browser { margin: 0 0 4px; }
.template-category-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.template-top-filter { cursor: default; }
.template-top-filter:hover, .template-top-filter.is-open { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.template-top-filter.is-selected { color: #fff; background: var(--primary); border-color: var(--primary); }
.template-top-filter.is-selected .template-filter-count { color: var(--primary-dark); }
.template-top-caret { font-size: 10px; color: var(--muted); }
.template-top-filter.is-selected .template-top-caret { color: #dbeafe; }
.template-subcategory-panel { margin-top: 12px; padding: 13px 14px; background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; }
.template-subcategory-panel[hidden] { display: none; }
.template-subcategory-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.template-subcategory-head b { font-size: 13px; color: var(--text); }
.template-subcategory-list { display: flex; flex-wrap: wrap; gap: 8px; }
.template-subcategory { padding: 7px 12px; font: inherit; font-size: 12.5px; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; transition: .16s; }
.template-subcategory:hover { color: var(--primary); border-color: var(--primary); }
.template-subcategory.active { color: var(--primary-dark); background: var(--primary-soft); border-color: var(--primary); }
.template-subcategory-empty { margin: 0; font-size: 12.5px; color: var(--muted); }
.template-filter.active .template-filter-count { color: var(--primary-dark); }
.template-filter-side { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex: 0 1 380px; }
.template-search { width: 240px; max-width: 100%; }
.template-search::-webkit-search-cancel-button { cursor: pointer; }
.template-category-note { margin: 8px 0 16px; }

.tpl-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.tpl-card { display: flex; flex-direction: column; overflow: hidden; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.tpl-card.is-current { border-color: var(--primary); }
.tpl-card[hidden] { display: none; }
.tpl-thumb { position: relative; aspect-ratio: 16 / 10; background: #f1f5f9 center top / cover no-repeat; overflow: hidden; }
.tpl-current-flag { position: absolute; top: 10px; left: 10px; padding: 4px 9px; font-size: 11.5px; font-weight: 600; color: #fff; background: rgba(14,159,110,.95); border-radius: 999px; }
.tpl-card-body { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.tpl-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tpl-card-head b { font-size: 14.5px; color: var(--text); }
.tpl-card-head .badge { flex: 0 0 auto; }
.tpl-desc { min-height: 40px; margin: 0; font-size: 12.5px; line-height: 1.65; color: var(--muted); }
.tpl-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-tags .badge { font-size: 11.5px; }
.tpl-card-body .row { margin-top: auto; padding-top: 12px; }
.template-empty { padding: 40px 20px; }

.current-template { padding: 6px 12px; border-radius: 20px; background: var(--primary-soft); color: var(--primary-dark); font-size: 12px; }

/* ---------------- 站点卡片 ---------------- */
.site-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.site-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.site-card h3 { margin: 0 0 6px; font-size: 15px; }
.site-card .url { font-size: 12px; color: var(--muted); word-break: break-all; }
.site-card .row { margin-top: 14px; }
.site-card.current { border-color: var(--primary); }

/* ---------------- 登录页 ---------------- */
.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 30px;
    background: radial-gradient(1200px 600px at 10% 0%, #e8f1fc 0%, #f5f7fb 55%);
}
.auth-card { width: 420px; max-width: 100%; background: #fff; border-radius: 18px; padding: 34px; box-shadow: 0 24px 60px rgba(15, 23, 42, .12); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-brand .brand-mark { width: 42px; height: 42px; border-radius: 11px; font-size: 19px; }
.auth-brand strong { font-size: 19px; display: block; }
.auth-brand span { font-size: 12px; color: var(--muted); }
.auth-card h2 { font-size: 18px; margin: 0 0 4px; }
.auth-card p.lead { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.auth-card .btn { width: 100%; padding: 11px; font-size: 14px; }
.auth-foot { text-align: center; font-size: 13px; color: var(--muted); margin-top: 18px; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1200px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tpl-grid, .site-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .sidebar { position: static; width: 100%; flex: 0 0 auto; }
    .admin-body { flex-direction: column; }
    .main { margin-left: 0; }
    .grid-2, .grid-3, .grid-4, .stat-grid, .site-grid { grid-template-columns: 1fr; }
    .tpl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .nav-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .nav-group-title { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
    .tpl-grid { grid-template-columns: 1fr; }
    .template-filter-side { flex: 1 1 100%; justify-content: flex-start; }
    .template-search { width: 100%; }
}
