:root {
  --bg: #ffffff;
  --bg-alt: #fafafa;
  --panel: #ffffff;
  --panel-light: #f5f5f5;
  --border: #e5e5e5;
  --border-dark: #000000;
  --text: #000000;
  --text-dim: #666666;
  --text-faint: #999999;
  --accent: #000000;
  /* 状态用形状/字重区分；颜色仅用极弱的灰阶差 */
  --green: #000000;
  --yellow: #000000;
  --red: #000000;
  --blue: #000000;
  --purple: #000000;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "PingFang SC", "Helvetica Neue", system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-dark);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-size: 16px; color: var(--text); font-weight: 600;
  display: flex; align-items: center; gap: 12px;
  letter-spacing: -.01em;
}
.brand .project-name {
  font-size: 13px; color: var(--text); font-weight: 400;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}
.project-switcher { font-size: 12px; color: var(--text-dim); }
.project-switcher select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 0;
  padding: 4px 10px; font: inherit; cursor: pointer;
}
.project-switcher select:focus { outline: none; border-color: var(--text); }
.project-switcher a { color: var(--text-dim); text-decoration: none; }
.project-switcher a:hover { color: var(--text); text-decoration: underline; }
.meta {
  display: flex; gap: 18px; font-size: 12px;
  color: var(--text-dim); align-items: center;
  font-variant-numeric: tabular-nums;
}
.sse-dot { color: var(--text); font-size: 8px; transition: color .3s; }
.sse-dot.disconnected { color: var(--text-faint); }

main {
  display: grid;
  gap: 0;
  padding: 0;
  grid-template-columns: 1fr 1fr;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
}
.panel h2 {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
}
.panel h2 .count {
  background: var(--text);
  color: var(--bg);
  padding: 2px 7px;
  border-radius: 0;
  font-size: 10px;
  font-weight: 600;
}
.panel h3 {
  font-size: 11px; color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
}

#panel-flow, #panel-bugs, #panel-releases, #panel-devlog { grid-column: span 2; }

/* 工作流 pipeline */
.flow-pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 8px 0;
}
.flow-pipeline .stage {
  padding: 10px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
  font-size: 12px;
  min-width: 72px;
  text-align: center;
  white-space: nowrap;
  color: var(--text-dim);
}
.flow-pipeline .stage.has-tasks {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  font-weight: 500;
}
.flow-pipeline .stage[data-count]::after {
  content: " " attr(data-count);
  font-weight: 700;
  margin-left: 4px;
}
.flow-pipeline .arrow {
  color: var(--text-faint);
  font-size: 10px;
  padding: 0 4px;
}

/* 任务 Kanban */
.kanban {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}
.kanban-col {
  background: var(--bg-alt);
  padding: 12px;
  min-height: 100px;
}
.kanban-col h4 {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  letter-spacing: .08em;
  font-weight: 500;
}
.kanban-col h4 span.cnt {
  background: var(--text);
  color: var(--bg);
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
}
.task-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text);
  border-radius: 0;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.task-card:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
.task-card:hover .tid, .task-card:hover .towner { color: var(--bg); }
.task-card .tid {
  color: var(--text-dim);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  margin-bottom: 2px;
}
.task-card .towner {
  display: inline-block;
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-dim);
}
.task-card.blocked { border-left-style: dashed; }
.task-card.blocked::before { content: "▲ "; font-size: 9px; }
.task-card.done { opacity: .35; border-left-color: var(--border); }
.task-card.done::before { content: "✓ "; font-size: 10px; }

/* 角色看板 */
.roles { list-style: none; }
.roles li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.roles li:last-child { border-bottom: none; }
.roles .role-name { display: flex; gap: 12px; align-items: center; }
.roles .role-badge {
  width: 22px; height: 22px;
  background: var(--text);
  color: var(--bg);
  border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
.roles .role-status {
  padding: 2px 8px;
  border: 1px solid var(--text);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.role-status.busy { background: var(--text); color: var(--bg); }
.role-status.idle { background: var(--bg); color: var(--text); }
.role-status.blocked { background: var(--bg); color: var(--text); border-style: dashed; }

/* 健康度 */
.health-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}
.health-card {
  background: var(--bg);
  padding: 14px;
  text-align: left;
  border-top: 3px solid var(--border);
}
.health-card.green { border-top-color: var(--text); }
.health-card.yellow { border-top-color: var(--text); border-top-style: dashed; }
.health-card.red { border-top-color: var(--text); border-top-width: 6px; }
.health-card .label {
  font-size: 10px; color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
}
.health-card .value {
  font-size: 26px; font-weight: 600;
  margin: 4px 0;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.health-card.red .value::after { content: " !"; }
.health-card .target {
  font-size: 10px; color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* Markdown snippet */
.markdown-snippet {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 12px;
  font: 11px/1.55 "SF Mono", "Menlo", monospace;
  color: var(--text-dim);
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 3列 */
.cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cols-3 ul { list-style: none; }
.cols-3 li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  font-family: "SF Mono", monospace;
}
.cols-3 li:hover { color: var(--text); cursor: pointer; }
.cols-3 li:last-child { border-bottom: none; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--bg);
  border: 1px solid var(--text);
  padding: 28px;
  max-width: 720px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}
.modal .close {
  position: absolute;
  top: 12px; right: 16px;
  background: none; border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.modal .close:hover { color: var(--text); }
.modal-content h3 {
  color: var(--text);
  margin-bottom: 12px;
  font-size: 16px;
  letter-spacing: -.01em;
}
.modal-content pre {
  white-space: pre-wrap;
  font: 12px/1.55 "SF Mono", monospace;
  color: var(--text);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 14px;
}
.history-line {
  font-size: 11px;
  color: var(--text-dim);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.history-line:last-child { border-bottom: none; }

@media (max-width: 1100px) {
  main { grid-template-columns: 1fr; }
  #panel-flow, #panel-bugs, #panel-releases, #panel-devlog { grid-column: span 1; }
  .kanban { grid-template-columns: repeat(3, 1fr); }
  .health-grid { grid-template-columns: repeat(2, 1fr); }
}
