/* ===== 基础重置 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-soft: #eff6ff;
  --text: #1f2937;
  --text-sub: #6b7280;
  --border: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --danger: #ef4444;
  --success: #10b981;
  --warn: #f59e0b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --tab-h: 60px;
  --top-h: 52px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; outline: none; }
ul { list-style: none; }
.hidden { display: none !important; }

/* ===== 布局 ===== */
.topbar {
  height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}
.topbar .brand { font-weight: 700; font-size: 17px; color: var(--primary-dark); }
.user-tag {
  background: var(--primary-soft); color: var(--primary-dark);
  padding: 5px 12px; border-radius: 20px; font-size: 13px; font-weight: 600;
  display: inline-block;
}
.icon-btn { padding: 6px; border-radius: 8px; }
.icon-btn:active { background: var(--bg); }

.app {
  position: absolute;
  top: calc(var(--top-h) + env(safe-area-inset-top));
  left: 0; right: 0;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.zone { display: none; }
.zone.active { display: block; }

/* ===== 二级导航 ===== */
.subnav {
  display: flex;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
  overflow-x: auto;
}
.subnav-item {
  flex: 1 0 auto;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text-sub);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all .15s;
}
.subnav-item.active { color: var(--primary-dark); border-bottom-color: var(--primary); font-weight: 600; }

.panel { display: none; padding: 12px; }
.panel.active { display: block; }

/* ===== 工具条 ===== */
.panel-toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.search-input, .select, .date-input, .textarea {
  flex: 1 1 120px;
  min-width: 0;
  padding: 9px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.textarea { flex-basis: 100%; resize: vertical; }
.select { flex: 0 1 auto; padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
.primary-btn {
  background: var(--primary); color: #fff;
  padding: 9px 16px; border-radius: 8px; font-weight: 600; font-size: 14px;
  white-space: nowrap;
}
.primary-btn:active { background: var(--primary-dark); }
.ghost-btn {
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
  color: var(--text-sub);
}
.text-btn { color: var(--primary); font-size: 13px; padding: 4px 8px; }

/* ===== 统计 ===== */
.stat-row {
  display: flex; gap: 8px; width: 100%; margin-bottom: 12px;
}
.stat-item {
  flex: 1; background: var(--card); border-radius: var(--radius);
  padding: 10px 8px; text-align: center; box-shadow: var(--shadow);
}
.stat-num { font-size: 18px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.stat-item.income .stat-num { color: var(--success); }
.stat-item.expense .stat-num { color: var(--danger); }
.stat-item.balance .stat-num { color: var(--primary-dark); }

/* ===== 任务看板 ===== */
.board {
  display: flex; gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}
.board-col {
  flex: 0 0 80%;
  min-width: 220px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  scroll-snap-align: start;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 220px);
}
.board-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-sub);
  padding: 4px 4px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-todo { background: var(--text-sub); }
.dot-doing { background: var(--warn); }
.dot-done { background: var(--success); }
.count { background: var(--bg); color: var(--text-sub); padding: 1px 8px; border-radius: 10px; font-size: 12px; margin-left: auto; }
.board-body {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 60px;
}
.add-btn {
  margin-top: 8px;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-sub);
  font-size: 13px;
  text-align: center;
}
.add-btn:active { background: var(--bg); }

/* ===== 卡片 ===== */
.task-card {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px;
  border-left: 3px solid var(--text-sub);
}
.task-card.pri-high { border-left-color: var(--danger); }
.task-card.pri-mid { border-left-color: var(--warn); }
.task-card.pri-low { border-left-color: var(--success); }
.task-card .task-title { font-weight: 600; font-size: 14px; word-break: break-word; }
.task-card .task-desc { color: var(--text-sub); font-size: 12px; margin-top: 4px; word-break: break-word; }
.task-card .task-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.task-card .task-actions { display: flex; gap: 6px; }
.task-card .task-actions button { padding: 6px 10px; font-size: 12px; border-radius: 6px; background: var(--card); border: 1px solid var(--border); color: var(--text-sub); min-height: 32px; }
.pri-tag { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--card); }
.pri-tag.high { color: var(--danger); }
.pri-tag.mid { color: var(--warn); }
.pri-tag.low { color: var(--success); }

/* ===== 列表项 ===== */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.list-item.row { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; word-break: break-word; }
.list-item .li-sub { color: var(--text-sub); font-size: 12px; }
.list-item .li-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-sub); }
.list-item .li-meta span { background: var(--bg); padding: 2px 8px; border-radius: 4px; }
.list-item .li-actions { display: flex; gap: 6px; }
.list-item .li-actions button { padding: 6px 12px; font-size: 12px; border-radius: 6px; border: 1px solid var(--border); color: var(--text-sub); background: var(--card); min-height: 32px; }
.list-item .li-actions .del { color: var(--danger); }
.amount.income { color: var(--success); font-weight: 700; }
.amount.expense { color: var(--danger); font-weight: 700; }

/* 待办勾选 */
.todo-check {
  width: 28px; height: 28px;
  border: 2px solid var(--border); border-radius: 50%;
  flex: 0 0 28px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff; transition: all .15s;
}
.todo-check.done { background: var(--success); border-color: var(--success); }
.todo-text { flex: 1; word-break: break-word; }
.todo-text.done { text-decoration: line-through; color: var(--text-sub); }
.todo-due { font-size: 11px; color: var(--text-sub); padding: 2px 6px; background: var(--bg); border-radius: 4px; }
.todo-due.overdue { color: var(--danger); }

/* ===== 底部 Tab ===== */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
}
.tab-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  color: var(--text-sub);
}
.tab-item.active { color: var(--primary-dark); }
.tab-ico { font-size: 20px; line-height: 1; }
.tab-label { font-size: 12px; }

/* ===== 模态框 ===== */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(17,24,39,0.45);
  z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: 100%; max-width: 500px;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  max-height: 88vh;
  display: flex; flex-direction: column;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 700; font-size: 16px; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.modal-foot button { flex: 1; }
.modal-foot .primary-btn { padding: 11px; }
.modal-foot .ghost-btn { padding: 11px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
}
.form-group textarea { resize: vertical; min-height: 70px; }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-chip {
  padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border);
  font-size: 13px; color: var(--text-sub);
}
.btn-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(17,24,39,0.9); color: #fff;
  padding: 10px 18px; border-radius: 8px; font-size: 13px;
  z-index: 200; max-width: 80%; text-align: center;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.empty {
  text-align: center; padding: 40px 20px; color: var(--text-sub); font-size: 13px;
}

/* 桌面预览居中 */
@media (min-width: 600px) {
  body { background: #e5e7eb; }
  .topbar, .tabbar { max-width: 480px; margin: 0 auto; }
  .app { max-width: 480px; margin: 0 auto; left: 50%; transform: translateX(-50%); right: auto; width: 100%; background: var(--bg); box-shadow: 0 0 24px rgba(0,0,0,0.08); }
  .modal-mask { background: rgba(17,24,39,0.6); align-items: center; }
  .modal { border-radius: 16px; }
}
