/* ============ 基础变量与重置 ============ */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --border: #e5e6eb;
  --primary: #3370ff;
  --primary-hover: #2b5fd9;
  --primary-light: #eef3ff;
  --success: #34c77b;
  --success-light: #e6f8ef;
  --warning: #ff8f1f;
  --warning-light: #fff2e5;
  --danger: #f54a45;
  --danger-light: #feeceb;
  --info: #3370ff;
  --info-light: #eef3ff;
  --gray-light: #f2f3f5;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(31, 35, 41, .06);
  --shadow-lg: 0 8px 30px rgba(31, 35, 41, .12);
  --sidebar-w: 232px;
  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

/* ============ 整体布局 ============ */
.layout { min-height: 100vh; display: flex; }

/* ---- 侧边栏 ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
}

.brand-logo {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3370ff, #6d4aff);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
  flex-shrink: 0;
}

.brand-name { font-size: 15px; font-weight: 600; }
.brand-sub { font-size: 11px; color: var(--text-3); display: block; }

.nav { padding: 8px 12px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-2);
  margin-bottom: 2px;
  font-size: 14px;
  transition: background .15s, color .15s;
}

.nav-item:hover { background: var(--gray-light); color: var(--text); }

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-icon { width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}

.mode-badge {
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.mode-badge.demo { background: var(--warning-light); color: var(--warning); }
.mode-badge.live { background: var(--success-light); color: var(--success); }

/* ---- 主区域 ---- */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; gap: 14px;
}

.menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  width: 34px; height: 34px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-2);
}

.page-title { font-size: 17px; font-weight: 600; flex: 1; }
.page-desc { font-size: 12px; color: var(--text-3); font-weight: 400; }

.content { padding: 24px 28px 48px; max-width: 1200px; width: 100%; }

/* 侧边栏遮罩（移动端） */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 90;
}

/* ============ 通用组件 ============ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card + .card { margin-top: 16px; }

.card-title {
  font-size: 15px; font-weight: 600;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-outline {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-outline:hover { color: var(--text); border-color: var(--text-3); }

.btn-danger-ghost {
  background: transparent; color: var(--danger);
  border: none; cursor: pointer;
  padding: 4px 8px; border-radius: 6px; font-size: 13px;
}
.btn-danger-ghost:hover { background: var(--danger-light); }

/* 状态标签 */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tag.todo    { background: var(--gray-light); color: var(--text-2); }
.tag.doing   { background: var(--info-light); color: var(--info); }
.tag.done    { background: var(--success-light); color: var(--success); }
.tag.blocked { background: var(--danger-light); color: var(--danger); }

/* 统计卡 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.stat-num { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.stat-card.accent { border-left: 3px solid var(--primary); }

/* 进度条 */
.progress-track {
  height: 8px; border-radius: 999px;
  background: var(--gray-light);
  overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #3370ff, #6d4aff);
  transition: width .4s ease;
}

/* 表格 */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th { font-size: 12px; color: var(--text-3); font-weight: 500; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

.task-title-cell { font-weight: 500; min-width: 160px; }

/* 表单 */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(51, 112, 255, .12);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 状态选择器（行内） */
.status-select {
  padding: 5px 28px 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238f959e' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: inherit;
}

.status-select.todo    { background-color: var(--gray-light); color: var(--text-2); }
.status-select.doing   { background-color: var(--info-light); color: var(--info); }
.status-select.done    { background-color: var(--success-light); color: var(--success); }
.status-select.blocked { background-color: var(--danger-light); color: var(--danger); }

/* 筛选栏 */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

.filter-bar select,
.filter-bar input[type="search"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  font-family: inherit;
}

.filter-bar input[type="search"] { flex: 1; min-width: 160px; }

/* Tab */
.tabs { display: inline-flex; background: var(--gray-light); border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.tab {
  border: none; background: transparent;
  padding: 6px 14px; border-radius: 6px;
  font-size: 13px; color: var(--text-2); cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* 成员卡片 */
.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.member-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}

.member-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  margin: 0 auto 10px;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600;
}

.avatar.sm { width: 28px; height: 28px; font-size: 12px; margin: 0; }

.member-name { font-size: 15px; font-weight: 600; }
.member-role { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.avatar-color-0 { background: #3370ff; }
.avatar-color-1 { background: #6d4aff; }
.avatar-color-2 { background: #00b386; }
.avatar-color-3 { background: #ff8f1f; }
.avatar-color-4 { background: #f54a45; }
.avatar-color-5 { background: #00a6c8; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .18s ease;
}

.modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  overflow-y: auto;
  animation: slideUp .22s ease;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 0;
}

.modal-title { font-size: 16px; font-weight: 600; }

.modal-close {
  border: none; background: transparent;
  font-size: 20px; color: var(--text-3);
  cursor: pointer; line-height: 1;
  padding: 4px;
}

.modal-body { padding: 16px 22px 22px; }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 0 22px 20px;
}

@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } }

/* Toast */
#toastRoot {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}

.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* 其他 */
.empty {
  text-align: center;
  color: var(--text-3);
  padding: 48px 0;
}
.empty .empty-icon { font-size: 34px; margin-bottom: 8px; }

.recent-list { list-style: none; }
.recent-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.recent-item:last-child { border-bottom: none; }
.recent-name { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-meta { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.quick-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.quick-link {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  color: var(--text);
  font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
.quick-link:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.quick-link .ql-icon { font-size: 22px; display: block; margin-bottom: 6px; }

.donut-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.donut-legend .dot { width: 8px; height: 8px; border-radius: 3px; display: inline-block; margin-right: 5px; }

.proj-row { padding: 16px 0; border-bottom: 1px solid var(--border); }
.proj-row:last-child { border-bottom: none; }
.proj-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.proj-name { font-weight: 600; }
.proj-pct { color: var(--primary); font-weight: 700; }
.proj-stats { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

.loading { text-align: center; padding: 60px 0; color: var(--text-3); }

.detail-list { list-style: none; }
.detail-list li { display: flex; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.detail-list li:last-child { border-bottom: none; }
.detail-label { width: 72px; color: var(--text-3); flex-shrink: 0; }
.detail-value { flex: 1; word-break: break-all; }

/* ============ 响应式：平板与手机 ============ */
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .overlay.show { display: block; }

  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }

  .content { padding: 16px 16px 40px; }
  .topbar { padding: 12px 16px; }

  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-num { font-size: 22px; }

  .card { padding: 16px; }

  .modal-mask { padding: 12px; align-items: flex-end; }
  .modal { max-height: 90vh; }

  th, td { padding: 10px 8px; }
  .hide-sm { display: none; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filter-bar select { max-width: 46%; }
}
