/* 邮箱管家 · 自建版 — 左右分栏布局 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f3f5f9; color: #1f2937; font-size: 15px; line-height: 1.5;
}
.hidden { display: none !important; }
.muted { color: #7b8794; }
.small { font-size: 12.5px; }
b { font-weight: 600; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block; border: 0; border-radius: 8px; padding: 8px 12px;
  font-size: 13.5px; font-weight: 500; cursor: pointer; color: #fff;
  background: #6b7280; transition: filter .15s; white-space: nowrap; user-select: none;
}
.btn:active { filter: brightness(.88); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.small { padding: 5px 9px; font-size: 12.5px; border-radius: 6px; }
.btn.block { display: block; width: 100%; }
.btn.primary { background: #3b82f6; }
.btn.cyan    { background: #06b6d4; }
.btn.orange  { background: #f59e0b; }
.btn.green   { background: #10b981; }
.btn.blue    { background: #6366f1; }
.btn.red     { background: #ef4444; }
.btn.ghost   { background: #e5e7eb; color: #374151; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  background: linear-gradient(160deg, #dbeafe, #f3f5f9 60%);
  padding: 24px 18px;
}
.login-card {
  width: 100%; max-width: 380px; background: #fff; border-radius: 18px;
  padding: 30px 24px; box-shadow: 0 10px 40px rgba(30,64,175,.10); text-align: center;
}
.login-logo { font-size: 44px; }
.login-card h1 { margin: 8px 0 2px; font-size: 22px; }
.login-card p { margin: 0 0 20px; font-size: 13px; }
.login-card input { width: 100%; margin-bottom: 12px; }

/* ---------- 输入控件 ---------- */
input[type=text], input[type=password], input:not([type]), select, textarea {
  width: 100%; border: 1px solid #d1d5db; border-radius: 9px;
  padding: 9px 11px; font-size: 14px; background: #fff; color: inherit;
  font-family: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
textarea { resize: vertical; line-height: 1.45; }
.err-text { color: #ef4444; font-size: 13px; min-height: 18px; margin-top: 8px; word-break: break-all; }
.ok-text { color: #10b981; font-size: 13px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #fff; border-bottom: 1px solid #e8ecf2;
}
.brand { font-weight: 700; font-size: 16px; }
.top-right { display: flex; gap: 8px; }

/* ========== 左右分栏核心布局 ========== */
.split-layout {
  display: flex;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  max-width: 1200px;
  margin: 0 auto;
  overflow: hidden;
}

/* ---------- 左侧面板 ---------- */
.left-panel {
  width: 340px;
  min-width: 280px;
  display: flex; flex-direction: column;
  border-right: 1px solid #e8ecf2;
  background: #f8f9fb;
  overflow: hidden;
}
.left-panel .stats {
  display: flex; gap: 12px; flex-wrap: wrap;
  padding: 8px 12px; font-size: 12.5px; color: #4b5563; flex: none;
  background: #fff; border-bottom: 1px solid #eef1f5;
}
.left-panel .stats b { color: #1d4ed8; }
.left-panel .toolbar { padding: 8px 10px; flex: none; background: #fff; border-bottom: 1px solid #eef1f5; }
.left-panel .toolbar .row1 { display: flex; gap: 6px; margin-bottom: 6px; }
.left-panel .toolbar .row1 input { flex: 1; font-size: 13px; padding: 7px 10px; }
.left-panel .toolbar .row1 select { width: 100px; flex: none; font-size: 13px; padding: 7px 8px; }
.left-panel .toolbar .row2 { display: flex; gap: 5px; flex-wrap: wrap; }
.left-panel .toolbar .row2 .btn { flex: 1 1 calc(25% - 5px); padding: 7px 4px; font-size: 12px; border-radius: 7px; min-width: 0; }
.left-panel .list-head { display: flex; align-items: center; gap: 10px; padding: 6px 12px; font-size: 12.5px; flex: none; border-bottom: 1px solid #eef1f5; }
.pick-all { display: flex; align-items: center; gap: 5px; user-select: none; font-size: 13px; }
input[type=checkbox] { width: 15px; height: 15px; accent-color: #3b82f6; }

/* ---------- 账号列表（左侧，可滚动） ---------- */
#acctList {
  flex: 1; overflow-y: auto; padding: 4px 8px 12px;
  display: flex; flex-direction: column; gap: 0;
}
.acct {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 10px; padding: 8px 10px;
  margin-top: 6px; border: 1px solid #e8ecf2; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.acct:hover { border-color: #bfdbfe; }
.acct:active { background: #f0f5ff; }
.acct.has-mail { border-left: 3px solid #3b82f6; }
.acct .main { flex: 1; min-width: 0; pointer-events: none; }
.acct .email-line { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.acct .email { font-weight: 600; font-size: 13.5px; word-break: break-all; }
.acct .sub { font-size: 11.5px; color: #8a94a3; margin-top: 1px; word-break: break-all; }
.chip {
  display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 999px;
  background: #eef2ff; color: #4f46e5; flex: none;
}
.badge { font-size: 10.5px; padding: 1px 6px; border-radius: 999px; flex: none; }
.badge.g { background: #ecfdf5; color: #059669; }
.badge.i { background: #fffbeb; color: #b45309; }
.badge.x { background: #f3f4f6; color: #6b7280; }
.badge.r { background: #fef2f2; color: #dc2626; }
.badge.e { background: #fff7ed; color: #ea580c; }
.badge.n { background: #eff6ff; color: #2563eb; }
.acct .sub-err { font-size: 11px; color: #dc2626; margin-top: 2px; word-break: break-all; line-height: 1.35; }

/* ---------- 表单字段 ---------- */
.fld { display: block; margin-bottom: 10px; }
.fld > span { display: block; font-size: 12.5px; color: #374151; margin-bottom: 4px; font-weight: 500; }
.acct .ops { display: flex; gap: 4px; flex: none; pointer-events: none; }
.acct .ops .btn { pointer-events: auto; padding: 4px 7px; font-size: 11.5px; border-radius: 5px; }
.empty { text-align: center; color: #9aa4b1; padding: 28px 12px; font-size: 14px; }

/* ---------- 检测进度条 ---------- */
.check-progress {
  margin-top: 8px; padding: 8px 10px; background: #f8fafc;
  border-radius: 8px; border: 1px solid #e2e8f0;
}
.cp-bar { height: 5px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
.cp-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #06b6d4); border-radius: 999px; transition: width .3s; width: 0%; }
.cp-info { display: flex; align-items: center; gap: 10px; font-size: 12px; color: #475569; }
.cp-ok { color: #059669; }
.cp-fail { color: #dc2626; }
.cp-info .btn { margin-left: auto; padding: 3px 8px; font-size: 11px; }

/* ========== 右侧面板 ========== */
.right-panel {
  flex: 1; display: flex; flex-direction: column;
  background: #fff; overflow: hidden; min-width: 0;
}
.rp-placeholder {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: #9aa4b1; gap: 8px;
}
.rpp-icon { font-size: 56px; opacity: .5; }
.rp-placeholder p { margin: 0; font-size: 14px; }

.rp-mail { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.rpm-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid #eef1f5; flex: none;
}
.rpm-acct { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex-shrink: 1; }
.rpm-tabs { display: flex; gap: 2px; flex: none; }
.rpm-tabs .tab {
  border: 0; background: transparent; padding: 6px 10px; font-size: 13px;
  color: #6b7280; cursor: pointer; border-bottom: 2px solid transparent; font-weight: 500;
}
.rpm-tabs .tab.active { color: #1d4ed8; border-bottom-color: #3b82f6; }
.rpm-actions { margin-left: auto; display: flex; gap: 4px; flex: none; }
.rpm-actions .btn { padding: 4px 8px; font-size: 13px; border-radius: 6px; }
.rpm-via { padding: 2px 14px; flex: none; }
.rpm-body { flex: 1; overflow-y: auto; padding: 8px 10px; }

/* ---------- 邮件列表（右侧） ---------- */
.mail-list { display: flex; flex-direction: column; }
.mail-item { padding: 10px 8px; border-bottom: 1px solid #f0f2f6; cursor: pointer; border-radius: 6px; }
.mail-item:hover { background: #f8fafc; }
.mail-item .l1 { display: flex; gap: 8px; align-items: baseline; }
.mail-item .from { font-size: 13px; color: #4b5563; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item .date { font-size: 11.5px; color: #9aa4b1; flex: none; }
.mail-item .subject { font-weight: 600; font-size: 13.5px; margin-top: 2px; word-break: break-all; }
.mail-item .preview { font-size: 12px; color: #8a94a3; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mail-item.unread .subject::before { content: "● "; color: #3b82f6; font-size: 9px; }

/* ---------- 邮件正文（右侧） ---------- */
.msg-view .msg-head { padding-bottom: 10px; border-bottom: 1px solid #eef1f5; margin-bottom: 10px; }
.msg-view .msg-subject { font-size: 16px; font-weight: 700; margin-bottom: 6px; word-break: break-all; }
.msg-view .msg-meta { font-size: 12px; color: #6b7280; word-break: break-all; line-height: 1.7; }
.msg-view iframe { width: 100%; height: 50vh; border: 1px solid #eef1f5; border-radius: 10px; background: #fff; }
.msg-view pre.plain { white-space: pre-wrap; word-break: break-all; font-size: 13.5px; background: #f8fafc; border-radius: 10px; padding: 12px; line-height: 1.6; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .modal { align-items: center; } }
.modal-card {
  background: #fff; width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh;
  border-radius: 18px 18px 0 0; display: flex; flex-direction: column; overflow: hidden;
}
@media (min-width: 640px) { .modal-card { border-radius: 18px; } }
.modal-card.small { max-width: 420px; }
.modal-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid #eef1f5; font-weight: 600; flex: none;
}
.modal-head .x {
  margin-left: auto; border: 0; background: #f3f4f6; border-radius: 50%;
  width: 30px; height: 30px; font-size: 14px; cursor: pointer; color: #555; flex: none;
}
.modal-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end; align-items: center;
  padding: 12px 16px; border-top: 1px solid #eef1f5; flex: none;
}

.tabs { display: flex; gap: 4px; }
.tab {
  border: 0; background: transparent; padding: 8px 12px; font-size: 14px;
  color: #6b7280; cursor: pointer; border-bottom: 2px solid transparent; font-weight: 500;
}
.tab.active { color: #1d4ed8; border-bottom-color: #3b82f6; }
.hint { font-size: 13px; color: #6b7280; background: #f8fafc; border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; line-height: 1.6; }
.import-result { margin-top: 12px; font-size: 13.5px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; }
.import-result.has-err { background: #fef2f2; border-color: #fecaca; }
.group-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.group-chips .chip { cursor: pointer; border: 1px solid #e0e7ff; background: #fff; padding: 4px 10px; font-size: 12.5px; }
.group-chips .chip:hover { background: #eef2ff; }
.radio { display: flex; align-items: center; gap: 8px; padding: 9px 2px; font-size: 14.5px; cursor: pointer; }
h4 { margin: 14px 0 8px; font-size: 14.5px; }
hr { border: 0; border-top: 1px solid #eef1f5; margin: 16px 0; }
#settingsModal .btn { margin-top: 4px; }
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(17,24,39,.92); color: #fff; font-size: 13.5px;
  padding: 9px 16px; border-radius: 999px; z-index: 99; max-width: 84vw;
  text-align: center; word-break: break-all;
}

/* ---------- 响应式：窄屏时左侧收窄 ---------- */
@media (max-width: 768px) {
  .left-panel { width: 240px; min-width: 200px; }
  .left-panel .toolbar .row2 .btn { font-size: 11px; padding: 5px 3px; }
}
@media (max-width: 600px) {
  .split-layout { flex-direction: column; }
  .left-panel { width: 100%; min-width: 0; height: 45vh; border-right: 0; border-bottom: 1px solid #e8ecf2; }
  .right-panel { height: 55vh; }
  .rp-placeholder { padding: 20px; }
  .rpp-icon { font-size: 40px; }
}