/* ---------- 基础 ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e5e7eb;
  --border-strong: #d5d8de;
  --text: #17191d;
  --text-2: #4b5563;
  --muted: #8b929e;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --gold: #e08c00;
  --gold-soft: #fff6e3;
  --green: #0f9d76;
  --green-soft: #e8f8f2;
  --red: #dc4b4b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px rgba(16, 24, 40, .07);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, .16);
}

html, body {
  height: 100%;
  margin: 0;
}

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

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: #d3d7de; border-radius: 6px; border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #bcc2cc; }

/* ---------- 布局 ---------- */
.app {
  display: grid;
  grid-template-columns: 216px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6 60%, #ec4899);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 10px rgba(99, 102, 241, .3);
  flex: none;
}

.brand-text b {
  display: block; font-size: 14.5px; letter-spacing: .2px;
}
.brand-text span {
  display: block; font-size: 11px; color: var(--muted); margin-top: 1px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: none; background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  text-align: left;
  transition: background .14s, color .14s;
  position: relative;
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .75; }
.nav-item:hover { background: #f4f5f7; color: var(--text); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  background: #eef0f3;
  color: var(--text-2);
  padding: 0 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
  font-weight: 600;
}
.nav-item.active .nav-badge { background: #dbe2ff; color: var(--primary); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 60px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 26px;
  position: sticky; top: 0; z-index: 20;
}

.topbar h1 {
  font-size: 15px; margin: 0; font-weight: 650; letter-spacing: .2px;
}
.topbar .sub { font-size: 12px; color: var(--muted); margin-left: 2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.view { padding: 24px 26px 60px; max-width: 1240px; width: 100%; }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 13px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  transition: background .14s, border-color .14s, transform .1s;
  white-space: nowrap;
}
.btn:hover { background: #f7f8fa; border-color: #c3c8d1; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, .28);
}
.btn.primary:hover { background: #443bd4; border-color: #443bd4; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: #f1f2f5; color: var(--text); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: #fdf1f1; border-color: #f3c9c9; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.field {
  display: flex; flex-direction: column; gap: 5px;
}
.field label { font-size: 12px; color: var(--text-2); font-weight: 500; }

.input, .select, .textarea {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .14s, box-shadow .14s;
  width: 100%;
}
.textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 66px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.select { appearance: none; padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b929e' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 13.5px; font-weight: 650; }
.card-head .hint { font-size: 12px; color: var(--muted); }
.card-head .spacer { margin-left: auto; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  background: #f0f1f4;
  color: var(--text-2);
  white-space: nowrap;
}
.tag.daily { background: #eef2ff; color: #4f46e5; }
.tag.weekly { background: #e6f6ff; color: #0284c7; }
.tag.monthly { background: #f3e9ff; color: #8b5cf6; }
.tag.once { background: #f1f5f9; color: #64748b; }
.tag.high { background: #fdeeee; color: #dc4b4b; }
.tag.low { background: #f1f3f5; color: #6b7280; }

.dot {
  width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none;
}

/* ---------- 今日看板 ---------- */
.board-head {
  display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px;
  flex-wrap: wrap;
}
.date-nav {
  display: flex; align-items: center; gap: 2px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 3px;
}
.date-nav button {
  width: 28px; height: 28px; border: none; background: transparent;
  border-radius: 6px; color: var(--text-2); display: grid; place-items: center;
}
.date-nav button:hover { background: #f1f2f5; color: var(--text); }
.date-nav .date-label {
  padding: 0 8px; font-size: 13px; font-weight: 600; min-width: 128px; text-align: center;
}
.date-nav .date-label small { color: var(--muted); font-weight: 500; margin-left: 4px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat .lbl {
  font-size: 11.5px; color: var(--muted); font-weight: 500;
  display: flex; align-items: center; gap: 5px;
}
.stat .val {
  font-size: 24px; font-weight: 680; letter-spacing: -.5px;
  margin-top: 5px; font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 4px;
}
.stat .val small { font-size: 12px; font-weight: 500; color: var(--muted); }
.stat .val .up { color: var(--green); font-size: 12px; }
.stat.gold .val { color: var(--gold); }
.stat.primary .val { color: var(--primary); }
.stat.green .val { color: var(--green); }

.progress-line {
  margin-top: 9px; height: 5px; border-radius: 4px; background: #eef0f3; overflow: hidden;
}
.progress-line i {
  display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  transition: width .45s cubic-bezier(.22, .9, .3, 1);
}
.stat.gold .progress-line i { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

/* 任务组 */
.group { margin-bottom: 14px; }
.group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 0 2px 8px;
}
.group-head .gname { font-size: 12.5px; font-weight: 650; letter-spacing: .2px; }
.group-head .gcount { font-size: 11.5px; color: var(--muted); }

.tasks { display: flex; flex-direction: column; gap: 8px; }

.task {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color .16s, box-shadow .16s, background .16s, opacity .16s;
}
.task:hover { border-color: #cfd4dd; box-shadow: 0 2px 10px rgba(16, 24, 40, .05); }

.check {
  width: 22px; height: 22px; flex: none;
  border-radius: 7px;
  border: 1.8px solid #ccd1da;
  background: #fff;
  display: grid; place-items: center;
  padding: 0;
  transition: all .16s;
}
.check svg { width: 12px; height: 12px; opacity: 0; transform: scale(.6); transition: all .16s; }
.check:hover { border-color: var(--green); }
.task.done .check {
  background: var(--green); border-color: var(--green);
}
.task.done .check svg { opacity: 1; transform: scale(1); }
.task.done { background: #fbfdfc; }
.task.done .t-title { color: var(--muted); text-decoration: line-through; text-decoration-color: #cfd4dd; }

.task-main { min-width: 0; flex: 1; }
.t-title {
  font-size: 13.5px; font-weight: 550; display: flex; align-items: center; gap: 7px;
  flex-wrap: wrap;
}
.t-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 11.5px; color: var(--muted); margin-top: 3px;
  flex-wrap: wrap;
}
.t-meta .sep { color: #dfe2e8; }

.t-points {
  font-size: 14px; font-weight: 680; color: var(--gold);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.t-points small { font-size: 10.5px; font-weight: 500; color: var(--muted); margin-left: 1px; }
.t-right { display: flex; align-items: center; gap: 12px; flex: none; }

.t-undone-badge { font-size: 11px; color: #a8aeb9; }

/* 「去完成」直达链接 */
.go-link {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 9px;
  border-radius: 7px;
  font-size: 12px; font-weight: 550;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid #dde2ff;
  text-decoration: none;
  white-space: nowrap;
  transition: background .14s, border-color .14s;
}
.go-link:hover { background: #e4e9ff; border-color: #c8d0ff; }
.go-link svg { width: 11px; height: 11px; opacity: .85; }

.mini-link {
  display: inline-flex; vertical-align: -2px; color: #9aa1ad;
  margin-left: 5px; text-decoration: none;
}
.mini-link:hover { color: var(--primary); }
.mini-link svg { width: 12px; height: 12px; }

/* ---------- 空态 ---------- */
.empty {
  padding: 46px 20px; text-align: center; color: var(--muted);
}
.empty .ic {
  width: 46px; height: 46px; border-radius: 14px; background: #f2f3f6;
  display: grid; place-items: center; margin: 0 auto 12px; color: #b3b9c4;
}
.empty h4 { margin: 0 0 4px; font-size: 13.5px; color: var(--text-2); font-weight: 600; }
.empty p { margin: 0; font-size: 12.5px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-weight: 600; font-size: 11.5px; color: var(--muted);
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap; background: var(--surface-2);
  position: sticky; top: 0;
}
table.tbl td {
  padding: 10px 12px; border-bottom: 1px solid #f1f2f5; vertical-align: middle;
}
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: #fafbfc; }
table.tbl .num { font-variant-numeric: tabular-nums; text-align: right; }
table.tbl .act { text-align: right; white-space: nowrap; }
table.tbl tr.inactive td { opacity: .5; }

/* ---------- 团队 ---------- */
.member-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.member {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm);
}
.member-top { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  color: #fff; font-weight: 650; font-size: 15px;
}
.member-name { font-size: 14px; font-weight: 640; }
.member-note { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.member-metrics {
  display: flex; gap: 16px; margin: 14px 0 12px;
  padding: 11px 0; border-top: 1px solid #f1f2f5; border-bottom: 1px solid #f1f2f5;
}
.metric { flex: 1; }
.metric b {
  display: block; font-size: 17px; font-weight: 680;
  font-variant-numeric: tabular-nums; letter-spacing: -.3px;
}
.metric span { font-size: 11px; color: var(--muted); }
.acc-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; font-size: 12.5px;
}
.acc-row .handle { color: var(--text-2); }
.acc-row .idx { margin-left: auto; display: flex; gap: 2px; }
.icon-btn {
  width: 24px; height: 24px; border: none; background: transparent;
  border-radius: 6px; display: grid; place-items: center; color: #b6bcc6;
}
.icon-btn:hover { background: #f1f2f5; color: var(--text); }

/* ---------- 图表 ---------- */
.chart-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px;
}
.chart-box { padding: 6px 8px 10px; }
.chart-legend {
  display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2);
  padding: 0 10px 4px;
}
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }
svg.chart { width: 100%; display: block; overflow: visible; }
.chart-tip {
  position: fixed; z-index: 200; pointer-events: none;
  background: #1f2430; color: #fff; font-size: 11.5px;
  padding: 5px 9px; border-radius: 6px; opacity: 0; transition: opacity .12s;
  white-space: nowrap; box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
}

.seg {
  display: inline-flex; background: #eef0f3; border-radius: 8px; padding: 2px; gap: 1px;
}
.seg button {
  border: none; background: transparent; padding: 4px 11px; border-radius: 6px;
  font-size: 12px; color: var(--text-2); font-weight: 500;
}
.seg button.on { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

/* 热力图 */
.heat {
  display: grid; grid-auto-flow: column;
  grid-template-rows: repeat(7, 13px);
  gap: 3px; padding: 4px 2px 0; justify-content: start;
  overflow-x: auto;
}
.heat i {
  width: 13px; height: 13px; border-radius: 3px; background: #eff1f4; display: block;
  transition: transform .1s;
}
.heat i:hover { transform: scale(1.35); }
.heat-legend {
  display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted);
  padding: 10px 2px 0; justify-content: flex-end;
}

/* 排行 */
.rank-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid #f4f5f7; font-size: 13px;
}
.rank-row:last-child { border-bottom: none; }
.rank-no {
  width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: #f1f2f5; color: var(--text-2); flex: none;
}
.rank-no.top1 { background: #fff3d6; color: #b45309; }
.rank-no.top2 { background: #eef1f5; color: #475569; }
.rank-no.top3 { background: #fbeee5; color: #9a5b34; }
.rank-bar { flex: 1; height: 6px; background: #f1f2f5; border-radius: 4px; overflow: hidden; min-width: 40px; }
.rank-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #a5b4fc, #6366f1); }
.rank-val { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 12.5px; white-space: nowrap; }

/* ---------- 模态 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 24, 32, .42);
  display: grid; place-items: center; z-index: 100; padding: 20px;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: #fff; border-radius: 15px; width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg); animation: pop .18s cubic-bezier(.2, .9, .3, 1);
  max-height: 88vh; display: flex; flex-direction: column;
}
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-head {
  padding: 16px 18px 12px; display: flex; align-items: center;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 13px; overflow-y: auto; }
.modal-foot {
  padding: 12px 18px 16px; display: flex; gap: 8px; justify-content: flex-end;
  border-top: 1px solid var(--border);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }

/* ---------- Toast ---------- */
.toasts {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 300; align-items: center;
}
.toast {
  background: #1f2430; color: #fff; font-size: 12.5px;
  padding: 9px 15px; border-radius: 9px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .25);
  animation: toastIn .2s ease;
  display: flex; align-items: center; gap: 7px;
}
.toast.err { background: #b91c1c; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto;
    flex-direction: row; padding: 6px 8px; border-right: none;
    border-top: 1px solid var(--border); z-index: 50;
  }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav-item { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 5px 8px; }
  .nav-badge { display: none; }
  .view { padding: 16px 14px 90px; }
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar h1 { font-size: 14px; }
  .seg { display: none; }
}

/* ---------- 登录遮罩 ---------- */
.login-mask {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center;
  background: rgba(23, 25, 29, .38);
  backdrop-filter: blur(3px);
  padding: 20px;
}
.login-mask[hidden] { display: none; }
.login-card {
  width: 320px; max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 26px 24px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.login-card .brand-mark { width: 38px; height: 38px; border-radius: 11px; font-size: 17px; }
.login-card h2 { margin: 2px 0 0; font-size: 15px; font-weight: 650; }
.login-sub { margin: 0; font-size: 12.5px; color: var(--muted); }
.login-card .input { width: 100%; margin-top: 4px; }
.login-err {
  margin: 0; min-height: 16px; width: 100%;
  font-size: 12px; color: var(--red); text-align: center;
}
.login-card .btn { width: 100%; justify-content: center; height: 34px; }
.login-hint {
  margin: 2px 0 0; font-size: 11.5px; color: var(--muted);
  text-align: center; line-height: 1.5;
}
