:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e2e5ea;
  --border-strong: #cdd2d9;
  --text: #1b1f24;
  --text-2: #5b6470;
  --text-3: #8b939e;
  --primary: #2361a8;
  --primary-dark: #1a4b85;
  --primary-soft: #e8f0fa;
  --danger: #c0403a;
  --danger-soft: #fbeceb;
  --warn: #a9701a;
  --warn-soft: #fdf3e2;
  --success: #2c7a55;
  --success-soft: #e8f5ee;
  --purple: #6b4fa8;
  --purple-soft: #efeafa;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(27, 31, 36, 0.06);
  --shadow-md: 0 4px 16px rgba(27, 31, 36, 0.1);
  --shadow-lg: 0 12px 40px rgba(27, 31, 36, 0.16);
  --sidebar-w: 216px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef2f7 0%, #f7f8fa 55%, #e9eef5 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px 30px;
  box-shadow: var(--shadow-md);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 15px;
  letter-spacing: .5px;
}
.login-card h1 { font-size: 19px; font-weight: 500; margin: 0; }
.login-card .sub { color: var(--text-3); font-size: 13px; margin: 6px 0 26px; }
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(35, 97, 168, .12);
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
  font-size: 13.5px;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #e8c9c7; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.login-error {
  display: none;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f0d3d1;
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
.login-error.show { display: block; }
.login-foot { margin-top: 22px; text-align: center; font-size: 12px; color: var(--text-3); }

/* ============ 主框架 ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #1e2936;
  color: #b6c1cf;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand .brand-mark { width: 28px; height: 28px; font-size: 13px; border-radius: 7px; }
.sidebar-brand .name { color: #f1f5f9; font-weight: 500; font-size: 14px; }
.sidebar-brand .sub { font-size: 11px; color: #7d8b9c; margin-top: -2px; }
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-group-label {
  font-size: 11px;
  color: #6c7a8b;
  padding: 12px 10px 6px;
  letter-spacing: .4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  cursor: pointer;
  color: #b6c1cf;
  font-size: 13.5px;
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background .14s, color .14s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #e8eef5; }
.nav-item.active { background: rgba(80, 145, 215, .22); color: #fff; }
.nav-item.disabled { opacity: .42; cursor: not-allowed; }
.nav-item .ico { width: 16px; height: 16px; flex: 0 0 16px; opacity: .9; }
.nav-item .tag-soon {
  margin-left: auto;
  font-size: 10px;
  background: rgba(255,255,255,.1);
  color: #93a1b3;
  padding: 1px 5px;
  border-radius: 4px;
}
.sidebar-foot {
  padding: 12px 14px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 12px;
  color: #8b98a8;
}
.sidebar-foot .user-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-foot .logout {
  color: #93a1b3;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 5px;
}
.sidebar-foot .logout:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h2 { font-size: 16px; font-weight: 500; margin: 0; }
.topbar .spacer { flex: 1; }
.topbar .today { font-size: 12.5px; color: var(--text-3); }

.page { padding: 22px 24px 60px; }
.page-narrow { max-width: 1080px; }

/* ============ 卡片 / 统计 ============ */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card .label { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.stat-card .value { font-size: 25px; font-weight: 500; line-height: 1.2; letter-spacing: -.3px; }
.stat-card .hint { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.stat-card.alert .value { color: var(--danger); }
.stat-card.ok .value { color: var(--success); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14px; font-weight: 500; margin: 0; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }

/* ============ 工具栏 ============ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar .search {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 320px;
}
.toolbar .search input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  outline: none;
}
.toolbar .search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(35,97,168,.12); }
.toolbar .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.toolbar select {
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  outline: none;
}
.toolbar select:focus { border-color: var(--primary); }
.toolbar .spacer { flex: 1; }
.seg {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.seg button {
  border: none;
  background: none;
  padding: 7px 13px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
}
.seg button.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.seg button + button { border-left: 1px solid var(--border); }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr { cursor: pointer; transition: background .1s; }
table.data tbody tr:hover { background: #f8fafc; }
table.data tbody tr:last-child td { border-bottom: none; }
.cell-title { font-weight: 500; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }

/* ============ 徽章 ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  line-height: 1.7;
}
.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .75;
}
.badge.plain::before { display: none; }
.b-in_progress { background: var(--primary-soft); color: var(--primary); }
.b-not_started { background: #eef1f4; color: #667080; }
.b-waiting { background: var(--warn-soft); color: var(--warn); }
.b-at_risk { background: var(--danger-soft); color: var(--danger); }
.b-review { background: var(--purple-soft); color: var(--purple); }
.b-done { background: var(--success-soft); color: var(--success); }
.b-paused { background: #eef1f4; color: #8b939e; }
.b-archived { background: #f1f3f5; color: #9aa3ad; }
.b-high { background: var(--danger-soft); color: var(--danger); }
.b-normal { background: #eef1f4; color: #667080; }
.b-low { background: #f1f3f5; color: #8b939e; }
.badge.b-high, .badge.b-normal, .badge.b-low { justify-content: center; min-width: 38px; }
.b-cat { background: #f1f4f8; color: #4d5b6d; }
.b-tag {
  background: #f1f4f8;
  color: #4d5b6d;
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: 4px;
}

/* ============ 进度条 ============ */
.progress {
  height: 5px;
  background: #eceff3;
  border-radius: 3px;
  overflow: hidden;
  min-width: 64px;
}
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s; }
.progress.done > span { background: var(--success); }
.progress.risk > span { background: var(--danger); }
.progress-cell { display: flex; align-items: center; gap: 8px; }
.progress-cell .num { font-size: 12px; color: var(--text-3); width: 30px; text-align: right; }

/* ============ 看板 ============ */
.kanban {
  display: grid;
  grid-template-columns: repeat(6, minmax(176px, 1fr));
  gap: 10px;
  padding-bottom: 12px;
  align-items: start;
  overflow-x: auto;
}
.kanban-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  max-height: calc(100vh - 220px);
  min-height: 180px;
  overflow-y: auto;
}
.kanban-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}
.kanban-col-head .count {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 7px;
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
}
.kcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s, transform .15s;
  box-shadow: var(--shadow-sm);
}
.kcard:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateY(-1px); }
.kcard .k-title { font-weight: 500; font-size: 13.5px; margin-bottom: 4px; line-height: 1.45; }
.kcard .k-meta { font-size: 11.5px; color: var(--text-3); display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.kcard .k-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kcard .due-over { color: var(--danger); }

/* ============ 详情页 ============ */
.detail-head {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.detail-title-row { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.detail-title-row h1 { font-size: 19px; font-weight: 500; margin: 0; line-height: 1.4; }
.detail-title-row .spacer { flex: 1; }
.detail-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.detail-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.detail-fields .k { font-size: 11.5px; color: var(--text-3); margin-bottom: 2px; }
.detail-fields .v { font-size: 13.5px; }
.detail-fields .v.is-empty { color: var(--text-3); }

.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.cell-over { color: var(--danger); }
@media (max-width: 1024px) {
  .detail-grid { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
}

/* ============ 列表条目 ============ */
.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .t { font-size: 13.5px; }
.list-item .s { font-size: 11.5px; color: var(--text-3); }
.list-item.done .t { color: var(--text-3); text-decoration: line-through; }
.list-item.ms-done .t { color: var(--text-3); }
.checkbox {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  flex: 0 0 16px;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  transition: all .14s;
}
.checkbox:hover { border-color: var(--primary); }
.checkbox.on { background: var(--success); border-color: var(--success); }
.checkbox.on::after {
  content: '';
  width: 8px; height: 4px;
  border-left: 1.6px solid #fff;
  border-bottom: 1.6px solid #fff;
  transform: rotate(-45deg) translate(0, -1px);
}
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 3px 5px;
  border-radius: 5px;
  font-size: 12.5px;
  opacity: 0;
  transition: all .14s;
}
.list-item:hover .icon-btn { opacity: 1; }
.icon-btn:hover { background: #eef1f4; color: var(--danger); }

/* ============ 时间线 ============ */
.timeline { padding: 4px 0; }
.tl-item { position: relative; padding: 0 0 16px 18px; border-left: 1px solid var(--border); margin-left: 5px; }
.tl-item:last-child { padding-bottom: 0; border-left-color: transparent; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -4px; top: 5px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
}
.tl-item:first-child::before { background: var(--primary); }
.tl-time { font-size: 11.5px; color: var(--text-3); margin-bottom: 2px; }
.tl-text { font-size: 13px; white-space: pre-wrap; word-break: break-word; }

/* ============ 空状态 ============ */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-3);
}
.empty .big { font-size: 14px; color: var(--text-2); margin-bottom: 6px; }
.empty .small { font-size: 12.5px; }
.empty svg { opacity: .35; margin-bottom: 12px; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 25, 32, .38);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 100;
  overflow-y: auto;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 620px;
  box-shadow: var(--shadow-lg);
  animation: pop .16s ease-out;
  margin: auto 0;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.modal-head h3 { font-size: 15px; font-weight: 500; margin: 0; }
.modal-head .spacer { flex: 1; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 20px; line-height: 1;
  padding: 2px 6px; border-radius: 6px;
}
.modal-close:hover { background: #f1f3f5; color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1 1 auto; }
.modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 14px 14px;
  flex: 0 0 auto;
}
.modal-foot .spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.hint-text { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

/* ============ 提示条 ============ */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #232b35;
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all .2s;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* ============ 杂项 ============ */
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mt-16 { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.section-title {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: .3px;
  margin: 0 0 8px;
}
.loading { text-align: center; padding: 40px; color: var(--text-3); font-size: 13px; }
.link-btn {
  background: none; border: none; color: var(--primary);
  cursor: pointer; font-size: 12.5px; padding: 2px 4px;
}
.link-btn:hover { text-decoration: underline; }
.dot-sep { color: var(--border-strong); margin: 0 2px; }
