/* ============ 设计变量 ============ */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e8eaef;
  --border-strong: #d7dbe3;
  --text: #14171c;
  --text-2: #5b6472;
  --text-3: #8d96a5;
  --accent: #2b5fe0;
  --accent-hover: #2450c4;
  --accent-soft: #eef2fe;
  --ok: #12864a;
  --ok-soft: #e7f6ee;
  --warn: #b07207;
  --warn-soft: #fdf3e2;
  --danger: #cf3626;
  --danger-soft: #fdeceb;
  --gray-soft: #f0f2f5;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 23, 28, 0.04);
  --shadow-md: 0 4px 16px rgba(20, 23, 28, 0.07);
  --shadow-lg: 0 18px 48px rgba(20, 23, 28, 0.16);
  --sidebar-w: 228px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; }
.hidden { display: none !important; }

/* ============ 品牌 ============ */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--accent); display: flex; line-height: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; letter-spacing: 0.02em; }
.brand-text i { font-style: normal; font-size: 11px; color: var(--text-3); letter-spacing: 0.08em; }

/* ============ 登录页 ============ */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, #e7ecfb 0%, transparent 60%),
    linear-gradient(180deg, #fbfcfe 0%, #f3f5f8 100%);
}

.login-card {
  width: 100%;
  max-width: 392px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 34px 32px 26px;
  box-shadow: var(--shadow-md);
}

.login-card h1 { font-size: 22px; font-weight: 650; margin: 22px 0 4px; letter-spacing: -0.01em; }
.login-sub { color: var(--text-2); font-size: 13px; margin-bottom: 22px; }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-2);
  margin-bottom: 6px;
}

input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="search"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 95, 224, 0.11);
}

textarea { resize: vertical; min-height: 78px; line-height: 1.6; }

.login-error { color: var(--danger); font-size: 12.5px; min-height: 18px; margin: 2px 0 10px; }

.login-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-3);
}

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  font-size: 13.5px;
  font-weight: 550;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.06s;
}

.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost { border-color: var(--border-strong); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fbdcd9; }

.btn-block { width: 100%; height: 42px; font-size: 14px; margin-top: 4px; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 9px; }

.icon-btn {
  width: 32px; height: 32px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--text-3);
  border-radius: 8px; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--gray-soft); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

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

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  z-index: 30;
}

.sidebar .brand { padding: 0 8px 20px; }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item-quiet { color: var(--text-3); }

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  padding: 12px 32px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.topbar-sub { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.content { padding: 26px 32px 72px; flex: 1; }

/* ============ 统计卡 ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

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

.stat-label { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 30px; font-weight: 680; letter-spacing: -0.02em; margin-top: 6px; line-height: 1.1; }
.stat-note { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.stat-note.is-danger { color: var(--danger); }
.stat-note.is-ok { color: var(--ok); }

/* ============ 面板 ============ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 { font-size: 13.5px; font-weight: 640; }
.panel-body { padding: 16px 18px; }
.panel-body.is-flush { padding: 0; }

.two-col { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; }

/* ============ 状态分布 ============ */
.dist { display: flex; flex-direction: column; gap: 14px; }

.dist-row { display: grid; grid-template-columns: 68px 1fr 34px; align-items: center; gap: 12px; }
.dist-name { font-size: 12.5px; color: var(--text-2); }
.dist-track { display: block; height: 7px; background: var(--gray-soft); border-radius: 4px; overflow: hidden; }
.dist-fill { display: block; height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.dist-num { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text-2); text-align: right; }

/* ============ 列表行 ============ */
.row-list { display: flex; flex-direction: column; }

.row-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; }
.row-title {
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ 徽标 / 药丸 ============ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  font-size: 11.5px;
  font-weight: 560;
  border-radius: 999px;
  white-space: nowrap;
}

.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.no-dot::before { display: none; }

.pill-todo { background: var(--gray-soft); color: #5b6472; }
.pill-doing { background: var(--accent-soft); color: var(--accent); }
.pill-done { background: var(--ok-soft); color: var(--ok); }
.pill-paused { background: var(--warn-soft); color: var(--warn); }
.pill-overdue { background: var(--danger-soft); color: var(--danger); }

.pri { font-size: 11.5px; color: var(--text-3); display: inline-flex; align-items: center; gap: 5px; }
.pri-dot { width: 6px; height: 6px; border-radius: 50%; }
.pri-high .pri-dot { background: var(--danger); }
.pri-mid .pri-dot { background: var(--warn); }
.pri-low .pri-dot { background: #9aa3b0; }

/* ============ 工具条 ============ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-wrap { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.search-wrap svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-3); pointer-events: none;
}
.search-wrap input { padding-left: 33px; height: 38px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  height: 32px;
  padding: 0 13px;
  font-size: 12.5px;
  font-weight: 520;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--text); border-color: var(--text); color: #fff; }

/* ============ 项目卡片 ============ */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
  gap: 14px;
}

.p-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.12s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.p-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.p-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.p-card-name {
  font-size: 14.5px;
  font-weight: 620;
  letter-spacing: -0.01em;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.p-card-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); }
.p-card-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--border-strong); }

.progress-line { display: flex; align-items: center; gap: 9px; }
.progress-track { display: block; flex: 1; height: 6px; background: var(--gray-soft); border-radius: 4px; overflow: hidden; }
.progress-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.4s ease; }
.progress-fill.done { background: var(--ok); }
.progress-num { font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--text-2); width: 32px; text-align: right; }

.p-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 11px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}

/* ============ 任务表 ============ */
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: var(--surface-2); }

.task-check {
  width: 18px; height: 18px; flex: none;
  padding: 0;
  border: 1.6px solid var(--border-strong);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: transparent;
  transition: all 0.15s;
}
.task-check:hover { border-color: var(--accent); }
.task-check.checked { background: var(--ok); border-color: var(--ok); color: #fff; }
.task-check svg { width: 11px; height: 11px; }

.task-title { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-title.is-done { color: var(--text-3); text-decoration: line-through; }
.task-project {
  width: 168px;
  flex: none;
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

/* ============ 空状态 ============ */
.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-3);
}
.empty svg { width: 34px; height: 34px; margin-bottom: 12px; color: var(--border-strong); }
.empty h3 { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.empty p { font-size: 12.5px; margin-bottom: 16px; }

/* ============ 遮罩 / 抽屉 / 弹窗 ============ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 20, 27, 0.34);
  backdrop-filter: blur(1.5px);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
  animation: fade 0.16s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes popIn { from { transform: scale(0.97); opacity: 0.5; } to { transform: none; opacity: 1; } }

.drawer {
  width: min(520px, 100%);
  height: 100%;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
}

#modalOverlay { align-items: center; justify-content: center; padding: 24px; }

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.16s ease;
}

.modal-head, .drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}

.modal-head h2, .drawer-head h2 { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.modal-head p, .drawer-head p { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

.modal .modal-head { border-radius: 18px 18px 0 0; }

.modal-body { padding: 20px 22px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--surface);
  border-radius: 0 0 18px 18px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* ============ 抽屉内容 ============ */
.drawer-body { padding: 20px 22px 32px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
  margin-bottom: 22px;
}

.detail-item .k { font-size: 11.5px; color: var(--text-3); letter-spacing: 0.02em; }
.detail-item .v { font-size: 13.5px; margin-top: 3px; font-weight: 500; }
.detail-item .v.muted { color: var(--text-3); font-weight: 400; }
.detail-item .v.danger { color: var(--danger); }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 10px;
  letter-spacing: 0.01em;
}

.task-list { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px; }

.add-task {
  display: flex;
  gap: 8px;
}
.add-task input { flex: 1; height: 36px; font-size: 13px; }
.add-task .btn { height: 36px; }

.note-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-2);
  white-space: pre-wrap;
  line-height: 1.65;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 14px);
  background: #1b2029;
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 90;
  max-width: min(88vw, 420px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* ============ 响应式 ============ */
@media (max-width: 1080px) {
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    width: 100%;
    height: auto;
    bottom: auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand { padding: 0; }
  .brand-text i { display: none; }
  .nav { flex-direction: row; margin-left: auto; gap: 2px; }
  .nav-item { width: auto; padding: 0 10px; }
  .nav-item span { display: none; }
  .sidebar-foot { margin: 0; padding: 0; border: 0; }
  .nav-item-quiet span { display: none; }
  .main { margin-left: 0; padding-top: 58px; }
  .topbar { top: 58px; padding: 10px 16px; }
  .content { padding: 18px 16px 64px; }
  .form-grid { grid-template-columns: 1fr; }
  .project-grid { grid-template-columns: 1fr; }
}
