/* ============================================================
   邮件控制台 · 统一设计系统
   所有页面（控制台 / 查看页 / 登录页）共用此文件
   ============================================================ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6e9f0;
  --text: #1b2230;
  --text-2: #5b6678;
  --text-3: #98a2b3;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-50: #eef2ff;
  --danger: #e5484d;
  --danger-50: #fdecec;
  --success: #16a34a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }

/* ---------- 顶部导航 ---------- */
.topnav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 0 24px;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: grid; place-items: center; color: #fff; font-size: 16px;
}
.brand small { font-weight: 500; color: var(--text-3); font-size: 12px; }
.nav-spacer { flex: 1; }

/* ---------- 通用容器 / 卡片 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }
.page-title { font-size: 22px; font-weight: 700; margin: 4px 0 2px; }
.page-sub { color: var(--text-2); font-size: 14px; margin: 0 0 22px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card-head h2 { font-size: 16px; margin: 0; }
.card-head .badge {
  margin-left: auto; font-size: 12px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 3px 10px; border-radius: 999px;
}
.card-head .ico { font-size: 18px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; transition: .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-50); color: var(--danger); border-color: #f7c5c5; }
.btn-danger:hover { background: #fbdada; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.field .hintline { font-size: 12px; color: var(--text-3); font-weight: 400; }
.input, textarea.input, select.input {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--text);
  padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); transition: .15s; resize: vertical;
}
.input:focus, textarea.input:focus, select.input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}
textarea.input { min-height: 120px; line-height: 1.6; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 13px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.msg { font-size: 13px; font-weight: 600; }
.msg-ok { color: var(--success); }
.msg-err { color: var(--danger); }

/* ---------- 粘贴解析预览 ---------- */
.parse-box { margin-top: 14px; }
.parse-empty { color: var(--text-3); font-size: 13px; padding: 14px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
table.preview { width: 100%; border-collapse: collapse; font-size: 13px; }
table.preview th, table.preview td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top;
}
table.preview th { color: var(--text-2); font-weight: 600; background: var(--surface-2); }
table.preview tr:last-child td { border-bottom: 0; }
.token-mask { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--text-2); }
.bad { color: var(--danger); font-weight: 600; }

/* ---------- 账户列表 ---------- */
.acc-list { display: flex; flex-direction: column; gap: 10px; }
.acc-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); transition: .15s;
}
.acc-row:hover { border-color: #d7dbe6; box-shadow: var(--shadow-sm); }
.avatar {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.acc-main { flex: 1; min-width: 0; }
.acc-main .e { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-main .m { font-size: 12px; color: var(--text-3); }
.empty-state { text-align: center; color: var(--text-3); font-size: 14px; padding: 30px 10px; }

/* ---------- token 轮换同步提醒 ---------- */
.sync-banner {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px 18px; margin: 0 0 20px;
  border: 1px solid #f5d08a; border-left: 4px solid #f59e0b;
  border-radius: var(--radius-sm);
  background: #fffbeb;
}
.sync-banner[hidden] { display: none; }
.sync-banner-icon { font-size: 20px; line-height: 1.2; flex: none; }
.sync-banner-body { flex: 1; min-width: 0; }
.sync-banner-title { font-weight: 700; font-size: 14px; color: #92400e; }
.sync-banner-desc { font-size: 12.5px; color: #a16207; margin-top: 5px; word-break: break-all; line-height: 1.7; }
.sync-banner-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.sync-file-path { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--text-2); }
.rot-flag { color: #b45309; font-weight: 600; }
.acc-actions { display: flex; gap: 8px; flex: none; }

/* ---------- 搜索 / 备注 / 批量操作（与卡片体系同色系） ---------- */
.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.search-input { flex: 1; min-width: 200px; max-width: 360px; }
.check-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check-label input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
.filter-info { font-size: 12px; color: var(--text-3); }
.acc-check { width: 16px; height: 16px; flex: none; accent-color: var(--primary); cursor: pointer; }

.note-input {
  margin-top: 7px; width: 100%; max-width: 420px; padding: 5px 9px;
  font-family: var(--font); font-size: 12px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 7px; outline: none; transition: .15s;
}
.note-input:focus { background: var(--surface); border-color: var(--primary); }
.note-input::placeholder { color: var(--text-3); }
.note-input.saved { border-color: var(--success); }

.batch-bar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 11px 13px; margin-bottom: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.batch-count { font-size: 13px; color: var(--text-2); margin-right: 4px; }
.batch-count b { color: var(--primary); font-size: 15px; }
#batchMsg:not(:empty) { display: block; margin-bottom: 10px; }

.batch-result {
  margin: 0 0 14px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.batch-result[hidden] { display: none; }
.batch-summary { font-size: 13px; color: var(--text-2); }
.batch-summary b { color: var(--text); }
.ok-n { color: var(--success) !important; }
.bad-n { color: var(--danger) !important; }
.batch-warn {
  margin-top: 8px; padding: 7px 10px; font-size: 12.5px;
  color: #92400e; background: #fffbeb;
  border: 1px solid #f5d08a; border-radius: 7px;
}
.batch-list {
  margin-top: 10px; max-height: 240px; overflow: auto;
  display: flex; flex-direction: column; gap: 5px;
}
.batch-item {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  padding: 5px 7px; background: var(--surface); border-radius: 6px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot-ok { background: var(--success); }
.dot-bad { background: var(--danger); }
.bi-email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.bi-info { color: var(--text-2); text-align: right; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 720px) {
  .acc-row { flex-wrap: wrap; }
  .acc-actions { width: 100%; justify-content: flex-end; }
  .acc-main { flex-basis: calc(100% - 80px); }
  .batch-bar .btn { flex: 1; }
  .search-input { max-width: none; }
}

/* ---------- 查看页双栏 ---------- */
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 18px 24px 40px; align-items: start; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; min-height: 240px;
}
.panel-head {
  display: flex; align-items: center; gap: 9px; padding: 14px 18px;
  border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14px;
  position: sticky; top: 60px; background: var(--surface); z-index: 5;
}
.panel-head .ico { font-size: 17px; }
.panel-head .count { color: var(--text-3); font-weight: 500; margin-left: 2px; }
.panel-body { padding: 6px 0; }

.mail {
  display: flex; gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid var(--border); transition: background .12s;
}
.mail:hover { background: var(--surface-2); }
.mail .m-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
}
.mail-body-col { flex: 1; min-width: 0; }
.mail-meta .from { font-weight: 700; font-size: 13px; }
.mail-meta .addr { color: var(--text-3); font-weight: 400; font-size: 12px; margin-left: 4px; }
.mail-meta .subject { font-size: 14px; margin: 3px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-meta .time { color: var(--text-3); font-size: 12px; }
.mail-preview { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-frame-wrap { margin-top: 8px; }
.mail-frame { width: 100%; min-height: 200px; border: 0; border-radius: var(--radius-sm); background: #fff; border: 1px solid var(--border); }
.mail-text { white-space: pre-wrap; font-size: 13px; color: #444; background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); }

/* 骨架屏 */
.skeleton { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; }
.sk-av { width: 36px; height: 36px; border-radius: 50%; background: #eef1f6; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.sk-line { height: 10px; border-radius: 6px; background: linear-gradient(90deg, #eef1f6 25%, #e3e8f0 37%, #eef1f6 63%); background-size: 400% 100%; animation: shimmer 1.2s infinite; }
.sk-line.w60 { width: 60%; } .sk-line.w40 { width: 40%; } .sk-line.w80 { width: 80%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------- 修改密码 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px;
  background: rgba(16, 24, 40, .45); backdrop-filter: blur(2px);
}
.modal-mask[hidden] { display: none; }
.modal {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 22px 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close {
  border: 0; background: transparent; font-size: 22px; line-height: 1;
  color: var(--text-3); cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal .form { margin-top: 10px; }

/* ---------- 分组 / 分页 / 二次确认弹窗 ---------- */
.group-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.group-row[hidden] { display: none; }
.group-row .input { max-width: 300px; }
.group-select, .group-filter { width: auto; min-width: 180px; }
.group-filter { min-width: 150px; }
.group-tag {
  display: inline-block; padding: 1px 7px; margin-left: 6px;
  font-size: 11px; line-height: 18px; color: var(--primary-600);
  background: var(--primary-50); border-radius: 5px;
}
.pager {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
}
.page-info { font-size: 13px; color: var(--text-2); min-width: 92px; text-align: center; }
.pager-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.pager-label { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); }
.page-num { width: 76px; padding: 5px 8px; font-size: 13px; }
.confirm-text {
  margin: 0 0 12px; padding: 10px 12px; font-size: 13px; line-height: 1.7;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
}
.confirm-text b { color: var(--primary); }
.confirm-list {
  margin: 6px 0 0; max-height: 96px; overflow: auto;
  font-size: 12px; color: var(--text-2); word-break: break-all;
}

/* ---------- 登录页 ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, #e9ecfb, var(--bg)); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 30px 28px; }
.auth-card .brand { justify-content: center; margin-bottom: 6px; }
.auth-card h1 { text-align: center; font-size: 18px; margin: 6px 0 2px; }
.auth-card .sub { text-align: center; color: var(--text-2); font-size: 13px; margin: 0 0 22px; }
.auth-card .btn-primary { width: 100%; margin-top: 6px; }
.auth-card .hint { margin: 18px 0 0; padding: 12px 13px; background: var(--bg); border: 1px dashed var(--border); border-radius: 10px; color: var(--text-2); font-size: 12px; line-height: 1.7; }
.auth-card .hint b { color: var(--text); }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .panels, .row-2 { grid-template-columns: 1fr; }
  .panel-head { position: static; }
}
