:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1a2233;
  --ink-soft: #5a6478;
  --line: #e3e8f2;
  --brand: #2f6bff;
  --brand-ink: #1e4fd6;
  --brand-soft: #eaf1ff;
  --green: #17a673;
  --green-soft: #e5f6ef;
  --amber: #d98a1a;
  --amber-soft: #fbf1de;
  --red: #d9483b;
  --red-soft: #fbe9e7;
  --shadow: 0 1px 3px rgba(20, 30, 60, .06), 0 6px 24px rgba(20, 30, 60, .06);
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
#app { display: flex; flex-direction: column; height: 100vh; }
code { font-family: "SF Mono", Consolas, monospace; background: #eef1f7; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 60px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-shrink: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 26px; }
.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--ink-soft); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.task-picker { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-soft); }
.task-picker select {
  font-size: 13px; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); min-width: 220px; max-width: 320px;
}
.mode-badge {
  font-size: 12px; background: var(--amber-soft); color: var(--amber);
  padding: 5px 10px; border-radius: 20px; font-weight: 600;
}

/* ---------- 布局 ---------- */
.body { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 210px; background: var(--panel); border-right: 1px solid var(--line);
  padding: 14px 10px; flex-shrink: 0; overflow-y: auto; display: flex; flex-direction: column;
}
.nav-group-title {
  font-size: 11px; color: var(--ink-soft); text-transform: uppercase;
  letter-spacing: .5px; padding: 12px 12px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: 2px 0;
  border-radius: 8px; cursor: pointer; color: var(--ink); font-size: 14px;
  text-decoration: none; user-select: none;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.nav-item .step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; background: var(--bg);
  font-size: 12px; flex-shrink: 0;
}
.nav-item.active .step { background: var(--brand); color: #fff; }
.sidebar-foot {
  margin-top: auto; padding: 12px; font-size: 11px; color: var(--ink-soft);
  line-height: 1.6; border-top: 1px solid var(--line);
}
.content { flex: 1; overflow-y: auto; padding: 24px 28px; min-width: 0; }

/* ---------- 通用组件 ---------- */
.page-head { margin-bottom: 18px; }
.page-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.page-desc { color: var(--ink-soft); font-size: 13px; margin: 0; max-width: 720px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-title { font-weight: 700; font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; transition: .12s;
}
.btn:hover { border-color: #c7d0e0; background: #fafbfe; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand-ink); }
.btn-danger { color: var(--red); border-color: var(--red-soft); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-weight: 400; color: var(--ink-soft); font-size: 12px; margin-left: 6px; }
.field input[type=text], .field textarea, .field select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; font-family: inherit; color: var(--ink); background: #fff;
}
.field textarea { resize: vertical; min-height: 80px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 20px; cursor: pointer;
  font-size: 13px; background: #fff; user-select: none;
}
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.chip-add { display: flex; gap: 8px; margin-top: 8px; }
.chip-add input { flex: 1; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-family: inherit; }
.chip-add input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 200px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #fafbfe; font-size: 12px; color: var(--ink-soft); font-weight: 600; position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbff; }
td.wrap, th.wrap { white-space: normal; min-width: 160px; }

/* ---------- 徽标 ---------- */
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.tag-lvA { background: var(--green-soft); color: var(--green); }
.tag-lvB { background: var(--amber-soft); color: var(--amber); }
.tag-lvC { background: #eef1f7; color: var(--ink-soft); }
.tag-verified { background: var(--green-soft); color: var(--green); }
.tag-unverified { background: #eef1f7; color: var(--ink-soft); }
.tag-invalid { background: var(--red-soft); color: var(--red); }
.tag-personal { background: var(--brand-soft); color: var(--brand-ink); }
.tag-department { background: var(--amber-soft); color: var(--amber); }
.tag-general { background: #eef1f7; color: var(--ink-soft); }
.tag-key { background: var(--green); color: #fff; }

.email-type-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-soft); margin-top: 8px; }

/* ---------- 关键词分组 ---------- */
.kw-group { margin-bottom: 16px; }
.kw-group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 600; font-size: 13px; }
.kw-group-head .count { color: var(--ink-soft); font-weight: 400; }
.kw-list { display: flex; flex-direction: column; gap: 6px; }
.kw-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13px;
}
.kw-item.on { border-color: var(--brand); background: var(--brand-soft); }
.kw-item input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.kw-item .kw-text { font-family: "SF Mono", Consolas, monospace; flex: 1; word-break: break-all; }
.kw-lang { font-size: 11px; color: var(--ink-soft); background: #eef1f7; padding: 1px 6px; border-radius: 4px; }

/* ---------- 步骤指示 / 提示 ---------- */
.callout {
  display: flex; gap: 10px; padding: 12px 14px; border-radius: 8px; font-size: 13px;
  background: var(--brand-soft); color: var(--brand-ink); border: 1px solid #d5e2ff; margin-bottom: 16px;
}
.callout.warn { background: var(--amber-soft); color: #8a5a10; border-color: #f0dcae; }
.callout.ok { background: var(--green-soft); color: #0d7a51; border-color: #c3e9d7; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--ink-soft); font-size: 12px; margin-top: 2px; }

.empty-state { text-align: center; color: var(--ink-soft); padding: 60px 20px; font-size: 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar select, .toolbar input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; }
.spacer { flex: 1; }
.muted { color: var(--ink-soft); }
a.link { color: var(--brand-ink); text-decoration: none; }
a.link:hover { text-decoration: underline; }

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 28, 50, .45);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; z-index: 50; overflow-y: auto;
}
.modal {
  background: var(--panel); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  width: 100%; max-width: 560px; padding: 22px 24px;
}
.modal.wide { max-width: 780px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--ink-soft); line-height: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1a2233; color: #fff; padding: 11px 20px; border-radius: 24px;
  font-size: 13px; z-index: 100; box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

/* ---------- 用户菜单 ---------- */
.user-menu { position: relative; }
.user-dropdown {
  position: absolute; right: 0; top: 40px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); min-width: 200px; padding: 6px; z-index: 20;
}
.user-dropdown-info { padding: 8px 10px; font-size: 12px; color: var(--ink-soft); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-dropdown-item { display: block; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--ink); text-decoration: none; }
.user-dropdown-item:hover { background: var(--bg); }

/* ---------- 登录/注册全屏门 ---------- */
#authScreen {
  position: fixed; inset: 0; z-index: 200; overflow: auto;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef2fb 0%, #e6ecfa 100%); padding: 24px;
}
.auth-layout {
  display: grid; grid-template-columns: 1.05fr 0.95fr;
  width: 100%; max-width: 940px; background: #fff;
  border-radius: 18px; overflow: hidden; box-shadow: 0 24px 70px rgba(20, 30, 60, .18);
}
.auth-hero {
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-ink) 100%);
  color: #fff; padding: 42px 38px; display: flex; flex-direction: column;
}
.auth-hero .hero-logo { font-size: 32px; }
.auth-hero h1 { font-size: 25px; line-height: 1.32; margin: 16px 0 10px; font-weight: 700; }
.auth-hero .hero-sub { font-size: 14px; opacity: .92; line-height: 1.6; margin: 0 0 26px; }
.auth-feats { display: flex; flex-direction: column; gap: 15px; }
.auth-feat { display: flex; gap: 12px; align-items: flex-start; }
.auth-feat .fi { font-size: 19px; line-height: 1.3; flex-shrink: 0; }
.auth-feat b { display: block; font-size: 13.5px; font-weight: 600; }
.auth-feat span { font-size: 12px; opacity: .85; line-height: 1.5; }
.auth-hero .hero-foot { margin-top: auto; padding-top: 26px; font-size: 12px; opacity: .8; }
.auth-panel { padding: 40px 36px; display: flex; align-items: center; justify-content: center; overflow-y: auto; }
.auth-card { width: 100%; max-width: 360px; }
.auth-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-link { color: var(--brand-ink); cursor: pointer; font-size: 12.5px; }
.auth-link:hover { text-decoration: underline; }
.auth-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--ink-soft); margin: 4px 0 14px; line-height: 1.5; cursor: pointer; }
.auth-consent input { margin-top: 2px; flex-shrink: 0; }
.auth-standalone {
  background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(20, 30, 60, .15);
  width: 100%; max-width: 420px; padding: 36px;
}
@media (max-width: 760px) {
  .auth-layout { grid-template-columns: 1fr; max-width: 440px; }
  .auth-hero { padding: 30px 26px; }
  .auth-hero h1 { font-size: 21px; }
  .auth-hero .hero-sub { margin-bottom: 4px; }
  .auth-feats { display: none; }
  .auth-hero .hero-foot { display: none; }
  .auth-panel { padding: 28px 24px; }
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .logo { font-size: 40px; }
.auth-brand h1 { font-size: 20px; margin: 8px 0 2px; }
.auth-brand p { color: var(--ink-soft); font-size: 13px; margin: 0; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tab { flex: 1; text-align: center; padding: 8px; border-radius: 7px; cursor: pointer; font-size: 14px; color: var(--ink-soft); }
.auth-tab.on { background: #fff; color: var(--brand-ink); font-weight: 600; box-shadow: var(--shadow); }
.auth-error { background: var(--red-soft); color: var(--red); padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.auth-ok { background: var(--green-soft); color: #0d7a51; padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 12px; color: var(--ink-soft); }
.pending-icon { font-size: 48px; text-align: center; }

/* ---------- 操作历史时间线 ---------- */
.timeline { max-height: 440px; overflow-y: auto; padding-left: 6px; }
.timeline-item { display: flex; gap: 12px; padding: 4px 0; position: relative; }
.timeline-item:not(:last-child) .timeline-dot::after {
  content: ''; position: absolute; left: 4px; top: 14px; bottom: -6px; width: 2px; background: var(--line);
}
.timeline-dot { position: relative; flex-shrink: 0; }
.timeline-dot::before { content: ''; display: block; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); margin-top: 4px; }
.timeline-body { padding-bottom: 10px; }

pre.email-body {
  background: #fafbfe; border: 1px solid var(--line); border-radius: 8px; padding: 14px;
  white-space: pre-wrap; word-break: break-word; font-family: "SF Mono", Consolas, monospace;
  font-size: 13px; line-height: 1.6; max-height: 420px; overflow-y: auto;
}
