:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e6eaf0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --todo: #94a3b8;
  --doing: #3b82f6;
  --done: #22c55e;
  --high: #ef4444;
  --medium: #f59e0b;
  --low: #10b981;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.05);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.app { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff; display: grid; place-items: center; font-size: 20px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; }
.brand-text span { font-size: 11px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  border: none; background: transparent; color: var(--muted);
  padding: 11px 12px; border-radius: 10px; cursor: pointer;
  font-size: 14px; text-align: left; transition: .15s;
}
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 16px; }

/* 主区 */
.main { flex: 1; padding: 28px 32px; max-width: 1280px; }
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 18px; }
.view-head h1 { margin: 0; font-size: 24px; }
.view-head .sub { margin: 4px 0 0; color: var(--muted); }

/* 卡片 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 15px; }
.toolbar { flex-wrap: wrap; gap: 12px; }

/* 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.stat-card .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-card .bar { height: 6px; border-radius: 6px; background: var(--surface-2); margin-top: 12px; overflow: hidden; }
.stat-card .bar > i { display: block; height: 100%; border-radius: 6px; background: var(--primary); }

/* 图表网格 */
.chart-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 280px; }

/* 表单 */
.task-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select { padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; background: #fff; color: var(--text); }
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.submit-row { grid-column: 1 / -1; display: flex; gap: 10px; justify-content: flex-end; }

/* 按钮 */
.btn-primary { background: var(--primary); color: #fff; border: none; padding: 9px 18px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 600; }
.btn-primary:hover { background: #4338ca; }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: 9px 16px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.btn-ghost:hover { background: #e9eef5; }
.btn-ghost.danger { color: var(--high); }
.btn-ghost.sm { padding: 7px 10px; font-size: 12px; }

/* 筛选 */
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters input, .filters select { padding: 8px 11px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; background: #fff; }

/* 表格 */
.table-wrap { overflow-x: auto; }
.task-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.task-table th, .task-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
.task-table th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.task-table tr:hover td { background: #fafbfd; }
.task-title { font-weight: 600; }
.task-notes { color: var(--muted); font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 28px; }

/* 标签 */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag.todo { background: #f1f5f9; color: #475569; }
.tag.doing { background: #e0edff; color: #1d4ed8; }
.tag.done { background: #dcfce7; color: #15803d; }
.tag.p-high { background: #fee2e2; color: #b91c1c; }
.tag.p-medium { background: #fef3c7; color: #b45309; }
.tag.p-low { background: #d1fae5; color: #047857; }

.icon-btn { border: none; background: transparent; cursor: pointer; color: var(--muted); padding: 4px 7px; border-radius: 7px; font-size: 13px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.del:hover { color: var(--high); }

/* 看板 */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.kcol { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 200px; }
.kcol-head { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 12px; padding: 0 4px; }
.kcol-head .kcount { margin-left: auto; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.todo { background: var(--todo); }
.dot.doing { background: var(--doing); }
.dot.done { background: var(--done); }
.kcol-body { display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.kcol-body.drag-over { outline: 2px dashed var(--primary); outline-offset: -4px; border-radius: 10px; }
.kcard { background: #fff; border: 1px solid var(--border); border-radius: 11px; padding: 11px 12px; box-shadow: var(--shadow); cursor: grab; }
.kcard:active { cursor: grabbing; }
.kcard .kc-title { font-weight: 600; margin-bottom: 6px; }
.kcard .kc-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.kcard .kc-due { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.kcard.overdue .kc-due { color: var(--high); font-weight: 600; }

/* 回顾 */
.summary { font-size: 14px; line-height: 1.9; }
.summary p { margin: 0 0 8px; }
.summary .hl { color: var(--primary); font-weight: 700; }
.summary .good { color: var(--done); font-weight: 700; }
.summary .bad { color: var(--high); font-weight: 700; }

/* 弹窗 */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--surface); border-radius: 16px; width: min(620px, 100%); padding: 20px 22px; box-shadow: 0 20px 60px rgba(15,23,42,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; }
.modal-head .x { border: none; background: transparent; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }

/* 响应式 */
@media (max-width: 980px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .task-form { grid-template-columns: 1fr 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .sidebar { width: 72px; }
  .brand-text, .nav-item span:not(.ico), .sidebar-foot .btn-ghost { display: none; }
  .nav-item { justify-content: center; }
}
@media (max-width: 640px) {
  .main { padding: 18px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .task-form { grid-template-columns: 1fr; }
}

/* 登录 / 注册 */
.login-modal { width: min(380px, 100%); }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tab { flex: 1; padding: 9px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 9px; cursor: pointer; font-size: 14px; color: var(--muted); }
.tab.active { background: var(--primary-soft); color: var(--primary); border-color: transparent; font-weight: 600; }
.auth-msg { font-size: 13px; color: var(--high); min-height: 18px; }

/* 侧边栏用户框 */
.user-box { display: flex; flex-direction: column; gap: 8px; }
.ub-name { font-size: 13px; color: var(--text); padding: 8px 10px; background: var(--surface-2); border-radius: 9px; }
