:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e3e6ea;
  --text: #1f2328;
  --muted: #6b7280;
  --accent: #2563eb;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

.muted { color: var(--muted); }

/* ---------- 登录 ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: min(360px, 92vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px 28px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}

.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 20px; }

.login-card label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}

.login-card input {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
}

.login-card button {
  width: 100%;
  margin-top: 6px;
  padding: 11px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

.error { color: var(--danger); margin-bottom: 12px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.topbar .search {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.topbar .search input {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  width: 220px;
}

.topbar button, .btn {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}

.subject-title { max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 列表 ---------- */
.wrap { max-width: 1080px; margin: 24px auto; padding: 0 16px; }

.mail-list {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.mail-list th, .mail-list td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.mail-list thead th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: #fafbfc;
}

.mail-list tbody tr:last-child td { border-bottom: 0; }
.mail-list tbody tr:hover { background: #f8fafc; }

.from .name { font-weight: 600; }
.from .addr { color: var(--muted); font-size: 13px; }
.subject a { font-weight: 500; }
.time, .size { white-space: nowrap; color: var(--muted); font-size: 13px; }
.actions { width: 1%; }

button.danger {
  color: var(--danger);
  border: 1px solid #fecaca;
  background: #fff5f5;
  border-radius: 7px;
  padding: 5px 10px;
  cursor: pointer;
}

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.flash {
  max-width: 1080px;
  margin: 14px auto 0;
  padding: 9px 14px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  border-radius: 8px;
}

.pager { display: flex; gap: 16px; justify-content: center; margin: 18px 0; color: var(--muted); }

/* ---------- 详情 ---------- */
.meta {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 6px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 0 0 18px;
}

.meta dt { color: var(--muted); font-size: 13px; }
.meta dd { margin: 0; word-break: break-all; }

.body-html iframe {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.body-text pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.attachments {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 18px;
  margin-bottom: 18px;
}

.attachments h3 { margin: 4px 0 8px; font-size: 14px; }
.attachments ul { margin: 0; padding-left: 20px; }

.danger-zone { margin: 28px 0 60px; }
