:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
}

* { box-sizing: border-box; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -0.3px; }
h2 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0 0 10px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 26px; padding-bottom: 40px; min-height: 60vh; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.break { word-break: break-all; }
.right { text-align: right; }
.center { justify-content: center; }
.mt { margin-top: 20px; }
.tight { margin: 6px 0 0; padding-left: 18px; }

/* 顶栏 */
.topbar { background: #0f172a; color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { color: #fff; font-weight: 700; font-size: 16px; letter-spacing: 0.5px; }
.brand:hover { text-decoration: none; }
nav a { color: #cbd5e1; margin-left: 22px; font-size: 14px; }
nav a:hover, nav a.active { color: #fff; text-decoration: none; }

/* 页头 */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.page-head p { margin: 2px 0 0; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.section-title { margin: 26px 0 12px; }
.inline { display: inline; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form input { max-width: 320px; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.table-card { padding: 0; overflow: hidden; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font-size: 14px; font-weight: 600;
  cursor: pointer; line-height: 1.4; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }

/* 表格 */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  background: #f8fafc; padding: 11px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid #eef2f7; vertical-align: top; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafcff; }
.table.compact th, .table.compact td { padding: 9px 14px; }
.task-name { font-weight: 600; margin-bottom: 4px; }
.url-cell { max-width: 250px; word-break: break-all; }
.url-cell a { color: #475569; }
.recipients-cell { max-width: 170px; word-break: break-all; }
.message-cell { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin: 2px 0 2px 4px; }
.status-text { margin-top: 2px; word-break: break-all; }
.status-text.ok { color: var(--ok); }
.status-text.error { color: var(--danger); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }

/* 徽标 */
.badge {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  background: #f1f5f9; color: #475569; font-size: 12px; font-weight: 600;
  border: 1px solid #e2e8f0; vertical-align: 1px;
}
.badge.on { background: #dcfce7; border-color: #bbf7d0; color: #166534; }
.badge.off { background: #f1f5f9; border-color: #e2e8f0; color: #64748b; }
.badge.new { background: #dbeafe; border-color: #bfdbfe; color: #1d4ed8; }
.badge.update { background: #fef3c7; border-color: #fde68a; color: #b45309; }
.badge.ok { background: #dcfce7; border-color: #bbf7d0; color: #166534; }
.badge.error { background: #fee2e2; border-color: #fecaca; color: #b91c1c; }
.badge.info { background: #e0f2fe; border-color: #bae6fd; color: #0369a1; }

/* 提示条 */
.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.flash.info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.flash.ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.flash.error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* 表单 */
label {
  display: block; margin-bottom: 16px;
  font-size: 13px; font-weight: 600; color: #334155;
}
input, select, textarea {
  width: 100%; margin-top: 6px; padding: 9px 12px;
  border: 1px solid #cbd5e1; border-radius: 9px; background: #fff;
  font-size: 14px; font-family: inherit; color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}
textarea { resize: vertical; line-height: 1.6; }
label.check {
  display: flex; align-items: center; gap: 8px;
  font-weight: 500; cursor: pointer;
}
label.check input { width: auto; margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 18px; }
.form-card section { padding-bottom: 6px; margin-bottom: 20px; border-bottom: 1px dashed var(--line); }
.form-card section:last-of-type { border-bottom: none; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 12.5px; margin: -8px 0 14px; }
.form-actions { display: flex; gap: 10px; padding-top: 6px; }

/* 预览 */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px; display: flex; flex-direction: column; gap: 2px;
}
.stat span { font-size: 12px; color: var(--muted); }
.stat strong { font-size: 22px; letter-spacing: -0.5px; }
.preview-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr); gap: 20px; align-items: start; }
.preview-grid .card { margin-bottom: 0; }
.email-preview {
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
}
.email-preview a { text-decoration: none; }
.item-list { list-style: none; margin: 0; padding: 0; }
.item-list li { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.item-list li:last-child { border-bottom: none; }
.item-title { font-weight: 600; line-height: 1.5; }
.snippet { color: #475569; font-size: 13px; margin: 6px 0 0; }
.kv { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; word-break: break-word; }

/* 空状态 / 登录 / 页脚 */
.empty-state { text-align: center; padding: 46px 24px; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { max-width: 560px; margin: 0 auto 10px; color: #475569; }
.empty-state .actions { margin-top: 18px; }
.login-wrap { display: flex; justify-content: center; padding: 8vh 0 6vh; }
.login-card { width: 100%; max-width: 380px; padding: 32px; }
.login-card h1 { font-size: 22px; }
.login-card .hint { margin: 14px 0 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label { margin-bottom: 0; }
.footer { color: #94a3b8; font-size: 12px; text-align: center; padding: 10px 20px 34px; }

@media (max-width: 900px) {
  .page-head { flex-direction: column; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .preview-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .table { min-width: 760px; }
  .topbar-inner { height: auto; padding: 12px 0; flex-direction: column; gap: 8px; }
  nav a { margin: 0 10px; }
  .actions-cell { white-space: normal; }
}
