/* ============================================================
   核验工作台 · 组件库
   视图模块只能使用本文件与 tokens.css/base.css 提供的类,
   不得自建颜色、阴影或字号。
   ============================================================ */

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: 8px 18px;
  font: 500 13.5px/1 var(--font-sans);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: default; pointer-events: none; }

.btn-primary { background: var(--c-accent); color: var(--c-on-accent); }
.btn-primary:hover { background: var(--c-accent-hover); }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-sep-strong);
}
.btn-secondary:hover { background: var(--c-surface-2); }

.btn-ghost { background: transparent; color: var(--c-accent-text); }
.btn-ghost:hover { background: var(--c-accent-bg); }

.btn-danger { background: transparent; color: var(--c-danger); border-color: transparent; }
.btn-danger:hover { background: var(--c-danger-bg); }

/* 暗色下次级按钮需比卡片底更亮一档,避免只剩边框 */
@media (prefers-color-scheme: dark) {
  .btn-secondary { background: var(--c-surface-3); }
  .btn-secondary:hover { background: #34343A; }
}

.btn-sm { padding: 5px 13px; font-size: 12.5px; }
.btn-lg { padding: 13px 28px; font-size: 15.5px; }

.btn-icon {
  padding: 6px; border-radius: var(--r-sm);
  background: transparent; color: var(--c-text-2);
  border: 0; cursor: pointer;
  display: inline-flex;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.btn-icon:hover { background: var(--c-surface-3); color: var(--c-text); }

/* ---------- 表单 ---------- */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.label { font: var(--fs-headline); color: var(--c-text); display: flex; gap: 6px; align-items: baseline; }
.label .req { color: var(--c-danger); font-weight: 600; }
.hint { font: var(--fs-foot); color: var(--c-text-3); }
.field-error { font: var(--fs-foot); color: var(--c-danger); display: none; }
.field.is-invalid .field-error { display: block; }
.field.is-invalid .input, .field.is-invalid .textarea, .field.is-invalid .select { border-color: var(--c-danger); }

.input, .textarea, .select {
  width: 100%;
  background: var(--c-surface);
  border: 1px solid var(--c-sep-strong);
  border-radius: var(--r-md);
  color: var(--c-text);
  font: var(--fs-callout);
  padding: 8px 12px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--c-text-3); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3.5px var(--c-accent-bg);
  outline: none;
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.65; }
.textarea-lg { min-height: 220px; font-family: var(--font-sans); }
.select { appearance: none; background-image: none; padding-right: 30px; cursor: pointer; }
.select-wrap { position: relative; display: inline-flex; min-width: 0; }
.select-wrap::after {
  content: ""; position: absolute; right: 11px; top: 50%;
  width: 7px; height: 7px; margin-top: -5px;
  border-right: 1.6px solid var(--c-text-3); border-bottom: 1.6px solid var(--c-text-3);
  transform: rotate(45deg); pointer-events: none;
}

.check-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font: var(--fs-callout); color: var(--c-text); }
.check-row input { margin-top: 2.5px; accent-color: var(--c-accent); width: 15px; height: 15px; }

.searchfield { position: relative; display: flex; min-width: 0; flex: 1; }
.searchfield > svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--c-text-3); }
.searchfield .input { padding-left: 34px; }

/* ---------- 卡片 ---------- */

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-sep);
  border-radius: var(--r-lg);
}
.card-pad { padding: var(--sp-5); }
.card-title { font: var(--fs-title-3); margin-bottom: var(--sp-3); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-sep);
  flex-wrap: wrap;
}
.card-head .card-title { margin: 0; }
.card-body { padding: var(--sp-5); }
.card-inset {
  background: var(--c-surface-2);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}

/* ---------- 状态章(四态 + 待定)----------
   颜色只作辅助,文字标签承载含义;禁止用红绿表达真假 */

.status-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--r-pill);
  padding: 2.5px 10px;
  font: 500 12px/1.5 var(--font-sans);
  border: 1px solid transparent;
  white-space: nowrap;
}
.status-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
/* 待复核用空心点,与「已完成」的实心点拉开语义区分 */
.is-pending .dot { background: transparent; border: 1.5px solid currentColor; width: 5px; height: 5px; }

.is-supported    { color: var(--st-supported-text);    background: var(--st-supported-bg);    border-color: var(--st-supported-border); }
.is-differs      { color: var(--st-differs-text);      background: var(--st-differs-bg);      border-color: var(--st-differs-border); }
.is-insufficient { color: var(--st-insufficient-text); background: var(--st-insufficient-bg); border-color: var(--st-insufficient-border); }
.is-corrected    { color: var(--st-corrected-text);    background: var(--st-corrected-bg);    border-color: var(--st-corrected-border); }
.is-pending      { color: var(--st-pending-text);      background: var(--st-pending-bg);      border-color: var(--st-pending-border); }

/* ---------- 来源章:内容是 AI / 规则 / 人工 / 原文 ---------- */

.prov-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font: 500 11px/1.4 var(--font-sans);
  border-radius: var(--r-sm);
  padding: 1.5px 7px;
}
.prov-ai     { color: var(--c-accent-text); background: var(--c-accent-bg); }
.prov-rule   { color: var(--c-text-2); background: var(--c-surface-3); }
.prov-manual { color: var(--st-corrected-text); background: var(--st-corrected-bg); }
.prov-source { color: var(--c-text-2); background: transparent; border: 1px solid var(--c-sep-strong); }

/* 登记号等编号:等宽 + 可复制样式 */
.idchip {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--c-surface-3);
  border-radius: var(--r-sm);
  padding: 2px 7px;
  color: var(--c-text);
  white-space: nowrap;
}

/* ---------- 表格 ---------- */

.table { width: 100%; border-collapse: collapse; font: var(--fs-callout); }
.table th {
  text-align: left; font: var(--fs-headline); color: var(--c-text-2);
  font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--c-sep-strong);
  white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--c-sep); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 列表行 ---------- */

.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-sep);
  text-decoration: none;
  color: inherit;
  transition: background var(--dur-fast) var(--ease);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--c-surface-2); text-decoration: none; }
.list-ico {
  width: 36px; height: 36px; border-radius: var(--r-md);
  background: var(--c-surface-3); color: var(--c-text-2);
  display: grid; place-items: center; flex: none;
}
.list-main { min-width: 0; flex: 1; }
.list-title { font: var(--fs-headline); color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-meta { font: var(--fs-sub); color: var(--c-text-3); display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-top: 2px; }
.list-side { display: flex; align-items: center; gap: var(--sp-2); flex: none; }

/* ---------- 证据行(签名组件)----------
   每条信息陈述一行,展开显示原文引句、来源、日期与范围 */

.ev-row { border: 1px solid var(--c-sep); border-radius: var(--r-lg); background: var(--c-surface); overflow: hidden; }
.ev-row + .ev-row { margin-top: var(--sp-2); }

.ev-head {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: var(--sp-3) var(--sp-4);
  background: none; border: 0; cursor: pointer;
  text-align: left; color: var(--c-text);
  transition: background var(--dur-fast) var(--ease);
}
.ev-head:hover { background: var(--c-surface-2); }
.ev-head .chev { color: var(--c-text-3); transition: transform var(--dur) var(--ease); }
.ev-row[data-open="true"] .ev-head .chev { transform: rotate(90deg); }
.ev-main { flex: 1; min-width: 0; }
.ev-statement { font: var(--fs-callout); font-weight: 500; line-height: 1.55; }
.ev-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.ev-body { display: none; padding: 0 var(--sp-4) var(--sp-4); }
.ev-row[data-open="true"] .ev-body { display: block; animation: ev-in var(--dur) var(--ease); }
@keyframes ev-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* 原文引句:黄底高亮摘录 */
.quote {
  background: var(--c-surface-2);
  border-left: 3px solid var(--c-accent);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: 10px 14px;
  font: var(--fs-callout);
  line-height: 1.8;
  color: var(--c-text);
  overflow-wrap: anywhere;
}
.quote mark { background: var(--mark-bg); color: var(--mark-text); border-radius: 3px; padding: 0 2px; }
.quote-src { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-top: 7px; font: var(--fs-foot); color: var(--c-text-3); }

/* ---------- 修订差异 ---------- */

.diff { display: flex; flex-direction: column; gap: 4px; font: var(--fs-foot); }
.diff .diff-line { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.diff-before { color: var(--c-text-3); text-decoration: line-through; text-decoration-color: rgba(149,89,13,.6); }
.diff-after { color: var(--st-corrected-text); font-weight: 600; }

/* ---------- 时间线 ---------- */

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1.5px; background: var(--c-sep-strong); }
.tl-item { position: relative; padding: 0 0 var(--sp-5); }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -22px; top: 4px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--c-surface); border: 2.5px solid var(--c-accent);
}
.tl-item.tl-muted .tl-dot { border-color: var(--c-sep-strong); }
.tl-date { font: var(--fs-foot); color: var(--c-text-3); font-variant-numeric: tabular-nums; }
.tl-title { font: var(--fs-callout); font-weight: 600; margin-top: 1px; }
.tl-desc { font: var(--fs-sub); color: var(--c-text-2); margin-top: 3px; line-height: 1.6; }

/* ---------- 步骤条(核验流程) ---------- */

.stepper { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.step-link {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: var(--r-pill);
  font: 500 13px/1 var(--font-sans);
  color: var(--c-text-2); text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.step-link:hover { background: var(--c-surface-3); color: var(--c-text); text-decoration: none; }
.step-link .step-num {
  width: 19px; height: 19px; border-radius: 50%;
  display: grid; place-items: center;
  font: 600 10.5px/1 var(--font-sans);
  background: var(--c-surface-3); color: var(--c-text-2);
  flex: none;
}
.step-link.current { background: var(--c-accent-bg); color: var(--c-accent-text); border-color: var(--st-pending-border); }
.step-link.current .step-num { background: var(--c-accent); color: var(--c-on-accent); }
.step-link.done .step-num { background: var(--st-supported-bg); color: var(--st-supported-text); }

/* ---------- 页签 ---------- */

.tabbar { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--c-sep); margin-bottom: var(--sp-4); overflow-x: auto; }
.tab {
  padding: 9px 13px; border: 0; background: none; cursor: pointer;
  font: 500 13.5px/1 var(--font-sans); color: var(--c-text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--c-text); }
.tab.active { color: var(--c-accent-text); border-bottom-color: var(--c-accent); }

/* ---------- 模态 ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(20,20,22,.4);
  backdrop-filter: saturate(1.2) blur(6px);
  -webkit-backdrop-filter: saturate(1.2) blur(6px);
  display: flex; padding: var(--sp-5);
  overflow-y: auto;
  animation: fade-in var(--dur) var(--ease);
}
/* margin:auto 保证矮窗口下模态从顶部可滚动,不被居中裁切 */
.modal {
  background: var(--c-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  width: 100%; max-width: 560px; max-height: min(84vh, 720px);
  margin: auto;
  display: flex; flex-direction: column;
  animation: modal-in var(--dur) var(--ease);
}
.modal-head { padding: var(--sp-5) var(--sp-5) var(--sp-3); font: var(--fs-title-3); }
.modal-body { padding: 0 var(--sp-5); overflow-y: auto; color: var(--c-text-2); font: var(--fs-callout); line-height: 1.7; }
.modal-foot { padding: var(--sp-4) var(--sp-5); display: flex; justify-content: flex-end; gap: var(--sp-2); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- 提示浮层 ---------- */

#toast-root { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-sep);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 10px 18px;
  font: 500 13px/1.5 var(--font-sans);
  display: flex; align-items: center; gap: 8px;
  animation: toast-in var(--dur) var(--ease);
  max-width: min(86vw, 480px);
}
.toast .t-ico { color: var(--c-accent-text); }
.toast.toast-error .t-ico { color: var(--c-danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: all var(--dur-fast) var(--ease); }

/* ---------- 空状态 ---------- */

.empty { text-align: center; padding: var(--sp-12) var(--sp-6); }
.empty-ico {
  width: 52px; height: 52px; margin: 0 auto var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--c-surface-3); color: var(--c-text-3);
  display: grid; place-items: center;
}
.empty-title { font: var(--fs-title-3); color: var(--c-text); }
.empty-desc { font: var(--fs-callout); color: var(--c-text-3); margin: var(--sp-2) auto 0; max-width: 44ch; line-height: 1.7; }
.empty .btn { margin-top: var(--sp-5); }

/* ---------- 提示块 ---------- */

.callout {
  display: flex; gap: 11px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-sep);
  border-radius: var(--r-md);
  padding: 12px 15px;
  font: var(--fs-callout);
  color: var(--c-text-2);
  line-height: 1.7;
}
.callout > svg { margin-top: 2px; color: var(--c-text-3); flex: none; }
.callout.is-accent { background: var(--c-accent-bg); border-color: var(--st-pending-border); }
.callout.is-accent > svg { color: var(--c-accent-text); }
.callout .callout-title { font-weight: 600; color: var(--c-text); }

/* ---------- 键值行 ---------- */

.kv { display: grid; grid-template-columns: 132px 1fr; gap: 6px var(--sp-4); align-items: baseline; }
.kv > .k { font: var(--fs-sub); color: var(--c-text-3); }
.kv > .v { font: var(--fs-callout); color: var(--c-text); min-width: 0; overflow-wrap: anywhere; line-height: 1.6; }
.kv .v .status-chip, .kv .v .prov-badge { margin-right: 6px; }

/* ---------- 示例数据横幅 ---------- */

.sample-banner {
  display: flex; align-items: center; gap: 8px;
  border: 1px dashed var(--st-differs-border);
  background: var(--st-differs-bg);
  color: var(--st-differs-text);
  border-radius: var(--r-md);
  padding: 5px 12px;
  font: 500 12px/1.55 var(--font-sans);
}

/* ---------- 加载与进度 ---------- */

.spinner {
  width: 16px; height: 16px; flex: none;
  border: 2px solid var(--c-sep-strong);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.meter { height: 4px; border-radius: var(--r-pill); background: var(--c-surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--c-accent); border-radius: var(--r-pill); transition: width var(--dur) var(--ease); }

.skeleton { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--c-surface-3) 25%, var(--c-surface-2) 50%, var(--c-surface-3) 75%); background-size: 200% 100%; animation: sk 1.1s ease infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- 工具条 ---------- */

.toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* ---------- 术语解释(abbr 式) ---------- */

.term { border-bottom: 1px dashed var(--c-text-3); cursor: help; }

/* ---------- 结果单内嵌预览 ---------- */

.report-doc {
  background: var(--c-surface);
  border: 1px solid var(--c-sep);
  border-radius: var(--r-lg);
  padding: clamp(20px, 4vw, 44px);
  font: var(--fs-callout);
  line-height: 1.85;
  color: var(--c-text);
}
.report-doc h2 { font: var(--fs-title-2); margin-bottom: var(--sp-4); }
.report-doc h3 { font: var(--fs-title-3); margin: var(--sp-5) 0 var(--sp-2); }
.report-doc p, .report-doc li { max-width: 72ch; }
.report-doc ul, .report-doc ol { padding-left: 1.4em; display: flex; flex-direction: column; gap: 4px; }
