* { box-sizing: border-box; }
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #e3e8ef;
  --text: #1f2733;
  --muted: #6b7686;
  --primary: #2f6bff;
  --primary-d: #1f54d6;
  --green: #1d9e75;
  --red: #e24b4a;
  --amber: #ba7517;
  --radius: 10px;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* 登录 */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 6px 24px rgba(20,40,80,.06); }
.login-box h1 { margin: 0 0 4px; font-size: 20px; }
.login-sub { margin: 0 0 18px; color: var(--muted); }
.login-tip { margin-top: 14px; color: var(--muted); font-size: 12px; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: 0 0 220px;
  background: #0f1b33; color: #cdd6e6;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 18px 12px; font-size: 16px; font-weight: 600; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.menu { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.menu-item {
  display: block; padding: 11px 14px; border-radius: 8px; color: #cdd6e6;
  text-decoration: none; font-size: 14px; transition: background .15s;
}
.menu-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.menu-item.active { background: var(--primary); color: #fff; }
.side-bottom { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 4px; }
.menu-item.logout { color: #ff9b9b; }
.menu-item.logout:hover { background: rgba(226,75,74,.18); color: #fff; }

.content { flex: 1; padding: 22px 26px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.page-head h2 { margin: 0; font-size: 18px; }
.page-desc { color: var(--muted); margin: 0 0 16px; }

/* 卡片/面板 */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.card-desc { color: var(--muted); font-size: 12px; margin: -8px 0 14px; }

/* 表单 */
label { display: block; font-size: 13px; margin: 12px 0 5px; color: #3a4456; }
input[type=text], input[type=password], input[type=email], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
  font-family: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,107,255,.12); }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.col-2 { grid-column: span 2; }

/* 按钮 */
.btn { display: inline-block; padding: 9px 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); cursor: pointer; font-size: 14px; text-decoration: none; }
.btn:hover { border-color: #c4ccda; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover, .btn[disabled]:hover { border-color: var(--line); }

/* 内容库：空类别视觉标记（让用户一眼看出"还没加内容"） */
.grp-item.empty span:first-child { color: #9099a8; font-style: italic; }

/* 提示 */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert-error { background: #fdecec; color: #a32d2d; border: 1px solid #f7c1c1; }
.alert-success { background: #eaf3de; color: #27500a; border: 1px solid #c0dd97; }
.alert-info { background: #e8f0fe; color: #0c447c; border: 1px solid #b5d4f4; }

/* 表格 */
table.tbl { width: 100%; border-collapse: collapse; background: var(--panel); font-size: 13px; }
table.tbl th, table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.tbl th { background: #f7f9fc; color: #3a4456; font-weight: 600; }
table.tbl tr:hover td { background: #fafbff; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }

/* 徽标状态 */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.badge.pending { background: #eef1f6; color: #6b7686; }
.badge.sending { background: #fff4e0; color: #854f0b; }
.badge.sent { background: #eaf3de; color: #27500a; }
.badge.failed { background: #fdecec; color: #a32d2d; }

/* 概览统计 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.green .n { color: var(--green); }
.stat.red .n { color: var(--red); }

/* 工具栏 */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.check { width: 16px; height: 16px; }

/* 批量操作条 */
.bulk-bar { display: none; align-items: center; gap: 8px; padding: 10px 12px; background: #eef3ff; border: 1px solid #c5d6ff; border-radius: 8px; margin-bottom: 12px; }
.bulk-bar.show { display: flex; }

/* 模板编辑器 */
.editor-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.editor-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.token-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.token-btn { padding: 4px 10px; border: 1px dashed var(--primary); color: var(--primary); background: #f3f7ff; border-radius: 6px; cursor: pointer; font-size: 12px; }
.token-btn:hover { background: #e3edff; }
.preview { border: 1px solid var(--line); border-radius: 8px; padding: 14px; min-height: 200px; background: #fff; }
.preview img { max-width: 100%; }

/* 富文本工具栏 */
.rte-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px; background: #f4f7fb; border: 1px solid var(--line); border-radius: 8px 8px 0 0; border-bottom: none; }
.rbtn { min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid #d4dbe6; background: #fff; border-radius: 6px; cursor: pointer; font-size: 14px; line-height: 1; color: #2d3748; display: inline-flex; align-items: center; justify-content: center; }
.rbtn:hover { background: #eaf1fb; }
.rsep { width: 1px; height: 20px; background: #cdd6e3; margin: 0 4px; }
.rcolor { position: relative; padding: 0 6px; }
.rcolor input[type=color] { width: 20px; height: 20px; border: none; background: none; padding: 0; cursor: pointer; vertical-align: middle; }
.rcall { background: #fff7e6; border-color: #f0c36d; color: #8a5a00; font-weight: bold; }
.rcall:hover { background: #fff0cc; }
.rte { border: 1px solid var(--line); border-radius: 0 0 8px 8px; min-height: 280px; padding: 16px; background: #fff; outline: none; overflow: auto; line-height: 1.7; }
.rte:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(43,108,176,.12); }
.rte:empty:before { content: attr(data-placeholder); color: #a7b0bd; }
.rte img { max-width: 100%; }
.rte a { color: #2b6cb0; }

/* 签名/小尺寸富文本编辑器 */
.rte-mini-wrap { border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.rte-toolbar-mini { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; padding: 6px 8px; background: #f4f7fb; border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.rbtn { padding: 3px 7px; border: 1px solid transparent; background: transparent; border-radius: 4px; cursor: pointer; font-size: 13px; min-width: 26px; line-height: 1.3; }
.rbtn:hover { background: #e3edff; border-color: var(--primary); }
.rbtn[data-cmd="fontSize"] { padding: 2px 4px; font-size: 12px; }
.rbtn[type="color"] { padding: 1px; height: 24px; width: 28px; cursor: pointer; }
.rte-mini { min-height: 120px; max-height: 360px; padding: 12px 14px; outline: none; overflow: auto; line-height: 1.6; font-size: 14px; }
.rte-mini:focus { box-shadow: inset 0 0 0 1px var(--primary); }
.rte-mini:empty:before { content: attr(data-placeholder); color: #a7b0bd; }
.rte-mini img { max-width: 100%; height: auto; }
.rte-mini table { border-collapse: collapse; }
.rte-mini a { color: #2b6cb0; }

/* 进度 */
.progress { height: 10px; background: #eef1f6; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--green); }

/* toast */
.toast { position: fixed; right: 20px; bottom: 20px; background: #1f2733; color: #fff; padding: 11px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transform: translateY(8px); transition: .2s; z-index: 99; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #a32d2d; }
.toast.success { background: #27500a; }

/* 响应式 */
@media (max-width: 980px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { border: none; padding: 12px 14px; }
  .menu { flex-direction: row; flex-wrap: wrap; padding: 0 10px; }
  .side-bottom { border: none; flex-direction: row; margin-left: auto; }
  .content { padding: 16px; }
  .field-grid, .editor-wrap, .stats { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .field-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
}

/* 富文本编辑器已换用 TinyMCE（assets/tinymce/），样式由插件自带，无需额外容器 CSS */
