:root {
  color-scheme: light;
  --plane: #f6f5f1;
  --surface: #fcfcfb;
  --surface-2: #f0efea;
  --ink: #16161a;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e1e0d9;
  --line-2: #c3c2b7;
  --accent: #16161a;
  --ad: #2a78d6;  --ad-bg: #e8f1fc;
  --ai: #eb6834;  --ai-bg: #fdeee7;
  --pet: #1baf7a; --pet-bg: #e3f6ee;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-ink: #006300; --crit-ink: #b42828;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --r: 12px;
  --font: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane: #0f0f0e; --surface: #1a1a19; --surface-2: #232321;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --line: #2c2c2a; --line-2: #383835;
    --accent: #f0efec;
    --ad: #3987e5;  --ad-bg: #182638;
    --ai: #d95926;  --ai-bg: #33201a;
    --pet: #199e70; --pet-bg: #142c24;
    --good-ink: #0ca30c; --crit-ink: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0f0f0e; --surface: #1a1a19; --surface-2: #232321;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --line: #2c2c2a; --line-2: #383835;
  --accent: #f0efec;
  --ad: #3987e5;  --ad-bg: #182638;
  --ai: #d95926;  --ai-bg: #33201a;
  --pet: #199e70; --pet-bg: #142c24;
  --good-ink: #0ca30c; --crit-ink: #e66767;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--plane); color: var(--ink); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
ul { margin: 0; padding-left: 1.2em; }

/* ---------- 顶栏 ---------- */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1280px; margin: 0 auto; padding: 10px 20px 0; }
.top-row { display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 12px; }
.save-state { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.save-state.err { color: var(--crit-ink); }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-top: 6px; }
.nav::-webkit-scrollbar { display: none; }
.nav a { text-decoration: none; padding: 8px 12px 10px; font-size: 14px; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.nav .badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--critical); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 600; }

main { max-width: 1280px; margin: 0 auto; padding: 20px 20px 80px; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .sub { color: var(--ink-2); font-size: 13px; }
.page-head .tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 基础组件 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-h h3 { font-size: 15px; }
.card-h .r { margin-left: auto; display: flex; gap: 6px; }
.grid { display: grid; gap: 16px; }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.mt { margin-top: 16px; }
@media (max-width: 960px) { .g3, .g21 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) { .g2 { grid-template-columns: minmax(0, 1fr); } main { padding: 14px 12px 80px; } .top-in { padding: 8px 12px 0; } }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.pri { background: var(--accent); color: var(--plane); border-color: var(--accent); }
.btn.pri:hover { opacity: .88; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); padding: 4px 8px; }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.danger { color: var(--crit-ink); }
.btn:disabled { opacity: .5; cursor: default; }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; line-height: 20px; padding: 0 8px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip.t-ad { background: var(--ad-bg); color: var(--ink); } .chip.t-ad .dot { background: var(--ad); }
.chip.t-ai { background: var(--ai-bg); color: var(--ink); } .chip.t-ai .dot { background: var(--ai); }
.chip.t-pet { background: var(--pet-bg); color: var(--ink); } .chip.t-pet .dot { background: var(--pet); }
.chip.draft { background: transparent; border: 1px dashed var(--line-2); color: var(--muted); line-height: 18px; }
.chip.st-good .dot { background: var(--good); }
.chip.st-warn .dot { background: var(--warning); }
.chip.st-bad .dot { background: var(--critical); }
.chip.q1 { background: color-mix(in srgb, var(--critical) 14%, transparent); color: var(--crit-ink); font-weight: 600; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 3px 12px; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.filters button.on { border-color: var(--ink); color: var(--ink); font-weight: 600; }

.empty { color: var(--muted); font-size: 13px; padding: 10px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ink2 { color: var(--ink-2); }
.edit-hint { cursor: pointer; border-radius: 6px; }
.edit-hint:hover { background: var(--surface-2); outline: 4px solid var(--surface-2); }

/* ---------- 总览 ---------- */
.hero { padding: 22px 24px; }
.hero .vision { font-size: 19px; font-weight: 600; line-height: 1.55; max-width: 980px; }
.hero .meta { margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 13px; }
.track-card { border-top: 4px solid var(--tc); }
.track-card .goal { font-size: 18px; font-weight: 700; }
.track-card .role { color: var(--ink-2); font-size: 13px; }
.track-card .note { margin: 10px 0 12px; font-size: 13px; color: var(--ink-2); }
.kpi-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; align-items: baseline; }
.kpi-row .v { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.kpi-row .v .t { color: var(--muted); font-weight: 400; }
.kpi-row .src { grid-column: 1 / -1; font-size: 11px; color: var(--muted); }
.bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--tc, var(--ink-2)); }

.list-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .t { font-size: 14px; font-weight: 500; }
.list-item .m { margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.list-item.click { cursor: pointer; }
.list-item.click:hover .t { text-decoration: underline; }
.check { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-2); background: var(--surface); flex: none; cursor: pointer; display: grid; place-items: center; margin-top: 1px; padding: 0; }
.check.on { background: var(--ink); border-color: var(--ink); }
.check.on::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--plane); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.done .t { text-decoration: line-through; color: var(--muted); }

/* 精力分配图 */
.alloc { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px 10px; align-items: center; font-size: 13px; }
.alloc .lbl { color: var(--ink-2); }
.stack { display: flex; gap: 2px; height: 26px; }
.stack > div { position: relative; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 600; min-width: 0; overflow: hidden; cursor: default; }
.stack .s-ad { background: var(--ad); } .stack .s-ai { background: var(--ai); } .stack .s-pet { background: var(--pet); }
.stack.empty-stack { border: 1px dashed var(--line-2); border-radius: 4px; color: var(--muted); font-size: 12px; align-items: center; justify-content: center; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tip { position: fixed; z-index: 90; pointer-events: none; background: var(--ink); color: var(--plane); font-size: 12px; padding: 6px 9px; border-radius: 6px; max-width: 260px; }

/* ---------- 战略 ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { border: 1px solid var(--line); background: var(--surface); padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.tabs button.on { border-color: var(--ink); font-weight: 600; }
.tabs .dot { width: 9px; height: 9px; border-radius: 50%; }
.flywheel { width: 100%; height: auto; display: block; }
.flywheel text { font-family: var(--font); }
.syn-list .list-item .arrow { font-size: 12px; white-space: nowrap; }
.road { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.road th, .road td { border: 1px solid var(--line); padding: 8px; vertical-align: top; text-align: left; }
.road th { background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--ink-2); }
.road td:first-child, .road th:first-child { width: 96px; }
.road .ri { display: flex; gap: 6px; align-items: flex-start; padding: 4px 0; }
.road .ri .check { width: 16px; height: 16px; border-radius: 4px; }
.road .ri .check.on::after { width: 8px; height: 4px; }
.road .ri span { cursor: pointer; }
.road .ri.done span { text-decoration: line-through; color: var(--muted); }
.road-wrap { overflow-x: auto; }
.road-wrap .road { min-width: 680px; }
.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 720px) { .kanban { grid-template-columns: minmax(0, 1fr); } }
.kanban .col { background: var(--surface-2); border-radius: 10px; padding: 10px; min-height: 80px; }
.kanban .col h4 { font-size: 12px; color: var(--ink-2); margin-bottom: 8px; font-weight: 600; }
.kanban .mv { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; cursor: pointer; }
.kanban .mv:hover { border-color: var(--line-2); }
.bullet-list { list-style: none; padding: 0; }
.bullet-list li { padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; display: flex; gap: 8px; align-items: flex-start; }
.bullet-list li:first-child { border-top: 0; }
.bullet-list li .tx { flex: 1; cursor: pointer; }

/* ---------- 问题矩阵 ---------- */
.matrix { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) { .matrix { grid-template-columns: minmax(0, 1fr); } }
.quad { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; min-height: 140px; }
.quad h3 { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.quad h3 small { font-weight: 400; color: var(--muted); font-size: 12px; }
.quad.q-1 { border-color: color-mix(in srgb, var(--critical) 45%, var(--line)); }
.issue { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); cursor: pointer; border-left: 3px solid var(--tc); }
.issue:hover { outline: 1px solid var(--line-2); }
.issue .t { font-weight: 600; font-size: 14px; }
.issue .m { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); align-items: center; }
.issue.closed { opacity: .55; }
.overdue { color: var(--crit-ink); font-weight: 600; }

/* ---------- 决策日志 ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.dec { position: relative; margin-bottom: 14px; }
.dec::before { content: ""; position: absolute; left: -21px; top: 18px; width: 10px; height: 10px; border-radius: 50%; background: var(--tc); border: 2px solid var(--plane); }
.dec .card { cursor: pointer; }
.dec .card:hover { border-color: var(--line-2); }
.dec dl { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 4px 10px; margin: 10px 0 0; font-size: 13px; }
.dec dt { color: var(--muted); }
.dec dd { margin: 0; white-space: pre-wrap; }
.dec.review .card { border-color: color-mix(in srgb, var(--warning) 70%, var(--line)); }

/* ---------- 周复盘 ---------- */
.week-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 960px) { .week-fields { grid-template-columns: minmax(0, 1fr); } }
.week-fields label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; font-weight: 600; }
details.past { margin-top: 10px; }
details.past summary { cursor: pointer; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
details.past[open] summary { border-radius: 10px 10px 0 0; }
details.past .body { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; padding: 12px 14px; background: var(--surface); font-size: 13px; }

/* ---------- 表单 / 弹窗 ---------- */
textarea, input[type=text], input[type=number], input[type=date], input[type=password], select {
  width: 100%; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; background: var(--surface); outline: none; }
textarea:focus, input:focus, select:focus { border-color: var(--ink); }
textarea { resize: vertical; min-height: 64px; line-height: 1.55; }
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.35); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px 12px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: min(640px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); border: 1px solid var(--line); }
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.modal-h h3 { font-size: 16px; }
.modal-h .x { margin-left: auto; }
.modal-b { padding: 14px 18px; display: grid; gap: 12px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.modal-f .sp { flex: 1; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.toggle input { width: 16px; height: 16px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 99; background: var(--ink); color: var(--plane); padding: 9px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }

/* ---------- 登录 ---------- */
.gate { position: fixed; inset: 0; z-index: 100; background: var(--plane); display: grid; place-items: center; padding: 20px; }
.gate form { width: min(340px, 100%); display: grid; gap: 12px; text-align: center; }
.gate h1 { font-size: 20px; }
.gate .err { color: var(--crit-ink); font-size: 13px; min-height: 20px; }

/* ---------- AI 参谋 ---------- */
.chat { display: flex; flex-direction: column; min-height: 60vh; }
.msgs { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 860px; padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--ink); color: var(--plane); max-width: 680px; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.msg.assistant b { font-weight: 700; }
.msg .act { margin-top: 8px; display: flex; gap: 6px; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.quick button { border: 1px solid var(--line); background: var(--surface); border-radius: 18px; padding: 6px 12px; font-size: 13px; cursor: pointer; text-align: left; }
.quick button:hover { border-color: var(--ink); }
.composer { position: sticky; bottom: 0; background: var(--plane); padding: 12px 0 4px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 48px; max-height: 200px; }

.hist-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.hist-row:first-child { border-top: 0; }
.hist-row .sp { flex: 1; }

@media print {
  .top, .tools, .btn, .composer, .quick { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* 表格 */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-2); padding: 6px 8px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl td.n, .alloc + .legend + .tbl td { font-variant-numeric: tabular-nums; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl .bar { height: 6px; }
