:root {
  --bg: #f4f7f5;
  --card: #ffffff;
  --line: #e3e9e5;
  --text: #1f2a24;
  --muted: #6b7a71;
  --accent: #16a34a;
  --accent-soft: #e7f6ed;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn-soft: #fff7e0;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- 登录 ---------- */
#loginOverlay {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(160deg, #134e2c, #16a34a);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--card); padding: 32px; border-radius: 16px;
  width: min(92vw, 380px); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.login-card label { display: block; font-size: 13px; margin-bottom: 12px; color: var(--muted); }
.login-card input { display: block; width: 100%; margin-top: 4px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.error-text { color: var(--danger); font-size: 13px; margin-bottom: 10px; }

/* ---------- 布局 ---------- */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; }
.header-right { display: flex; align-items: center; gap: 10px; }

#tabs { display: flex; gap: 4px; padding: 10px 20px 0; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; }
#tabs button {
  border: none; background: none; padding: 10px 16px; font-size: 14px;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
#tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 880px; margin: 0 auto; padding: 16px 16px 60px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.card-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.card-num { font-size: 28px; font-weight: 700; }
.card-num.accent { color: var(--accent); }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.6; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.progress { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); transition: width .3s; }

/* ---------- 表单 ---------- */
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-row label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.form-row input, .form-row select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff;
}
.file-label { position: relative; overflow: hidden; }
button { border: none; border-radius: 8px; cursor: pointer; font-size: 14px; padding: 9px 16px; }
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: #12873d; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
button.ghost:hover { border-color: var(--muted); }
button.small { padding: 5px 10px; font-size: 12px; }
button.block { width: 100%; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 列表 ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px;
  flex-wrap: wrap;
}
.item.revoked { opacity: .55; text-decoration: line-through; }
.item .meta { color: var(--muted); font-size: 12px; }
.item .actions { display: flex; gap: 6px; }
.chip {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.chip.gray { background: #eef1ef; color: var(--muted); }
.chip.warn { background: var(--warn-soft); color: #a16207; }
.chip.red { background: var(--danger-soft); color: var(--danger); }

.img-preview { max-height: 160px; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- 草稿卡（B02） ---------- */
.draft-card {
  border: 1.5px dashed var(--accent); border-radius: 10px; padding: 12px; margin-top: 10px; background: var(--accent-soft);
}
.draft-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: #0f5c2e; }
.draft-card table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.draft-card th, .draft-card td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.draft-card input { padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; width: 100%; font-size: 13px; }
.draft-card input.missing { border-color: var(--danger); background: var(--danger-soft); }
.draft-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- 聊天 ---------- */
.chat-card { display: flex; flex-direction: column; }
.chat-log {
  display: flex; flex-direction: column; gap: 10px; min-height: 320px; max-height: 480px;
  overflow-y: auto; padding: 10px; background: var(--bg); border-radius: 10px; margin-bottom: 10px;
}
.msg { max-width: 82%; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.draft-card { max-width: 100%; }

/* ---------- 弹层 / Toast ---------- */
#modalMask { position: fixed; inset: 0; background: rgba(20,30,24,.4); z-index: 60; display: flex; align-items: center; justify-content: center; }
#modalMask[hidden] { display: none; }
.modal { background: #fff; border-radius: 14px; padding: 20px; width: min(92vw, 420px); }
.modal h3 { margin: 0 0 12px; font-size: 16px; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.modal input { display: block; width: 100%; margin-top: 4px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1f2a24; color: #fff; padding: 12px 14px; border-radius: 10px; font-size: 13px;
  display: flex; gap: 10px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 340px; flex-wrap: wrap;
}
.toast button { background: #fff; color: #1f2a24; font-size: 12px; padding: 4px 10px; }

/* ---------- 验证结果 ---------- */
.verify-summary { margin-top: 12px; font-size: 14px; font-weight: 700; padding: 10px 12px; border-radius: 8px; }
.verify-summary.all-pass { background: var(--accent-soft); color: var(--accent); }
.verify-summary.has-fail { background: var(--danger-soft); color: var(--danger); }
.vitem { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.vitem .mark { font-weight: 700; }
.vitem.pass .mark { color: var(--accent); }
.vitem.fail .mark { color: var(--danger); }
.vitem .detail { color: var(--muted); font-size: 12px; }

@media (max-width: 600px) {
  .form-row label { flex: 1 1 45%; }
  .card-num { font-size: 22px; }
}
