/* 全域商业参谋 · 工作台样式
   主题令牌集中在 :root 与 [data-theme="dark"]，
   跟随系统时由 prefers-color-scheme 自动切换，切换过程无闪烁。 */

:root {
  --bg: #f4f3ef;
  --bg-tint: #eceae3;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #16181c;
  --ink-soft: #3c4149;
  --muted: #696e74;
  --line: rgba(22, 24, 28, .10);
  --line-strong: rgba(22, 24, 28, .18);
  --accent: #1d6f63;
  --accent-ink: #ffffff;
  --accent-soft: rgba(29, 111, 99, .10);
  --gold: #916429;
  --gold-soft: rgba(151, 105, 42, .12);
  --ok: #1f7a4d;
  --ok-soft: rgba(31, 122, 77, .12);
  --warn: #96640a;
  --warn-soft: rgba(169, 114, 12, .13);
  --bad: #b03a2e;
  --bad-soft: rgba(176, 58, 46, .12);
  --shadow-sm: 0 1px 2px rgba(16, 20, 24, .05), 0 4px 14px rgba(16, 20, 24, .04);
  --shadow-md: 0 2px 6px rgba(16, 20, 24, .06), 0 18px 44px rgba(16, 20, 24, .08);
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", Georgia, serif;
}

[data-theme="dark"] {
  --bg: #0c0e11;
  --bg-tint: #121519;
  --surface: #15181d;
  --surface-2: #191d23;
  --ink: #e9e7e2;
  --ink-soft: #c3c7cd;
  --muted: #8b9199;
  --line: rgba(255, 255, 255, .10);
  --line-strong: rgba(255, 255, 255, .18);
  --accent: #4fbfa9;
  --accent-ink: #06231e;
  --accent-soft: rgba(79, 191, 169, .14);
  --gold: #d3a559;
  --gold-soft: rgba(211, 165, 89, .15);
  --ok: #4fbf85;
  --ok-soft: rgba(79, 191, 85, .15);
  --warn: #d9a441;
  --warn-soft: rgba(217, 164, 65, .16);
  --bad: #e2705f;
  --bad-soft: rgba(226, 112, 95, .15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, .45), 0 20px 48px rgba(0, 0, 0, .42);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --bg: #0c0e11; --bg-tint: #121519; --surface: #15181d; --surface-2: #191d23;
    --ink: #e9e7e2; --ink-soft: #c3c7cd; --muted: #8b9199;
    --line: rgba(255,255,255,.10); --line-strong: rgba(255,255,255,.18);
    --accent: #4fbfa9; --accent-ink: #06231e; --accent-soft: rgba(79,191,169,.14);
    --gold: #d3a559; --gold-soft: rgba(211,165,89,.15);
    --ok: #4fbf85; --ok-soft: rgba(79,191,85,.15);
    --warn: #d9a441; --warn-soft: rgba(217,164,65,.16);
    --bad: #e2705f; --bad-soft: rgba(226,112,95,.15);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
    --shadow-md: 0 2px 8px rgba(0,0,0,.45), 0 20px 48px rgba(0,0,0,.42);
  }
}

* { box-sizing: border-box; }

/* 关键：作者样式里的 display 会盖过浏览器默认的 [hidden]{display:none}。
   .drawer（position:fixed; inset:0; z-index:60）与 .view-research（display:grid）
   都带 display 声明，若不强制，hidden 元素仍会占满视口并吞掉所有点击。 */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background-color .35s var(--ease), color .35s var(--ease);
}

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── 顶栏 ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 20px;
  padding: 0 clamp(16px, 4vw, 44px);
  height: 66px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 12px; flex-shrink: 0; }
.mark {
  font-family: var(--serif); font-size: 21px; font-weight: 700; letter-spacing: .06em;
  color: var(--accent);
}
.brandname { font-size: 13px; letter-spacing: .22em; color: var(--muted); text-transform: none; }

.tabs { display: flex; gap: 2px; margin-left: auto; }
.tabs button {
  background: none; border: 0; padding: 7px 15px; border-radius: 999px;
  font: 14px var(--sans); color: var(--muted); cursor: pointer;
  transition: color .25s var(--ease), background-color .25s var(--ease);
}
.tabs button:hover { color: var(--ink); background: var(--accent-soft); }
.tabs button.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.topright { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.modelchip {
  font-size: 11.5px; letter-spacing: .04em; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px;
  white-space: nowrap; max-width: 190px; overflow: hidden; text-overflow: ellipsis;
}

.themewrap { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.themewrap button {
  border: 0; background: none; width: 32px; height: 30px; cursor: pointer;
  color: var(--muted); font-size: 13px; line-height: 1;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.themewrap button:hover { background: var(--accent-soft); color: var(--accent); }
.themewrap button.on { background: var(--accent); color: var(--accent-ink); }

/* ── 通用 ─────────────────────────────────────────────── */
main { max-width: 1560px; margin: 0 auto; padding: clamp(18px, 3vw, 34px) clamp(16px, 4vw, 44px); position: relative; z-index: 1; }

h1 { font-family: var(--serif); font-size: clamp(28px, 4vw, 40px); line-height: 1.25; margin: 4px 0 14px; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 14px; font-weight: 650; letter-spacing: .01em; }
h3 { font-size: 13px; margin: 0 0 10px; font-weight: 650; color: var(--ink-soft); letter-spacing: .04em; }
p { margin: 8px 0 14px; }
.eyebrow { color: var(--gold); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; margin: 0 0 6px; font-weight: 600; }
.lead { color: var(--ink-soft); max-width: 46ch; }
.hint { font-size: 12.5px; color: var(--muted); }
code { font-size: .92em; background: var(--bg-tint); padding: 1px 6px; border-radius: 5px; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}

button {
  border: 0; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink);
  padding: 9px 17px; font: 14px var(--sans); cursor: pointer; font-weight: 550;
  transition: transform .18s var(--ease), box-shadow .25s var(--ease), opacity .2s var(--ease), background-color .2s var(--ease);
}
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line-strong); }
button.ghost:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
button.danger { background: var(--bad-soft); color: var(--bad); }
button.small { padding: 5px 11px; font-size: 12.5px; }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin: 12px 0 0; letter-spacing: .02em; }
input, textarea, select {
  display: block; width: 100%; padding: 10px 12px; margin-top: 6px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font: 14px/1.6 var(--sans); background: var(--surface-2); color: var(--ink);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 96px; resize: vertical; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid2 .span2 { grid-column: 1 / -1; }
.grid2 button { margin-top: 16px; justify-self: start; }

.count { font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 6px; }

/* ── 登录 ─────────────────────────────────────────────── */
.login-wrap { display: flex; justify-content: center; padding-top: clamp(40px, 10vh, 110px); }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: clamp(28px, 5vw, 46px); width: min(520px, 100%);
  box-shadow: var(--shadow-md);
}
.login-card button { margin-top: 22px; width: 100%; padding: 12px; }

/* ── 研究视图 ─────────────────────────────────────────── */
.view-research { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; }
.rail { position: sticky; top: 90px; }

.modes { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.mode {
  text-align: left; background: var(--surface-2); color: var(--ink-soft);
  border: 1px solid var(--line); padding: 9px 13px; border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 2px;
}
.mode b { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.mode small { font-size: 11.5px; color: var(--muted); font-weight: 400; line-height: 1.45; }
.mode:hover { border-color: var(--accent); }
.mode.active { border-color: var(--accent); background: var(--accent-soft); }
.mode.active b { color: var(--accent); }

.tasklist { display: flex; flex-direction: column; gap: 4px; max-height: 46vh; overflow-y: auto; }
.taskitem {
  display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left;
  background: none; color: var(--ink); border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 9px 11px;
}
.taskitem:hover { background: var(--surface-2); border-color: var(--line); transform: none; }
.taskitem.selected { background: var(--accent-soft); border-color: var(--accent); }
.taskitem .t { font-size: 13px; line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.taskitem small { font-size: 11px; color: var(--muted); }

.stage {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(20px, 3vw, 32px); box-shadow: var(--shadow-sm); min-height: 60vh;
}
.empty { text-align: center; padding: 12vh 20px; color: var(--muted); }
.empty h2 { font-family: var(--serif); font-size: 22px; color: var(--ink); margin-bottom: 8px; }

/* ── 任务头 ───────────────────────────────────────────── */
.taskhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap; }
.taskhead h2 { font-family: var(--serif); font-size: clamp(20px, 2.6vw, 27px); font-weight: 600; margin: 4px 0 0; line-height: 1.4; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  padding: 3px 11px; border-radius: 999px; background: var(--bg-tint); color: var(--muted);
  border: 1px solid var(--line); white-space: nowrap;
}
.badge.run { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.gold { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.badge.live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 6px; }

.notice {
  background: var(--warn-soft); border-left: 3px solid var(--warn);
  padding: 11px 15px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px; color: var(--ink-soft); margin: 14px 0;
}
.notice.info { background: var(--accent-soft); border-color: var(--accent); }

.divider { height: 1px; background: var(--line); margin: 26px 0; }

/* ── 资料 ─────────────────────────────────────────────── */
.source {
  display: flex; align-items: center; gap: 12px; padding: 10px 13px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin-bottom: 7px; background: var(--surface-2);
}
.source .nm { flex: 1; font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source .meta { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.source .reason { font-size: 11.5px; color: var(--bad); }

details.formbox { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); }
details.formbox summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--accent); }
details.formbox > form { display: flex; flex-direction: column; gap: 2px; }

/* ── 报告 ─────────────────────────────────────────────── */
.report { margin-top: 8px; }
.report section { margin-bottom: 22px; }
.report .judgment {
  font-family: var(--serif); font-size: clamp(17px, 2.1vw, 21px); line-height: 1.65;
  padding: 18px 22px; background: var(--accent-soft); border-radius: var(--radius);
  border-left: 3px solid var(--accent); color: var(--ink);
}
.report ul { margin: 0; padding-left: 18px; }
.report li { margin-bottom: 9px; font-size: 14px; }

.basis {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 8px; background: var(--surface-2);
}
.basis .bt { font-size: 14px; font-weight: 550; margin-bottom: 5px; }
.basis .bq {
  font-size: 12.5px; color: var(--ink-soft); border-left: 2px solid var(--line-strong);
  padding-left: 10px; margin-top: 5px; line-height: 1.65;
}
.basis .bm { font-size: 11px; color: var(--muted); margin-top: 7px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── 门禁 ─────────────────────────────────────────────── */
.gates { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.gate { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; background: var(--surface-2); }
.gate .gh { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.gate .gn { font-size: 12.5px; font-weight: 650; }
.gate .gr { font-size: 11.5px; color: var(--muted); line-height: 1.55; }

/* ── 证据表 ───────────────────────────────────────────── */
.evidence { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.evidence th { text-align: left; font-size: 11px; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); }
.evidence td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.evidence tr:hover td { background: var(--surface-2); }
.evidence .q { color: var(--ink-soft); max-width: 460px; }
.evidence .loc { color: var(--muted); white-space: nowrap; font-size: 11.5px; }
.evidence a { color: var(--accent); cursor: pointer; text-decoration: none; border-bottom: 1px dashed currentColor; }
.evidence a:hover { border-bottom-style: solid; }

/* ── 版本 ─────────────────────────────────────────────── */
.versions { display: flex; flex-direction: column; gap: 6px; }
.version {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
  font-size: 13px; cursor: pointer; transition: border-color .2s var(--ease);
}
.version:hover { border-color: var(--accent); }
.version .v { font-weight: 650; font-family: var(--serif); font-size: 15px; }
.version .t { flex: 1; color: var(--muted); font-size: 11.5px; }

.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 14px; }
.compare .cbox { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px; background: var(--surface-2); }
.compare .ch { font-size: 12.5px; font-weight: 650; margin-bottom: 8px; }
.compare .ci { font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }

/* ── 抽屉 ─────────────────────────────────────────────── */
.drawer {
  position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .38);
  backdrop-filter: blur(3px); display: flex; justify-content: flex-end;
  animation: fade .22s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer-inner {
  width: min(560px, 100%); background: var(--surface); height: 100%; overflow-y: auto;
  padding: 26px; box-shadow: var(--shadow-md); animation: slide .3s var(--ease);
}
@keyframes slide { from { transform: translateX(28px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-inner .orig {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; font-size: 13.5px; line-height: 1.8; white-space: pre-wrap;
  max-height: 52vh; overflow-y: auto; margin-top: 10px;
}
.mark-hit { background: var(--gold-soft); border-radius: 3px; padding: 1px 0; }

/* ── 消息与页脚 ───────────────────────────────────────── */
#message {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 20px; border-radius: 999px;
  font-size: 13px; z-index: 80; opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
  box-shadow: var(--shadow-md); max-width: 86vw; text-align: center;
}
#message.show { opacity: 1; transform: translate(-50%, 0); }
#message.err { background: var(--bad); color: #fff; }

footer {
  text-align: center; padding: 30px 20px 44px; color: var(--muted);
  font-size: 12px; letter-spacing: .04em;
}

.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; flex-wrap: wrap; }
.pagehead h1 { margin-bottom: 0; }

.itemrow {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 15px;
  background: var(--surface-2); display: flex; gap: 12px; align-items: flex-start;
}
.itemrow .ib { flex: 1; min-width: 0; }
.itemrow .it { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.itemrow .id { font-size: 12px; color: var(--muted); line-height: 1.6; }

@media (max-width: 900px) {
  .view-research { grid-template-columns: 1fr; }
  .rail { position: static; }
  .tasklist { max-height: 220px; }
  .grid2 { grid-template-columns: 1fr; }
  .tabs { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .topright { margin-left: auto; }
  .modelchip { display: none; }
  .brandname { display: none; }
  .stage { min-height: 0; }
  .evidence thead { display: none; }
  .evidence, .evidence tbody, .evidence tr, .evidence td { display: block; width: 100%; }
  .evidence tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .evidence td { border: 0; padding: 2px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
