:root {
  --primary: #6a5cff;
  --primary-dark: #5847e8;
  --primary-soft: #efedff;
  --bg: #f4f5f9;
  --panel: #ffffff;
  --text: #1d2130;
  --sub: #8a90a6;
  --line: #eceef5;
  --danger: #e5484d;
  --ok: #17a673;
  --warn: #e08a2e;
  --sidebar: #171a2b;
}

* { box-sizing: border-box; }

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

button, input, select, textarea { font-family: inherit; font-size: 14px; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #eef0ff, #f7f4ff); }
.login-card { width: 360px; padding: 34px 30px; background: #fff; border-radius: 18px; box-shadow: 0 18px 50px rgba(31,35,41,.10); }
.login-card h1 { margin: 0 0 6px; font-size: 20px; }
.login-card p { margin: 0 0 22px; color: var(--sub); font-size: 13px; }
.login-card input { width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: #f8f9fc; outline: none; }
.login-card input:focus { border-color: var(--primary); background: #fff; }
.login-card button { width: 100%; height: 46px; margin-top: 16px; border: none; border-radius: 10px; background: var(--primary); color: #fff; font-size: 15px; font-weight: 600; }
.login-card button:hover { background: var(--primary-dark); }
.login-error { min-height: 18px; margin-top: 12px; color: var(--danger); font-size: 13px; }

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

.sidebar { width: 208px; flex-shrink: 0; display: flex; flex-direction: column; min-height: 100vh; background: var(--sidebar); color: #cfd3e4; padding: 22px 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.brand-logo { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 10px; background: linear-gradient(135deg, #7b6cff, #a084ff); font-size: 17px; }
.brand-name { font-size: 15px; font-weight: 600; color: #fff; }
.brand-sub { font-size: 11px; color: #7e849e; }

.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; margin-bottom: 4px; border-radius: 10px; color: #cfd3e4; font-size: 14px; cursor: pointer; }
.nav-item:hover { background: rgba(255,255,255,.06); }
.nav-item.on { background: var(--primary); color: #fff; font-weight: 600; }
.nav-icon { width: 18px; text-align: center; }

#nav { flex: 1; }
.sidebar-foot { display: block; margin-top: 20px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 11px; color: #6b7189; line-height: 1.7; }

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-title { font-size: 19px; font-weight: 700; }
.page-desc { margin-top: 4px; font-size: 12px; color: var(--sub); }
.head-actions { display: flex; gap: 8px; }

/* ---------- 通用控件 ---------- */
.btn { height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text); font-size: 13px; white-space: nowrap; flex: none; }
.btn:hover { border-color: #d7dbe8; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #ffd9d9; background: #fff6f6; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }

.field-input { height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; outline: none; }
.field-input:focus { border-color: var(--primary); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }

.panel { background: var(--panel); border-radius: 14px; box-shadow: 0 6px 22px rgba(31,35,41,.045); overflow: hidden; }
.panel-pad { padding: 18px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border-radius: 14px; padding: 16px 18px; box-shadow: 0 6px 22px rgba(31,35,41,.045); }
.stat b { display: block; font-size: 23px; letter-spacing: .5px; }
.stat span { color: var(--sub); font-size: 12px; }
.stat small { display: block; margin-top: 6px; font-size: 11px; color: var(--sub); }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--sub); font-weight: 500; background: #fafbfe; white-space: nowrap; }
tbody tr:hover { background: #fbfbff; }
tr:last-child td { border-bottom: none; }
td.num { font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 600; }
.cell-sub { margin-top: 4px; color: var(--sub); font-size: 12px; }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }

.pill {
  white-space: nowrap; display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; }
.pill.on { background: #e9f9f2; color: var(--ok); }
.pill.off { background: #f4f5f9; color: var(--sub); }
.pill.wait { background: #fff4e2; color: #c77700; }
.pill-cat { background: #f1efff; color: #6a5cff; }
.pill.top { background: #ffeceb; color: #f5343c; }
.pill.hot { background: var(--primary-soft); color: var(--primary); }

.empty { padding: 52px 0; text-align: center; color: var(--sub); font-size: 13px; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--sub); }
.pager-btns { display: flex; gap: 6px; }
.pager-btns button { height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.pager-btns button[disabled] { color: #c9cede; cursor: not-allowed; }

/* ---------- 弹窗 ---------- */
.mask { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(17,20,32,.45); }
.modal { width: 640px; max-height: 88vh; display: flex; flex-direction: column; background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(15,18,30,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 10px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 6px 24px 10px; overflow-y: auto; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px 20px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-inline input[type=file] { flex: 1; min-width: 180px; }
.cover-thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); flex: none; }
.cover-thumb.empty { display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--sub); background: #f6f7fb; }

/* 空图表 */
.chart-empty { display: flex; align-items: center; justify-content: center; height: 120px; color: var(--sub); font-size: 13px; background: repeating-linear-gradient(90deg, transparent, transparent 46px, #f3f4f9 46px, #f3f4f9 47px); border-radius: 10px; margin-top: 14px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { color: var(--sub); font-size: 12px; }
.form-item input, .form-item select, .form-item textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; background: #f8f9fc; padding: 9px 12px; outline: none; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--primary); background: #fff; }
.form-item textarea { min-height: 88px; resize: vertical; line-height: 1.6; }
.form-checks { display: flex; gap: 20px; padding: 4px 0 14px; }
.form-checks label { display: flex; align-items: center; gap: 6px; font-size: 13px; }

.toast { position: fixed; left: 50%; top: 22px; transform: translateX(-50%); z-index: 90; padding: 10px 18px; border-radius: 10px; background: rgba(29,33,48,.93); color: #fff; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

/* ---------- 近 7 天趋势 ---------- */
.chart { display: flex; align-items: flex-end; gap: 14px; height: 140px; margin-top: 16px; padding: 0 4px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.chart-bar { width: 100%; max-width: 46px; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, #8f7bff, #6a5cff); }
.chart-num { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-label { font-size: 11px; color: var(--sub); }

/* ---------- 封面色块 ---------- */
.tone-blue { background: linear-gradient(135deg, #2a2f6b, #4d5fd6); }
.tone-purple { background: linear-gradient(135deg, #4a3f9e, #7d6ae8); }
.tone-amber { background: linear-gradient(135deg, #8a5a2b, #c98b46); }
.tone-pink { background: linear-gradient(135deg, #8d3b6b, #d1639b); }
.tone-teal { background: linear-gradient(135deg, #1f5f5c, #2fa5a0); }
.tone-indigo { background: linear-gradient(135deg, #3b2f7a, #6b5bd0); }
.tone-orange { background: linear-gradient(135deg, #a34b1f, #e08243); }
.tone-green { background: linear-gradient(135deg, #1f5c3d, #3aa374); }

.foot-logout {
  display: block;
  width: fit-content;
  margin-bottom: 10px;
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 7px;
  color: #c2c7d8;
  font-size: 12px;
  cursor: pointer;
}
.foot-logout:hover { color: #fff; border-color: rgba(255,255,255,.32); }

/* ---------- 轮播图 ---------- */
.banner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.banner-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.banner-card.off { opacity: .55; }
.banner-thumb { aspect-ratio: 15 / 8; background: #f3f4f9; }
.banner-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.banner-body { padding: 12px 14px 14px; }
.banner-title { font-size: 14px; font-weight: 600; }
.banner-meta { margin-top: 4px; font-size: 12px; color: var(--sub); }
.banner-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- 上传区 ---------- */
.upload-box { display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 15 / 8; max-height: 230px; border: 1px dashed #cfd4e6; border-radius: 12px; background: #f8f9fc; cursor: pointer; overflow: hidden; }
.upload-box:hover { border-color: var(--primary); background: #f5f3ff; }
.upload-preview { width: 100%; height: 100%; object-fit: cover; }
.upload-empty { text-align: center; color: var(--sub); font-size: 13px; line-height: 1.8; }
.upload-empty small { color: #aab0c4; font-size: 11px; }
.upload-hint { font-size: 12px; color: var(--sub); }

/* ---------- 分类图标小方块 ---------- */
.cat-emoji { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 10px; font-size: 20px; }
.cat-emoji.tone-blue { background: #e8efff; }
.cat-emoji.tone-purple { background: #efeaff; }
.cat-emoji.tone-amber { background: #fff2e0; }
.cat-emoji.tone-pink { background: #ffe9f3; }
.cat-emoji.tone-teal { background: #e3f7f4; }
.cat-emoji.tone-indigo { background: #ecebff; }
.cat-emoji.tone-orange { background: #fff0e6; }
.cat-emoji.tone-green { background: #e6f7ee; }

/* ---------- 个人中心表单 ---------- */
.form-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.form-label { color: var(--sub); font-size: 12px; min-width: 60px; }
.form-section { margin: 22px 0 12px; padding-top: 14px; border-top: 1px solid var(--line); font-weight: 600; font-size: 13px; }

/* ---------- 资料编辑页 ---------- */
.back-link { display: inline-block; margin-bottom: 6px; color: var(--sub); font-size: 12px; cursor: pointer; }
.back-link:hover { color: var(--primary); }
.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.edit-col, .edit-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel-title { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.panel-title-hint { font-weight: 400; font-size: 12px; color: var(--sub); }
.panel-title .rte-count { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--sub); }
.panel > .form-grid, .panel > .cover-box, .panel > .switch-list { padding: 16px 18px; }
.req-mark { margin-left: 4px; padding: 1px 6px; border-radius: 5px; background: #ffeceb; color: #f5343c; font-size: 11px; }

/* 富文本编辑器 */
.rte-toolbar { position: sticky; top: 0; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 10px; background: #f8f9fc; border-bottom: 1px solid var(--line); }
.rte-btn { min-width: 30px; height: 30px; padding: 0 9px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #4a5162; font-size: 13px; line-height: 1; cursor: pointer; }
.rte-btn:hover { background: #eceef7; }
.rte-btn--text { padding: 0 8px; font-size: 12px; }
.rte-btn.on { background: var(--primary-soft); color: var(--primary); border-color: #dcd5ff; }
.rte-group { display: inline-flex; align-items: center; gap: 4px; }
.rte-sep { width: 1px; height: 20px; margin: 0 3px; background: var(--line); }
.rte-select { height: 30px; padding: 0 6px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: #4a5162; font-size: 12px; outline: none; }
.rte-color { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 30px; border: 1px solid transparent; border-radius: 7px; cursor: pointer; }
.rte-color:hover { background: #eceef7; }
.rte-color-label { font-size: 14px; font-weight: 700; line-height: 1.1; color: #4a5162; border-bottom: 3px solid #1d2130; }
.rte-color--bg .rte-color-label { border-bottom-color: #fff3b0; }
.rte-color input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.rte-editor { min-height: 360px; max-height: 620px; overflow-y: auto; padding: 18px 20px; background: #fff; font-size: 15px; line-height: 1.8; color: #1d2130; outline: none; }
.rte-editor:empty::before { content: attr(data-placeholder); color: #a8aebd; }
.rte-editor p { margin: 0 0 10px; }
.rte-editor h1 { margin: 18px 0 10px; font-size: 24px; }
.rte-editor h2 { margin: 16px 0 8px; font-size: 20px; }
.rte-editor h3 { margin: 14px 0 8px; font-size: 17px; }
.rte-editor blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--primary); background: #f7f6ff; color: #555c6e; }
.rte-editor img { display: block; max-width: 100%; margin: 10px 0; border-radius: 8px; }
.rte-editor ul, .rte-editor ol { margin: 10px 0; padding-left: 24px; }
.rte-editor li { margin: 4px 0; }
.rte-editor a { color: var(--primary); text-decoration: underline; }
.rte-editor hr { margin: 18px 0; border: none; border-top: 1px dashed var(--line); }

/* 封面 */
.cover-box { display: flex; flex-direction: column; gap: 12px; }
.cover-preview { display: flex; align-items: center; justify-content: center; width: 100%; height: 150px; border-radius: 12px; overflow: hidden; }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-empty { text-align: center; font-size: 12px; line-height: 1.6; color: rgba(255,255,255,.88); }
.cover-actions { display: flex; align-items: center; gap: 10px; }
.cover-actions input[type=file] { flex: 1; min-width: 0; font-size: 12px; }

/* 开关行 */
.switch-list { display: flex; flex-direction: column; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.switch-row:last-child { border-bottom: none; }
.switch-row b { display: block; font-size: 13px; font-weight: 600; }
.switch-row em { display: block; margin-top: 2px; font-size: 11px; font-style: normal; color: var(--sub); }
.switch-row input[type=checkbox] { width: 18px; height: 18px; flex: none; accent-color: var(--primary); }

@media (max-width: 1180px) {
  .edit-grid { grid-template-columns: 1fr; }
}

/* 支付方式选择（资料编辑页） */
.pay-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pay-tab {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: #f8f9fc; text-align: left; cursor: pointer; transition: all .15s;
}
.pay-tab b { font-size: 13px; font-weight: 600; color: #1d2130; }
.pay-tab em { font-style: normal; font-size: 11px; color: var(--sub); }
.pay-tab:hover { border-color: #cdc4ff; background: #faf9ff; }
.pay-tab.on { border-color: var(--primary); background: #f4f2ff; box-shadow: 0 0 0 3px rgba(106,92,255,.08); }
.pay-tab.on b { color: var(--primary); }
.form-item.is-off { opacity: .45; }
.form-item.is-off input { cursor: not-allowed; }
.pill.free { background: #fff1e8; color: #e06a1f; }
.form-item.is-off .req-mark { display: none; }

/* 表单字段旁的小说明 */
.form-hint { margin-left: 10px; font-size: 12px; color: var(--sub); }

/* 次要按钮（取消会员等） */
.btn-ghost {
  background: #f4f5f9;
  color: var(--sub);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: #eceef5; color: #5a6070; }
