:root { --bg:#f5f6f8; --card:#fff; --line:#e5e7eb; --pri:#2563eb; --txt:#1f2937; --mut:#6b7280; --danger:#dc2626; --ok:#16a34a; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--txt); font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif; }
.hidden { display: none !important; }
button { font: inherit; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 32px; width: 380px; box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card .tip { color: var(--mut); font-size: 12px; margin: 0 0 20px; }
.login-card label { display: block; font-size: 13px; color: var(--mut); margin-bottom: 12px; }
.login-card input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.login-card button[type=submit] { width: 100%; background: var(--pri); color: #fff; border: 0; border-radius: 8px; padding: 11px; cursor: pointer; font-size: 15px; }
.msg { color: var(--danger); min-height: 20px; margin-top: 8px; font-size: 13px; }

/* 布局 */
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 220px; background: #111827; color: #d1d5db; display: flex; flex-direction: column; z-index: 10; }
.brand { padding: 18px 16px; font-size: 16px; font-weight: 700; color: #fff; border-bottom: 1px solid #1f2937; }
.sidebar nav { flex: 1; overflow: auto; padding: 8px; }
.sidebar nav button { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: #9ca3af; padding: 9px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; margin-bottom: 2px; }
.sidebar nav button:hover { background: #1f2937; color: #fff; }
.sidebar nav button.active { background: var(--pri); color: #fff; }
.side-foot { padding: 12px; border-top: 1px solid #1f2937; }
.side-foot button { width: 100%; background: #1f2937; color: #d1d5db; border: 0; border-radius: 7px; padding: 8px; cursor: pointer; }
.maint-btn { position: relative; }
.maint-dot { display: none; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; margin-left: 6px; vertical-align: middle; }
.maint-dot.on { display: inline-block; }
.sidebar nav button.need-maint { color: #fca5a5; }
.main { margin-left: 220px; min-height: 100vh; }
.topbar { height: 52px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 5; font-size: 13px; color: var(--mut); }
#panels { padding: 20px 24px 60px; max-width: 1200px; }

/* 通用 */
.panel h2 { margin: 0 0 16px; font-size: 18px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar input, .toolbar select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font: inherit; }
.btn { background: var(--pri); color: #fff; border: 0; border-radius: 7px; padding: 8px 14px; cursor: pointer; }
.btn.grey { background: #6b7280; }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.tbl { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tbl th, .tbl td { padding: 9px 11px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: top; }
.tbl th { background: #f9fafb; color: var(--mut); font-weight: 600; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; }
.pill.published, .pill.active, .pill.approved { background: #dcfce7; color: #166534; }
.pill.draft, .pill.pending, .pill.idle { background: #fef3c7; color: #92400e; }
.pill.offline, .pill.banned, .pill.spam, .pill.error { background: #fee2e2; color: #991b1b; }
.pager { display: flex; gap: 5px; margin-top: 14px; align-items: center; flex-wrap: wrap; }
.pager button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.pager button.on { background: var(--pri); color: #fff; border-color: var(--pri); }
.hint { color: var(--mut); font-size: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.stat-card b { display: block; font-size: 26px; margin-top: 6px; }
.stat-card span { color: var(--mut); font-size: 13px; }

/* 表单弹层 */
.mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 12px; width: min(760px, 100%); max-height: 90vh; overflow: auto; padding: 22px; }
.modal h3 { margin: 0 0 16px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.field label { display: block; font-size: 12px; color: var(--mut); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 14px; }
.field.full { grid-column: 1 / -1; }
.field textarea { min-height: 120px; resize: vertical; font-family: inherit; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.tabs-sub { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs-sub button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 6px 12px; cursor: pointer; }
.tabs-sub button.on { background: var(--pri); color: #fff; }
pre.codebox { background: #0f172a; color: #cbd5e1; border-radius: 8px; padding: 12px; font: 12px/1.6 ui-monospace, Consolas, monospace; overflow: auto; max-height: 300px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: .25s; z-index: 100; pointer-events: none; }
.toast.on { opacity: .95; transform: translate(-50%, 0); }
.toast.bad { background: var(--danger); }
@media (max-width: 800px) { .sidebar { width: 100%; height: auto; position: static; } .sidebar nav { display: flex; flex-wrap: wrap; } .main { margin-left: 0; } }

/* ===== 文章专用编辑器 ===== */
.article-modal { width: min(1100px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 16px; }
.modal-head h3 { margin: 0; }
.icon-btn { background: transparent; border: 0; font-size: 18px; cursor: pointer; color: var(--mut); }
.editor-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.editor-main { min-width: 0; }
.editor-side { background: #f9fafb; border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; max-height: 560px; overflow: auto; }
.editor-side .field label { display: flex; align-items: center; gap: 6px; }
.auto-tag { background: #eef2ff; color: var(--pri); font-size: 10px; padding: 1px 6px; border-radius: 99px; font-weight: 500; }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; background: #f9fafb; border: 1px solid var(--line); border-radius: 8px 8px 0 0; padding: 6px; }
.rte-toolbar button { border: 1px solid transparent; background: #fff; border-radius: 5px; padding: 4px 9px; cursor: pointer; font-size: 13px; color: #374151; }
.rte-toolbar button:hover { border-color: var(--pri); color: var(--pri); }
.rte-toolbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.rte { min-height: 300px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 8px 8px; padding: 16px; font-size: 15px; line-height: 1.8; background: #fff; outline: none; overflow: auto; }
.rte:focus { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(79,70,229,.08); }
.rte:empty::before { content: attr(data-placeholder); color: #b6bec9; }
.rte img { max-width: 100%; border-radius: 8px; }
.rte h2 { font-size: 1.3rem; }
.downloads-edit { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.de-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.de-head h4 { margin: 0; font-size: 14px; }
.auto-switch { margin-right: auto; font-size: 13px; color: var(--mut); display: flex; align-items: center; gap: 5px; }
@media (max-width: 900px) { .editor-layout { grid-template-columns: 1fr; } .editor-side { max-height: none; } }

/* ===== 统计图表 ===== */
.chart-box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.chart-box h3 { margin: 0 0 14px; font-size: 15px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 18px; justify-content: center; margin-top: 8px; font-size: 12px; color: var(--mut); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bar-chart { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar-label { width: 130px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #475569; }
.bar-track { flex: 1; height: 18px; background: #f1f5f9; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #4f46e5, #7c3aed); border-radius: 99px; transition: width .5s; }
.bar-val { width: 48px; text-align: right; flex: none; color: #334155; }

/* 模板卡片 */
.tpl-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.tpl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tpl-foot { display: flex; gap: 8px; }
.tpl-card .codebox { font: 12px/1.6 ui-monospace, Consolas, monospace; }
