:root {
  --bg: #f6f8fa;      /* page 浅灰白 */
  --panel: #ffffff;   /* 卡片白 */
  --panel2: #f8fafc;  /* 次级 */
  --panel3: #eef1f5;  /* 三级 */
  --line: #e4e7eb;    /* hairline */
  --line2: #c9d0d8;   /* hairline-strong */
  --text: #181d26;    /* ink 近黑 */
  --muted: #5b6472;   /* secondary */
  --subtle: #7a8088;  /* subtle */
  --accent: #e8590c;  /* 橘 */
  --accent2: #f07818;
  --ok: #1a7f37;
  --warn: #b45309;
  --bad: #c62828;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter Variable", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  letter-spacing: -0.01em;
}

/* ---------- 椤舵爮 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.logout-btn {
  margin-left: auto;
  height: 26px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 4px;
  cursor: pointer;
}
.logout-btn:hover { color: var(--text); border-color: var(--accent); }

/* ---------- 鐧诲綍椤?---------- */
.login-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  align-items: center;
  justify-content: center;
}
.login-overlay.show { display: flex; }
.login-box {
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 6px;
}
.login-box input {
  height: 40px;
  padding: 0 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-size: 14px;
}
.login-box input:focus { outline: none; border-color: var(--accent); }
.login-msg { min-height: 18px; color: var(--bad); font-size: 12px; text-align: center; }
.login-btn {
  height: 40px;
  width: 100%;
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.login-btn:hover { filter: brightness(1.1); }
.login-btn:disabled { opacity: 0.6; cursor: default; }
.brand { font-size: 16px; font-weight: 600; letter-spacing: 1px; }
.tabs { display: flex; gap: 6px; }
.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 6px 16px;
  cursor: pointer;
  font-size: 13px;
  border-radius: 6px;
}
.tab:hover { color: var(--text); background: var(--panel3); }
.tab.active { background: #e8effa; color: var(--accent); border-color: #cfe0f7; font-weight: 600; }
.update { margin-left: auto; color: var(--muted); }
.update span { color: var(--accent); font-weight: 600; }

/* ---------- 绛涢€夋爮 ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.ms-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ms-title { color: var(--muted); font-size: 11px; }
.ms {
  position: relative;
  width: 160px;
}
.ms-trigger {
  width: 100%;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 10px;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.ms-trigger:hover { border-color: var(--accent); }
.ms-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-caret { color: var(--muted); font-size: 10px; }
.ms-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 2px;
  min-width: 210px;
  max-width: 280px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 50;
  overflow: hidden;
}
.ms-panel.open { display: block; }
.ms-actions {
  display: flex;
  justify-content: space-between;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.ms-actions button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  padding: 0 4px;
}
.ms-actions button:hover { text-decoration: underline; }
.ms-options {
  max-height: 250px;
  overflow-y: auto;
  padding: 4px;
}
.ms-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
}
.ms-opt:hover { background: rgba(255,255,255,.06); }
.ms-opt input { accent-color: var(--accent); cursor: pointer; }
.ms-opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filters input[type="date"] {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  height: 28px;
  padding: 2px 6px;
}
.filters .btn {
  height: 28px;
  padding: 0 14px;
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}
.filters .btn:hover { filter: brightness(1.1); }

/* ---------- 椤甸潰 ---------- */
.page { display: none; padding: 14px 18px; }
.page.active { display: block; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
}
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; color: var(--accent); }
.kpi .sub { color: var(--muted); font-size: 11px; margin-top: 3px; }
.kpi .value.good { color: var(--ok); }
.kpi .value.bad { color: var(--bad); }
.kpi .value.up { color: var(--bad); }
.kpi .value.down { color: var(--ok); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
}
/* 鎬昏〃鍥捐〃鏇村锛氭闈㈠浐瀹?鍒楋紝閬垮厤鎸や笉涓?*/
#page-overview .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.card.wide { grid-column: 1 / -1; }
.card-title {
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.chart { width: 100%; height: 280px; }
.chart.tall { height: 340px; }

/* ---------- 琛ㄦ牸 ---------- */
.table-wrap { overflow-x: auto; max-height: 520px; overflow-y: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th, .data-table td {
  padding: 7px 10px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--panel2);
  color: var(--muted);
  font-weight: 600;
  z-index: 1;
}
.data-table tbody tr:hover { background: rgba(255,255,255,.04); }
.data-table tbody tr.total-row td {
  font-weight: 700;
  background: var(--panel2);
  border-top: 2px solid var(--line);
  position: sticky;
  bottom: 0;
}
.up { color: var(--bad); }
.down { color: var(--ok); }
.spark { display: inline-block; vertical-align: middle; }

.loading {
  display: none;
  position: fixed;
  top: 12px; right: 20px;
  background: var(--accent);
  color: #1a1a1a;
  padding: 6px 14px;
  border-radius: 4px;
  font-weight: 600;
  z-index: 50;
}
.loading.show { display: block; }

/* ================= 寰呭姙 ================= */
.todo-top { padding: 14px 16px; }
.todo-add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.todo-add-row input, .todo-add-row select, .todo-history-head input {
  padding: 9px 12px; border: 1px solid #e0e4e9; border-radius: 8px; background: #ffffff; color: #181d26; }
#todoNewSrc { max-width: 150px; }
#todoNewContent { flex: 1; min-width: 240px; }
#todoNewDue { max-width: 140px; }
#todoNewTag { max-width: 170px; }
.todo-add-row select { padding: 9px; border: 1px solid #e0e4e9; border-radius: 8px; background: #ffffff; color: #181d26; }
#todoRefresh { margin-left: auto; }
/* 联系人多选：输入框 + 已选标签 */
.cp-wrap { display: flex; flex-direction: column; gap: 4px; }
.cp-wrap input { width: 100%; }
.cp-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.cp-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; background: #eef1f6; color: #4f6ed8; padding: 2px 8px; border-radius: 10px; }
.cp-x { cursor: pointer; font-weight: 700; color: #181d26; padding: 0 2px; }
.cp-x:hover { color: #d9534f; }
.merge-bar { display: flex; align-items: center; gap: 10px; padding: 6px 0; color: #5b6472; font-size: 13px; }
.merge-bar .btn.ok { background: #166534; color: #dcfce7; border: none; padding: 6px 14px; border-radius: 6px; cursor: pointer; }
.tc-merge { display: inline-flex; align-items: center; margin-right: 2px; }
.tc-merge input { width: 17px; height: 17px; accent-color: #e8590c; }
.todo-cols { display: flex; gap: 18px; padding: 4px 16px 16px; align-items: flex-start; }
.todo-col { flex: 1; min-width: 0; }
.col-title { font-weight: 700; color: #cf8b30; margin: 10px 0 12px; font-size: 15px; }
.todo-col + .todo-col { border-left: 1px solid #e0e4e9; padding-left: 18px; }
.tc { border: 1px solid #e0e4e9; border-radius: 12px; background: #ffffff; padding: 12px 14px; margin-bottom: 12px; border-left: 5px solid #c9d0d8; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.tc.pri-high { border-left-color: #d9534f; }
.tc.pri-medium { border-left-color: #cf8b30; }
.tc.pri-low { border-left-color: #4caf7d; }
.tc.done { opacity: .5; }
.tc.done .tc-content { text-decoration: line-through; color: #4b5563; }
.tc.dragging { opacity: .4; border-style: dashed; }
.tc.out { clip-path: inset(0 0 0 0); animation: wipeout 10s forwards; overflow: hidden; }
@keyframes wipeout {
  0% { clip-path: inset(0 0 0 0); opacity: 1; }
  100% { clip-path: inset(0 100% 0 0); opacity: 0; }
}
.undo-pill { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 9999;
  display: flex; align-items: center; gap: 14px; background: #eef2f6; border: 1px solid #e0e4e9;
  padding: 12px 18px; border-radius: 12px; box-shadow: 0 6px 22px rgba(0,0,0,.55); pointer-events: auto; }
.undo-txt { color: #20262f; font-size: 13px; }
.undo-btn { background: #22c55e; color: #052e16; font-weight: 700; padding: 8px 18px; border: none;
  border-radius: 8px; cursor: pointer; font-size: 14px; }
.undo-btn:hover { background: #16a34a; }
.tc-head { display: flex; align-items: center; gap: 10px; }
.tc-main { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; flex-wrap: wrap; }
.tc-badge { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 5px; }
.pri-high .tc-badge { background: #7f1d1d; color: #fecaca; }
.pri-medium .tc-badge { background: #78350f; color: #fde68a; }
.pri-low .tc-badge { background: #14532d; color: #bbf7d0; }
.tc-pin { font-size: 14px; }
.tc-recur { font-size: 11px; color: #7c3aed; background: #f0effb; padding: 1px 7px; border-radius: 5px; }
.tc-src { font-size: 12px; color: #4b5fd0; background: #eef1f6; padding: 3px 9px; border-radius: 5px; cursor: pointer; }
.tc-srcs { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.tc-content { flex: 1; font-size: 14px; min-width: 120px; white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.tc-confirm-tag { font-size: 11px; color: #fde68a; background: #78350f; padding: 2px 8px; border-radius: 5px; }
.tc-due { font-size: 12px; padding: 2px 8px; border-radius: 5px; }
.due-overdue { background: #7f1d1d; color: #fecaca; font-weight: 600; }
.due-today { background: #78350f; color: #fde68a; font-weight: 600; }
.due-soon { background: #14532d; color: #bbf7d0; }
.tc-time { color: #6b7280; font-size: 12px; }
.tc-tags { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 4px 6px; min-height: 30px; border-radius: 8px; }
.cat-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 10px; align-items: center; }
.cat-label { font-size: 12px; color: #6b7280; white-space: nowrap; }
.tag-chip { font-size: 12px; padding: 4px 12px; border-radius: 14px; border: 1px solid #e0e4e9; background: #ffffff; color: #5b6472; cursor: pointer; }
.tag-chip:hover { background: #e9edf2; }
.tag-chip.active { background: #e8590c; color: #fff; border-color: #e8590c; }
.empty-inline { color: #6b7280; font-size: 12px; }
.tc-tags { cursor: pointer; }
.tc-tags:hover { background: rgba(29, 79, 216, .08); }
.tag { cursor: pointer; }
.tag-none { font-size: 12px; color: #6b7280; }
.tag-edit-btn { font-size: 12px; color: #4b5fd0; }
.tag-picker { margin-top: 6px; padding: 8px; background: #f8fafc; border: 1px solid #e0e4e9; border-radius: 8px; }
.tp-common { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 6px; }
.tp-add { font-size: 11px; padding: 3px 9px; border-radius: 12px; border: 1px solid #e0e4e9; background: #ffffff; color: #4f6ed8; cursor: pointer; }
.tp-add:hover { background: #e9edf2; }
.tp-new { display: flex; gap: 6px; }
.tp-new input { flex: 1; padding: 6px 10px; border: 1px solid #e0e4e9; border-radius: 6px; background: #f8fafc; color: #181d26; font-size: 12px; }
.tag { font-size: 11px; background: #eef1f6; color: #4f6ed8; padding: 2px 8px; border-radius: 10px; }
.tag-x { color: #4b5563; margin-left: 4px; padding: 0 2px; }
.tag-x:hover { color: #f87171; }
.tc-actions { display: flex; gap: 5px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }

.tc-note-box { margin-top: 9px; border-top: 1px dashed #e0e4e9; padding-top: 8px; }
.content-edit { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.ce-row { display: flex; gap: 6px; align-items: flex-start; }
.ce-row input, .ce-row select { flex: 1; padding: 7px 10px; background: #f8fafc; color: #181d26; border: 1px solid #e0e4e9; border-radius: 7px; font-size: 12px; }
.ce-row select { flex: 0 0 70px; }
.content-edit textarea { width: 100%; min-height: 52px; background: #f8fafc; color: #181d26; border: 1px solid #e0e4e9; border-radius: 8px; padding: 8px; }
.content-edit .btn.ok { align-self: flex-end; background: #166534; color: #dcfce7; border: none; padding: 6px 14px; border-radius: 6px; cursor: pointer; }
.note-input { display: flex; gap: 6px; }
.note-input input { flex: 1; padding: 7px 10px; border: 1px solid #e0e4e9; border-radius: 7px; background: #f8fafc; color: #181d26; font-size: 13px; }
.notes-list { margin-top: 6px; }
.note-row { display: flex; gap: 8px; font-size: 12px; margin: 3px 0; }
.note-time { color: #6b7280; white-space: nowrap; font-size: 11px; }
.note-text { color: #4b5563; }
.notes-all { margin-top: 6px; border-top: 1px dashed #e0e4e9; padding-top: 6px; }
.btn.sm { font-size: 12px; padding: 4px 11px; border: none; border-radius: 6px; cursor: pointer; background: #e9edf2; color: #181d26; }
.btn.sm:hover { background: #e6eaef; }
.btn.sm.ok { background: #166534; color: #dcfce7; }
.btn.sm.ok:hover { background: #15803d; }
.btn.ghost { background: transparent; border: 1px solid #e0e4e9; color: #181d26; }
.btn.ghost:hover { background: #e9edf2; }
.btn.sm.fb-invalid { color: #e0a0a0; border: 1px solid #7f1d1d; }
.btn.sm.fb-invalid:hover { background: #fdecec; }
/* 新增行通用按钮：深色底、明显文字 */
.todo-add-row .btn {
  background: #e9edf2;
  border: 1px solid #e0e4e9;
  color: #181d26;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
}
.todo-add-row .btn:hover { background: #e6eaef; }
.todo-add-row .btn.ghost { background: transparent; }
.todo-add-row .btn.ghost:hover { background: #e9edf2; }
/* 日期选择图标：深色下更显眼 */
#todoNewDue::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}
.empty { color: #6b7280; padding: 12px; }
.badge { background: #d9534f; color: #fff; font-size: 12px; padding: 3px 10px; border-radius: 10px; font-weight: 600; }
.todo-history { border-top: 1px solid #e0e4e9; margin-top: 10px; padding: 14px 18px; }
.todo-history-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; font-weight: 700; color: #5b6472; }
.todo-history-head .hist-search { display: flex; gap: 6px; margin-left: auto; }
.todo-history-head .hist-search input { min-width: 200px; }
/* 鑱旂郴浜?缇ゆ爣绛?椤甸潰 */
.contacts-top { padding: 16px 18px 10px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.contacts-title { font-weight: 700; color: #cf8b30; font-size: 16px; }
.chat-filters { display: flex; gap: 4px; align-items: center; }
.cf.active { background: #e8590c !important; color: #fff !important; border-color: #e8590c !important; }
.contacts-hint { color: #6b7280; font-size: 12px; width: 100%; }
.contacts-list { padding: 6px 18px 20px; max-width: 900px; }
.chat-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid #e9edf2; }
.chat-name { flex: 1; min-width: 0; font-size: 13px; color: #20262f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-ops { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.sel-work { background: #166534 !important; color: #dcfce7 !important; }
.sel-life { background: #713f12 !important; color: #fde68a !important; }
.sel-ig { background: #7f1d1d !important; color: #fecaca !important; }
.src-tag { font-size: 10px; color: #6b7280; }
.src-tag.manual { color: #4caf7d; }

@media (max-width: 900px) { .todo-cols { flex-direction: column; } .todo-col + .todo-col { border-left: none; padding-left: 0; } }
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  #page-overview .grid { grid-template-columns: 1fr; }
  .filters { gap: 8px; }
}

