/* ---------- 基础 ---------- */
:root {
  --bg: #f5f6f9;
  --card: #ffffff;
  --text: #16181d;
  --text-2: #4b525c;
  --muted: #858c96;
  --line: #e7e9ee;
  --line-2: #f0f1f5;
  --accent: #4f46e5;
  --accent-2: #7c6cf6;
  --accent-soft: #eef0ff;
  --green: #10b981;
  --red: #e11d48;
  --amber: #f59e0b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a20;
    --text: #eef0f3;
    --text-2: #b8bec8;
    --muted: #7c838f;
    --line: #262a32;
    --line-2: #1e222a;
    --accent: #8b86f7;
    --accent-2: #a78bfa;
    --accent-soft: #23213a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -16px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { cursor: pointer; }

.hint { color: var(--muted); font-weight: 400; font-size: 12px; }

/* ---------- 登录页 ---------- */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1000px 600px at 15% -10%, rgba(124, 108, 246, .16), transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(79, 70, 229, .12), transparent 60%),
    var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 36px 28px 28px;
  text-align: center;
}

.login-mark {
  width: 46px; height: 46px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 22px; font-weight: 700;
  box-shadow: 0 6px 18px -6px rgba(79, 70, 229, .6);
}

.login-card h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.2px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

.login-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-btn {
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 600;
  letter-spacing: .5px;
  transition: filter .15s, transform .05s;
}
.login-btn:hover { filter: brightness(1.06); }
.login-btn:active { transform: translateY(1px); }

.login-error {
  margin-top: 12px;
  color: var(--red);
  font-size: 13px;
}

/* ---------- 布局 ---------- */
.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 20px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 4px 14px -6px rgba(79, 70, 229, .7);
}
.brand-name { font-weight: 650; letter-spacing: -.2px; }

.date-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 4px;
  box-shadow: var(--shadow);
}

.date-label {
  border: 0;
  background: none;
  padding: 5px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.date-label:hover { background: var(--line-2); }

.date-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px; height: 1px;
}

.icon-btn {
  border: 0;
  background: none;
  width: 30px; height: 30px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 18px;
  line-height: 1;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--line-2); color: var(--text); }

.ghost-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-2);
  padding: 6px 12px;
  border-radius: 9px;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.top-right { display: flex; align-items: center; gap: 10px; }

.mini-progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
}
.mini-progress b { font-size: 15px; font-variant-numeric: tabular-nums; }
.mini-progress span { font-size: 11px; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 288px;
  gap: 18px;
  align-items: start;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { order: 2; }
  .date-nav { margin-left: 0; width: 100%; justify-content: space-between; }
  .top-right { margin-left: auto; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.side { display: grid; gap: 18px; position: sticky; top: 20px; }

.card h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 650;
  color: var(--text-2);
  letter-spacing: .3px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

/* ---------- 主卡片 ---------- */
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 19px; letter-spacing: -.3px; }
.sub { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.progressbar {
  height: 5px;
  background: var(--line-2);
  border-radius: 99px;
  margin: 16px 0;
  overflow: hidden;
}
#progFill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .35s cubic-bezier(.4, 0, .2, 1);
}

.add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}
.add-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.add-row input:focus {
  border-color: var(--accent);
  background: var(--card);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.add-row select {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  padding: 0 8px;
  outline: none;
  color: var(--text-2);
  cursor: pointer;
}
.primary-btn {
  border: 0;
  border-radius: 10px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 600;
  transition: filter .15s, transform .05s;
}
.primary-btn:hover { filter: brightness(1.07); }
.primary-btn:active { transform: translateY(1px); }

/* ---------- 任务列表 ---------- */
.tasks {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.task {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px 10px 4px;
  border-radius: 10px;
  border-bottom: 1px solid var(--line-2);
  transition: background .12s;
}
.task:last-child { border-bottom: 0; }
.task:hover { background: var(--line-2); }
.task.dragging { opacity: .45; }
.task.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.task.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }

.cb-wrap { display: grid; place-items: center; width: 22px; height: 22px; margin-top: 1px; }
.cb-wrap input { display: none; }
.cb-box {
  width: 18px; height: 18px;
  border: 1.6px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  display: grid; place-items: center;
  transition: all .15s;
  flex: none;
}
.cb-wrap:hover .cb-box { border-color: var(--accent); }
.cb-wrap input:checked + .cb-box {
  background: var(--green);
  border-color: var(--green);
}
.cb-wrap input:checked + .cb-box::after {
  content: "";
  width: 4px; height: 8px;
  border: 2px solid #fff;
  border-top: 0; border-left: 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.t-body { flex: 1; min-width: 0; display: grid; gap: 3px; }

.t-title {
  width: 100%;
  border: 0;
  background: none;
  outline: none;
  padding: 1px 0;
  font-size: 14.5px;
  color: var(--text);
  border-radius: 4px;
  transition: color .15s;
}
.t-title:focus { background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }

.t-note {
  width: 100%;
  border: 0;
  background: none;
  outline: none;
  resize: none;
  padding: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  overflow: hidden;
  border-radius: 4px;
  transition: color .15s;
}
.t-note::placeholder { color: transparent; }
.task:hover .t-note::placeholder { color: var(--muted); opacity: .7; }
.t-note:focus { color: var(--text-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.t-note:focus::placeholder { color: var(--muted); opacity: .8; }

.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.task.done .t-note { opacity: .65; }

.pri {
  border: 0;
  background: none;
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
  margin-top: 2px;
  border-radius: 6px;
  font-weight: 600;
  opacity: .9;
  transition: background .12s;
}
.pri:hover { background: var(--line); }
.pri-2 { color: var(--red); }
.pri-1 { color: var(--amber); }
.pri-0 { color: var(--muted); }

.del {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  width: 24px; height: 24px;
  border-radius: 6px;
  margin-top: 1px;
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s;
}
.task:hover .del, .task:focus-within .del { opacity: 1; }
.del:hover { background: rgba(225, 29, 72, .1); color: var(--red); }

.empty { text-align: center; padding: 40px 16px 34px; }
.empty-icon { font-size: 28px; color: var(--line); margin-bottom: 6px; }
.empty p { margin: 4px 0; }
.empty .hint { max-width: 340px; margin: 6px auto 0; line-height: 1.7; }

/* ---------- 侧栏 ---------- */
.spark {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 92px;
  padding-top: 6px;
}
.spark-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}
.spark-bar {
  width: 100%;
  max-width: 22px;
  border-radius: 5px;
  background: var(--line);
  position: relative;
  transition: height .3s;
  min-height: 3px;
}
.spark-bar i {
  position: absolute;
  left: 0; bottom: 0; width: 100%;
  border-radius: 5px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  display: block;
}
.spark-bar.zero { background: var(--line); }
.spark-day { font-size: 10.5px; color: var(--muted); }
.spark-day.today { color: var(--accent); font-weight: 700; }
.spark-val { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.tpl-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 2px; }
.tpl-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.tpl-item:hover { background: var(--line-2); }
.tpl-item.off { opacity: .45; }
.tpl-dot { width: 6px; height: 6px; border-radius: 99px; flex: none; }
.tpl-dot.p2 { background: var(--red); }
.tpl-dot.p1 { background: var(--amber); }
.tpl-dot.p0 { background: var(--line); }
.tpl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-x {
  border: 0; background: none; color: var(--muted);
  font-size: 15px; line-height: 1; opacity: 0; padding: 0 4px;
}
.tpl-item:hover .tpl-x { opacity: 1; }
.tpl-x:hover { color: var(--red); }

.tpl-add { display: flex; gap: 6px; }
.tpl-add input {
  flex: 1; min-width: 0;
  padding: 7px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: none;
  outline: none;
  font-size: 13px;
}
.tpl-add input:focus { border-style: solid; border-color: var(--accent); }
.tpl-add button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  width: 32px;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1;
}
.tpl-add button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: #1b1e24;
  color: #fff;
  padding: 9px 18px;
  border-radius: 99px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 99;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 移动端微调 ---------- */
/* ---------- 概览 / 筛选 ---------- */
.overview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.overview .ov b {
  font-size: 14px;
  color: var(--text);
  margin-right: 3px;
  font-variant-numeric: tabular-nums;
}
.overview .ov.warn b { color: var(--red); }

.filters {
  display: flex;
  gap: 4px;
  margin: 4px 0 10px;
  flex-wrap: wrap;
}
.filters button {
  border: 0;
  background: none;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--muted);
  transition: background .12s, color .12s;
}
.filters button:hover { background: var(--line-2); color: var(--text); }
.filters button.on {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.filters button i {
  font-style: normal;
  opacity: .6;
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 任务行增强 ---------- */
.t-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.t-line .t-title { flex: 1; min-width: 0; }

.badge {
  flex: none;
  font-size: 11px;
  line-height: 1.5;
  padding: 1px 7px;
  border-radius: 99px;
  white-space: nowrap;
  font-weight: 500;
  border: 1px solid transparent;
}
.b-todo { color: var(--muted); background: var(--line-2); }
.b-doing {
  color: #0284c7;
  background: rgba(14, 165, 233, .12);
}
.b-over {
  color: var(--red);
  background: rgba(225, 29, 72, .1);
}
.b-done {
  color: var(--green);
  background: rgba(16, 185, 129, .1);
}
.b-late {
  color: #b45309;
  background: rgba(245, 158, 11, .14);
}

.badge:empty { display: none; }

.t-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 1px;
}
.chip {
  border: 0;
  background: none;
  font-size: 11.5px;
  line-height: 1.6;
  padding: 1px 7px;
  border-radius: 6px;
  color: var(--muted);
  white-space: nowrap;
  transition: background .12s;
}
.chip:hover { background: var(--line-2); }
.plan-chip { color: var(--text-2); font-variant-numeric: tabular-nums; }
.start-btn {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.start-btn:hover { background: var(--accent); color: #fff; }

/* 分类色 */
.cat-1 { --c: #6366f1; }
.cat-2 { --c: #0ea5e9; }
.cat-3 { --c: #f59e0b; }
.cat-4 { --c: #10b981; }
.cat-5 { --c: #8b5cf6; }
.cat-0 { --c: #9aa1ab; }
.cat-chip {
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
}
.cat-chip:hover { background: color-mix(in srgb, var(--c) 20%, transparent); }
.tpl-dot.cat-1, .tpl-dot.cat-2, .tpl-dot.cat-3,
.tpl-dot.cat-4, .tpl-dot.cat-5, .tpl-dot.cat-0 {
  background: var(--c);
}

/* 延期行整体提示 */
.task.s-overdue { background: rgba(225, 29, 72, .035); }
.task.s-overdue:hover { background: rgba(225, 29, 72, .06); }
.task.s-overdue .t-title { color: var(--red); }

.delay-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  background: rgba(225, 29, 72, .06);
  border-radius: 7px;
  padding: 3px 8px;
}
.delay-label {
  font-size: 11.5px;
  color: var(--red);
  flex: none;
  font-weight: 600;
}
.delay-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  font-size: 12.5px;
  color: var(--text-2);
  padding: 2px 0;
}
.delay-input::placeholder { color: var(--muted); opacity: .8; }

.detail {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
}
.d-field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.d-field select, .d-field input {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  padding: 3px 6px;
  font-size: 12px;
  outline: none;
  color: var(--text);
}
.d-field select:focus, .d-field input:focus { border-color: var(--accent); }

/* 新增任务的更多选项 */
.more-btn {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
  width: 38px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}
.more-btn:hover { border-color: var(--accent); color: var(--accent); }

.add-extra {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin: 10px 0 2px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 9px;
}
.add-extra label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.add-extra select, .add-extra input {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
  padding: 4px 7px;
  font-size: 12.5px;
  outline: none;
  color: var(--text);
}
.add-extra select:focus, .add-extra input:focus { border-color: var(--accent); }

/* 说明卡 */
.tip-card .tips {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}
.tip-card .tips b { color: var(--text-2); font-weight: 600; }

/* ---------- 移动端微调 ---------- */
@media (max-width: 560px) {
  .wrap { padding: 18px 14px 48px; }
  .card { padding: 15px; border-radius: 13px; }
  .del { opacity: 1; }
  .task { padding-right: 0; }
  .brand-name { font-size: 14px; }
  .card-head h2 { font-size: 17px; }
  .overview { gap: 4px 10px; font-size: 12px; }
  .filters button { padding: 4px 8px; font-size: 12px; }
  .t-line { flex-wrap: wrap; gap: 4px 6px; }
  .badge { font-size: 10.5px; }
  .detail { gap: 8px; }
  .add-extra { gap: 8px 12px; }
  .tip-card { display: none; }
}
