:root {
  --primary: #0078d4;
  --primary-dark: #005a9e;
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #1b1f23;
  --muted: #6b7280;
  --border: #e5e9f0;
  --green: #1a9e5c;
  --red: #d13438;
  --orange: #d9822b;
  --radius: 14px;
  --shadow: 0 2px 14px rgba(16, 42, 90, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #eef4ff 0%, var(--bg) 320px);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand a { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.logo {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; border-radius: 10px; font-size: 17px;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.link-btn { color: var(--primary); text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.link-btn:hover { background: #eef6fd; }
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 8px;
}
.nav a:hover { background: #f0f5fb; color: var(--primary); }

.hero { text-align: center; padding: 26px 10px 8px; }
.hero h1 { font-size: 32px; margin: 0 0 12px; letter-spacing: .5px; }
.hero-sub { font-size: 16px; color: var(--muted); max-width: 640px; margin: 0 auto 18px; line-height: 1.7; }
.hero-badges { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.hero-badge { font-size: 13px; background: #e8f3fc; color: var(--primary-dark); padding: 6px 14px; }

.section-block { margin: 34px 0 8px; }
.section-block h2 { font-size: 22px; text-align: center; margin: 0 0 20px; }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.step {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.step-num {
  width: 36px; height: 36px; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; border-radius: 50%; font-weight: 700;
}
.step h3 { margin: 0 0 8px; font-size: 16px; }
.step p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.6; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.feature {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.feature-icon { font-size: 26px; margin-bottom: 8px; }
.feature h3 { margin: 0 0 8px; font-size: 16px; }
.feature p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.6; }

.faq { max-width: 760px; margin: 0 auto; }
.faq details {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.faq summary {
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 600;
  font-size: 15px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq summary::after { content: "▾"; color: var(--muted); }
.faq details[open] summary::after { transform: rotate(180deg); }
.faq details p { margin: 0; padding: 0 18px 16px; font-size: 14px; color: var(--muted); line-height: 1.7; }

.footer { background: #101820; color: #c6d0dc; margin-top: 50px; padding: 36px 24px 0; }
.footer-inner {
  max-width: 1080px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 26px;
}
.footer-col { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.footer-col h4 { margin: 0 0 6px; color: #fff; font-size: 15px; }
.footer-col a { color: #c6d0dc; text-decoration: none; }
.footer-col a:hover { color: #fff; }
.footer-col p { margin: 0; line-height: 1.7; }
.brand-col .brand { color: #fff; }
.footer-bottom {
  max-width: 1080px; margin: 28px auto 0;
  border-top: 1px solid rgba(255,255,255,.12);
  padding: 16px 0;
  font-size: 13px; color: #8fa0b1;
}

/* 内容页 */
.page {
  max-width: 820px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 38px;
  margin: 24px auto 0;
}
.page h1 { font-size: 26px; margin: 0 0 6px; }
.page .page-meta { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.page h2 { font-size: 20px; margin: 28px 0 12px; }
.page h3 { font-size: 17px; margin: 22px 0 10px; }
.page p, .page li { font-size: 15px; line-height: 1.85; color: #333; }
.page ul, .page ol { padding-left: 22px; }
.page a { color: var(--primary); }
.prose-box { background: #f7fafd; border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; font-size: 14px; color: var(--muted); margin: 14px 0; }

.article-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 10px; }
.article-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform .12s, box-shadow .12s;
}
.article-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(16,42,90,.12); }
.article-card .ac-date { font-size: 12px; color: var(--muted); }
.article-card h3 { margin: 8px 0; font-size: 16px; }
.article-card p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.6; }
.ac-cover { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); display: block; }

.cover { margin: 18px 0 24px; }
.cover img { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--border); display: block; }

.container { width: min(860px, 94%); margin: 26px auto 40px; flex: 1; }
.container.wide { width: min(1080px, 96%); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}

.mailbox-label { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.mailbox-email-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.email-text { font-size: 21px; font-weight: 700; word-break: break-all; flex: 1; min-width: 200px; }
.email-text.loading { color: var(--muted); font-weight: 400; font-size: 16px; }
.email-text.ready { color: var(--primary-dark); }
.mailbox-meta { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, transform .05s;
  font-family: inherit;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: #f4f7fb; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { background: #fff; border-color: #f2c4c5; color: var(--red); }
.btn.danger:hover { background: #fdf0f0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error-text { color: var(--red); font-size: 14px; margin-top: 10px; min-height: 18px; }
.result-box { margin-top: 12px; font-size: 13px; line-height: 1.7; color: var(--muted); }
.result-box .ok { color: var(--green); }
.result-box .bad { color: var(--red); }

.inbox-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.inbox-head h2, .card h2 { margin: 0 0 10px; font-size: 17px; }
.message-list { list-style: none; margin: 0; padding: 0; }
.message-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 10px;
  border-radius: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.message-list li:last-child { border-bottom: none; }
.message-list li:hover { background: #f6f9fe; }
.message-list li.unread { background: #eef6fd; }
.message-list li.unread:hover { background: #e3f0fb; }
.avatar {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  background: #dcebf7; color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.msg-main { flex: 1; min-width: 0; }
.msg-top { display: flex; align-items: baseline; gap: 8px; }
.msg-from { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { font-size: 12px; color: var(--muted); flex: none; margin-left: auto; }
.msg-subject { font-size: 14px; color: var(--text); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-preview { font-size: 13px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: none; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.empty .empty-icon { font-size: 42px; margin-bottom: 8px; }
.empty.error { color: var(--red); }

.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 18px; }

.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 20, 40, .45); }
.modal-card {
  position: relative;
  width: min(860px, 96%);
  height: min(86vh, 760px);
  background: #fff;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.m-subject { font-size: 16px; font-weight: 700; margin-bottom: 4px; word-break: break-word; }
.m-meta { font-size: 13px; color: var(--muted); }
.m-body { flex: 1; width: 100%; border: 0; background: #fff; }
.m-loading { position: absolute; left: 50%; top: 55%; transform: translate(-50%, -50%); color: var(--muted); font-size: 14px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #232a33;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  max-width: 86%;
}
.toast.error { background: var(--red); }

/* Admin */
.login-card { max-width: 420px; margin: 60px auto; }
.login-card form { display: flex; gap: 10px; }
.login-card input, .card textarea, .card input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  width: 100%;
}
.login-card input:focus, .card textarea:focus, .card input:focus { border-color: var(--primary); }
.card textarea { resize: vertical; margin: 4px 0 12px; }
.row-end { display: flex; justify-content: flex-end; }
.row { display: flex; align-items: center; gap: 10px; }

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 18px;
  margin: 4px 0 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.dropzone:hover, .dropzone.over {
  border-color: var(--primary);
  background: #f4f9fe;
  color: var(--text);
}
.dz-icon { font-size: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .num { font-size: 26px; font-weight: 800; }
.stat .lbl { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat.green .num { color: var(--green); }
.stat.red .num { color: var(--red); }
.stat.blue .num { color: var(--primary); }
.stat.gray .num { color: var(--muted); }

.table-wrap { overflow-x: auto; }
.box-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.box-table th, .box-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.box-table th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
.box-table td { min-width: 90px; }
.box-table .email-cell { font-weight: 600; word-break: break-all; min-width: 200px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.healthy { background: #e3f7ec; color: var(--green); }
.badge.error { background: #fdeaea; color: var(--red); }
.badge.unknown { background: #f1f3f6; color: var(--muted); }
.badge.disabled { background: #e9ecf0; color: #4b5563; text-decoration: line-through; }
.op-row { display: flex; gap: 6px; flex-wrap: wrap; }
.err-tip { max-width: 260px; color: var(--red); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 后台查看邮件 */
.mail-modal .modal-card { height: min(88vh, 820px); }
.mail-view { display: flex; flex: 1; min-height: 0; }
.mail-list-pane {
  width: 330px;
  flex: none;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: #fafcff;
}
.mail-list-pane .mm-status { padding: 10px 14px; }
.mail-mini-list li { padding: 10px 12px; }
.mail-mini-list li.load-more { justify-content: center; cursor: default; }
.mail-mini-list li.load-more:hover { background: none; }
.mail-body-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  position: relative;
}
.mail-body-pane .m-subject { margin-bottom: 2px; }
.mail-body-pane .m-meta { margin-bottom: 10px; }
.mail-body-pane .m-body { flex: 1; min-height: 0; border: 1px solid var(--border); border-radius: 8px; }
.mail-body-pane .m-loading { top: 45%; }

@media (max-width: 720px) {
  .mail-view { flex-direction: column; }
  .mail-list-pane { width: 100%; max-height: 42%; border-right: 0; border-bottom: 1px solid var(--border); }
  .mail-body-pane { min-height: 280px; }
}

@media (max-width: 640px) {
  .container { width: 96%; margin-top: 14px; }
  .email-text { font-size: 17px; }
  .card { padding: 16px; }
  .mailbox-email-row .btn { flex: 1; text-align: center; }
}
