:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --text: #1f2329;
  --muted: #8a8f99;
  --border: #ecedf0;
  --border-strong: #dfe2e7;
  --accent: #3a66db;
  --accent-soft: #eaf0ff;
  --green: #18a058;
  --red: #e5484d;
  --amber: #f0a020;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 50, 0.04), 0 4px 16px rgba(20, 30, 50, 0.06);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 10px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }

#app { height: 100%; }
.boot { display: grid; place-items: center; height: 100%; color: var(--muted); }

/* ---------- 布局 ---------- */
.layout { display: flex; height: 100%; }
.sidebar {
  width: 232px; flex: 0 0 232px; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 18px 12px;
}
.brand { font-size: 18px; font-weight: 700; padding: 6px 10px 18px; letter-spacing: .3px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: none; background: none; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 14px; text-align: left; width: 100%;
  transition: background .15s, color .15s;
}
.nav-item .ic { width: 20px; height: 20px; flex: 0 0 20px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-foot { font-size: 12px; color: var(--muted); padding: 12px 12px 0; border-top: 1px solid var(--border); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; flex: 0 0 56px; border-bottom: 1px solid var(--border);
  background: var(--surface); display: flex; align-items: center;
  justify-content: space-between; padding: 0 22px;
}
.top-title { font-size: 16px; font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--red); border-color: #f3c2c4; background: #fdf0f0; }
.icon-btn .ic { width: 17px; height: 17px; }
.content { flex: 1; overflow-y: auto; padding: 22px; }

/* ---------- 通用组件 ---------- */
.page { max-width: 1080px; margin: 0 auto; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-weight: 600; }
.link-btn { background: none; border: none; color: var(--accent); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 36px 0; font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); border-radius: var(--radius-sm);
  padding: 8px 14px; font-size: 13px; transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2f57c4; }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-block { width: 100%; justify-content: center; padding: 11px; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar input[type='date'], .toolbar select { min-width: 120px; }

.chip {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.chip-note { background: #eaf0ff; color: #3a66db; }
.chip-idea { background: #f3eaff; color: #8b5cf6; }
.chip-kb { background: #e6f7f3; color: #0d9488; }
.chip-kind { background: #fff3e6; color: #d97706; }
.chip-cust { background: #e8f0fe; color: #1B2D4F; cursor: pointer; border: 1px solid #c9dbf5; }
.chip-cust:hover { background: #d6e4fc; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-high { background: var(--red); }
.dot-mid { background: var(--amber); }
.dot-low { background: var(--green); }

.tag { display: inline-block; font-size: 12px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; margin: 2px 4px 2px 0; }
.tag-lvl { background: #eef2ff; color: #3a51c9; border-color: #cdd6f7; }
.tag-region { background: #eafaf3; color: #0d9488; border-color: #bfe9dd; }
.lvl { display: inline-block; font-size: 11px; font-weight: 600; color: #3a51c9; background: #eef2ff; border: 1px solid #cdd6f7; border-radius: 6px; padding: 0 6px; margin-left: 4px; }
.cd-tags { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; }
.cd-remarks { margin-top: 8px; font-size: 13px; color: var(--text); background: var(--surface-2); border-left: 3px solid var(--accent); border-radius: 6px; padding: 8px 10px; }
.cd-proj { display: flex; flex-direction: column; gap: 6px; }
.cd-proj-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.pj-tasks { margin: 8px 0 4px; display: flex; flex-direction: column; gap: 4px; }
.pj-task { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.pj-task.done { color: var(--muted); text-decoration: line-through; }
.pj-todos { margin: 8px 0 4px; padding: 8px 10px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; }
.pj-todos-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.pj-todo { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; cursor: pointer; }
.pj-todo:hover { color: var(--accent); }
.pj-todo.done .pj-todo-text { color: var(--muted); text-decoration: line-through; }
.pj-todo .chk { width: 18px; height: 18px; flex: 0 0 18px; border-width: 2px; }
.pj-todo .chk .ic { width: 11px; height: 11px; }
.pj-todo.done .chk { background: var(--green); border-color: var(--green); }
.pj-todo.done .chk .ic { opacity: 1; }
.pj-todo-text { flex: 1; }
.pj-todo-cust { font-size: 13px; opacity: .65; }
.cd-todos { display: flex; flex-direction: column; gap: 4px; }
.cd-todo { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; }
.cd-todo.done { color: var(--muted); text-decoration: line-through; }
.customer-row.open { border-color: var(--accent); background: var(--surface); }
.cust-detail-inline { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.project-row { cursor: pointer; }
.project-row.open { border-color: var(--accent); }
.project-row.open .project-note, .project-row.open .pj-tasks, .project-row.open .pj-todos, .project-row.open .progress { margin-top: 8px; }
.chip-seq { background: #eef2ff; color: #3a51c9; border-color: #cdd6f7; }
.tag-seq { background: #eef2ff; color: #3a51c9; border-color: #cdd6f7; }

/* ---------- 概览 ---------- */
.dash-greet { margin-bottom: 18px; }
.dash-greet h2 { font-size: 22px; font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-label { color: var(--text); margin-top: 4px; font-weight: 600; }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mini-row { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.mini-row:last-child { border-bottom: none; }
.mini-row.done .mini-title { text-decoration: line-through; color: var(--muted); }
.mini-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-time { color: var(--muted); font-size: 12px; }
.quick-add input { width: 100%; margin-bottom: 8px; }

/* ---------- 待办 ---------- */
.todo-list { display: flex; flex-direction: column; gap: 8px; }
.todo-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.todo-row.done .todo-title { text-decoration: line-through; color: var(--muted); }
.chk { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; color: #fff; flex: 0 0 22px; }
.chk .ic { width: 13px; height: 13px; opacity: 0; }
.todo-row.done .chk { background: var(--green); border-color: var(--green); }
.todo-row.done .chk .ic { opacity: 1; }
.todo-main { flex: 1; min-width: 0; }
.todo-title { font-weight: 500; }
.todo-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.todo-acts { display: flex; gap: 4px; }

/* ---------- 笔记 ---------- */
.note-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.note-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); cursor: pointer; transition: border-color .15s, transform .1s; }
.note-card:hover { border-color: var(--border-strong); }
.note-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.note-title { font-weight: 600; margin-bottom: 4px; }
.note-snippet { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tags { margin-top: 8px; }

/* ---------- 追踪 ---------- */
.subtabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px; width: fit-content; margin-bottom: 16px; }
.subtabs button { border: none; background: none; padding: 7px 16px; border-radius: 999px; color: var(--muted); font-size: 13px; }
.subtabs button.active { background: var(--accent); color: #fff; font-weight: 600; }
.habit-list { display: flex; flex-direction: column; gap: 10px; }
.habit-row { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); }
.habit-emoji { font-size: 24px; width: 36px; text-align: center; }
.habit-info { flex: 1; }
.habit-name { font-weight: 600; }
.log-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.log-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 14px; box-shadow: var(--shadow); }
.log-main { flex: 1; min-width: 0; }
.log-title { font-weight: 500; }

.chart-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-top: 14px; }
.chart-title { font-weight: 600; margin-bottom: 14px; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar { width: 60%; max-width: 38px; background: linear-gradient(180deg, #5b82e8, #3a66db); border-radius: 6px 6px 0 0; min-height: 3px; position: relative; display: flex; align-items: flex-start; justify-content: center; }
.bar span { position: absolute; top: -18px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.bar-x { font-size: 11px; color: var(--muted); }
.cat-box { margin-top: 14px; }
.cat-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cat-pill { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.cat-pill b { color: var(--accent); }
.cat-total { margin-left: auto; font-weight: 700; }

/* ---------- 文件 ---------- */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.file-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); cursor: pointer; }
.file-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.file-cat { font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 9px; border-radius: 999px; }
.file-name { font-weight: 600; margin-bottom: 6px; }
.file-link { display: inline-block; margin: 6px 0; font-size: 13px; }
.file-note { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ---------- 项目 ---------- */
.project-list { display: flex; flex-direction: column; gap: 10px; }
.project-row { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.project-row.status-active { border-left-color: var(--green); }
.project-row.status-stalled { border-left-color: var(--red); }
.project-row.status-done { border-left-color: var(--muted); opacity: .8; }
.project-left { flex: 1; min-width: 0; }
.project-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.project-stage { color: var(--muted); font-size: 13px; margin-top: 2px; }
.project-note { color: var(--muted); font-size: 13px; margin-top: 4px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; margin: 8px 0 4px; overflow: hidden; max-width: 320px; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; }
.project-acts { display: flex; align-items: center; gap: 8px; }
.status-pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.status-pill.status-active { background: #e6f6ed; color: var(--green); }
.status-pill.status-stalled { background: #fdeaea; color: var(--red); }
.status-pill.status-done { background: var(--surface-2); color: var(--muted); }

/* ---------- 客户 ---------- */
.customer-list { display: flex; flex-direction: column; gap: 8px; }
.customer-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer; }
.customer-row:hover { border-color: var(--border-strong); }
.customer-main { flex: 1; min-width: 0; }
.customer-name { font-weight: 600; }
.cust-detail .cd-section { margin-bottom: 16px; }
.cd-edit-grid { display: flex; flex-direction: column; gap: 2px; }
.cd-label { font-weight: 600; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.cd-hint { font-size: 12px; color: var(--muted); opacity: .8; margin: -4px 0 8px; }
.cd-table { width: 100%; border-collapse: collapse; }
.cd-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.cd-table td:first-child { color: var(--muted); width: 96px; }
.cd-scope { display: flex; flex-wrap: wrap; }
.tl-row { display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.tl-date { color: var(--muted); width: 92px; flex: 0 0 92px; }
.tl-type { color: var(--accent); width: 84px; flex: 0 0 84px; }

/* ---------- 弹窗 / 表单 ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(20, 28, 45, 0.4); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 50; opacity: 0; transition: opacity .2s; padding: 20px; }
.modal-overlay.show { opacity: 1; }
.modal-panel { background: var(--surface); border-radius: 16px; width: 100%; max-width: 520px; box-shadow: 0 20px 60px rgba(20, 30, 50, 0.25); transform: translateY(8px); transition: transform .2s; max-height: 90vh; display: flex; flex-direction: column; }
.modal-overlay.show .modal-panel { transform: translateY(0); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-weight: 700; font-size: 16px; }
.modal-close { border: none; background: none; color: var(--muted); width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; }
.modal-close:hover { background: var(--surface-2); }
.modal-close .ic { width: 18px; height: 18px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-foot-btns { display: flex; justify-content: flex-end; gap: 10px; width: 100%; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-body p { margin-bottom: 12px; }
.confirm-msg { color: var(--text); }

/* ---------- Toast ---------- */
#toast-root { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1f2329; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #1f2329; }
.toast-error { background: var(--red); }

/* ---------- 接入引导 ---------- */
.setup { display: grid; place-items: center; height: 100%; padding: 20px; }
.setup-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 30px; max-width: 460px; width: 100%; }
.brand-lg { font-size: 22px; font-weight: 700; margin-bottom: 12px; }
.setup-card p { margin-bottom: 16px; }
.ic.rotate-180 { transform: rotate(180deg); }

/* ---------- 移动端 ---------- */
.bottomnav { display: none; }
@media (max-width: 820px) {
  .sidebar { display: none; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around;
  }
  .bottomnav .nav-item { flex-direction: column; gap: 3px; font-size: 10px; padding: 4px 6px; flex: 1; }
  .bottomnav .nav-item .ic { width: 22px; height: 22px; }
  .bottomnav .nav-item span { font-size: 10px; }
  .content { padding: 16px 14px 80px; }
  .topbar { padding: 0 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-cols { grid-template-columns: 1fr; }
  .note-list, .file-grid { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
}
