/* AI 外贸邮件中心 · 一期界面样式（无框架，纯手写） */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --hot: #b45309;
  --ok: #047857;
  --err: #b91c1c;

  /* ===== S11：统一卡片 token（视觉边界统一） ===== */
  --card-border: #e5e7eb;        /* 卡片边线 */
  --card-radius: 10px;           /* 卡片圆角 */
  --card-gap: 16px;              /* 卡片之间的间距 */
  --card-padding: 14px 16px;     /* 卡片内 padding */
  --card-shadow-hover: 0 4px 14px rgba(15, 23, 42, 0.08);  /* hover 时轻微上浮 */
  --card-shadow-rest: 0 1px 2px rgba(15, 23, 42, 0.04);    /* 默认静态 */
  --card-title-muted: #6b7280;   /* 卡片标题小字 */
  --section-spacing: 20px;       /* section 之间的纵向间距 */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.7;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 24px;
  background: #111827;
  color: #fff;
}
.topbar nav { display: flex; gap: 8px; flex: 1; align-items: center; }
.topbar .brand { color: #fff; font-weight: 700; text-decoration: none; }
.ai-state { font-size: 12px; padding: 2px 10px; border-radius: 999px; }
.ai-state.on { background: #14532d; color: #bbf7d0; }
.ai-state.off { background: #7f1d1d; color: #fecaca; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 24px 64px; }

h1 { font-size: 20px; margin: 8px 0 14px; }
h2 { font-size: 16px; margin: 26px 0 10px; }
h3 { font-size: 14px; margin: 18px 0 6px; color: var(--muted); }
a { color: var(--brand); }

.muted { color: var(--muted); }
.err { color: var(--err); }
.ok { color: var(--ok); }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.wrap { word-break: break-word; }
.hidden { display: none; }

ul.status { list-style: none; padding: 0; margin: 0 0 16px; }
ul.status li { padding: 5px 0; border-bottom: 1px dashed var(--line); }

table { border-collapse: collapse; width: 100%; background: var(--card); }
table.grid th, table.grid td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
table.grid thead th { background: #f3f4f6; font-weight: 600; position: sticky; top: 0; }

table.meta { table-layout: fixed; background: var(--card); border: 1px solid var(--line); }
table.meta th, table.meta td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.meta th { width: 130px; text-align: left; color: var(--muted); font-weight: 600; background: #fafafa; }
table.meta tr:last-child th, table.meta tr:last-child td { border-bottom: none; }
td.missing { color: var(--muted); }

.mail-list td.subject { max-width: 460px; }
.mail-list tr.unread td.subject a { font-weight: 700; }
.mail-list .sender { display: block; }
.mail-list .email { display: block; color: var(--muted); font-size: 12px; }
.mail-list td.c-view { white-space: nowrap; min-width: 96px; }
.mail-list td.c-date { white-space: nowrap; }

/* S7.1：7 列布局列宽 */
.c-view { width: 110px; }
.c-source { width: 180px; }
.c-from { width: 160px; }
.mail-list td.c-date { width: 110px; }
.c-status { width: 130px; white-space: nowrap; }

/* 中文摘要：最多 2 行，超出 line-clamp */
.c-sum { max-width: 320px; }
.mail-list td.c-sum.summary {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  line-height: 1.5;
  max-height: 3em;
}

/* 主题：单行优先，超出 ellipsis */
.mail-list td.subject a {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 12px; }
.badge.none { background: #f3f4f6; color: var(--muted); }
.badge.ok { background: #d1fae5; color: var(--ok); }
.badge.run { background: #fef3c7; color: var(--hot); }
.badge.fail { background: #fee2e2; color: var(--err); }
.badge.crm-pending { background: #f3f4f6; color: var(--muted); }
.badge.crm-synced { background: #d1fae5; color: var(--ok); }
.badge.crm-failed { background: #fee2e2; color: var(--err); }
.badge.crm-ignored { background: #e0e7ff; color: #3730a3; }

.crm-panel { margin: 16px 0; padding: 12px 16px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; }

.cat { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 12px; background: #eef2ff; color: #3730a3; }
.cat.inquiry { background: #dcfce7; color: #166534; }
.cat.existing_customer { background: #cffafe; color: #155e75; }
.cat.supplier_or_sales { background: #ffedd5; color: #9a3412; }
.cat.platform_or_security { background: #e0e7ff; color: #3730a3; }
.cat.spam { background: #f3f4f6; color: var(--muted); }

.tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 3px; font-size: 11px; background: #f3f4f6; color: var(--muted); }
.tag.hot { background: #fef3c7; color: var(--hot); font-weight: 600; }

button, .btn {
  font: inherit;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: #fff; color: var(--brand); }
.chk { font-weight: 400; color: var(--muted); margin-left: 8px; }

.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.filters a { padding: 2px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; }
.filters a.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.filters .sep { color: var(--line); }

.pager { display: flex; gap: 6px; margin-top: 14px; align-items: center; }
.pager a, .pager .cur { padding: 2px 9px; border: 1px solid var(--line); border-radius: 4px; background: #fff; text-decoration: none; }
.pager .cur { background: var(--brand); border-color: var(--brand); color: #fff; }

pre.output { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow: auto; max-height: 320px; font-size: 12px; white-space: pre-wrap; }

.subject-title { margin-bottom: 12px; word-break: break-word; }
.crumb { color: var(--muted); font-size: 12px; }

section { margin-top: var(--section-spacing); }
.ai-panel { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--card-radius); padding: 14px 16px 16px; }
.ai-panel h2 { margin-top: 14px; }

/* S11：视觉分区（设置页 / 表单页通用） */
.form-section {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: 14px 16px;
  margin-top: var(--section-spacing);
}
.form-section:first-of-type { margin-top: 0; }
.form-section-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--card-title-muted);
  text-transform: uppercase;
}
.form-section .form-grid { margin-top: 4px; }
.cost { font-size: 12px; }
.warn { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: 8px 12px; border-radius: 6px; }
.warn-inline { color: var(--err); }
ul.missing { margin: 4px 0 0; padding-left: 20px; }
ul.missing li { margin: 2px 0; }
details { margin-top: 10px; }
details summary { cursor: pointer; color: var(--brand); }

.body-html {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  overflow: auto;
  max-width: 100%;
  margin-bottom: var(--card-gap);
}
.body-html img { max-width: 100%; height: auto; }
.body-html table { width: auto; }
.body-plain {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  margin-bottom: var(--card-gap);
}
.translation .body-plain { margin-top: 8px; }

/* ---- S6：登录页 ---- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #111827 0%, #1e3a8a 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: 12px;
  padding: 34px 32px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
  text-align: center;
}
.login-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 26px;
  line-height: 52px;
}
.login-card h1 { font-size: 18px; margin: 6px 0 2px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.login-error {
  background: #fee2e2;
  color: var(--err);
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
.login-form { text-align: left; }
.login-form label { display: block; margin-bottom: 14px; }
.login-form label span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.login-form input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}
.login-form input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.login-btn {
  width: 100%;
  padding: 10px 0;
  font-size: 15px;
  letter-spacing: 4px;
  margin-top: 4px;
}
.login-foot { font-size: 12px; margin: 16px 0 0; }

/* ---- 顶栏用户区 ---- */
.user-box { display: flex; align-items: center; gap: 10px; font-size: 12px; color: #cbd5e1; }
.user-box .uname { color: #fff; }
.logout-form { display: inline; margin: 0; }
.logout-form button {
  padding: 2px 10px;
  font-size: 12px;
  background: transparent;
  border: 1px solid #475569;
  color: #cbd5e1;
  border-radius: 4px;
}
.logout-form button:hover { border-color: #fff; color: #fff; }

/* ---- 详情页：中文优先布局 ---- */
.detail-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.detail-actions { flex-shrink: 0; }

/* S7.1：详情页宽屏布局（左侧主内容 + 右侧 sticky 辅助栏） */
.detail-wrap.detail-wide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
}
.detail-main { min-width: 0; }
.detail-sidebar { display: flex; flex-direction: column; gap: var(--card-gap); position: sticky; top: 60px; max-height: calc(100vh - 70px); overflow-y: auto; padding-right: 4px; }
.sb-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  font-size: 13px;
}
.sb-card h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.sb-status { margin: 0 0 6px; font-weight: 600; }
.sb-status.ok { color: var(--ok); }
.sb-status.err { color: var(--err); }
.sb-status.muted { color: var(--muted); font-weight: 500; }
.sb-meta { margin: 0 0 6px; }
.sb-card button.primary,
.sb-card .btn-webmail { width: 100%; box-sizing: border-box; text-align: center; margin: 4px 0; }
.sb-card .chk { display: block; margin: 4px 0 0; font-size: 12px; }

/* 详情页未分析提示卡：醒目 */
.unanalyzed-card {
  background: #fffbeb;
  border: 2px dashed #f59e0b;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.unanalyzed-card h3 { margin: 0 0 6px; color: #92400e; font-size: 14px; }
.unanalyzed-card button.primary { background: #d97706; border-color: #d97706; }
.unanalyzed-card button.primary:hover { background: #b45309; }

/* 移动端：右侧栏在主内容之后 */
@media (max-width: 900px) {
  .detail-wrap.detail-wide {
    grid-template-columns: 1fr;
  }
  .detail-sidebar {
    position: static;
    max-height: none;
    margin-top: 12px;
    order: 2;
  }
  .detail-main { order: 1; }
}
.btn-webmail {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 6px;
  background: #1e3a8a;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}
.btn-webmail:hover { background: #1e40af; }

.cn-first .cn-summary-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  margin-bottom: var(--card-gap);
}
/* S11：默认 cn-summary-box（无需 .cn-first 时也走 token，避免粘连） */
.cn-summary-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  margin-bottom: var(--card-gap);
}
.cn-summary { font-size: 15px; line-height: 1.7; margin: 4px 0 8px; }

.cn-translation-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  margin-bottom: var(--card-gap);
}
.cn-translation { font-size: 14px; line-height: 1.8; }

.cn-extracted-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  margin-bottom: var(--card-gap);
}

.cn-ocr-box {
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  margin-bottom: var(--card-gap);
}
.ocr-text { font-size: 12px; white-space: pre-wrap; word-break: break-word; max-height: 400px; overflow: auto; background: #fff; padding: 8px; border-radius: 4px; border: 1px solid var(--line); }
.ocr-cn { font-size: 14px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; background: #fff; padding: 10px; border-radius: 4px; border: 1px solid var(--line); }
.ocr-cn-section h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); }

.ai-meta { margin-top: 8px; }

/* 发件人链接样式 */
.mail-list .sender { display: block; color: inherit; text-decoration: none; }
.mail-list .sender:hover { color: var(--brand); text-decoration: underline; }

/* 列表摘要列加宽 */
.c-sum { max-width: 320px; }

/* ===== S7：设置中心 ===== */
.settings-subnav { display: flex; gap: 12px; margin: 0 0 16px; }
.settings-subnav a { padding: 4px 10px; border-radius: 4px; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); }
.settings-subnav a:hover { background: #f3f4f6; }

.settings-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--card-gap); margin: 16px 0; }
.settings-card {
  display: block;
  padding: var(--card-padding);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  text-decoration: none;
  color: var(--ink);
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.settings-card:hover { box-shadow: var(--card-shadow-hover); border-color: #cbd5e1; transform: translateY(-1px); }
.settings-card-static { cursor: default; }
.settings-card-static:hover { box-shadow: none; transform: none; }
.settings-card-title { font-weight: 600; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.settings-card-stat { margin: 6px 0 10px; }
.settings-card-stat .big { font-size: 22px; font-weight: 700; }
.settings-card-foot { font-size: 12px; margin-top: 6px; }
.settings-status { list-style: none; margin: 8px 0 0; padding: 0; }
.settings-status li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.settings-status li:last-child { border-bottom: none; }
.settings-status .lbl { color: var(--muted); }
.settings-status .val.ok { color: var(--ok); font-weight: 600; }
.settings-status .val.muted { color: var(--muted); }

/* 公司徽章 */
.badge.company-badge { font-weight: 600; padding: 1px 8px; }
.badge.company-LUBAN { background: #dbeafe; color: #1e3a8a; }
.badge.company-CONGOU { background: #fce7f3; color: #9d174d; }
.badge.company-OTHER { background: #f3f4f6; color: var(--muted); }
.badge.source-badge { font-family: Consolas, monospace; font-size: 11px; }
.badge.source-db { background: #ede9fe; color: #5b21b6; }
.badge.source-env { background: #fef3c7; color: #92400e; }

/* 列表行左侧公司色条 */
tr.row-with-stripe { border-left: 4px solid transparent; }
tr.row-with-stripe.company-LUBAN { border-left-color: #2563eb; }
tr.row-with-stripe.company-CONGOU { border-left-color: #db2777; }
tr.row-with-stripe.company-OTHER { border-left-color: #9ca3af; }

/* 邮箱账号后台表格 */
.mail-acct-table td { font-size: 13px; }
.mail-acct-table td.actions { white-space: nowrap; }
.mail-acct-table td.actions button { margin-left: 8px; }
.mail-acct-table .state-cell .toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.mail-acct-table .toggle input { margin: 0; }

/* 表单 */
.settings-form { background: var(--card); padding: var(--card-padding); border: 1px solid var(--card-border); border-radius: var(--card-radius); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px 18px; }
.form-grid label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label .req { color: var(--err); }
.form-grid input[type=text],
.form-grid input[type=email],
.form-grid input[type=url],
.form-grid input[type=number],
.form-grid input[type=password],
.form-grid select,
.form-grid textarea {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
}
.form-grid input[type=password] { letter-spacing: .15em; font-family: Consolas, monospace; }
.form-grid .checkbox-line { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.form-grid .checkbox-line input { margin: 0; }
.form-actions { margin-top: 14px; display: flex; gap: 10px; align-items: center; }
.form-msg { margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 13px; }
.form-msg.ok { background: #d1fae5; color: var(--ok); }
.form-msg.err { background: #fee2e2; color: var(--err); }
.btn-primary { background: var(--brand); color: #fff; padding: 6px 14px; border: 0; border-radius: 6px; cursor: pointer; font-size: 14px; }
.btn-primary:disabled { background: #9ca3af; cursor: not-allowed; }
button:disabled { cursor: not-allowed; opacity: .7; }
.muted.small { font-size: 12px; }

/* 测试连接结果 */
.imap-result { margin: 14px 0; padding: 12px 16px; border-radius: 8px; font-size: 13px; }
.imap-result.ok { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }
.imap-result.fail { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.imap-result .muted { color: inherit; opacity: .7; }

/* 警告 */
.alert-warn { background: #fffbeb; border: 1px solid #fde68a; padding: 10px 14px; border-radius: 8px; margin: 12px 0; font-size: 13px; }

/* AI catalog */
.catalog-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--card-gap); margin: 12px 0; }
.catalog-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: var(--card-padding);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  cursor: pointer;
  background: #fff;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.catalog-item:hover { background: #f9fafb; box-shadow: var(--card-shadow-rest); border-color: #cbd5e1; }
.catalog-item input { margin-top: 4px; }
.catalog-label { font-weight: 600; }
.catalog-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 本地未查看 / 已查看（mail 列表） */
tr.viewed-no { background: #fefce8; }
tr.viewed-no td.subject a { font-weight: 700; color: #111827; }
tr.viewed-yes { background: #ffffff; }
tr.viewed-yes td.subject a { font-weight: 400; color: #374151; }
.viewed-pill { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 4px; font-weight: 600; }
.viewed-pill.no { background: #fde68a; color: #92400e; }
.viewed-pill.yes { background: #e5e7eb; color: #4b5563; }

/* 服务器 IMAP 未读 / 已读（mail 列表） */
.unread-pill { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 4px; margin-left: 4px; font-weight: 600; }
.unread-pill.unread { background: #fee2e2; color: #b91c1c; }
.unread-pill.read { background: #f3f4f6; color: var(--muted); }

/* 邮箱来源（mail 列表）：两行 + 公司强色 */
.acc-line { display: block; font-weight: 600; }
.acc-mail { display: block; color: var(--muted); font-size: 12px; }
.c-source { vertical-align: top; }
.c-source .src-line { display: flex; align-items: center; gap: 6px; }
.c-source .acc-line { font-weight: 600; font-size: 13px; }
.c-source .acc-mail { margin-top: 2px; }
.c-source.company-LUBAN .src-line .acc-line { color: #1e3a8a; }
.c-source.company-CONGOU .src-line .acc-line { color: #9d174d; }
.c-source.company-OTHER .src-line .acc-line { color: var(--ink); }

/* 状态列：badge 间隔 */
td.c-status .badge,
td.c-status .cat,
td.c-status .tag.hot { margin-right: 4px; margin-bottom: 2px; }

/* 公司徽章（强一致性）：badge / 左侧色条 / 来源列三者统一 */
.badge.company-badge { font-weight: 600; padding: 1px 8px; }
.badge.company-LUBAN,
.c-source.company-LUBAN .badge.company-LUBAN { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }
.badge.company-CONGOU,
.c-source.company-CONGOU .badge.company-CONGOU { background: #fce7f3; color: #9d174d; border: 1px solid #f9a8d4; }
.badge.company-OTHER,
.c-source.company-OTHER .badge.company-OTHER { background: #f3f4f6; color: var(--muted); border: 1px solid #d1d5db; }

tr.row-with-stripe { border-left: 4px solid transparent; }
tr.row-with-stripe.company-LUBAN { border-left: 4px solid #2563eb; background-clip: padding-box; }
tr.row-with-stripe.company-CONGOU { border-left: 4px solid #db2777; background-clip: padding-box; }
tr.row-with-stripe.company-OTHER { border-left: 4px solid #9ca3af; background-clip: padding-box; }
/* 强一致性：未查看行由 viewed-no 覆盖浅黄，左条仍按公司 */
tr.viewed-no.company-LUBAN { box-shadow: inset 4px 0 0 #2563eb; }
tr.viewed-no.company-CONGOU { box-shadow: inset 4px 0 0 #db2777; }
tr.viewed-no.company-OTHER { box-shadow: inset 4px 0 0 #9ca3af; }

/* S7.1：顶栏 active 样式 */
.topbar nav.topnav a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.topbar nav.topnav a:hover { color: #fff; background: #1f2937; }
.topbar nav.topnav a.active { color: #fff; background: var(--brand); font-weight: 600; }

/* ===== S8：Gmail/QQ 风格工作台布局 ===== */
body.layout-mail { display: block; min-height: 100vh; }
.topbar {
  /* S8：精简顶部，仅 brand + 搜索 + AI/用户 */
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: #111827;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .brand { font-size: 16px; }
.topbar .ai-state { margin-left: auto; }

/* 顶栏搜索框 */
.topbar-search {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 480px;
}
.topbar-search input[type=search] {
  flex: 1;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #374151;
  background: #1f2937;
  color: #f3f4f6;
  font-size: 13px;
}
.topbar-search input[type=search]::placeholder { color: #9ca3af; }
.topbar-search input[type=search]:focus {
  outline: none;
  border-color: var(--brand);
  background: #111827;
}
.topbar-search button {
  padding: 6px 14px;
  font-size: 13px;
}

/* 工作台主壳：左侧栏 + 右侧主区 */
.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 56px);
}
.app-main {
  padding: 20px 24px 64px;
  min-width: 0;
  background: var(--bg);
}

/* 左侧 sidebar */
.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 14px 10px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 56px;
  align-self: flex-start;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
}
.sb-section h5 {
  margin: 0 0 6px;
  padding: 0 8px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.sb-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
}
.sb-nav a:hover { background: #f3f4f6; }
.sb-nav a.active { background: #dbeafe; color: #1e3a8a; font-weight: 600; }
.sb-nav .ico { font-size: 14px; width: 16px; text-align: center; }
.sb-nav .ico.company-LUBAN { color: #2563eb; }
.sb-nav .ico.company-CONGOU { color: #db2777; }
.sb-nav .ico.company-OTHER { color: #9ca3af; }
.sb-nav .cnt { margin-left: auto; font-size: 11px; color: var(--muted); }
.sb-foot {
  margin-top: auto;
  padding: 10px 8px 0;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}
.sb-foot .uname { color: var(--muted); }

/* 列表页表头：c-wf 列宽 */
.c-wf { width: 110px; white-space: nowrap; }

/* 工作流 pill */
.wf-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.wf-pill-inbox { background: #e0f2fe; color: #075985; }
.wf-pill-pending { background: #fef3c7; color: #92400e; }
.wf-pill-later { background: #ede9fe; color: #5b21b6; }
.wf-pill-replied { background: #d1fae5; color: #065f46; }
.wf-pill-archived { background: #e5e7eb; color: #374151; }
.wf-pill-ignored { background: #fee2e2; color: #991b1b; }

/* 状态筛选链接 */
.wf-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.wf-link .cnt { font-size: 11px; color: var(--muted); }
.wf-link.active .cnt { color: inherit; font-weight: 700; }
.wf-link.wf-pending.active { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.wf-link.wf-later.active { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }
.wf-link.wf-replied.active { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.wf-link.wf-archived.active { background: #e5e7eb; color: #374151; border-color: #d1d5db; }
.wf-link.wf-ignored.active { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.wf-link.wf-active.active { background: #dbeafe; color: #1e3a8a; border-color: #93c5fd; }

/* 详情页右栏：本地状态卡的 5 个按钮 */
.wf-form { display: flex; flex-direction: column; gap: 6px; }
.wf-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.wf-btn {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.wf-btn:hover { background: #f9fafb; }
.wf-btn.active { font-weight: 700; border-color: var(--brand); background: #dbeafe; color: #1e3a8a; }
.wf-btn-inbox.active { background: #e0f2fe; color: #075985; border-color: #7dd3fc; }
.wf-btn-pending.active { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.wf-btn-later.active { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }
.wf-btn-replied.active { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.wf-btn-archived.active { background: #e5e7eb; color: #374151; border-color: #d1d5db; }
.wf-btn-ignored.active { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.wf-snooze {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  background: #f9fafb;
  border: 1px dashed var(--line);
  border-radius: 4px;
  font-size: 12px;
}
.wf-snooze select { font-size: 12px; padding: 3px 6px; }
.wf-restore-form { margin-top: 4px; }
.wf-restore-form button { width: 100%; }

/* 翻译全文按钮 */
#translate-btn, #translate-btn-side {
  background: #0d9488;
  border-color: #0d9488;
}
#translate-btn:hover, #translate-btn-side:hover { background: #0f766e; }

/* 移动端：sidebar 折到顶部 */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    overflow-x: auto;
    gap: 14px;
    padding: 8px 12px;
  }
  .sb-section h5 { display: none; }
  .sb-nav { flex-direction: row; gap: 6px; }
  .sb-nav a { white-space: nowrap; }
  .sb-foot { display: none; }
  .topbar-search { display: none; }
  .detail-wrap.detail-wide { grid-template-columns: 1fr; }
  .detail-sidebar { position: static; max-height: none; order: 2; }
  .detail-main { order: 1; }
}

/* 翻译全文空状态卡：浅色提示 */
.cn-translation-empty { background: #fff7ed; border-color: #fed7aa; }
.cn-translation-empty h3 { color: #9a3412; }

/* ===== S10：邮件工作台中文化与可读性 ===== */
/* 列表卡片化布局 — 三行预览 + 右侧 badges */
.mail-card-list {
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
  margin-top: 12px;
}
.mail-card {
  /* S11：统一对齐到 --card-border / --card-radius / --card-padding */
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 4px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-left-width: 4px;            /* 公司色只走左侧 4px 边条 */
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow-rest);
  font-size: 13px;
  color: var(--ink);
  position: relative;
  box-sizing: border-box;
  transition: box-shadow .15s ease, border-color .15s ease, background .15s ease;
}
.mail-card .mail-card-main { grid-column: 1 / -1; grid-row: 1; display: flex; flex-direction: column; gap: 3px; text-decoration: none; color: inherit; min-width: 0; }
.mail-card .mail-card-side { grid-column: 1; grid-row: 2; flex-direction: row; flex-wrap: wrap; align-items: center; }
.mail-card .mail-card-actions { grid-column: 2; grid-row: 2; justify-self: end; border-top: none; padding-top: 0; margin-top: 0; position: relative; z-index: 2; }
.mail-card:hover {
  /* S11：hover 时轻 box-shadow + 边框稍深 */
  box-shadow: var(--card-shadow-hover);
  border-color: #cbd5e1;
}
.mail-card.viewed-no {
  /* 未查看：加粗 + 浅蓝背景，不让公司色盖主题 */
  background: #f8fbff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08);
}
.mail-card.viewed-yes {
  background: #fff;
}
/* 公司色只走左侧 4px 边条，绝不染主题摘要正文 */
.mail-card.company-LUBAN { border-left-color: #2563eb; }
.mail-card.company-CONGOU { border-left-color: #db2777; }
.mail-card.company-OTHER { border-left-color: #9ca3af; }

.mail-card-main {
  /* S12.B：本身就是 <a>，整体可点击；保留原 line-1/2/3 子元素布局 */
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.mail-card-main:hover { text-decoration: none; color: inherit; }
.mail-card:hover .mail-card-main .sender,
.mail-card:hover .mail-card-main .cn-subject { color: var(--brand); }
.mail-line-1 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: nowrap;
}
.mail-line-1 .sender {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  flex: 0 0 auto;
}
.mail-line-1 .sender.strong { font-weight: 700; }
.mail-line-1 .sender:hover { text-decoration: underline; color: var(--brand); }
.mail-line-1 .email {
  color: var(--muted);
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.mail-line-1-right {
  margin-left: auto;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex: 0 0 auto;
}
.mail-line-1-right .viewed-pill,
.mail-line-1-right .unread-pill { padding: 0 6px; border-radius: 3px; }
.mail-line-1-right .viewed-pill.no { background: #fef3c7; color: #92400e; }
.mail-line-1-right .viewed-pill.yes { background: #ecfdf5; color: #065f46; }
.mail-line-1-right .unread-pill.unread { background: #dbeafe; color: #1e3a8a; }
.mail-line-1-right .unread-pill.read { background: #f3f4f6; color: var(--muted); }
.mail-line-1-right .mail-date { white-space: nowrap; }

.mail-line-2 {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.mail-line-2 .cn-subject {
  display: block;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mail-line-2 .cn-subject.strong { font-weight: 700; }
.mail-line-2 .cn-subject:hover { color: var(--brand); }
.mail-line-2 .raw-subject {
  display: block;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-line-3 {
  min-width: 0;
}
.mail-line-3 .mail-summary {
  display: block;
  color: var(--ink);
  line-height: 1.45;
  /* 中文摘要两行预览 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.mail-line-3 .mail-summary:empty::before {
  content: "（暂无摘要）";
  color: var(--muted);
}

.mail-card-side {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 132px;
  max-width: 220px;
}
.mail-card-side .badge,
.mail-card-side .cat,
.mail-card-side .wf-pill,
.mail-card-side .quick-ignore-btn,
.mail-card-side .quick-restore-btn {
  font-size: 11px;
}
.mail-card-side .wf-pill {
  align-self: flex-end;
}

.quick-ignore-btn {
  margin-top: 0;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.quick-ignore-btn:hover {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fca5a5;
}
.quick-restore-btn {
  margin-top: 0;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.quick-restore-btn:hover {
  background: #ecfdf5;
  color: #065f46;
  border-color: #6ee7b7;
}

/* S12.B：邮件卡 actions 容器 — 承载忽略/恢复/重点/真实回收站按钮；z-index 高于 mail-card-main <a> */
.mail-card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.mail-card-actions .badge,
.mail-card-actions .cat,
.mail-card-actions .wf-pill { font-size: 11px; }
.mail-card-actions .quick-ignore-btn,
.mail-card-actions .quick-restore-btn,
.mail-card-actions .star-btn,
.mail-card-actions .trash-btn {
  margin-left: 0;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  position: relative;            /* 让 z-index 生效，盖在 anchor 上层 */
  z-index: 3;
}
.mail-card-actions .foot-spacer { flex: 1 1 auto; }
.mail-card-actions .star-btn { color: #b45309; border-color: #fcd34d; background: #fffbeb; }
.mail-card-actions .star-btn:hover { background: #fef3c7; color: #92400e; }
.mail-card-actions .star-btn.is-starred { background: #fde68a; color: #92400e; border-color: #f59e0b; }
.mail-card-actions .trash-btn { color: #b91c1c; border-color: #fca5a5; background: #fff5f5; }
.mail-card-actions .trash-btn:hover { background: #fee2e2; color: #7f1d1d; border-color: #ef4444; }

/* S12.F：询盘【询盘】醒目标签 — 较大 + 高对比 + 轻度红橙；不染整卡背景 */
.tag-inquiry-big {
  display: inline-block;
  padding: 2px 9px;
  margin-right: 4px;
  background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%);
  color: #b91c1c;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.4;
  vertical-align: baseline;
}
.tag-star-big {
  display: inline-block;
  margin-right: 4px;
  color: #f59e0b;
  font-size: 14px;
  line-height: 1;
}
/* 询盘卡片加左侧高对比色条 — 比普通公司色更醒目 */
.mail-card.is-inquiry { border-left-color: #f97316; box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.10) inset; }
/* 重点询盘 — 顶部细金边 */
.mail-card.starred { border-top: 2px solid #f59e0b; }

/* S11：邮件卡第四行 — badge + 右侧快速忽略（已并入 .mail-card-actions） */
.mail-card-foot { display: none; }

/* ===== S11：草稿统一卡片 ===== */
.draft-card-list {
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
  margin-top: 12px;
}
.draft-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--card-padding);
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow-rest);
  font-size: 13px;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.draft-card:hover { box-shadow: var(--card-shadow-hover); border-color: #cbd5e1; }
.draft-card-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}
.draft-card-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.draft-line-1 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.draft-line-1 .to { font-weight: 600; color: var(--ink); }
.draft-line-1 .to-mail { color: var(--muted); font-size: 12px; }
.draft-line-1 .meta { margin-left: auto; font-size: 12px; color: var(--muted); display: inline-flex; gap: 6px; align-items: baseline; }
.draft-line-2 {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.draft-line-2 .cn-subject {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.draft-line-2 .raw-subject {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.draft-line-3 {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

/* 草稿状态 pill（轻量色） */
.draft-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.draft-status-draft     { background: #e0f2fe; color: #075985; }
.draft-status-scheduled { background: #ede9fe; color: #5b21b6; }
.draft-status-sending   { background: #fef3c7; color: #92400e; }
.draft-status-sent      { background: #d1fae5; color: #065f46; }
.draft-status-failed    { background: #fee2e2; color: #991b1b; }
.draft-status-cancelled { background: #e5e7eb; color: #374151; }

/* 单行 ellipsis 工具类（中文主题 / 邮箱） */
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  min-width: 0;
}
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 公司色规则（S10 不变式：颜色只能染左侧 4px + 徽章，不染主题摘要正文） */
.badge.company-badge.company-LUBAN { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }
.badge.company-badge.company-CONGOU { background: #fce7f3; color: #9d174d; border: 1px solid #f9a8d4; }
.badge.company-badge.company-OTHER { background: #f3f4f6; color: var(--muted); border: 1px solid #d1d5db; }

/* 草稿详情页：内部中文备注样式 */
.cn-note-section {
  margin: 14px 0 8px;
  padding: 10px 12px;
  border: 1px solid #fed7aa;
  background: #fffbeb;
  border-radius: 6px;
}
.cn-note-section.cn-note-readonly { background: #fffbeb; }
.cn-note-title { margin: 0 0 6px 0; font-size: 13px; color: #9a3412; }
.cn-note-warn { margin: 0 0 6px 0; }
.cn-note-warn strong { color: #9a3412; }
textarea.draft-internal-cn-note {
  width: 100%;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  padding: 8px;
  border: 1px solid #fde68a;
  border-radius: 4px;
  background: #fff;
  box-sizing: border-box;
  resize: vertical;
}
.cn-note-body {
  white-space: pre-wrap;
  word-break: break-word;
  background: #fff;
  padding: 8px;
  border: 1px solid #fde68a;
  border-radius: 4px;
  margin: 0;
}
.draft-body-title {
  margin: 12px 0 4px;
  font-size: 13px;
}

/* 旧 mail-list table 不再使用；保留可读性兜底（仍可被全局样式命中） */
table.mail-list { width: 100%; }
table.mail-list th, table.mail-list td { padding: 6px 8px; }

/* ============================================================
   S12.C：AI 模型管理页面（/settings/ai）
   - 当前激活大卡（高对比、醒目标识）
   - 模型卡片网格（按 ⭐ 日常主力 / 💎 复杂任务 / 其他 分组）
   - 编辑/新增弹窗与表单栅格
   ============================================================ */

.ai-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 20px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-section-title .ai-section-icon { font-size: 15px; }

/* 当前激活模型大卡 */
.ai-current-card {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  padding: 18px 20px;
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  border: 2px solid #f59e0b;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.12);
  margin: 12px 0 24px;
}
.ai-current-card.is-empty {
  background: #f9fafb;
  border: 2px dashed #d1d5db;
  box-shadow: none;
}
.ai-current-left .ai-current-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #92400e;
  background: #fde68a;
  padding: 2px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.ai-current-left .ai-current-name {
  font-size: 18px;
  font-weight: 700;
  color: #78350f;
  margin-bottom: 4px;
}
.ai-current-left .ai-current-provider {
  font-size: 13px;
  color: #92400e;
  margin-bottom: 6px;
}
.ai-current-left .ai-current-desc {
  font-size: 12px;
  color: #92400e;
  opacity: 0.85;
}
.ai-current-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #78350f;
  border-left: 1px dashed #f59e0b;
  padding-left: 16px;
}
.ai-current-right .ai-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.ai-current-right .ai-stat-key { color: #92400e; opacity: 0.75; }
.ai-current-right .ai-stat-val { font-weight: 600; color: #78350f; }
.ai-current-right .ai-stat-val.muted { color: #b45309; opacity: 0.7; font-weight: 400; }
.ai-current-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* 模型网格 */
.ai-model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--card-gap);
  margin: 8px 0 20px;
}
.ai-model-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow .15s ease, border-color .15s ease, transform .15s ease;
  position: relative;
}
.ai-model-card:hover {
  box-shadow: var(--card-shadow-hover);
  border-color: #cbd5e1;
  transform: translateY(-1px);
}
.ai-model-card.is-current {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
  background: #fffbeb;
}
.ai-model-card.is-archived {
  opacity: 0.55;
  background: #f9fafb;
  border-style: dashed;
}
.ai-model-card.is-inactive {
  opacity: 0.75;
}
.ai-model-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.ai-model-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  flex: 1 1 auto;
  word-break: break-word;
}
.ai-model-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 0 0 auto;
}
.ai-pill {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  line-height: 1.4;
}
.ai-pill-current {
  background: #f59e0b;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}
.ai-pill-daily {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}
.ai-pill-complex {
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #c4b5fd;
}
.ai-pill-on {
  background: #d1fae5;
  color: #065f46;
}
.ai-pill-off {
  background: #f3f4f6;
  color: var(--muted);
}
.ai-pill-archived {
  background: #e5e7eb;
  color: #4b5563;
  border: 1px dashed #9ca3af;
}
.ai-pill-provider {
  background: #eff6ff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
}

.ai-model-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font-size: 12px;
  color: var(--muted);
}
.ai-model-meta .meta-key { color: var(--muted); opacity: 0.85; }
.ai-model-meta .meta-val { color: var(--ink); font-weight: 500; word-break: break-all; }
.ai-model-notes {
  font-size: 12px;
  color: var(--muted);
  background: #f9fafb;
  padding: 6px 8px;
  border-radius: 4px;
  margin-top: 4px;
  border-left: 2px solid var(--line);
}
.ai-model-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

/* AI 测试结果盒 */
.ai-card-test {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: 4px;
}
.ai-card-test.ok {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #065f46;
}
.ai-card-test.err {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}
.ai-card-test.pending {
  background: #f3f4f6;
  color: var(--muted);
  border: 1px dashed var(--line);
}

/* 按钮通用样式（轻量） */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
  transition: all .15s ease;
  font-family: inherit;
}
.btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: #f8fafc;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.btn-primary:hover {
  background: #1d4ed8;
  color: #fff;
  border-color: #1d4ed8;
}
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--brand);
}
.btn-ghost:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.btn-danger {
  background: #fff;
  color: var(--err);
  border-color: #fecaca;
}
.btn-danger:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}
.btn-sm {
  padding: 3px 8px;
  font-size: 11px;
}

/* 弹窗 */
.ai-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ai-modal-mask.is-open { display: flex; }
.ai-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.ai-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #f9fafb;
}
.ai-modal-head .ai-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.ai-modal-head .ai-modal-close {
  background: transparent;
  border: 0;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
  padding: 0 6px;
  line-height: 1;
}
.ai-modal-head .ai-modal-close:hover { color: var(--err); }
.ai-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1 1 auto;
}
.ai-modal-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #f9fafb;
}

/* 表单栅格 */
.ai-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.ai-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ai-form-field.full { grid-column: 1 / -1; }
.ai-form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.ai-form-field label .req { color: var(--err); margin-left: 2px; }
.ai-form-field input[type="text"],
.ai-form-field input[type="password"],
.ai-form-field input[type="number"],
.ai-form-field input[type="url"],
.ai-form-field select,
.ai-form-field textarea {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-family: inherit;
  color: var(--ink);
  box-sizing: border-box;
}
.ai-form-field input:focus,
.ai-form-field select:focus,
.ai-form-field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.ai-form-field .field-hint {
  font-size: 11px;
  color: var(--muted);
}
.ai-form-field .field-error {
  font-size: 11px;
  color: var(--err);
  margin-top: 2px;
}
.ai-key-input-wrap {
  display: flex;
  gap: 6px;
}
.ai-key-input-wrap input { flex: 1 1 auto; }
.ai-key-input-wrap .ai-key-toggle {
  flex: 0 0 auto;
}
.ai-check-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink);
}
.ai-check-line input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

/* 通用业务工作台统计行（总览 / 邮箱健康） */
.biz-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--card-gap);
  margin: 16px 0;
}
.biz-stat {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: box-shadow .15s ease;
}
.biz-stat:hover { box-shadow: var(--card-shadow-hover); }
.biz-stat .biz-stat-label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.biz-stat .biz-stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.biz-stat .biz-stat-foot {
  font-size: 11px;
  color: var(--muted);
}
.biz-stat.accent-inquiry { border-left: 4px solid #f97316; }
.biz-stat.accent-todo { border-left: 4px solid #2563eb; }
.biz-stat.accent-unread { border-left: 4px solid #b91c1c; }
.biz-stat.accent-ignored { border-left: 4px solid #6b7280; }
.biz-stat.accent-new { border-left: 4px solid #047857; }

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--card-gap);
  margin: 12px 0;
}
.health-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.health-card .health-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}
.health-card .health-key { color: var(--muted); }
.health-card .health-val { font-weight: 600; }
.health-card .health-status-ok { color: #047857; }
.health-card .health-status-warn { color: #b45309; }
.health-card .health-status-err { color: #b91c1c; }
.health-card .health-status-off { color: #6b7280; }

/* ============================================================
   S12.D：邮箱账号卡片化设置页（/settings/mail-accounts）
   ============================================================ */
.acct-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 12px 0 16px;
  flex-wrap: wrap;
}
.acct-page-head p { margin: 0; }

.acct-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--card-gap);
  margin: 12px 0 24px;
}
.acct-empty {
  grid-column: 1 / -1;
  padding: 40px;
  text-align: center;
  border: 1px dashed var(--card-border);
  border-radius: var(--card-radius);
  background: var(--card);
}

.acct-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--line);
  border-radius: var(--card-radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.acct-card:hover { box-shadow: var(--card-shadow-hover); }
.acct-card.is-pinned {
  border-left-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.1);
}
.acct-card.is-inactive {
  opacity: 0.65;
  background: #f9fafb;
}
.acct-card.company-LUBAN { border-left-color: #2563eb; }
.acct-card.company-CONGOU { border-left-color: #db2777; }
.acct-card.company-OTHER { border-left-color: #9ca3af; }
.acct-card.is-pinned.company-LUBAN { border-left-color: #f59e0b; }
.acct-card.is-pinned.company-CONGOU { border-left-color: #f59e0b; }
.acct-card.is-pinned.company-OTHER { border-left-color: #f59e0b; }

.acct-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.acct-head-left { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.acct-head-right { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.acct-pill {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.acct-pill.pin { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.acct-label { font-weight: 700; font-size: 14px; color: var(--ink); }

.acct-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  cursor: pointer;
}
.acct-toggle input[type="checkbox"] { width: 14px; height: 14px; }

.acct-email-row { font-size: 13px; }
.acct-email { color: var(--ink); }

.acct-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 12px;
}
.acct-meta { display: flex; flex-direction: column; gap: 2px; }
.acct-meta-key { color: var(--muted); font-size: 11px; }
.acct-meta-val { color: var(--ink); font-weight: 500; }
.acct-state-on { color: #047857; font-weight: 600; }
.acct-state-pending { color: #b45309; font-weight: 600; }
.acct-state-err { color: #b91c1c; font-weight: 600; }

.acct-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  flex-wrap: wrap;
}
.acct-foot-left, .acct-foot-right { display: flex; gap: 6px; flex-wrap: wrap; }

/* ============================================================
   S12.E：邮件列表筛选区 — 邮箱下拉 / 搜索 / 置顶优先
   ============================================================ */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  padding: 8px 12px;
  margin: 8px 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
}
.filters > span { color: var(--muted); font-size: 12px; }
.filters > a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  flex-direction: row;
}
.filters > a:hover { border-color: var(--brand); color: var(--brand); }
.filters > a.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.filters > a.pinned {
  border-color: #fcd34d;
  background: #fffbeb;
}
.filters > a.pinned.active {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #fff;
}
.filters .sep { color: var(--line); padding: 0 2px; }
.filters .pin-pin { font-size: 10px; margin-right: 2px; }

/* S12.I：邮件详情页"复制给 AI 分析"操作栏 */
.detail-action-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 18px 0;
  padding: 10px 12px;
  background: var(--card, #fff);
  border: 1px dashed var(--line, #e5e7eb);
  border-radius: 10px;
}
.detail-action-bar #copy-to-ai-status {
  font-size: 12px;
  color: var(--muted, #6b7280);
}
.detail-action-bar #copy-to-ai-status .err { color: #b91c1c; }

/* S12.F：询盘 / 重点大徽标 — 详情页 subject-title 旁 */
.tag-inquiry-big,
.tag-star-big {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  padding: 4px 10px;
  border-radius: 999px;
  margin-left: 10px;
  vertical-align: middle;
  letter-spacing: 0.5px;
}
.tag-inquiry-big {
  color: #fff;
  background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.35);
}
.tag-star-big {
  color: #92400e;
  background: linear-gradient(135deg, #fde68a 0%, #fbbf24 100%);
  border: 1px solid #f59e0b;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.35);
}

.acct-more {
  position: relative;
  display: inline-block;
}
.acct-more > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px dashed var(--line);
  background: #f9fafb;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.acct-more > summary::-webkit-details-marker { display: none; }
.acct-more[open] > summary {
  background: var(--brand);
  color: #fff;
  border-style: solid;
  border-color: var(--brand);
}
.acct-more-panel {
  position: absolute;
  z-index: 50;
  top: 100%;
  left: 0;
  margin-top: 6px;
  width: 320px;
  max-height: 360px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.acct-more-search {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-sizing: border-box;
}
.acct-more-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1 1 auto;
}
.acct-more-list > a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink);
  text-decoration: none;
}
.acct-more-list > a:hover { background: #eff6ff; color: var(--brand); }
.acct-more-list > a.active {
  background: var(--brand);
  color: #fff;
}
.acct-more-list > a.pinned { border-left: 3px solid #f59e0b; }
.acct-more-list > a.hidden-by-search { display: none; }

/* ============================================================
   S12.G：业务总览 / 系统健康 / 邮箱概览
   ============================================================ */
.health-card .health-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 4px;
}
.health-card .health-row .health-val {
  text-align: right;
  word-break: break-word;
}
.health-card .health-row .btn { margin: 0; }
.acct-row-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.acct-row-head .health-val {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}
.health-card .acct-email {
  word-break: break-all;
  margin-bottom: 6px;
}
.health-card a.health-val {
  text-decoration: none;
  font-weight: 600;
  color: var(--brand);
}
.health-card a.health-val:hover { text-decoration: underline; }

