:root {
  --ink: #1a2233;
  --ink-soft: #5b6478;
  --surface: #f6f5f1;
  --card: #ffffff;
  --line: #e3e1d8;
  --accent: #14532d;
  --accent-soft: #e6f2ea;
  --gold: #b8860b;
  --pass: #15803d;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --fail: #b91c1c;
  --fail-bg: #fee2e2;
  --edited: #1d4ed8;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; }

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

.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ---- 顶栏 ---- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px; background: var(--ink); color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; gap: 14px; align-items: center; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px;
  background: var(--gold); color: var(--ink); font-weight: 800;
  border-radius: 6px; font-family: Georgia, serif; letter-spacing: .5px;
}
.topbar h1 { font-size: 17px; font-weight: 650; letter-spacing: .3px; }
.subtitle { font-size: 12px; color: #aeb6c6; }
.topbar-actions { display: flex; gap: 10px; }

main { max-width: 1500px; margin: 26px auto; padding: 0 28px; }

/* ---- 按钮 ---- */
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 7px 16px; border-radius: 6px; cursor: pointer; font-size: 13.5px;
  transition: transform .06s ease, box-shadow .15s ease;
}
.btn:hover:not(:disabled) { box-shadow: 0 2px 8px rgba(26,34,51,.12); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--fail); border-color: #ecc5c5; }
.btn.ghost { background: transparent; border-color: #47506488; color: inherit; }
main .btn.ghost { color: var(--ink-soft); border-color: var(--line); }

/* ---- 队列 ---- */
.queue-toolbar { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.queue-toolbar h2 { font-size: 20px; font-family: Georgia, "Songti SC", serif; }
.queue-table {
  width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(26,34,51,.06);
}
.queue-table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--ink-soft); padding: 10px 16px; border-bottom: 2px solid var(--line);
  background: #fbfaf7;
}
.queue-table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.queue-table tr:last-child td { border-bottom: none; }
.queue-table tr.row-click { cursor: pointer; }
.queue-table tr.row-click:hover { background: #fbfaf5; }
.notice-name { font-weight: 600; }
.notice-file { font-size: 12px; color: var(--ink-soft); font-family: var(--mono); }
.amount { font-family: var(--mono); font-weight: 600; text-align: right; }

/* ---- 状态与徽章 ---- */
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chip.pending   { background: #eef0f4; color: var(--ink-soft); }
.chip.parsed    { background: #dbeafe; color: #1e40af; }
.chip.confirmed { background: var(--accent-soft); color: var(--pass); }
.chip.returned  { background: var(--fail-bg); color: var(--fail); }
.badge { font-size: 11.5px; padding: 2px 8px; border-radius: 4px; margin-right: 6px; font-weight: 700; }
.badge.fail { background: var(--fail-bg); color: var(--fail); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.pass { background: var(--accent-soft); color: var(--pass); }

/* ---- 复核三栏 ---- */
.review-grid {
  display: grid; grid-template-columns: minmax(340px, 1.05fr) minmax(420px, 1.25fr) minmax(300px, .9fr);
  gap: 18px; align-items: start;
}
.pane {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 1px 3px rgba(26,34,51,.06);
}
.pane-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; border-bottom: 1px solid var(--line); background: #fbfaf7;
  border-radius: 10px 10px 0 0;
}
.pane-head h3 { font-size: 14px; letter-spacing: .4px; }
#raw-text {
  padding: 18px; white-space: pre-wrap; word-break: break-word;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  max-height: 76vh; overflow: auto;
}
#raw-text mark {
  background: #ffe9a8; outline: 2px solid var(--gold); border-radius: 2px;
  transition: background .2s;
}

/* ---- 表单 ---- */
.pane-form #form-root { padding: 14px 18px 18px; max-height: 76vh; overflow: auto; }
.fgroup { margin-bottom: 16px; }
.fgroup > h4 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--ink-soft); border-bottom: 1px solid var(--line);
  padding-bottom: 4px; margin-bottom: 10px;
}
.frow { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.frow label { flex: 0 0 128px; font-size: 12.5px; color: var(--ink-soft); }
.frow input, .frow select {
  flex: 1; padding: 6px 9px; border: 1px solid var(--line); border-radius: 5px;
  font-size: 13px; font-family: inherit; background: #fff; min-width: 0;
}
.frow input.num { font-family: var(--mono); text-align: right; }
.frow input:focus, .frow select:focus { outline: 2px solid #14532d33; border-color: var(--accent); }
.frow input.low-conf { background: var(--warn-bg); border-color: #f0d48a; }
.frow input.edited, .frow select.edited { border-color: var(--edited); box-shadow: 0 0 0 1px var(--edited); }
.conf-tag { flex: 0 0 44px; font-size: 11px; text-align: center; border-radius: 4px; padding: 2px 0; font-family: var(--mono); }
.conf-tag.hi { color: var(--pass); background: var(--accent-soft); }
.conf-tag.lo { color: var(--warn); background: var(--warn-bg); font-weight: 700; }
.edited-tag { font-size: 11px; color: var(--edited); font-weight: 700; white-space: nowrap; }

.li-table { width: 100%; border-collapse: collapse; }
.li-table th { font-size: 11.5px; color: var(--ink-soft); text-align: left; padding: 4px 6px; }
.li-table td { padding: 3px 4px; }
.li-table select, .li-table input {
  width: 100%; padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; font-size: 12.5px;
}
.li-table input.num { font-family: var(--mono); text-align: right; }
.li-table .low-conf { background: var(--warn-bg); }
.li-table .edited { border-color: var(--edited); box-shadow: 0 0 0 1px var(--edited); }
.warn-list { margin-top: 8px; padding: 10px 12px; background: var(--warn-bg); border-radius: 6px; font-size: 12.5px; }
.warn-list li { margin-left: 16px; }

/* ---- 校验清单 ---- */
#check-list { list-style: none; padding: 12px 14px; }
#check-list li {
  display: flex; gap: 10px; padding: 9px 10px; border-radius: 7px; margin-bottom: 6px;
  font-size: 12.5px; border: 1px solid transparent;
}
#check-list li.PASS { background: #f4faf6; border-color: #d3e8da; }
#check-list li.WARN { background: var(--warn-bg); border-color: #f0d48a; }
#check-list li.FAIL { background: var(--fail-bg); border-color: #efbcbc; }
#check-list li.SKIP { background: #f2f2ef; color: var(--ink-soft); }
.check-icon { font-weight: 800; flex: 0 0 18px; text-align: center; }
li.PASS .check-icon { color: var(--pass); }
li.WARN .check-icon { color: var(--warn); }
li.FAIL .check-icon { color: var(--fail); }
.check-name { font-weight: 650; }
.check-msg { color: var(--ink-soft); font-size: 12px; }

.fund-card { margin: 4px 14px; padding: 12px 14px; background: #fbfaf7; border: 1px dashed var(--line); border-radius: 8px; font-size: 12.5px; }
.fund-card h5 { font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; letter-spacing: .5px; }
.fund-card table { width: 100%; }
.fund-card td { padding: 2px 0; }
.fund-card td:last-child { text-align: right; font-family: var(--mono); }

.review-actions { display: flex; flex-direction: column; gap: 8px; padding: 14px; }


/* ---- LLM 状态灯 ---- */
.llm-status {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px; font-size: 12px;
  background: #ffffff14; color: #cfd6e4; font-family: var(--mono);
}
.llm-dot { width: 9px; height: 9px; border-radius: 50%; background: #8a93a6; }
.llm-status.checking .llm-dot { animation: llm-blink 1s infinite; }
.llm-status.ok .llm-dot { background: #2ecc71; box-shadow: 0 0 6px 1px #2ecc7188; }
.llm-status.fail .llm-dot { background: #e74c3c; box-shadow: 0 0 6px 1px #e74c3c88; }
@keyframes llm-blink { 50% { opacity: .3; } }

/* ---- 规则配置 ---- */
.rules-grid { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(480px, 1.4fr); gap: 18px; align-items: start; }
.rule-form { padding: 14px 18px 18px; }
.rf-label { font-size: 12.5px; color: var(--ink-soft); display: block; margin-bottom: 6px; }
.rf-row { display: flex; gap: 8px; margin-bottom: 14px; }
.rf-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.rf-fields { border-top: 1px dashed var(--line); padding-top: 12px; }
.rf-actions { display: flex; gap: 8px; margin-top: 10px; }
.rule-test-result { margin-top: 12px; padding: 10px 12px; background: #fbfaf7; border: 1px dashed var(--line); border-radius: 6px; font-size: 12.5px; }
.rule-vars { margin-top: 12px; font-size: 12px; color: var(--ink-soft); }
.rule-vars summary { cursor: pointer; }
.rule-vars code { background: #f2f1ec; padding: 1px 5px; border-radius: 3px; font-family: var(--mono); }
.rule-vars div { margin-top: 8px; line-height: 1.9; }
.queue-table.borderless { box-shadow: none; }
.rule-cond { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.rule-off { opacity: .5; }

@media (max-width: 1100px) { .rules-grid { grid-template-columns: 1fr; } }

/* ---- 上传弹窗 ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(26,34,51,.45); z-index: 50;
  display: grid; place-items: center;
}
.modal {
  width: min(720px, 92vw); background: var(--card); border-radius: 12px;
  box-shadow: 0 18px 60px rgba(0,0,0,.3); overflow: hidden;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: #fbfaf7;
}
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 16px 20px 6px; }
.modal-body .frow label { flex: 0 0 92px; }
.modal-body textarea {
  width: 100%; margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 6px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  resize: vertical;
}
.modal-body textarea:focus { outline: 2px solid #14532d33; border-color: var(--accent); }
.modal-hint { font-size: 12px; color: var(--ink-soft); margin: 8px 0 4px; }
.modal-foot { display: flex; justify-content: flex-end; padding: 12px 20px 16px; }
.btn-del { border: none; background: none; color: var(--fail); cursor: pointer; font-size: 12.5px; padding: 4px 6px; }
.btn-del:hover { text-decoration: underline; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 22px; border-radius: 8px;
  font-size: 13.5px; box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 100;
  max-width: 70vw;
}
.toast.error { background: var(--fail); }

@media (max-width: 1100px) {
  .review-grid { grid-template-columns: 1fr; }
  #raw-text { max-height: 40vh; }
}
