/* Archived spreadsheet review */
.spreadsheet-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.spreadsheet-filters label { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; color: var(--ink-2); }
.spreadsheet-filters select, .spreadsheet-filters input { height: 38px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 6px 9px; background: var(--panel); color: var(--ink); font: inherit; }
.spreadsheet-filters select[name="source_id"] { max-width: 340px; }
.spreadsheet-filters select[name="sheet"] { max-width: 270px; }
.spreadsheet-search { flex: 1; min-width: 180px; }
.spreadsheet-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.spreadsheet-stat { display: flex; flex-direction: column; gap: 6px; }
.spreadsheet-stat strong { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.spreadsheet-diagnostic-summary p { margin: 6px 0 0; }
.spreadsheet-badge { display: inline-block; border-radius: 5px; padding: 2px 7px; font-size: .77rem; white-space: nowrap; margin: 2px 4px; }
.spreadsheet-badge.ok { color: var(--accent); background: var(--accent-soft); }
.spreadsheet-badge.check { color: var(--warning); background: var(--warning-soft); }
.spreadsheet-badge.error { color: var(--danger); background: var(--danger-soft); }
.spreadsheet-pager { display: flex; gap: 12px; align-items: center; justify-content: end; padding: 12px 0; }
.spreadsheet-method { margin: 12px 0 20px; }
.spreadsheet-method summary, .spreadsheet-precision summary, details.spreadsheet-context > summary { cursor: pointer; color: var(--accent); }
.spreadsheet-detail { margin-top: 24px; scroll-margin-top: 16px; }
.spreadsheet-comparison { padding: 18px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r-sm); margin: 16px 0; }
.spreadsheet-comparison.diagnostic { border-left-color: var(--warning); }
.spreadsheet-field { display: grid; grid-template-columns: minmax(150px, 240px) minmax(0, 1fr); gap: 12px; margin: 8px 0; }
.spreadsheet-field > div { overflow-wrap: anywhere; }
.spreadsheet-formula { white-space: normal; overflow-wrap: anywhere; max-width: 520px; min-width: 180px; }
.spreadsheet-precision { margin-top: 12px; font-size: .87rem; }
.spreadsheet-context { margin-top: 24px; }
.spreadsheet-cell-link { border: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit; text-align: left; padding: 2px; overflow-wrap: anywhere; }
.spreadsheet-cell-link:hover { background: var(--accent-soft); color: var(--accent-strong); }
#spreadsheet-list .table-wrap, .spreadsheet-context .table-wrap { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); }
#spreadsheet-list td { vertical-align: top; }
@media (max-width: 800px) {
  .spreadsheet-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spreadsheet-field { grid-template-columns: 1fr; gap: 3px; }
  .spreadsheet-filters select[name="source_id"], .spreadsheet-filters select[name="sheet"] { max-width: 100%; }
  .spreadsheet-filters label { max-width: 100%; }
}

/* ============================================================
   设计系统 · 投资法律审查 Gateway
   浅色专业风：浅灰底 + 白卡片 + 深绿主色
   ============================================================ */

:root {
  color-scheme: light;

  /* 色板 */
  --ink: #1c2622;
  --ink-2: #41504a;
  --muted: #6d7a73;
  --faint: #93a19a;
  --line: #e2e8e4;
  --line-strong: #cdd6d0;
  --paper: #f3f6f4;
  --panel: #ffffff;
  --accent: #14624a;
  --accent-strong: #0d4b38;
  --accent-soft: #e5f1eb;
  --accent-line: #bcd8cb;
  --success: #177245;
  --success-soft: #e1f3e9;
  --warning: #8f620c;
  --warning-soft: #fbf2da;
  --danger: #b3352b;
  --danger-soft: #fcebe9;
  --neutral-soft: #eceff0;

  /* 圆角 / 阴影 */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(18, 32, 26, .05);
  --shadow-2: 0 2px 6px rgba(18, 32, 26, .06), 0 8px 24px rgba(18, 32, 26, .06);
  --shadow-3: 0 4px 12px rgba(18, 32, 26, .08), 0 16px 40px rgba(18, 32, 26, .10);

  /* 布局 */
  --sidebar-w: 250px;
  --content-w: 1440px;

  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.3; letter-spacing: -0.01em; }
h1 { font-size: 1.65rem; margin: 0 0 6px; font-weight: 720; }
h2 { font-size: 1.1rem; margin: 0 0 14px; font-weight: 680; }
h3 { font-size: 1rem; font-weight: 660; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

svg.icon { flex: none; vertical-align: -3px; }

/* ============ 布局：侧边栏 + 主区 ============ */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  color: var(--ink);
  font-weight: 760;
  font-size: 1.02rem;
  letter-spacing: .02em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-1);
}

.side-nav { display: grid; gap: 2px; padding: 6px 12px; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-weight: 560;
  transition: background .15s, color .15s;
}
.side-nav a:hover { background: var(--paper); text-decoration: none; }
.side-nav a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 640;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}
.account-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.account-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: .85rem;
  flex: none;
}
.account-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 620;
  font-size: .92rem;
}
.account-card .icon-btn { color: var(--faint); }
.account-card .icon-btn:hover { color: var(--danger); background: var(--danger-soft); }

.main {
  margin-left: var(--sidebar-w);
  padding: 36px 44px 96px;
}
.main-inner { max-width: var(--content-w); margin: 0 auto; }

/* 移动端顶栏与抽屉 */
.nav-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
}
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 26, 21, .4);
  z-index: 35;
}
.scrim.show { display: block; }

/* ============ 按钮 ============ */

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 620;
  font-size: .94rem;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: background .15s, box-shadow .15s, transform .1s;
  white-space: nowrap;
}
button:hover, .button:hover { background: var(--accent-strong); text-decoration: none; }
button:active, .button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: wait; transform: none; }

.button-secondary {
  background: var(--panel);
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
}
.button-secondary:hover { background: var(--paper); color: var(--ink); }

.button-ghost {
  background: transparent;
  color: var(--accent);
  box-shadow: none;
  padding: 8px 12px;
}
.button-ghost:hover { background: var(--accent-soft); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}
.icon-btn:hover { background: var(--paper); color: var(--ink); }

/* loading 态 */
button.is-loading { pointer-events: none; opacity: .75; }
button.is-loading .btn-label { opacity: .8; }
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link-button { padding: 0; background: transparent; color: inherit; box-shadow: none; }
.inline-form { display: inline; }

/* ============ 状态徽章 ============ */

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--ink-2);
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.status-queued { background: var(--neutral-soft); color: #55606c; }
.status-validating, .status-running { background: var(--warning-soft); color: var(--warning); }
.status-validating .status-dot, .status-running .status-dot,
.status-queued .status-dot { animation: pulse 1.4s ease-in-out infinite; }
.status-succeeded { background: var(--success-soft); color: var(--success); }
.status-failed, .status-blocked { background: var(--danger-soft); color: var(--danger); }
.status-cancelled { background: var(--neutral-soft); color: var(--muted); }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.8); }
}

/* ============ 卡片 / 面板 ============ */

.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px 26px;
  box-shadow: var(--shadow-1);
}
.panel { margin: 0 0 22px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; }

/* ============ 页头 / 面包屑 ============ */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .86rem;
  color: var(--muted);
  margin-bottom: 14px;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--faint); }
.breadcrumb .current { color: var(--ink-2); font-weight: 580; }

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}
.page-heading .meta { color: var(--muted); font-size: .92rem; margin: 2px 0 0; }

/* ============ 项目卡片 ============ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.project-card {
  display: block;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow-1);
  color: inherit;
  transition: border-color .15s, box-shadow .2s, transform .15s;
}
.project-card:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
  text-decoration: none;
}
.project-card .card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.file-badge {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  flex: none;
}
.project-card h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 660;
  overflow-wrap: anywhere;
}
.project-card .card-meta {
  color: var(--muted);
  font-size: .87rem;
  margin-top: 2px;
}
.project-card .card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* ============ 空状态 ============ */

.empty {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 6px;
  padding: 72px 24px;
  background: var(--panel);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  color: var(--muted);
}
.empty .empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 10px;
}
.empty h2, .empty h1 { margin: 0; color: var(--ink); }
.empty p { margin: 0 0 14px; max-width: 40ch; }

/* ============ 表格 ============ */

.table-wrap { overflow-x: auto; margin: 0 -26px; padding: 0 26px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th {
  padding: 9px 12px;
  text-align: left;
  font-size: .8rem;
  font-weight: 640;
  color: var(--muted);
  text-transform: none;
  letter-spacing: .02em;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--paper); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-file { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cell-file .name { overflow-wrap: anywhere; }
.cell-file svg { color: var(--faint); flex: none; }

/* ============ 审查记录时间线 ============ */

.run-list { display: grid; }
.run-row {
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 13px 10px;
  margin: 0 -10px;
  border-radius: var(--r-sm);
  border-bottom: 1px solid var(--line);
  color: inherit;
  transition: background .12s;
}
.run-row:last-child { border-bottom: 0; }
.run-row:hover { background: var(--paper); text-decoration: none; }
.run-row .run-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--paper);
  color: var(--muted);
}
.run-row .run-time { font-size: .92rem; font-weight: 560; }
.run-row .run-quality { color: var(--muted); font-size: .86rem; }

/* ============ 表单 ============ */

.stack { display: grid; gap: 18px; }
label, .field { display: grid; gap: 7px; font-weight: 620; font-size: .93rem; }
label .hint, .field .hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type="text"], input[type="password"], input:not([type]) {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 11px 13px;
  font: inherit;
  background: var(--panel);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 98, 74, .14);
}
input::placeholder { color: var(--faint); }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 15px;
  border-radius: 10px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #f3c8c3;
  font-size: .92rem;
  font-weight: 540;
}
.alert-info {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: #eedfae;
}

/* ============ 登录 / 注册 ============ */

.auth-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background:
    radial-gradient(1200px 500px at 50% -10%, #e7f0ea 0%, transparent 60%),
    var(--paper);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 38px 36px 30px;
  box-shadow: var(--shadow-3);
}
.auth-card .auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 26px;
  font-weight: 740;
  font-size: 1.05rem;
}
.auth-card h1 { font-size: 1.4rem; }
.auth-card .auth-sub { color: var(--muted); font-size: .9rem; margin: -2px 0 22px; }
.auth-card button[type="submit"] { width: 100%; padding: 12px; }
.auth-card .auth-alt {
  margin: 20px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: .89rem;
  color: var(--muted);
}
.auth-card .alert { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ============ 上传页 ============ */

.dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
  padding: 40px 24px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.dropzone .dz-icon { color: var(--accent); }
.dropzone strong { color: var(--ink-2); font-weight: 640; }
.dropzone .dz-hint { font-size: .85rem; }

.file-preview {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.file-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--paper);
  font-size: .85rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.file-preview ul {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
}
.file-preview li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: .88rem;
  border-bottom: 1px solid var(--line);
}
.file-preview li:last-child { border-bottom: 0; }
.file-preview li .fp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview li .fp-size { color: var(--faint); font-size: .8rem; font-variant-numeric: tabular-nums; }
.file-preview li .icon-btn { width: 26px; height: 26px; }
.file-notice {
  margin: 0;
  padding: 10px 14px;
  font-size: .85rem;
  line-height: 1.6;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 6%, transparent);
  border-top: 1px solid var(--line);
}

/* 步骤条 */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 4px 0 18px;
  padding: 0;
  list-style: none;
}
.steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .87rem;
  color: var(--faint);
  font-weight: 560;
  white-space: nowrap;
}
.steps li .step-dot {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--neutral-soft);
  color: var(--faint);
  font-size: .75rem;
  font-weight: 700;
  flex: none;
}
.steps li.active { color: var(--accent-strong); }
.steps li.active .step-dot { background: var(--accent); color: #fff; box-shadow: 0 0 0 4px rgba(20,98,74,.15); }
.steps li.done { color: var(--success); }
.steps li.done .step-dot { background: var(--success); color: #fff; }
.steps li + li::before {
  content: "";
  width: 28px;
  height: 2px;
  background: var(--line-strong);
  margin: 0 10px;
}
.steps li.done + li::before, .steps li.done::after { background: var(--success); }

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--neutral-soft);
  overflow: hidden;
  margin-top: 14px;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #1e8263);
  transition: width .3s ease;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: .84rem;
  color: var(--muted);
  margin-top: 8px;
  min-height: 1.4em;
}
.action-status { white-space: pre-wrap; color: var(--muted); min-height: 1.5em; font-size: .9rem; }
.action-status.error { color: var(--danger); }

/* ============ 审查结果：阅读器布局 ============ */

.result-layout {
  display: grid;
  grid-template-columns: var(--toc-w, 280px) 12px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.main-inner-wide { max-width: 1760px; }
.toc-resizer {
  cursor: col-resize;
  align-self: stretch;
  border-radius: 6px;
  position: relative;
}
.toc-resizer::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line);
  transition: background .15s;
}
.toc-resizer:hover::after, .toc-resizer.dragging::after { background: var(--accent); }
.result-toc {
  position: sticky;
  top: 32px;
  display: grid;
  gap: 22px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding-right: 4px;
}
.toc-block h3 {
  margin: 0 0 8px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.toc-block ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 1px; }
.toc-block li a {
  display: block;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--ink-2);
  font-size: .89rem;
  border-left: 2px solid transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc-block li a:hover { background: var(--panel); text-decoration: none; }
.toc-block li a.current {
  color: var(--accent-strong);
  font-weight: 620;
  background: var(--accent-soft);
}
.toc-block li.toc-h3 a { padding-left: 24px; font-size: .85rem; }
.toc-block li a .toc-count {
  float: right;
  font-size: .76rem;
  color: var(--faint);
  background: var(--neutral-soft);
  border-radius: 999px;
  padding: 1px 7px;
}

.result-body { min-width: 0; }
.result-body > * { max-width: none; }
.result-body .markdown { max-width: 120ch; }

/* 报告正文排版 */
.markdown { line-height: 1.8; overflow-wrap: anywhere; font-size: .98rem; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { scroll-margin-top: 28px; }
.markdown h1 { font-size: 1.5rem; margin: 0 0 18px; }
.markdown h2 {
  font-size: 1.22rem;
  margin: 34px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.markdown h3 { font-size: 1.06rem; margin: 26px 0 10px; }
.markdown p { margin: 12px 0; }
.markdown ul, .markdown ol { padding-left: 1.5em; }
.markdown li { margin: 4px 0; }
.markdown blockquote {
  margin: 16px 0;
  padding: 4px 18px;
  border-left: 3px solid var(--accent-line);
  color: var(--ink-2);
  background: var(--paper);
  border-radius: 0 8px 8px 0;
}
.markdown code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
}
.markdown pre {
  overflow-x: auto;
  background: #f0f3f1;
  border: 1px solid var(--line);
  padding: 14px 16px;
  border-radius: 10px;
}
.markdown pre code { background: none; border: 0; padding: 0; }
.markdown table { font-size: .9rem; margin: 16px 0; }
.markdown th { background: var(--paper); }
.markdown img { max-width: 100%; border-radius: 8px; }

/* 风险卡片 */
.risk {
  border: 1px solid var(--line);
  border-left: 4px solid var(--faint);
  border-radius: var(--r-md);
  background: var(--panel);
  padding: 16px 20px;
  margin: 14px 0;
  box-shadow: var(--shadow-1);
}
.risk header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}
.risk header strong { font-size: .98rem; }
.risk p { margin: 6px 0; }
.risk .risk-locator {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  color: var(--faint);
}
.risk-high, .risk-critical { border-left-color: var(--danger); }
.risk-high .status, .risk-critical .status { background: var(--danger-soft); color: var(--danger); }
.risk-medium { border-left-color: #d8a938; }
.risk-medium .status { background: var(--warning-soft); color: var(--warning); }
.risk-low { border-left-color: var(--line-strong); }

/* 附件 */
.artifact-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.artifact-list a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  color: var(--ink-2);
  font-size: .9rem;
  font-weight: 560;
  transition: border-color .15s, box-shadow .15s;
}
.artifact-list a:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-1);
  text-decoration: none;
  color: var(--accent-strong);
}
.artifact-list a .dl-icon { margin-left: auto; color: var(--faint); }

/* 运行中提示条 */
.run-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 22px;
  border-radius: var(--r-md);
  background: var(--panel);
  border: 1px solid var(--accent-line);
  box-shadow: var(--shadow-1);
  color: var(--ink-2);
  font-size: .92rem;
}
.run-banner .spinner { color: var(--accent); }
.run-banner .refresh-btn { margin-left: auto; }

/* ============ Toast ============ */

.toast-root {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 10px;
  z-index: 100;
  width: min(420px, calc(100vw - 40px));
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #20302a;
  color: #eaf2ee;
  font-size: .9rem;
  box-shadow: var(--shadow-3);
  animation: toast-in .25s ease;
}
.toast.toast-error { background: #5c2320; }
.toast.toast-success { background: var(--accent-strong); }
.toast.fade { opacity: 0; transition: opacity .3s; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ 要素缺口页 ============ */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 18px;
  display: grid;
  gap: 2px;
  box-shadow: var(--shadow-1);
}
.stat-value { font-size: 1.5rem; font-weight: 720; line-height: 1.2; }
.stat-value.stat-open { color: var(--warning); }
.stat-value.stat-integrated { color: var(--success); }
.stat-label { color: var(--muted); font-size: .86rem; }

.gap-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
}
.gap-filters label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: .86rem;
}
.gap-filters select {
  min-width: 130px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--ink);
  font-size: .92rem;
}

.gap-list { display: grid; gap: 12px; }
.gap-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-1);
}
.gap-card.gap-status-open { border-left-color: var(--warning); }
.gap-card.gap-status-accepted { border-left-color: var(--accent); }
.gap-card.gap-status-integrated { border-left-color: var(--success); }
.gap-card.gap-status-rejected { border-left-color: var(--faint); }

.gap-head { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.gap-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--ink-2);
  font-size: .78rem;
  font-weight: 600;
}
.gap-tag-type { background: var(--accent-soft); color: var(--accent-strong); }
.gap-tag-status { background: var(--warning-soft); color: var(--warning); }
.gap-status-integrated .gap-tag-status { background: var(--success-soft); color: var(--success); }
.gap-status-accepted .gap-tag-status { background: var(--accent-soft); color: var(--accent-strong); }
.gap-status-rejected .gap-tag-status { background: var(--neutral-soft); color: var(--muted); }
.gap-tag-element { background: var(--success-soft); color: var(--success); }

.gap-title { margin: 0 0 6px; font-size: 1.02rem; }
.gap-detail { margin: 0 0 10px; color: var(--ink-2); font-size: .92rem; }
.gap-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: .84rem;
}
.gap-meta span { display: inline-flex; align-items: center; gap: 5px; }

/* ============ 响应式 ============ */

@media (max-width: 1100px) {
  .result-layout { grid-template-columns: 1fr; }
  .result-toc { position: static; max-height: none; order: 2; }
  .toc-resizer { display: none; }
}

@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-3);
  }
  .sidebar.open { transform: translateX(0); }
  .nav-toggle { display: grid; }
  .main { margin-left: 0; padding: 68px 20px 80px; }
}

@media (max-width: 680px) {
  .page-heading { flex-direction: column; align-items: stretch; }
  .page-heading button, .page-heading .button { align-self: flex-start; }
  .run-row { grid-template-columns: 34px 1fr; }
  .run-row .status, .run-row .run-quality { grid-column: 2; }
  .steps { flex-wrap: wrap; gap: 8px; }
  .steps li + li::before { width: 14px; margin: 0 6px; }
  .panel { padding: 18px; }
  .table-wrap { margin: 0 -18px; padding: 0 18px; }
}

/* 项目设置 */
.settings-row { padding: 4px 0 2px; }
.settings-toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.settings-toggle input { width: 16px; height: 16px; accent-color: var(--accent, #2563eb); cursor: pointer; }

/* 结果页追问 */
.qa-turns { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.qa-turn { border-top: 1px solid var(--border, #e5e7eb); padding-top: 10px; }
.qa-turn:first-child { border-top: 0; padding-top: 0; }
.qa-q { font-weight: 500; margin: 0 0 4px; }
.qa-a { margin: 0; white-space: pre-wrap; color: var(--text, #1f2937); }
.qa-form { display: flex; gap: 10px; align-items: flex-end; }
.qa-form textarea { flex: 1; resize: vertical; padding: 8px 10px; border: 1px solid var(--border, #e5e7eb); border-radius: 6px; font: inherit; }
.qa-form textarea:focus { outline: 2px solid var(--accent, #2563eb); outline-offset: -1px; }

/* 主体与架构 */
.party-graph-wrap { overflow-x: auto; margin: 6px 0 18px; }
.party-graph { min-width: 320px; text-align: center; }
.party-graph svg { max-width: 100%; height: auto; }
.party-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.party-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  padding: 14px 16px;
  box-shadow: var(--shadow-1);
}
.party-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.party-card header strong { font-size: .95rem; }
.party-role {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: .75rem;
  white-space: nowrap;
}
.party-card p { margin: 6px 0; }
.party-facts { margin: 6px 0; padding-left: 18px; }
.party-facts li { margin: 2px 0; }
.party-meta {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
}

/* ============ Tab 页签 ============ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line-strong);
  margin-bottom: 22px;
  overflow-x: auto;
}
.tab {
  border: none;
  background: none;
  padding: 10px 18px;
  font-size: .95rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  font-weight: 550;
}
.tab:hover { color: var(--ink); background: var(--accent-soft); }
.tab.active {
  color: var(--accent-strong);
  border-bottom-color: var(--accent);
  font-weight: 650;
}
.tab-count {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--ink-2);
  font-size: .76rem;
}
.tab.active .tab-count { background: var(--accent-soft); color: var(--accent-strong); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============ 风险卡片 ============ */
.risk-list { display: grid; gap: 16px; }
.risk-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px 22px;
  box-shadow: var(--shadow-1);
}
.risk-card.flash { animation: risk-flash 1.6s ease; }
@keyframes risk-flash {
  0%, 60% { background: var(--accent-soft); }
  100% { background: var(--panel); }
}
.risk-card-head { display: flex; gap: 10px; align-items: baseline; }
.risk-title { font-size: 1.02rem; }
.sev-badge {
  flex: none;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 650;
}
.sev-badge.sev-high { background: var(--danger-soft); color: var(--danger); }
.sev-badge.sev-medium { background: var(--warning-soft); color: var(--warning); }
.sev-badge.sev-low, .sev-badge.sev-other { background: var(--neutral-soft); color: var(--ink-2); }
.version-diff { margin-bottom: 14px; }
.version-diff > summary { cursor: pointer; font-weight: 600; }
.version-diff h3 { font-size: .92rem; margin: 12px 0 6px; }
.version-diff ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.version-diff li .sev-badge { margin-right: 4px; }
.archive-badge {
  flex: none;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}
.party-archive-btn { margin-left: auto; }
.party-card header .archive-badge { margin-left: auto; }
.party-archive-list { display: grid; gap: 12px; }
.party-archive-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.party-archive-head strong { font-size: 1.02rem; }
.party-archive-delete { margin-left: auto; }

/* 正文内证据来源标注：彩色徽标，选中/复制时跳过 */
.ev-tag {
  -webkit-user-select: none;
  user-select: none;
  font-size: .68em;
  font-weight: 650;
  font-style: normal;
  padding: 1px 7px;
  margin: 0 2px;
  border-radius: 999px;
  vertical-align: 0.08em;
  white-space: nowrap;
  background: var(--neutral-soft);
  color: var(--ink-2);
}
.ev-tag.ev-direct { background: #e2efe5; color: #256b3f; }
.ev-tag.ev-relay { background: #e6edfb; color: #33559e; }
.ev-tag.ev-infer { background: #f7ecd8; color: #96690f; }
.ev-tag.ev-todo { background: #f5e3e0; color: #a33b2e; }
.sev-border-high { border-left: 3px solid var(--danger); }
.sev-border-medium { border-left: 3px solid var(--warning); }
.risk-meta { margin: 6px 0 10px; }
.risk-body { display: grid; gap: 8px; }
.risk-part { display: grid; gap: 2px; }
.risk-part p { margin: 0; line-height: 1.75; }
.risk-part-label {
  display: inline-block;
  font-size: .74rem;
  font-weight: 700;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 1px 7px;
  margin-right: 6px;
  letter-spacing: .04em;
}
.risk-basis, .risk-check { margin: 10px 0 0; line-height: 1.75; font-size: .93rem; }
.verified-badge {
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: .75rem;
  font-weight: 600;
}
.risk-evidence { margin-top: 12px; display: grid; gap: 6px; }
.evidence-item {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--paper);
}
.evidence-item summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: .87rem;
  color: var(--ink-2);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.evidence-item summary:hover { color: var(--accent-strong); }
.evidence-item summary::before { content: "▸"; color: var(--faint); }
.evidence-item[open] summary::before { content: "▾"; }
.evidence-item blockquote {
  margin: 0;
  padding: 10px 14px 12px;
  border-top: 1px dashed var(--line-strong);
  font-size: .86rem;
  line-height: 1.7;
  color: var(--ink-2);
  white-space: pre-wrap;
}

/* ============ 项目概况卡 ============ */
.overview-panel .overview-conclusion { line-height: 1.8; margin: 4px 0 14px; }
.overview-cards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.overview-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 20px;
  display: grid;
  gap: 2px;
  min-width: 120px;
  background: var(--paper);
}
.overview-num { font-size: 1.5rem; font-weight: 700; color: var(--accent-strong); }
.overview-label { font-size: .82rem; color: var(--muted); }
.overview-risks { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 7px; }
.overview-risks li { display: flex; gap: 8px; align-items: baseline; }
.collapsible { padding: 0; }
.collapsible > summary {
  cursor: pointer;
  padding: 16px 22px;
  font-weight: 650;
  color: var(--ink-2);
  list-style: none;
}
.collapsible > summary::before { content: "▸ "; color: var(--faint); }
.collapsible[open] > summary::before { content: "▾ "; }
.collapsible > summary:hover { color: var(--accent-strong); }
.collapsible > *:not(summary) { margin: 0 22px 18px; }

/* ============ 目录收起 / 追问等待 / 图谱工具 ============ */
.toc-toggle {
  float: right;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  width: 22px;
  height: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  font-size: .85rem;
}
.toc-block.collapsed ul { display: none; }
.qa-pending {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .9rem;
  padding: 8px 2px;
}
.qa-a.markdown { line-height: 1.75; }
.party-graph-toolbar { display: flex; gap: 6px; margin-bottom: 8px; }
.party-graph-toolbar .button-ghost { padding: 3px 12px; font-size: .85rem; }
.party-graph-wrap {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--paper);
  padding: 12px;
}
.party-graph { min-width: 480px; }

/* ============ 关系分组表 / 图谱小节 ============ */
.party-sub {
  font-size: .82rem;
  font-weight: 700;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 18px 0 8px;
}
.relation-table td, .relation-table th { padding: 7px 12px; font-size: .9rem; }
.relation-arrow { color: var(--faint); }
.relation-kind {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 650;
  background: var(--neutral-soft);
  color: var(--ink-2);
}
.relation-持股, .relation-出资, .relation-担保 { background: var(--accent-soft); color: var(--accent-strong); }
.relation-审批 { background: var(--warning-soft); color: var(--warning); }
