* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0f172a; --panel: #1e293b; --panel2: #273449; --border: #334155;
  --text: #e2e8f0; --muted: #94a3b8; --accent: #38bdf8; --accent2: #818cf8;
  --green: #34d399; --yellow: #fbbf24; --red: #f87171; --purple: #c084fc;
  --radius: 8px;
}
body { background: var(--bg); color: var(--text); font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; }
.app { display: flex; flex-direction: column; height: 100vh; }

/* 顶栏 */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-size: 16px; font-weight: 700; color: var(--accent); }
.project-select { display: flex; align-items: center; gap: 6px; }
.project-select label { color: var(--muted); }
.project-select select { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; max-width: 200px; }
.btn-mini { background: var(--panel2); color: var(--accent); border: 1px solid var(--border); border-radius: 6px; width: 28px; height: 28px; cursor: pointer; font-size: 14px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { background: transparent; color: var(--muted); border: none; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.tab.active { background: var(--accent); color: #0f172a; font-weight: 600; }
.topbar-right { display: flex; gap: 6px; }
.token-input { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; width: 80px; font-size: 12px; }

/* 主体 */
.body { flex: 1; overflow: auto; padding: 16px; }
.view { display: none; }
.view.active { display: block; }

/* 工具栏 */
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 7px 14px; cursor: pointer; font-size: 13px; }
.btn.primary { background: var(--accent); color: #0f172a; font-weight: 600; border: none; }
.btn.danger { background: var(--red); color: #fff; border: none; }
.toolbar input, .toolbar select { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 13px; }

/* 看板 */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kanban-col { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); min-height: 200px; display: flex; flex-direction: column; }
.kanban-col.drag-over { border-color: var(--accent); background: var(--panel2); }
.kanban-head { padding: 10px 12px; font-weight: 600; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; }
.kanban-head .count { background: var(--panel2); border-radius: 10px; padding: 1px 8px; font-size: 12px; color: var(--muted); }
.kanban-cards { padding: 8px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.task-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 10px; cursor: grab; position: relative; }
.task-card.dragging { opacity: .5; }
.task-card .t-title { font-weight: 600; margin-bottom: 6px; word-break: break-all; }
.task-card .t-meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 500; }
.badge.p1 { background: rgba(248,113,113,.2); color: var(--red); }
.badge.p2 { background: rgba(251,191,36,.2); color: var(--yellow); }
.badge.p3 { background: rgba(56,189,248,.2); color: var(--accent); }
.badge.p4 { background: rgba(148,163,184,.2); color: var(--muted); }
.badge.blocked { background: rgba(248,113,113,.25); color: var(--red); }
.badge.overdue { background: rgba(248,113,113,.3); color: #fff; }
.deadline { font-size: 11px; color: var(--muted); }
.deadline.overdue { color: var(--red); font-weight: 600; }
.progress-bar { height: 5px; background: var(--border); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 3px; }

/* 表格 */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.task-table { width: 100%; border-collapse: collapse; }
.task-table th, .task-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.task-table th { color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; background: var(--panel2); }
.task-table th:hover { color: var(--accent); }
.task-table tbody tr { cursor: pointer; }
.task-table tbody tr:hover { background: var(--panel2); }
.pager { margin-top: 10px; display: flex; gap: 6px; }

/* 时间线 */
.timeline { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.timeline-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.timeline-label { width: 180px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-track { flex: 1; position: relative; height: 26px; background: var(--panel2); border-radius: 4px; }
.timeline-bar { position: absolute; height: 100%; border-radius: 4px; min-width: 8px; }

/* 团队 */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.team-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.team-card .t-name { font-weight: 700; font-size: 15px; margin-bottom: 8px; }
.team-card .t-role { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.team-stat { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 4px 0; }

/* 统计 */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-card .num { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.stat-card .lbl { color: var(--muted); font-size: 12px; }

/* 通知 */
.notify-list { display: flex; flex-direction: column; gap: 8px; }
.notify-item { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.notify-item .n-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.notify-item .n-type { font-size: 11px; color: var(--accent); }
.notify-item .n-time { font-size: 11px; color: var(--muted); }
.notify-item .n-title { font-weight: 600; margin-bottom: 4px; }
.notify-item .n-content { white-space: pre-wrap; font-size: 13px; color: var(--muted); }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-mask[hidden] { display: none; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); width: 640px; max-width: 95vw; max-height: 90vh; display: flex; flex-direction: column; }
.modal.wide { width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.btn-close { background: transparent; color: var(--muted); border: none; font-size: 22px; cursor: pointer; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.row { margin-bottom: 12px; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field span { color: var(--muted); font-size: 12px; }
.field input, .field select, .field textarea { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 13px; font-family: inherit; }

/* Markdown 编辑器 */
.md-toolbar { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.md-toolbar button { background: var(--panel2); color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 4px 9px; cursor: pointer; font-size: 12px; }
.md-toolbar button:hover { color: var(--text); border-color: var(--accent); }
.md-toolbar button.on { background: var(--accent); color: #0f172a; }
.md-split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.md-split.single { grid-template-columns: 1fr; }
.md-edit, .md-preview { background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 10px; min-height: 200px; max-height: 340px; overflow-y: auto; }
.md-edit { font-family: monospace; font-size: 13px; color: var(--text); outline: none; white-space: pre-wrap; }
.md-preview { font-size: 13px; line-height: 1.6; }
.md-preview h1, .md-preview h2, .md-preview h3 { margin: 8px 0 4px; }
.md-preview img { max-width: 100%; border-radius: 4px; }
.md-preview code { background: var(--bg); padding: 1px 5px; border-radius: 3px; font-family: monospace; }
.md-preview pre { background: var(--bg); padding: 10px; border-radius: 6px; overflow-x: auto; }
.md-preview table { border-collapse: collapse; width: 100%; }
.md-preview th, .md-preview td { border: 1px solid var(--border); padding: 5px 8px; }
.md-preview ul, .md-preview ol { padding-left: 20px; }
.md-preview blockquote { border-left: 3px solid var(--accent); padding-left: 10px; color: var(--muted); }

/* 详情 */
.detail-section { margin-bottom: 16px; }
.detail-section h4 { color: var(--accent); font-size: 13px; margin-bottom: 8px; }
.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 13px; }
.detail-meta .k { color: var(--muted); }
.history-item { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 10px 20px; border-radius: 8px; font-size: 13px; z-index: 200; opacity: 0; transition: opacity .3s; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.error { border-color: var(--red); color: var(--red); }
.toast.success { border-color: var(--green); color: var(--green); }

/* 响应式 */
@media (max-width: 900px) {
  .kanban { grid-template-columns: 1fr; }
  .row.two { grid-template-columns: 1fr; }
  .md-split { grid-template-columns: 1fr; }
  .tabs { order: 3; width: 100%; }
}
