/* 专利预审台 · 唯一外壳样式
   零外部依赖：系统字体、无 CDN、无构建步骤。
   状态一律「形状 + 文字标签 + 颜色」三重表达，不单靠颜色区分。 */

:root {
  --canvas: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --line-soft: #e8e8ed;
  --accent: #0066cc;
  --accent-soft: #e8f1fc;
  --ok: #1a7f37;
  --ok-soft: #e7f5ea;
  --warn: #8a6100;
  --warn-soft: #fff6e0;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 16px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-2: 0 12px 34px rgba(0, 0, 0, .16);
  --motion-1: 120ms cubic-bezier(.2, .7, .2, 1);
  --motion-2: 180ms cubic-bezier(.2, .7, .2, 1);
  --motion-3: 220ms cubic-bezier(.2, .7, .2, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #171719;
    --surface: #232326;
    --surface-2: #1d1d20;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --line: #3a3a3e;
    --line-soft: #2e2e32;
    --accent: #66b0ff;
    --accent-soft: #1c2c40;
    --ok: #6fcf97;
    --ok-soft: #1b2e22;
    --warn: #f2c94c;
    --warn-soft: #33290f;
    --danger: #ff8a80;
    --danger-soft: #3a1f1d;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-2: 0 12px 34px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 13px/1.55 var(--font);
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 16px; }
h2 { font-size: 14px; }
h3 { font-size: 13px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  cursor: pointer;
  transition: background var(--motion-1), border-color var(--motion-1),
              transform var(--motion-1);
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:active:not(:disabled) { transform: scale(.985); }
button:disabled { opacity: .48; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { filter: brightness(1.06); }
button.ghost { background: transparent; }
button.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.small { padding: 2px 8px; font-size: 12px; }
input, select, textarea {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  outline: none;
  transition: border-color var(--motion-1), box-shadow var(--motion-1);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }

/* ---------- 顶部导航 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line-soft);
}
#topbar .brand { font-weight: 600; font-size: 15px; letter-spacing: .2px; }
#topbar .spacer { flex: 1; }
#who { color: var(--muted); font-size: 12px; }

#nav-tabs {
  display: inline-flex; gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-s);
}
.nav-tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 5px 16px; border-radius: 6px;
  transition: background var(--motion-2), color var(--motion-2);
}
.nav-tab:hover { color: var(--text); }
.nav-tab.is-active {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-1);
}

#shell-main { padding: 20px; max-width: 1240px; margin: 0 auto; }

/* ---------- 面板与工具条 ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-1);
  padding: 16px;
}
.panel + .panel { margin-top: 16px; }
#toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
#toolbar .spacer { flex: 1; }
.toolbar-hint { color: var(--muted); font-size: 12px; }

/* ---------- 表格 ---------- */
table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line-soft); }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tbody tr { transition: background var(--motion-1); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--accent-soft); }
td .meta, td.meta { color: var(--muted); }

/* ---------- 提示条 ---------- */
.banner {
  display: none;
  margin: 12px 20px 0;
  padding: 9px 12px;
  border-radius: var(--radius-s);
  border: 1px solid;
  white-space: pre-wrap;
}
.banner.warn { display: block; background: var(--warn-soft); border-color: var(--warn); color: var(--text); }
.banner.err { display: block; background: var(--danger-soft); border-color: var(--danger); color: var(--text); }
.banner.info { display: block; background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

/* ---------- 登录 / 初始化 ---------- */
#login-view, #setup-view {
  max-width: 360px; margin: 14vh auto;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-2);
  padding: 28px 26px;
}
#login-view h1, #setup-view h1 { text-align: center; margin-bottom: 18px; }
#login-view p, #setup-view p { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; }
#login-view label, #setup-view label { color: var(--muted); font-size: 12px; }
#login-msg, #setup-msg { color: var(--danger); margin-top: 10px; min-height: 18px; font-size: 12px; }

/* ---------- 可拖动工作台 ---------- */
#modal-mask {
  position: fixed; inset: 56px 0 0; background: rgba(0, 0, 0, .22);
  display: none; z-index: 40;
}
#modal {
  position: fixed; top: 84px; left: 50%; transform: translateX(-50%);
  width: min(1080px, calc(100vw - 40px));
  max-height: calc(100vh - 130px);
  display: none; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-2);
  z-index: 41;
  overflow: hidden;
}
#modal-header {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
  cursor: move; user-select: none;
}
#modal-header b { flex: 0 1 auto; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#modal-header .spacer { flex: 1; }
#modal-tabs { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface-2);
  border: 1px solid var(--line-soft); border-radius: var(--radius-s); }
#modal-tabs button { border: 0; background: transparent; color: var(--muted); padding: 3px 12px; border-radius: 6px; }
#modal-tabs button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
#modal-body { overflow-y: auto; padding: 14px; }
.pane[hidden] { display: none; }

/* ---------- 分区卡片 ---------- */
.sec {
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-m);
  background: var(--surface-2);
}
.sec h3 { margin: 0 0 8px; }
.sec > p { margin: 6px 0 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.wrap { row-gap: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meta { color: var(--muted); font-size: 12px; }
small.meta { color: var(--muted); }
ul.tight { margin: 6px 0; padding-left: 18px; }
ul.tight li { margin: 3px 0; }
pre.json {
  max-height: 260px; overflow: auto;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-soft); border-radius: var(--radius-s);
  padding: 10px; font: 12px/1.5 var(--mono);
}
details summary { cursor: pointer; color: var(--muted); }

/* ---------- 步骤状态徽章 ---------- */
.step-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; margin: 0 6px 6px 0;
  border-radius: 999px; border: 1px solid var(--line);
  font-size: 12px; background: var(--surface);
}
.step-badge::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; opacity: .85;
}
.st-done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: var(--ok-soft); }
.st-pending { color: var(--muted); }
.st-running { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); }
.st-failed, .st-gate_failed { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: var(--danger-soft); }
.st-waiting_human { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); background: var(--warn-soft); }

/* ---------- 任务进度 ---------- */
.job-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-s);
  background: var(--surface);
  padding: 10px 12px;
  margin-top: 8px;
}
.job-line { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.job-status { font-weight: 600; }
.job-status.running, .job-status.queued { color: var(--accent); }
.job-status.done { color: var(--ok); }
.job-status.waiting_human { color: var(--warn); }
.job-status.failed { color: var(--danger); }
.job-error { color: var(--danger); margin-top: 6px; white-space: pre-wrap; }
.progress-track {
  margin-top: 8px; height: 4px; border-radius: 2px;
  background: var(--line-soft); overflow: hidden;
}
.progress-track > i {
  display: block; height: 100%; width: 0;
  background: var(--accent); border-radius: 2px;
  transition: width var(--motion-3);
}
.file-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-s); background: var(--surface);
  text-decoration: none; color: var(--text);
}
.file-chip:hover { border-color: var(--accent); }
.file-chip .size { color: var(--muted); font-size: 12px; }
.file-chip.unavailable { opacity: .55; cursor: default; }

/* ---------- 历史 ---------- */
#history-chain-tabs {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-s);
}
#history-chain-tabs .seg-tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 4px 14px; border-radius: 6px; font-size: 13px;
  transition: background var(--motion-2), color var(--motion-2);
}
#history-chain-tabs .seg-tab:hover { color: var(--text); }
#history-chain-tabs .seg-tab.is-active {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-1);
}
#history-layout { display: grid; grid-template-columns: minmax(320px, 1.1fr) minmax(360px, 1.4fr); gap: 16px; }
#history-list-panel { max-height: calc(100vh - 190px); overflow: auto; }
#history-detail-panel { max-height: calc(100vh - 190px); overflow: auto; }
#history-table tr.is-selected { background: var(--accent-soft); }
#history-table th { white-space: nowrap; }
#history-table td .step-badge { white-space: nowrap; }
.history-empty { color: var(--muted); padding: 24px 8px; text-align: center; }

/* ---------- 预见性/三性等既有面板样式（保留原视觉语义） ---------- */
#foresight-paths, #report-fe-paths { border-collapse: separate; border-spacing: 0; margin: 6px 0; }
#foresight-paths tr.legal-conclusion td,
#report-fe-paths tr.legal-conclusion td { border: 1px solid #2e7d32; background: rgba(46, 125, 50, .08); }
#foresight-paths tr.foresight-prediction td,
#report-fe-paths tr.foresight-prediction td { border: 1px dashed #b8860b; background: rgba(184, 134, 11, .08); }
.foresight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.foresight-cell { border: 1px solid var(--line-soft); background: var(--surface); padding: 8px 10px; border-radius: var(--radius-s); font-size: 12px; }
.foresight-cell b { color: var(--accent); }
tr.snap-flash td { background: var(--warn-soft); transition: background var(--motion-3); }
button.lit-ref { border: none; background: none; color: var(--accent); text-decoration: underline; padding: 0; font: inherit; }

/* ---------- 窄屏 ---------- */
@media (max-width: 1100px) {
  #history-layout { grid-template-columns: 1fr; }
  #history-list-panel, #history-detail-panel { max-height: none; }
  #modal { width: calc(100vw - 24px); left: 12px; transform: none; }
}
@media (max-width: 760px) {
  #topbar { flex-wrap: wrap; gap: 8px; }
  .grid-2, .foresight-grid { grid-template-columns: 1fr; }
  #shell-main { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* 当前任务的实际进展和代理人待办；完整依据仍在原复核区。 */
.c-job-brief:not([hidden]) {display:grid;gap:6px;margin:8px 0 12px;padding:10px 12px;background:var(--bg-subtle,#f2f6f5);border-left:3px solid var(--accent,#316660);border-radius:4px;}
.c-job-brief > div {display:grid;grid-template-columns:minmax(5em,auto) 1fr;gap:8px;align-items:baseline;color:var(--text,#223d43);font-size:13px;overflow-wrap:anywhere;}
.c-job-brief b {font-weight:650;}
@media (max-width:620px) {.c-job-brief > div {grid-template-columns:1fr;gap:1px;}}
