/* 个人工作台 · 浅色主题 */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e7ebf2;
  --text: #1f2937;
  --muted: #7b8494;
  --accent: #4f7cff;
  --accent-soft: #eef3ff;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --shadow: 0 6px 24px rgba(31, 41, 55, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* 顶栏 */
.topbar {
  height: 68px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px;
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, #4f7cff, #7aa2ff);
  color: #fff; font-weight: 700; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(79, 124, 255, .28);
}
.brand-title { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 14px; }
.stat-chip {
  background: var(--accent-soft); color: #3b5fcb;
  border: 1px solid #dbe5ff;
  padding: 6px 12px; border-radius: 20px; font-size: 12px;
}
.stat-chip b { font-size: 13px; margin-left: 2px; }
.chip-icon { margin-right: 4px; }

.btn {
  border: 0; border-radius: 9px; padding: 8px 15px;
  font-weight: 600; font-size: 13px; transition: .16s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 3px 10px rgba(79,124,255,.22); }
.btn-primary:hover { background: #3f6df0; transform: translateY(-1px); }
.btn-ghost { background: #f1f4f9; color: #5b6472; }
a.btn { text-decoration: none; display: inline-block; }
.btn-ghost:hover { background: #e7ebf2; }

/* 工具按钮（编辑 / 数据管理）：与旧站 icon-btn 一致 */
.tool-btn {
  min-height: 40px; padding: 0 13px; border: 1px solid var(--border);
  background: #fff; border-radius: 10px; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: border-color .18s, background .18s, transform .18s;
}
.tool-btn:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.tool-btn .lbl { white-space: nowrap; }

.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--muted); font-size: 18px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; transition: .15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.tool-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tool-btn.on:hover { background: var(--accent); color: #fff; }

.wrap { max-width: 1440px; margin: 0 auto; padding: 24px 32px 48px; }
.hero-row { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(0, .96fr); gap: 20px; align-items: stretch; }
.hero-row > .card { height: 100%; min-width: 0; display: flex; flex-direction: column; }
.hero-row > .card .hint { margin-top: auto; padding-top: 12px; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.card-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.card-head .sub { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.count-pill {
  background: #f1f4f9; color: #6b7382; border-radius: 20px;
  padding: 4px 11px; font-size: 12px; white-space: nowrap;
}
.hint { margin-top: 12px; font-size: 11px; color: #a5adba; text-align: right; }

/* 表单 */
.inline-form, .quick-add, .modal form { display: flex; flex-direction: column; gap: 9px; }
.inline-form input, .quick-add input, .modal input, .modal textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 11px; background: #fbfcfe; outline: none; transition: .15s;
}
.inline-form input:focus, .quick-add input:focus, .modal input:focus, .modal textarea:focus {
  border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(79,124,255,.1);
}
.quick-add { flex-direction: row; margin-bottom: 14px; }
.quick-add input { flex: 1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-dot {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: .15s; padding: 0;
}
.color-dot.active { border-color: #1f2937; transform: scale(1.12); box-shadow: 0 0 0 2px #fff inset; }

/* 习惯列表 */
.habit-list, .memo-list { display: flex; flex-direction: column; gap: 7px; min-height: 120px; }
.habit-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 11px;
  background: #fff; transition: .15s;
}
.habit-item:hover { border-color: #cfd8ea; background: #fcfdff; }
.habit-check {
  width: 25px; height: 25px; flex: 0 0 25px; border-radius: 50%;
  border: 2px solid var(--hc, var(--accent)); background: transparent;
  color: #fff; font-size: 13px; display: flex; align-items: center; justify-content: center;
  padding: 0; transition: .16s;
}
.habit-check.done { background: var(--hc, var(--accent)); }
.habit-check:hover { transform: scale(1.08); }
.habit-main { flex: 1; min-width: 0; }
.habit-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit-item.done .habit-name { color: #9aa3b1; text-decoration: line-through; }
.habit-meta { display: flex; gap: 6px; align-items: center; margin-top: 3px; font-size: 11px; color: var(--muted); }
.target-tag { background: #f2f5fa; border-radius: 5px; padding: 1px 6px; }
.streak { color: #f59e0b; font-weight: 600; }
.dots { display: flex; gap: 3px; }
.dot { width: 7px; height: 7px; border-radius: 2px; background: #e8ebf1; }
.dot.on { background: var(--hc, var(--accent)); }
.dot.today { outline: 1.5px solid var(--hc, var(--accent)); outline-offset: 1px; }
.del-btn {
  border: 0; background: transparent; color: #c3cad5; font-size: 17px;
  padding: 2px 5px; opacity: 0; transition: .15s;
}
.habit-item:hover .del-btn, .memo-item:hover .del-btn { opacity: 1; }
.del-btn:hover { color: var(--red); }

/* 备忘列表 */
.memo-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; transition: .15s;
}
.memo-item:hover { border-color: #cfd8ea; }
.memo-check {
  width: 19px; height: 19px; flex: 0 0 19px; border-radius: 6px;
  border: 1.8px solid #cbd3e0; background: #fff; color: #fff; font-size: 12px;
  display: flex; align-items: center; justify-content: center; padding: 0; transition: .15s;
}
.memo-check.done { background: var(--green); border-color: var(--green); }
.memo-text { flex: 1; font-size: 13px; word-break: break-word; }
.memo-item.done .memo-text { color: #a5adba; text-decoration: line-through; }
.memo-edit { flex: 1; border: 1px solid var(--accent); border-radius: 6px; padding: 3px 6px; outline: none; }
.empty { color: #a5adba; font-size: 12px; text-align: center; padding: 26px 10px; }

/* 甘特图 */
.gantt-card { margin-top: 20px; }
.legend { display: flex; gap: 14px; font-size: 11px; color: var(--muted); align-items: center; }
.legend span { display: flex; align-items: center; gap: 5px; }
.lg { width: 14px; height: 4px; border-radius: 3px; display: inline-block; }
.lg-parallel { background: #a78bfa; }
.lg-seq { background: #f59e0b; }
.lg-today { background: var(--red); height: 12px; width: 2px; }
.gantt-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; gap: 12px; flex-wrap: wrap;
}
.range-label { font-size: 12px; color: var(--muted); }
.gantt-controls { display: flex; align-items: center; gap: 16px; }
.switch-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; cursor: pointer; }
.zoom-group { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.zoom-group button {
  border: 0; background: #fff; padding: 4px 12px; font-size: 12px; color: var(--muted);
}
.zoom-group button.active { background: var(--accent-soft); color: #3b5fcb; font-weight: 600; }

.gantt { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.gantt-inner { position: relative; min-width: 760px; }
.gantt-head {
  display: grid; grid-template-columns: var(--label-w, 196px) var(--timeline-w, 1fr);
  background: #fafbfe; border-bottom: 1px solid var(--border); position: relative; z-index: 3;
}
.gantt-head-label {
  padding: 9px 14px; font-size: 11px; color: var(--muted); font-weight: 600;
  border-right: 1px solid var(--border);
}
.gantt-head-cells { display: flex; position: relative; width: var(--timeline-w, auto); }
.gantt-bucket {
  flex: 0 0 auto; padding: 8px 6px; font-size: 11px; color: #8b95a5;
  border-right: 1px solid #edf0f5; text-align: center; white-space: nowrap; overflow: hidden;
}
.gantt-row {
  display: grid; grid-template-columns: var(--label-w, 196px) var(--timeline-w, 1fr);
  border-bottom: 1px solid #f0f2f7; position: relative;
}
.gantt-row:last-child { border-bottom: 0; }
.gantt-row-label {
  padding: 9px 14px; border-right: 1px solid var(--border); background: #fff; z-index: 2;
}
.gp-name { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.gp-name i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; flex: 0 0 8px; }
.gp-dates { font-size: 10px; color: #99a2b0; margin: 2px 0 3px; }
.rel-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.rel-chip {
  font-size: 9px; padding: 1px 5px; border-radius: 4px; white-space: nowrap;
}
.rel-chip.par { background: #f3edff; color: #7c4ddb; }
.rel-chip.seq { background: #fff3e2; color: #b97008; }
.gantt-body { position: relative; }
.gantt-track { position: relative; min-height: 58px; background: #fff; width: var(--timeline-w, auto); }
.gantt-bar {
  position: absolute; top: 13px; height: 31px; border-radius: 8px;
  display: flex; align-items: center; padding: 0 9px;
  cursor: pointer; overflow: hidden; transition: .16s; min-width: 12px;
  border: 1px solid var(--gc); background: var(--gc-soft);
}
.gantt-bar:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(31,41,55,.14); z-index: 5; }
.gantt-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--gc); opacity: .88; }
.gantt-bar-text {
  position: relative; z-index: 2; font-size: 11px; font-weight: 600;
  color: #263044; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gantt-bar-pct { position: relative; z-index: 2; margin-left: auto; padding-left: 8px; font-size: 10px; color: #3f4a5e; }
.grid-line { position: absolute; top: 0; bottom: 0; width: 1px; background: #edf0f5; pointer-events: none; z-index: 1; }
.today-overlay { position: absolute; top: 0; bottom: 0; pointer-events: none; z-index: 6; }
.today-overlay .today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(239,68,68,.75); }
.today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(239,68,68,.75); pointer-events: none; z-index: 4; }
.today-line::after { display: none; }
.today-line.head::after {
  display: block;
  content: '今天'; position: absolute; top: -1px; left: 4px; font-size: 9px; color: var(--red);
  background: #fff; padding: 0 2px; white-space: nowrap;
}
.rel-svg { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: visible; }
.gantt-empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* 弹窗 + 提示 */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(24, 31, 44, .42);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 440px;
  padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal label { font-size: 12px; color: #667085; display: flex; flex-direction: column; gap: 5px; }
.modal .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 数据管理弹窗（旧站风格） */
.dm-modal {
  position: fixed; inset: 0; z-index: 70; display: flex;
  align-items: center; justify-content: center; padding: 20px;
}
.dm-modal[hidden] { display: none; }
.dm-modal .modal-mask {
  position: absolute; inset: 0; background: rgba(24, 31, 44, .45);
  backdrop-filter: blur(3px);
}
.dm-modal .modal-box {
  position: relative; width: min(480px, 100%); max-height: 84vh; overflow: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.dm-modal .modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.dm-modal .modal-head h3 { margin: 0; font-size: 17px; }
.dm-modal .modal-head .icon-btn { width: auto; padding: 0 11px; height: 34px; font-size: 12px; }
.dm-modal .modal-body p { font-size: 13px; color: #667085; margin: 0 0 14px; line-height: 1.7; }
.dm-modal .modal-body textarea {
  width: 100%; min-height: 120px; resize: vertical; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #fbfcfe;
  outline: none; font-size: 12px; line-height: 1.55;
}
.dm-modal .modal-body textarea:focus { border-color: var(--accent); background: #fff; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: #1f2937; color: #fff; padding: 9px 18px; border-radius: 9px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .22s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 项目详情页 */
.project-page .wrap { max-width: 900px; }
.back-link { color: var(--muted); text-decoration: none; font-size: 13px; display: inline-block; margin-bottom: 14px; }
.back-link:hover { color: var(--accent); }
.pj-hero { display: flex; gap: 20px; align-items: flex-start; }
.pj-hero-main { flex: 1; min-width: 0; }
.pj-title-input {
  font-size: 22px !important; font-weight: 700; border: 1px solid transparent !important;
  background: transparent !important; padding: 4px 6px !important; margin-left: -6px;
}
.pj-title-input:hover, .pj-title-input:focus { border-color: var(--border) !important; background: #fff !important; }
.pj-note { width: 100%; margin-top: 10px; resize: vertical; border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; background: #fbfcfe; outline: none; font-size: 13px; }
.pj-note:focus { border-color: var(--accent); background: #fff; }
.progress-ring { width: 104px; height: 104px; flex: 0 0 104px; position: relative; }
.progress-ring svg { transform: rotate(-90deg); }
.progress-ring .ring-label {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-label b { font-size: 21px; }
.ring-label span { font-size: 10px; color: var(--muted); }
.pj-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }

/* 外部数据来源面板 */
.source-panel {
  margin-top: 18px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid #dbe5ff; background: #f5f8ff; font-size: 12px; color: #4b5c7a;
}
.source-panel .sp-head { display: flex; align-items: center; gap: 8px; font-weight: 600; color: #2f4a8a; margin-bottom: 6px; }
.source-panel .sp-dot { width: 8px; height: 8px; border-radius: 50%; }
.source-panel .sp-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.source-panel .sp-grid b { color: #1f2937; }
.source-panel a { color: var(--accent); text-decoration: none; }
.source-panel .sp-note { margin-top: 6px; color: #7b8494; }
.source-panel.sp-error { border-color: #fecaca; background: #fff7f7; color: #b42318; }
.pj-fields label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.pj-fields input, .pj-fields select {
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; background: #fbfcfe; outline: none;
}
.pj-section-title { font-size: 14px; font-weight: 700; margin: 24px 0 12px; display: flex; justify-content: space-between; align-items: center; }
.task-add { display: flex; gap: 8px; margin-bottom: 12px; }
.task-add input[type=text] { flex: 1; border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; outline: none; }
.task-add input[type=date] { border: 1px solid var(--border); border-radius: 9px; padding: 8px; outline: none; }
.task-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 7px; background: #fff;
}
.task-item.done .task-title { color: #9aa3b1; text-decoration: line-through; }
.task-title { flex: 1; font-size: 13px; }
.task-due { font-size: 11px; color: var(--muted); }
.pj-meta-row { display: flex; gap: 18px; margin-top: 16px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.pj-meta-row b { color: var(--text); }
.danger-link { color: var(--red); background: transparent; border: 0; font-size: 12px; }

@media (max-width: 600px) {
  .topbar { padding: 0 14px; }
  .tool-btn { min-height: 36px; padding: 0 9px; font-size: 12px; }
  .stat-chip { display: none; }
  .top-actions .lbl { display: none; }
  .top-actions .btn { padding: 7px 11px; font-size: 12px; }
  .hint { text-align: left; }
}

/* 编辑模式：标注可编辑的界面文字 */
body[data-edit="1"] [data-lbl],
body[data-edit="1"] [data-lblph] {
  outline: 1px dashed rgba(79, 124, 255, .65);
  outline-offset: 2px; border-radius: 3px; cursor: text;
  background: rgba(79, 124, 255, .05);
}
body[data-edit="1"] [data-lbl]:focus {
  outline: 2px solid var(--accent); background: #fff;
}

@media (max-width: 900px) {
  .hero-row { grid-template-columns: minmax(0, 1fr); }
  .wrap { padding: 18px 16px 36px; }
  .topbar { padding: 0 16px; }
  .legend { display: none; }
  .pj-fields { grid-template-columns: 1fr 1fr; }
  .pj-hero { flex-direction: column; }
}
