* { box-sizing: border-box; }
:root {
  --bg: #f3f5f8; --card: #fff; --line: #e6e9ef; --text: #1f2933; --muted: #7b8794;
  --primary: #13398b; --primary-h: #0e2c6d; --gray: #556170; --danger: #d64545;
  --green-bg: #dff5e3; --green: #1d7a35; --red-bg: #fde2e4; --red: #c0392b; --amber-bg: #fff1d6; --amber: #a86a00;
  --mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .nowrap { white-space: nowrap; } .right { text-align: right; }
.mono { font-family: var(--mono); } .spacer { flex: 1; } .danger-text { color: var(--danger); }
code { font-family: var(--mono); background: #f0f2f6; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* ---------- 顶栏 ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 28px; padding: 0 28px; height: 56px;
  background: #fff; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 8px 14px; border-radius: 8px; cursor: pointer; color: var(--gray); user-select: none; }
.topbar nav a:hover { background: #f0f2f6; }
.topbar nav a.active { background: #e8eefb; color: var(--primary); font-weight: 600; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); }
main { padding: 24px 28px; max-width: 1500px; margin: 0 auto; }

/* ---------- 卡片 / 工具栏 ---------- */
.card { background: var(--card); border-radius: 14px; padding: 22px 24px; box-shadow: 0 1px 3px rgba(16,24,40,.06); }
.card-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 20px; }
.card h3 { margin: 22px 0 10px; font-size: 15px; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 3px 10px; border-radius: 99px; background: #eef1f5; font-size: 12.5px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.input { height: 38px; padding: 0 12px; border: 1px solid #cfd5dd; border-radius: 8px; font: inherit; background: #fff; color: inherit; }
.input:focus { outline: 2px solid #b9cbf3; border-color: var(--primary); }
.input.sm { height: 30px; padding: 0 8px; font-size: 13px; }
.input.search { width: 320px; }
textarea.input { height: auto; padding: 10px 12px; }
.batchbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 12px;
  background: #eef3ff; border: 1px solid #d4e0fb; border-radius: 10px; }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 38px; padding: 0 16px; border-radius: 8px;
  border: 1px solid #cfd5dd; background: #fff; color: var(--text); font: inherit; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f5f7fa; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-h); }
.btn.gray { background: var(--gray); border-color: var(--gray); color: #fff; }
.btn.danger { background: #fff; border-color: #f1b5b5; color: var(--danger); }
.btn.danger:hover { background: #fdf0f0; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--gray); }
.btn.ghost:hover { background: #f0f2f6; }
.btn.block { width: 100%; }
.icon-btn { border: 0; background: #e9ecf1; border-radius: 6px; margin-left: 6px; padding: 2px 6px; cursor: pointer; font-size: 12px; line-height: 1.6; }
.icon-btn:hover { background: #d9dee6; }
.link { color: var(--primary); cursor: pointer; text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { background: #eef1f5; text-align: left; font-weight: 600; padding: 12px 12px; white-space: nowrap; }
.tbl th:first-child { border-radius: 8px 0 0 8px; } .tbl th:last-child { border-radius: 0 8px 8px 0; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: #fafbfd; }
.tbl tr.sel td { background: #f2f6ff; }
.tbl .ck { width: 36px; } .tbl .mono { font-size: 14px; }
.tbl td.empty, .empty { text-align: center; color: var(--muted); padding: 48px 12px; }
.empty.err { color: var(--danger); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: #eef1f5; font-size: 12px; margin-right: 6px; }
.tag.warn { background: var(--amber-bg); color: var(--amber); }
.pw { letter-spacing: .5px; }
.status-sel { border: 0; border-radius: 99px; padding: 3px 8px; font: inherit; font-size: 13px; cursor: pointer; appearance: none; -webkit-appearance: none; text-align: center; }
.st-unused { background: var(--green-bg); color: var(--green); }
.st-assigned { background: var(--amber-bg); color: var(--amber); }
.st-used { background: var(--red-bg); color: var(--red); }
.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; padding: 20px; }
.dialog { background: #fff; border-radius: 14px; padding: 22px 24px; width: 460px; max-width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.dialog.wide { width: 720px; }
.dialog h3 { margin: 0 0 16px; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-weight: 600; }
.field .input { font-weight: normal; }
.radio { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--primary); background: #f5f8ff; }
.radio input { margin-top: 4px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.result-box { width: 100%; height: 340px; font-size: 13px; resize: vertical; }

/* ---------- 查看邮件 ---------- */
.modal.full { padding: 16px; align-items: stretch; }
.mv { background: #fff; border-radius: 14px; width: 100%; display: flex; flex-direction: column; overflow: hidden; }
.mv-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mv-acct { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mv-acct b { font-size: 15px; }
.mv-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.mv-body { flex: 1; display: flex; min-height: 0; }
.mv-list { width: 360px; flex-shrink: 0; border-right: 1px solid var(--line); overflow-y: auto; }
.mv-item { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.mv-item:hover { background: #f7f9fc; }
.mv-item.active { background: #e8eefb; }
.mv-item.unread .mv-from, .mv-item.unread .mv-subj { font-weight: 700; }
.mv-item-top { display: flex; justify-content: space-between; gap: 8px; }
.mv-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.mv-subj { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-meta { margin-top: 3px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-detail { flex: 1; overflow-y: auto; padding: 18px 22px; min-width: 0; }
.mail-subj { margin: 0 0 12px; font-size: 20px; word-break: break-word; }
.hdrs { border-collapse: collapse; margin-bottom: 12px; }
.hdrs th { text-align: left; color: var(--muted); font-weight: normal; padding: 3px 14px 3px 0; white-space: nowrap; vertical-align: top; }
.hdrs td { padding: 3px 0; word-break: break-all; }
.addr { display: inline-block; background: #f0f2f6; border-radius: 6px; padding: 0 8px; margin: 1px 4px 1px 0; font-family: var(--mono); font-size: 13px; }
.atts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.att { padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--primary); text-decoration: none; font-size: 13px; }
.att:hover { background: #f5f8ff; }
.mail-tabs { display: flex; gap: 6px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.tab { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font: inherit; color: var(--gray); }
.tab.active { background: #e8eefb; color: var(--primary); font-weight: 600; }
.mail-content iframe { width: 100%; height: 62vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.code { background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: 10px; font: 12.5px/1.6 var(--mono); overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 0 0 10px; }
.code.source { max-height: 62vh; overflow: auto; }
.links { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.links summary { cursor: pointer; font-weight: 600; }
.links ul { list-style: none; margin: 8px 0 0; padding: 0; }
.links li { padding: 8px 0; border-top: 1px dashed var(--line); }
.lk-text { font-size: 13px; color: var(--muted); }
.lk-row { display: flex; gap: 10px; align-items: center; }
.lk-url { flex: 1; min-width: 0; color: var(--primary); font-size: 12.5px; word-break: break-all; }

/* ---------- 设置 ---------- */
.token-row { display: flex; gap: 10px; flex-wrap: wrap; }
.token-row .input { flex: 1; min-width: 300px; }
.examples .ex-title { font-weight: 600; margin: 12px 0 6px; }
.pw-form { display: flex; gap: 10px; flex-wrap: wrap; }
.pw-form .input { width: 220px; }

/* ---------- 登录 ---------- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #e8eefb, #f3f5f8); }
.login-card { width: 360px; background: #fff; border-radius: 16px; padding: 34px 30px; box-shadow: 0 20px 50px rgba(16,24,40,.12); }
.login-logo { font-size: 40px; text-align: center; }
.login-card h1 { text-align: center; font-size: 20px; margin: 6px 0 24px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-weight: 600; }
.login-card input { height: 42px; padding: 0 12px; border: 1px solid #cfd5dd; border-radius: 8px; font: inherit; font-weight: normal; }
.login-err { color: var(--danger); min-height: 20px; margin: 4px 0 10px; font-size: 13px; }

/* ---------- 提示 ---------- */
#toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: #1f2933; color: #fff; padding: 10px 18px; border-radius: 10px; transition: all .2s; z-index: 100; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--danger); }

@media (max-width: 900px) {
  .topbar { gap: 12px; padding: 0 12px; } main { padding: 12px; } .input.search { width: 100%; }
  .mv-body { flex-direction: column; } .mv-list { width: auto; max-height: 35vh; border-right: 0; border-bottom: 1px solid var(--line); }
}
