:root {
  --bg: #F3F4F1;
  --surface: #FFFFFF;
  --ink: #1C1F23;
  --ink2: #374151;
  --muted: #5B6470;
  --line: #E3E5E8;
  --line2: #EEF0F2;
  --field: #D5D9DE;
  --accent: #1F5FBF;
  --accent-ink: #1A4F9E;
  --accent-soft: #EAF1FC;
  --danger: #B4410C;
  --done-bg: #DDF1EA; --done-fg: #11604F; --done-bar: #1F8A6E;
  --doing-bg: #E2EBFA; --doing-fg: #1A4F9E; --doing-bar: #2F6FD0;
  --late-bg: #FDE6D8; --late-fg: #9A3412; --late-bar: #D9580F;
  --todo-bg: #ECEDEF; --todo-fg: #4B5563; --todo-bar: #9AA1AB;
  --empty-bg: #FFF1C2; --empty-fg: #7A5B00; --empty-bar: #C9A227;
  --plan-bar: #D3D8DE;
  --radius: 12px;
  --mono: "SF Mono", "JetBrains Mono", Consolas, Menlo, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px; line-height: 1.5; -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; background: none; border: 0; margin: 0; padding: 0; cursor: pointer; text-align: left; }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- 布局 ---------- */
.shell { min-height: 100vh; }
.main { min-width: 0; padding-bottom: calc(80px + var(--safe-b)); }
.page { padding: 0 16px 24px; max-width: 1100px; margin: 0 auto; }
.page.full { max-width: none; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg); display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 6px 12px 6px 16px; }
.topbar .title { font-size: 16px; font-weight: 600; flex: 1; text-align: center; margin-right: 44px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .grow { flex: 1; }
.back { display: inline-flex; align-items: center; gap: 2px; height: 44px; padding: 0 6px 0 0; font-size: 15px; flex: none; }
.proj-btn { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--field); font-weight: 600; max-width: 70vw; }
.proj-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding-bottom: var(--safe-b); }
.tabbar a { position: relative; height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #6B7280; font-size: 12px; font-weight: 600; }
.tabbar a.on { color: var(--accent); }
.badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #C2410C; color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

.side { display: none; }
@media (min-width: 960px) {
  .shell { display: flex; }
  .side { display: flex; flex-direction: column; gap: 4px; width: 220px; flex: none; position: sticky; top: 0; height: 100vh; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--line); }
  .side .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 8px 16px; }
  .side a, .side button.nav { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px; border-radius: 10px; color: var(--ink2); font-weight: 500; width: 100%; }
  .side a.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
  .side .sep { height: 1px; background: var(--line); margin: 10px 4px; }
  .side .me { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 8px; font-size: 13px; }
  .main { flex: 1; padding-bottom: 32px; }
  .tabbar { display: none; }
  .topbar { padding: 10px 24px; }
  .page { padding: 0 24px 32px; margin: 0; max-width: 1400px; }
  .topbar .title { text-align: left; margin-right: 0; }
}

/* ---------- 通用块 ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 10px; }
.section-h { display: flex; align-items: baseline; justify-content: space-between; margin: 20px 0 8px; }
.section-h h2 { font-size: 16px; font-weight: 700; }
.h1 { font-size: 22px; font-weight: 700; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid-cards { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 700px) { .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1300px) { .grid-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.empty { background: var(--surface); border-radius: var(--radius); padding: 24px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 12px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 600; font-family: var(--mono); line-height: 1.3; }
.divider { height: 1px; background: var(--line2); margin: 12px 0; }

.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.st-done { background: var(--done-bg); color: var(--done-fg); }
.st-doing { background: var(--doing-bg); color: var(--doing-fg); }
.st-late { background: var(--late-bg); color: var(--late-fg); }
.st-todo { background: var(--todo-bg); color: var(--todo-fg); }
.st-empty { background: var(--empty-bg); color: var(--empty-fg); }
.st-closed { background: #E3E7EC; color: #2F3640; }
.st-waiting { background: #EEE8F7; color: #5B3F8C; }
.flowlink { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 2px 0 2px 18px; }
.flowlink .ln { width: 2px; height: 18px; background: var(--field); }
.flowlink.par .ln { width: 10px; height: 2px; }
.mode-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-ink); }
.order-btns { display: flex; flex-direction: column; gap: 4px; flex: none; }
.order-btns button { width: 40px; height: 34px; border-radius: 8px; border: 1px solid var(--field); background: #fff; text-align: center; }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 12px; border: 1px solid var(--field); border-radius: 10px; background: #fff; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; }
.st-cancelled { background: #EFEFEF; color: #6B7280; }
.banner { display: flex; align-items: center; gap: 10px; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; font-size: 14px; }
.banner.info { background: #EAF1FC; color: #1A4F9E; }
.banner.ok { background: #E6F4EF; color: #11604F; }
.banner.mute { background: #ECEDEF; color: #374151; }
.banner .btn { margin-left: auto; flex: none; }
.close-card { border: 1px solid #D5DCE4; }
.close-card .sum { white-space: pre-wrap; word-break: break-word; margin-top: 8px; line-height: 1.7; }
.tag { display: inline-block; font-size: 12px; color: var(--ink2); background: #F0F1F3; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.tag.hi { color: var(--late-fg); background: transparent; border: 1px solid #F1B48F; padding: 1px 6px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 600; flex: none; overflow: hidden; }
.bar { height: 6px; border-radius: 3px; background: #E8EAED; overflow: hidden; flex: 1; }
.bar > i { display: block; height: 100%; }
.due-late { color: var(--late-fg); }
.due-done { color: var(--done-fg); }

/* 卡片 */
.issue-card, .step-card { display: block; width: 100%; background: var(--surface); border-radius: var(--radius); padding: 14px; }
.issue-card:active, .step-card:active { background: #FAFAFA; }
.issue-card .t { display: block; font-size: 16px; font-weight: 600; margin-top: 6px; }
.step-card .t { display: block; font-size: 15px; font-weight: 600; margin-top: 4px; }
.step-card .sub, .issue-card .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.no { font-size: 15px; font-weight: 700; }

/* ---------- 表单 ---------- */
.field { display: block; margin-top: 14px; }
.field:first-child { margin-top: 0; }
.field.grid2 { display: grid; }
.field > .lbl { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field > .lbl small { font-weight: 400; color: var(--muted); }
.input, .textarea, .select { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--field); border-radius: 10px; background: #fff; }
.textarea { padding: 10px 12px; resize: vertical; min-height: 84px; }
.input:focus, .textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.input[type="date"] { padding: 0 10px; }
.input:disabled { background: #F6F7F8; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.err { font-size: 13px; color: var(--danger); margin-top: 10px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--field); background: #fff; font-size: 13px; font-weight: 500; white-space: nowrap; }
.pill.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button { height: 44px; border-radius: 10px; border: 1px solid var(--field); background: #fff; font-weight: 600; text-align: center; }
.seg button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.picker { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 0 12px 0 6px; border: 1px solid var(--field); border-radius: 10px; background: #fff; }
.picker .ph { color: var(--muted); padding-left: 6px; }

.btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 48px; padding: 0 18px; border-radius: 12px; font-weight: 600; font-size: 15px; text-align: center; }
.btn.sm { height: 40px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.dark { background: var(--ink); color: #fff; }
.btn.ghost { border: 1px solid var(--field); background: #fff; }
.btn.danger { border: 1px solid #F1B48F; color: var(--late-fg); background: #fff; }
.btn.block { width: 100%; }
.actionbar { position: sticky; bottom: 0; z-index: 15; display: flex; gap: 10px; padding: 12px 16px calc(12px + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--line); margin: 16px -16px 0; }
.actionbar .btn { flex: 1; }
@media (min-width: 960px) { .actionbar { position: static; background: transparent; border: 0; padding: 0; margin: 16px 0 0; justify-content: flex-start; } .actionbar .btn { flex: none; min-width: 160px; } }
.fab { position: fixed; right: 16px; bottom: calc(76px + var(--safe-b)); z-index: 25; height: 48px; padding: 0 18px; border-radius: 24px; background: var(--accent); color: #fff; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 6px 16px rgba(20, 40, 80, .25); }
@media (min-width: 960px) { .fab { position: static; box-shadow: none; height: 40px; border-radius: 10px; } }

/* 详情字段 */
.kv { display: flex; align-items: center; min-height: 46px; border-bottom: 1px solid var(--line2); gap: 8px; }
.kv:last-child { border-bottom: 0; }
.kv > .k { width: 80px; flex: none; font-size: 13px; color: var(--muted); }
.kv > .v { flex: 1; min-width: 0; padding: 10px 0; word-break: break-word; }

/* 迷你甘特 */
.mg { position: relative; margin-top: 10px; }
.mg .r { display: flex; align-items: center; height: 24px; }
.mg .lab { width: 52px; flex: none; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.mg .trk { position: relative; flex: 1; height: 24px; }
.mg .pl { position: absolute; top: 5px; height: 14px; border-radius: 4px; background: var(--plan-bar); }
.mg .ac { position: absolute; top: 9px; height: 6px; border-radius: 3px; }
.mg .today { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--danger); }
.legend { display: flex; gap: 12px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { display: inline-block; border-radius: 2px; }

/* 全量甘特 */
.gantt-box { background: var(--surface); border-radius: var(--radius); overflow: auto; border: 1px solid var(--line); max-height: calc(100vh - 210px); }
.gantt { position: relative; }
.g-row { display: flex; border-bottom: 1px solid var(--line2); }
.g-head { position: sticky; top: 0; z-index: 3; background: #fff; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); font-weight: 600; }
.g-left { position: sticky; left: 0; z-index: 2; background: #fff; display: flex; flex: none; border-right: 1px solid var(--line); }
.g-head .g-left { z-index: 4; }
.g-cell { display: flex; align-items: center; padding: 0 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.g-cat { background: #F6F7F8; font-weight: 700; font-size: 13px; }
.g-cat .g-left { background: #F6F7F8; }
.g-issue { font-weight: 600; cursor: pointer; }
.g-step { font-size: 13px; cursor: pointer; }
.g-step:hover .g-left, .g-issue:hover .g-left { background: #FAFBFC; }
.g-trk { position: relative; flex: none; }
.g-trk .pl { position: absolute; top: 8px; height: 18px; border-radius: 4px; background: var(--plan-bar); }
.g-trk .pl.late { background: #F6D2BE; }
.g-trk .ac { position: absolute; top: 14px; height: 6px; border-radius: 3px; }
.g-trk .span { position: absolute; top: 16px; height: 6px; border-radius: 3px; background: #4B5563; }
.g-trk .due { position: absolute; top: 14px; width: 10px; height: 10px; background: var(--ink); transform: rotate(45deg); }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 1; pointer-events: none; }
.g-weeks { display: flex; }
.g-weeks div { flex: none; border-right: 1px solid var(--line2); padding: 4px 4px 0; font-family: var(--mono); font-weight: 500; }

/* 附件 */
.thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
@media (min-width: 700px) { .thumbs { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.thumb { position: relative; aspect-ratio: 1 / 1; border-radius: 10px; background: #E9ECEF; overflow: hidden; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 12px; color: var(--muted); padding: 6px; word-break: break-all; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .88); display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 100%; max-height: 100%; }

/* 记录 */
.logs { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.log { display: flex; gap: 10px; }
.log .meta { font-size: 12px; color: var(--muted); }
.log.event .txt { color: var(--muted); font-size: 13px; }

/* 弹层 */
.sheet-mask { position: fixed; inset: 0; z-index: 60; background: rgba(20, 24, 30, .42); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 86vh; overflow: auto; background: #fff; border-radius: 18px 18px 0 0; padding: 18px 16px calc(16px + var(--safe-b)); }
@media (min-width: 700px) { .sheet { left: 50%; right: auto; bottom: auto; top: 10vh; width: 520px; transform: translateX(-50%); border-radius: 16px; max-height: 80vh; } }
.sheet h3 { font-size: 17px; margin-bottom: 12px; }
.opt { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 6px 4px; border-bottom: 1px solid var(--line2); }
.opt.on { color: var(--accent-ink); font-weight: 600; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); z-index: 90; max-width: calc(100vw - 32px); background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 16px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.warnbar { background: #FFF6E0; color: #7A5B00; font-size: 13px; padding: 8px 16px; }
.stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: #E8EAED; }
.scroll-x { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.ok { color: var(--done-fg); }
.bad { color: var(--late-fg); }
pre.msg { white-space: pre-wrap; word-break: break-all; background: #F6F7F8; border-radius: 8px; padding: 8px; font-size: 12px; margin: 6px 0 0; max-height: 240px; overflow: auto; }

/* 结案审批、@提及、项目设置 */
.st-pending { background: #FFF1C2; color: #7A5B00; }
.banner.warn { background: #FFF1C2; color: #6B4E00; }
.close-card.pending { border-color: #E9C46A; background: #FFFBEB; }
.mention-box { position: relative; }
.mention-pop { position: absolute; left: 52px; right: 70px; top: 48px; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); padding: 2px 8px; max-height: 260px; overflow: auto; }
.mention { color: var(--accent-ink); font-weight: 600; }
.member-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line2); flex-wrap: wrap; }
.member-row .who { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 150px; }
.member-row select { height: 36px; border: 1px solid var(--field); border-radius: 8px; background: #fff; padding: 0 8px; }
.member-row label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.settings-sec h2 { font-size: 16px; margin-bottom: 4px; }
.settings-sec .desc { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; cursor: pointer; }
.switch input { width: 20px; height: 20px; }
.kpi4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 600px) { .kpi4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.import-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.import-table td, .import-table th { padding: 6px 8px; border-bottom: 1px solid var(--line2); text-align: left; }

/* 甘特图：初始计划（基线） */
.g-trk .bl { position: absolute; top: 28px; height: 0; border-top: 2px dashed #8A9099; }
