:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e8eaed;
  --text: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
}

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

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

a { color: inherit; text-decoration: none; }

.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1180px;
  margin: 0 auto;
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 36px;
}
.brand {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
}
.brand-mark {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 2px;
  margin-right: 9px;
  vertical-align: 2px;
}
.nav-links { display: flex; gap: 28px; flex: 1; }
.nav-links a {
  color: var(--muted);
  font-size: 14px;
  padding: 20px 0;
  border-bottom: 2px solid transparent;
  transition: color .15s;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.nav-user { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #eef2ff;
  color: #4338ca;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}
.link-btn {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  padding: 0;
}
.link-btn:hover { color: var(--primary); }

main { max-width: 1180px; margin: 0 auto; padding: 40px 28px 80px; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 28px; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -.2px; }
.section-sub { color: var(--muted); font-size: 13px; margin-top: 6px; }

.notice {
  background: #fffdf5;
  border: 1px solid #f0e6c8;
  color: #7a6428;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.notice-dot { width: 6px; height: 6px; border-radius: 50%; background: #c99a2e; flex-shrink: 0; }

.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: #cfd8e3; transform: translateY(-1px); }
.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--cat-color, var(--primary));
}
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.cat-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
}
.cat-badge i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.date-badge { padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.card-title { font-size: 15px; font-weight: 500; line-height: 1.5; margin-bottom: 10px; }
.card-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--border); padding-top: 14px; }
.status-pill { padding: 3px 9px; border-radius: 5px; font-size: 12px; font-weight: 500; }
.status-pending { background: #f3f4f6; color: #6b7280; }
.status-doing { background: #eff6ff; color: #2563eb; }
.status-done { background: #ecfdf5; color: #059669; }
.status-postponed { background: #fffbeb; color: #b45309; }
.card-date-text { color: var(--faint); font-size: 12px; margin-right: auto; }
.postpone-note { color: #b45309; font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: inherit; cursor: pointer;
  transition: all .15s;
}
.btn:hover { border-color: #cbd5e1; background: #fafbfc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-mini { padding: 5px 10px; font-size: 12px; }
.btn-danger { border-color: #fecaca; color: #b91c1c; }
.btn-danger:hover { border-color: #f87171; background: #fef2f2; }

.role-badge { padding: 3px 9px; border-radius: 5px; font-size: 12px; font-weight: 500; }
.role-super { background: #f3e8ff; color: #7e22ce; }
.role-admin { background: #eff6ff; color: #2563eb; }
.role-emp { background: #f3f4f6; color: #6b7280; }
.btn-block { width: 100%; }

.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(17, 24, 39, .42);
  z-index: 50;
  place-items: center;
  padding: 20px;
}
.modal-overlay:target { display: grid; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%; max-width: 480px;
  max-height: 88vh; overflow-y: auto;
  padding: 26px 28px 28px;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.modal-title { font-size: 16px; font-weight: 600; line-height: 1.5; }
.modal-close { color: var(--faint); font-size: 20px; line-height: 1; }
.modal-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.form-row { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.form-row label { font-size: 13px; font-weight: 500; }
.form-row input, .form-row select, .form-row textarea {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--primary); }
.form-row textarea { resize: vertical; min-height: 76px; }
.form-card { max-width: 520px; padding: 26px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.req { color: #dc2626; }
.history-title { font-size: 13px; font-weight: 500; margin: 22px 0 10px; }
.history-item { background: #f9fafb; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 8px; }
.history-item .reason { color: var(--muted); margin-top: 4px; }
.history-empty { color: var(--faint); font-size: 13px; }

.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 15px 20px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-size: 12px; font-weight: 500; background: #fafbfc; }
tr:last-child td { border-bottom: none; }
td.task-title-cell { font-weight: 500; }
td.date-cell { width: 190px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 30px; font-weight: 500; letter-spacing: -.5px; line-height: 1.3; margin-top: 6px; }
.stat-hint { color: var(--faint); font-size: 12px; margin-top: 2px; }
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; }
.panel h2 { font-size: 15px; font-weight: 500; margin-bottom: 18px; }
.bar-row { margin-bottom: 15px; }
.bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 7px; color: var(--muted); }
.bar-track { height: 6px; background: #f1f3f5; border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.mini-row:last-child { border-bottom: none; }
.mini-row .who { color: var(--faint); font-size: 12px; white-space: nowrap; }

.toast {
  background: #1f2937; color: #fff;
  padding: 11px 16px; border-radius: 8px;
  font-size: 13px;
  position: fixed; top: 78px; right: 24px; z-index: 80;
}
.toast.error { background: #b91c1c; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 38px 36px; }
.login-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.login-card .btn { margin-top: 8px; padding: 10px; }
.login-msg { background: #f3f4f6; color: var(--muted); padding: 9px 12px; border-radius: 7px; font-size: 13px; text-align: center; margin-bottom: 18px; }

.empty { text-align: center; color: var(--faint); padding: 70px 20px; }

/* ============ 多端适配 ============ */
/* 平板：导航收紧、内容区两栏 */
@media (max-width: 1024px) {
  .nav-inner { gap: 22px; padding: 0 20px; }
  .nav-links { gap: 18px; }
  .nav-user { gap: 10px; }
  main { padding: 32px 20px 64px; }
  .panels { grid-template-columns: 1fr; }
}

/* 手机：导航可横滑、卡片单列、表格横滚、弹窗贴底 */
@media (max-width: 640px) {
  .nav-inner {
    height: auto;
    min-height: 0;
    flex-wrap: wrap;
    gap: 0 12px;
    padding: 12px 16px 0;
  }
  .brand { font-size: 15px; padding-bottom: 10px; }
  .nav-user { margin-left: auto; padding-bottom: 10px; font-size: 12px; }
  .nav-user > span:last-of-type { display: none; }
  .nav-links {
    order: 3;
    flex-basis: 100%;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a {
    white-space: nowrap;
    padding: 11px 0;
    margin-right: 22px;
    font-size: 13px;
  }

  main { padding: 24px 16px 56px; }
  h1 { font-size: 20px; }
  .section-head { align-items: center; margin-bottom: 20px; }
  .section-sub { font-size: 12px; }
  .btn { padding: 9px 13px; }
  .btn-mini { padding: 5px 9px; font-size: 12px; }
  .notice { font-size: 12px; padding: 10px 12px; }

  .task-grid { grid-template-columns: 1fr; gap: 14px; }
  .card { padding: 17px 18px; }
  .card-top { margin-bottom: 12px; }
  .card-foot { flex-wrap: wrap; gap: 8px; }
  .card-date-text { margin-right: 0; flex-basis: 100%; order: -1; }

  .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }
  th, td { padding: 12px 14px; font-size: 13px; }
  td.date-cell, th.date-cell { width: auto; white-space: nowrap; }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat { padding: 16px; }
  .stat-value { font-size: 26px; }
  .mini-row { flex-wrap: wrap; }
  .mini-row .who { white-space: normal; }

  .modal-overlay { padding: 0; align-items: end; }
  .modal {
    max-width: none;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  }
  .form-row input, .form-row select, .form-row textarea { font-size: 16px; }
  .form-actions .btn { flex: 1; }

  .toast { left: 16px; right: 16px; top: auto; bottom: 20px; text-align: center; }
  .login-wrap { padding: 16px; }
  .login-card { padding: 30px 22px; }
  .empty { padding: 50px 16px; }
}

/* 超窄屏兜底 */
@media (max-width: 360px) {
  .stats { grid-template-columns: 1fr; }
  .nav-links a { margin-right: 18px; }
}

/* 多列表格（人员管理）需要更宽的横向滚动区域，避免表头竖排 */
@media (max-width: 640px) {
  .table-wide table { min-width: 760px; }
  .table-wide th { white-space: nowrap; }
}

/* ============ 协作分工 ============ */
.collab-badge { padding: 4px 9px; border-radius: 6px; font-size: 12px; font-weight: 500; background: #eef2ff; color: #4338ca; white-space: nowrap; }
.collab-panel { background: #fafbfc; border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; margin-bottom: 14px; }
.collab-myrole { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.role-chip { padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 500; }
.role-owner { background: #eef2ff; color: #4338ca; }
.role-member { background: #f3f4f6; color: #6b7280; }
.collab-progress { font-size: 12px; color: var(--faint); margin: 8px 0; }
.collab-members { display: flex; flex-direction: column; gap: 6px; }
.member-chip { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 4px 8px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); flex-wrap: wrap; }
.member-chip.is-owner { border-color: #c7d2fe; }
.member-part { color: var(--faint); flex: 1; min-width: 80px; }

.collab-block { border: 1px solid var(--border); border-radius: 9px; padding: 14px 16px; margin-bottom: 16px; }
.collab-title { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 500; margin-bottom: 12px; }
.collab-hint { color: var(--faint); font-size: 12px; margin-top: 10px; }
.collab-list { display: flex; flex-direction: column; gap: 8px; }
.collab-row { display: flex; gap: 8px; align-items: center; }
.collab-row select, .collab-row input { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 7px; padding: 9px 11px; font-size: 14px; font-family: inherit; color: var(--text); background: var(--surface); outline: none; }
.collab-row select:focus, .collab-row input:focus { border-color: var(--primary); }
.collab-remove { flex-shrink: 0; width: 30px; height: 34px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--muted); font-size: 17px; cursor: pointer; line-height: 1; }
.collab-remove:hover { border-color: #f87171; color: #b91c1c; background: #fef2f2; }

@media (max-width: 640px) {
  .collab-row { flex-wrap: wrap; }
  .collab-row select, .collab-row input { flex: 1 1 100%; }
  .collab-remove { width: 100%; }
  .collab-block { padding: 12px; }
}

.team-detail { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; max-width: 320px; }
