/* ============================================================
   微信推送管理后台 · 统一主题（总部 Center / 子站 Worker 共用）
   ============================================================ */
:root {
  --primary: #2f6bff;
  --primary-600: #2053d6;
  --primary-soft: #e8efff;
  --success: #16a34a;
  --success-soft: #e7f6ec;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warning: #d97706;
  --warning-soft: #fdf3e2;
  --text: #1e293b;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --sidebar-w: 232px;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .06);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

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

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0f1e3d 0%, #13294f 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand-logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #22d3ee);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, .45);
}
.brand-title { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.2; }
.brand-sub { font-size: 11px; color: #7c8db5; }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 4px;
  border-radius: 9px; cursor: pointer; color: #b6c2dd;
  font-size: 13.5px; font-weight: 500;
  transition: all .15s ease;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, .28), rgba(59, 130, 246, .08));
  color: #fff; box-shadow: inset 3px 0 0 #3b82f6;
}
.nav-item .ico { font-size: 16px; width: 20px; text-align: center; }
.nav-item .badge {
  margin-left: auto; background: #ef4444; color: #fff;
  font-size: 11px; padding: 1px 7px; border-radius: 99px; font-weight: 700;
}
.sidebar-foot {
  padding: 14px 18px; border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 12px; color: #7c8db5; display: flex; align-items: center; gap: 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }
.dot.off { background: #64748b; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 26px; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 4px 12px; border-radius: 99px; font-weight: 600;
}
.pill.ok { background: var(--success-soft); color: var(--success); }
.pill.warn { background: var(--warning-soft); color: var(--warning); }
.pill.mock { background: var(--primary-soft); color: var(--primary); }
.pill.gray { background: #f1f5f9; color: var(--text-2); }

.content { padding: 26px; flex: 1; }
.page { display: none; }
.page.active { display: block; }

/* ---------- 统计卡片 ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ""; position: absolute; right: -24px; top: -24px;
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, var(--tint, rgba(47, 107, 255, .14)), transparent 70%);
}
.stat-card.clickable { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.stat-card.clickable:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15, 23, 42, .12); }
.stat-card.clickable .stat-value { text-decoration: underline dotted; text-underline-offset: 5px; }
.stat-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.stat-desc { font-size: 12px; color: var(--text-3); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  margin-bottom: 24px; overflow: hidden;
}
.card-head {
  padding: 16px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .spacer { flex: 1; }
.card-body { padding: 8px 22px 22px; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 12px; color: var(--text-2); font-weight: 600;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: #f8fafc; white-space: nowrap;
}
td {
  padding: 11px 14px; border-bottom: 1px solid #f1f5f9;
  font-size: 13.5px; vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafcff; }
.mono { font-family: var(--mono); font-size: 12.5px; }
/* 多行文本单元格：保留换行（微信模板内容的 \n），超长可滚动 */
.cell-multiline {
  white-space: pre-wrap; word-break: break-word;
  line-height: 1.6; overflow: auto; max-width: 100%;
}
.tbl-empty { text-align: center; color: var(--text-3); padding: 34px 0 !important; }

/* 宽表格横向滚动兜底：.card 是 overflow:hidden，表格超出宽度会被直接裁掉（不是滚动） */
.tbl-wrap { overflow-x: auto; }

/* 表格列显示规则（与子站 worker 保持一致，**不做任何省略号截断**）：
   · 短字段（时间/子站/模板/openid/任务/结果）→ 完整显示 + 不可换行（.cell-nw）
   · 长字段（发送数据/错误说明，长度不定）→ 完整显示 + 允许换行（.cell-tags） */
.cell-nw { white-space: nowrap; }
.cell-tags { white-space: normal; word-break: break-word; overflow-wrap: anywhere; line-height: 1.9; }
.cell-tags .tag { white-space: normal; word-break: break-word; line-height: 1.5; }

.tag {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 2px 10px; border-radius: 99px;
}
.tag.blue { background: var(--primary-soft); color: var(--primary); }
.tag.green { background: var(--success-soft); color: var(--success); }
.tag.red { background: var(--danger-soft); color: var(--danger); }
.tag.gray { background: #f1f5f9; color: var(--text-2); }
.tag.amber { background: var(--warning-soft); color: var(--warning); }
.tag.purple { background: #f1ebfe; color: #7c3aed; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 8px 16px; border-radius: 9px; cursor: pointer;
  font-size: 13px; font-weight: 600; transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary {
  background: linear-gradient(135deg, #2f6bff, #2563eb); color: #fff; border: none;
  box-shadow: 0 4px 12px rgba(47, 107, 255, .3);
}
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn.sm { padding: 5px 12px; font-size: 12.5px; border-radius: 7px; }
.btn.ghost { border: none; background: transparent; color: var(--text-2); }
.btn.ghost:hover { color: var(--primary); background: var(--primary-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 粉丝/列表工具栏 ---------- */
.fans-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.fans-toolbar .input.sm {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 12.5px; outline: none; background: #fff; color: var(--text);
}
.fans-toolbar .input.sm:focus { border-color: var(--primary); }
.fans-toolbar .chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.pager { display: flex; align-items: center; justify-content: flex-end; margin-top: 12px; gap: 4px; font-size: 13px; color: var(--text-2); }
.pager .btn:disabled { opacity: .4; }
.modal-body .chk { font-size: 13px; color: var(--text); cursor: pointer; }

/* 用户弹窗「所属城市」多选列表：复选框必须在行首、保持原生尺寸。
   ⚠️ 通用样式 `.field input { width:100%; padding:9px 12px; border:1px solid ... }`
   会命中这里的 checkbox，把复选框撑满整行、文字被挤到下一行（曾出现错位）。
   故这里显式复位 width/padding/border/background，并用 flex 保证左对齐。 */
.city-list {
  display: block; max-height: 220px; overflow: auto;
  border: 1px solid var(--border); border-radius: 9px; padding: 6px 12px;
}
.city-list .chk {
  display: flex; align-items: center; gap: 8px;
  margin: 6px 0; font-size: 13px; font-weight: 400;
  color: var(--text); cursor: pointer;
}
.city-list .chk input[type="checkbox"] {
  width: auto; min-width: 0; height: auto; flex: 0 0 auto;
  margin: 0; padding: 0; border: 0; border-radius: 0; background: none;
  box-shadow: none; accent-color: var(--primary);
}
.city-list .chk input[type="checkbox"]:focus { box-shadow: none; }
.city-list .chk .chk-txt { flex: 1 1 auto; min-width: 0; line-height: 1.6; }
.fan-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; display: inline-block; vertical-align: middle; }
.fan-avatar.empty { display: inline-flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); font-size: 14px; font-weight: 600; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 9px; font-size: 13.5px; font-family: inherit;
  background: #fff; color: var(--text); outline: none; transition: border .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 107, 255, .12);
}
.field textarea { resize: vertical; min-height: 76px; font-family: var(--mono); font-size: 12.5px; }
.field .hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: none; align-items: center; justify-content: center; z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-mask.show { display: flex; }
.modal {
  width: min(560px, calc(100vw - 40px)); max-height: 88vh; overflow-y: auto;
  background: #fff; border-radius: 16px; box-shadow: 0 24px 64px rgba(15, 23, 42, .25);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-head .spacer { flex: 1; }
.modal-close { border: none; background: none; font-size: 20px; color: var(--text-3); cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px 24px; }
.modal-foot {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ---------- Key 展示 ---------- */
.key-box {
  display: flex; align-items: center; gap: 8px;
  background: #f8fafc; border: 1px dashed var(--border);
  border-radius: 9px; padding: 10px 14px; margin-top: 12px;
  font-family: var(--mono); font-size: 12.5px; word-break: break-all; color: var(--text);
}

/* ---------- 连接状态大卡片（子站） ---------- */
.conn-hero {
  border-radius: 14px; padding: 26px 28px; color: #fff; margin-bottom: 24px;
  display: flex; align-items: center; gap: 22px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
}
.conn-hero.on { background: linear-gradient(135deg, #16a34a, #15803d); }
.conn-hero.off { background: linear-gradient(135deg, #64748b, #475569); }
.conn-hero .big { font-size: 30px; font-weight: 800; }
.conn-hero .meta { font-size: 13px; opacity: .85; }
.conn-ico {
  width: 54px; height: 54px; border-radius: 50%;
  background: rgba(255, 255, 255, .18); display: flex;
  align-items: center; justify-content: center; font-size: 26px;
}

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 74px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 10px 30px rgba(15, 23, 42, .3);
  animation: slideIn .2s ease; display: flex; align-items: center; gap: 8px;
  max-width: 380px;
}
.toast.error { background: #b91c1c; }
.toast.ok { background: #15803d; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 状态点行内 ---------- */
.inline-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.inline-dot.on { background: #22c55e; }
.inline-dot.off { background: #cbd5e1; }

/* ---------- 日志列表 ---------- */
.log-list { max-height: 420px; overflow-y: auto; }
.log-item {
  display: flex; gap: 12px; padding: 10px 6px;
  border-bottom: 1px dashed #eef2f7; font-size: 13px;
}
.log-item:last-child { border-bottom: none; }
.log-time { color: var(--text-3); font-family: var(--mono); font-size: 12px; white-space: nowrap; }

/* ---------- 空态 / 提示条 ---------- */
.notice {
  background: var(--primary-soft); border: 1px solid #d5e3ff;
  color: #2053d6; border-radius: 10px; padding: 12px 16px; font-size: 13px;
  /* block + line-height：notice 内含 <b>/<code> 等内联标签，
     用 flex 会把它们拆成独立 flex 项导致排版错乱（与子站样式表保持一致）。 */
  margin-bottom: 20px; display: block; line-height: 1.7;
}

@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .brand-title, .brand-sub, .nav-item span.txt, .sidebar-foot span { display: none; }
  .nav-item { justify-content: center; }
  .form-grid { grid-template-columns: 1fr; }
}
