/* Claw 个人助理 样式 */
:root {
  --primary: #4f6ef7;
  --primary-dark: #3d5ae0;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c9b;
  --border: #e8ecf3;
  --danger: #f56c6c;
  --success: #27ae60;
  --warning: #e6a23c;
  --income: #e74c3c;
  --expense: #27ae60;
  --radius: 10px;
  --sidebar-w: 200px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 10; }
.logo { font-size: 20px; font-weight: 700; padding: 4px 12px 18px; color: var(--primary); }
.logo span { font-size: 13px; color: var(--text-light); font-weight: 400; margin-left: 4px; }
#nav a { display: block; padding: 10px 14px; margin: 2px 0; border-radius: 8px; color: var(--text); text-decoration: none; transition: all .15s; }
#nav a:hover { background: #f0f3ff; }
#nav a.active { background: var(--primary); color: #fff; }
.sidebar-footer { margin-top: auto; font-size: 11px; color: var(--text-light); padding: 10px 12px; }
.content { flex: 1; margin-left: var(--sidebar-w); padding: 22px 26px; max-width: calc(100vw - var(--sidebar-w)); }

.page-title { font-size: 20px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; }
.page-title .sub { font-size: 12px; color: var(--text-light); font-weight: 400; }

/* 卡片 */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 4px rgba(30,50,90,.06); margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }

/* 指标卡 */
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 1px 4px rgba(30,50,90,.06); }
.metric .label { color: var(--text-light); font-size: 12px; margin-bottom: 6px; }
.metric .value { font-size: 22px; font-weight: 700; }
.metric .value.red { color: var(--income); }
.metric .value.green { color: var(--expense); }
.metric .delta { font-size: 11px; margin-top: 4px; color: var(--text-light); }
.metric .delta .up { color: var(--income); }
.metric .delta .down { color: var(--expense); }

/* 今日学习卡片 */
.daily-card { background: linear-gradient(135deg, #4f6ef7 0%, #6f8bff 100%); color: #fff; border: none; }
.daily-card .dc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.daily-card .dc-badge { background: rgba(255,255,255,.22); padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.daily-card .dc-theme { font-weight: 700; font-size: 15px; }
.daily-card .dc-done-badge { margin-left: auto; background: rgba(255,255,255,.25); padding: 3px 10px; border-radius: 20px; font-size: 12px; }
.daily-card .dc-content { font-size: 14px; line-height: 1.6; opacity: .97; }
.daily-card .dc-action { margin-top: 8px; font-size: 13px; opacity: .92; }
.daily-card .btn.primary { background: #fff; color: #4f6ef7; margin-top: 12px; border: none; }
.daily-card .btn.primary:hover { background: #eef2ff; }

/* 学习主题卡片 */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.topic-card { background: var(--card); border-radius: var(--radius); padding: 10px 12px; box-shadow: 0 1px 4px rgba(30,50,90,.06); border-left: 4px solid var(--primary); }
.topic-header h4 { margin: 0 0 4px; font-size: 14px; }
.topic-header .muted { font-size: 11px; margin-left: 6px; }
.topic-notes { margin-top: 6px; }
.topic-note { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-top: 1px dashed var(--border); flex-wrap: wrap; cursor: default; transition: background .15s; }
.topic-note:hover { background: rgba(0,0,0,.02); border-radius: 4px; }
.topic-note.done .tn-title { text-decoration: line-through; opacity: .6; }
.tn-type { display: inline-block; font-size: 10px; color: var(--primary); min-width: 42px; flex-shrink: 0; }
.tn-title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.tn-title:hover { color: var(--primary); }
.tn-meta { font-size: 10px; color: var(--text-light); margin-left: auto; flex-shrink: 0; white-space: nowrap; }
.tn-expand { cursor: pointer; font-size: 11px; color: var(--text-light); width: 16px; text-align: center; flex-shrink: 0; user-select: none; transition: transform .15s; }
.tn-expand:hover { color: var(--primary); }
.tn-detail { width: 100%; margin-top: 4px; padding: 6px 8px; background: rgba(0,0,0,.02); border-radius: 4px; }
.tn-detail .tn-preview { font-size: 12px; color: var(--text); line-height: 1.5; margin-bottom: 4px; white-space: pre-wrap; word-break: break-word; }
.tn-detail .tn-meta { margin-left: 0; display: block; margin-bottom: 4px; }
.tn-actions { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.tn-actions .btn { font-size: 11px; padding: 2px 8px; }
.topic-more { font-size: 11px; color: var(--text-light); margin-top: 4px; padding: 4px 0; cursor: pointer; }
.topic-more:hover { color: var(--primary); }

/* 按钮 */
.btn { display: inline-block; padding: 7px 16px; border-radius: 7px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; font-size: 13px; transition: all .15s; text-decoration: none; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.sm { padding: 3px 10px; font-size: 12px; border-radius: 5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 表格 */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; white-space: nowrap; }
th { color: var(--text-light); font-weight: 500; background: #fafbfd; }
tr:hover td { background: #f8faff; }
.table-wrap { overflow-x: auto; }

/* 表单 */
.form-item { margin-bottom: 14px; }
.form-item label { display: block; font-size: 12px; color: var(--text-light); margin-bottom: 5px; }
.form-item input, .form-item select, .form-item textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; outline: none; background: #fff;
}
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* 标签 */
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; }
.tag.income { background: #fdeeee; color: var(--income); }
.tag.expense { background: #e8f7ef; color: var(--expense); }
.tag.transfer { background: #eef2fd; color: var(--primary); }
.tag.pending { background: #fdf6ec; color: var(--warning); }
.tag.posted { background: #e8f7ef; color: var(--success); }
.tag.done { background: #e8f7ef; color: var(--success); }
.tag.todo { background: #eef2fd; color: var(--primary); }
.tag.canceled { background: #f0f1f3; color: var(--text-light); }
.tag.new { background: #e8f7ef; color: var(--success); }
.tag.duplicate { background: #fdf6ec; color: var(--warning); }
.tag.error { background: #fdeeee; color: var(--danger); }

/* 筛选栏 */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-bar input, .filter-bar select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; background: #fff; }

/* 分页 */
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 12px; color: var(--text-light); }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(20,30,50,.45); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 94vw; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.modal.wide { width: 860px; }
.modal-head { padding: 15px 20px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.modal-head .close { cursor: pointer; color: var(--text-light); font-size: 18px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* toast */
#toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 22px; border-radius: 8px; color: #fff; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.15); animation: fadein .2s; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes fadein { from { opacity: 0; transform: translateY(-8px);} to { opacity: 1; transform: none; } }

/* 日历 */
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.cal-toolbar .btn-group { gap: 6px; }
.cal-view-switch .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.cal-title { font-size: 16px; font-weight: 600; min-width: 160px; text-align: center; }
.calendar { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 4px rgba(30,50,90,.06); }
.cal-week-header { display: grid; grid-template-columns: repeat(7, 1fr); background: #fafbfd; border-bottom: 1px solid var(--border); }
.cal-week-header div { padding: 8px 0; text-align: center; font-size: 12px; color: var(--text-light); }
.cal-month-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell { min-height: 96px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px; cursor: pointer; }
.cal-cell:hover { background: #f6f9ff; }
.cal-cell.other-month { background: #fafbfd; color: #c5cdd8; }
.cal-cell .day-num { font-size: 12px; margin-bottom: 3px; }
.cal-cell.today .day-num { background: var(--primary); color: #fff; border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.cal-event { font-size: 11px; padding: 1px 5px; border-radius: 4px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; color: #fff; }
.cal-event.done { opacity: .55; text-decoration: line-through; }
.cal-more { font-size: 11px; color: var(--text-light); }
/* 周/日视图：时间网格 */
.cal-time-grid { display: grid; grid-template-columns: 52px 1fr; }
.cal-time-col { border-right: 1px solid var(--border); }
.cal-time-label { height: 48px; font-size: 11px; color: var(--text-light); text-align: right; padding-right: 6px; position: relative; top: -7px; }
.cal-day-col { position: relative; border-right: 1px solid var(--border); }
.cal-hour-row { height: 48px; border-bottom: 1px solid #f0f2f7; cursor: pointer; }
.cal-hour-row:hover { background: #f6f9ff; }
.cal-abs-event { position: absolute; left: 2px; right: 2px; border-radius: 6px; font-size: 11px; color: #fff; padding: 2px 6px; overflow: hidden; cursor: pointer; line-height: 1.35; }
.cal-abs-event.done { opacity: .55; text-decoration: line-through; }
.cal-day-columns { display: grid; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 5; }

/* 日/周视图：拖拽选区 */
.cal-time-grid { user-select: none; -webkit-user-select: none; }
/* 手机端允许纵向滚动（pan-y），避免滑动被误判为拖拽选区；桌面端鼠标拖拽不受影响 */
.cal-day-col { touch-action: pan-y; }
.cal-touch-hint {
  background: rgba(79, 110, 247, .08); border: 1px solid rgba(79, 110, 247, .25);
  color: #3b4cca; font-size: 12.5px; padding: 7px 10px; border-radius: 8px; margin-bottom: 10px;
}
.cal-sel {
  position: absolute; left: 2px; right: 2px; z-index: 6; pointer-events: none;
  background: rgba(79, 110, 247, .18); border: 1px solid rgba(79, 110, 247, .55);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #3b4cca; box-shadow: 0 1px 4px rgba(79,110,247,.25);
}

/* 凭证 */
.voucher-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin-bottom: 10px; background: #fff; }
.voucher-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-wrap: wrap; gap: 6px; }
.voucher-no { font-weight: 600; color: var(--primary); font-size: 13px; }
.entry-row { display: grid; grid-template-columns: 60px 1fr 110px 110px 30px; gap: 8px; align-items: center; margin-bottom: 6px; }
.entry-row select, .entry-row input { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }

/* 报表 */
.report-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.report-tabs .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.report-table td.amount, .report-table th.amount { text-align: right; font-variant-numeric: tabular-nums; }
.report-table tr.total td { font-weight: 700; background: #fafbfd; }
.balance-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.unbalanced { color: var(--danger); font-weight: 600; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-box { height: 320px; }

/* 导入向导 */
.import-steps { display: flex; gap: 8px; margin-bottom: 16px; font-size: 12px; }
.import-steps .step { padding: 6px 14px; border-radius: 20px; background: #f0f2f7; color: var(--text-light); }
.import-steps .step.active { background: var(--primary); color: #fff; }
.import-steps .step.done { background: #e8f7ef; color: var(--success); }
.dropzone { border: 2px dashed var(--border); border-radius: 10px; padding: 40px; text-align: center; color: var(--text-light); cursor: pointer; }
.dropzone:hover { border-color: var(--primary); color: var(--primary); }

/* 设置 */
.channel-card { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.channel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.channel-head .name { font-weight: 600; }
.switch { position: relative; width: 40px; height: 22px; background: #d5dbe5; border-radius: 20px; cursor: pointer; transition: .2s; }
.switch.on { background: var(--success); }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.switch.on::after { left: 20px; }
.hint { font-size: 11px; color: var(--text-light); line-height: 1.7; }
.preview-box { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.empty { text-align: center; color: var(--text-light); padding: 40px 0; }
.muted { color: var(--text-light); font-size: 12px; }

/* 列表页筛选条（笔记/热点等） */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-bar input, .filter-bar select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; background: #fff; }
.filter-bar input { flex: 1; min-width: 160px; }
.nw-value { font-size: 26px; }
.amount-red { color: var(--income); }
.amount-green { color: var(--expense); }
/* ===== 导航分组 ===== */
.nav-group { margin-top: 12px; }
.nav-group-title { font-size: 11px; color: var(--text-light); padding: 0 14px 4px; letter-spacing: 1px; }
#nav a { font-size: 13px; padding: 8px 14px; }

/* ===== 底部一级导航 / 二级导航（移动端） ===== */
.bottom-tab { display: none; }
.subnav { display: none; }
@media (max-width: 900px) {
  /* 底部一级 Tab：常驻屏幕底部，含 iOS 安全区 */
  .bottom-tab {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    height: calc(54px + env(safe-area-inset-bottom));
    background: #fff; border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    justify-content: space-around; align-items: stretch;
  }
  .bottom-tab a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--text-light); text-decoration: none; font-size: 11px; -webkit-tap-highlight-color: transparent;
  }
  .bottom-tab a.active { color: var(--primary); }
  .bottom-tab a .bt-ico { font-size: 20px; line-height: 1; }
  .bottom-tab a.active .bt-ico { transform: translateY(-1px); }
  /* 二级导航：进入一级 Tab 后，在内容顶部横向滑动的胶囊 */
  .subnav {
    display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 10px 2px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border);
  }
  .subnav a {
    flex: 0 0 auto; padding: 6px 14px; border-radius: 20px;
    background: #f0f3ff; color: var(--primary); font-size: 13px; text-decoration: none; white-space: nowrap;
  }
  .subnav a.active { background: var(--primary); color: #fff; }
  /* 内容区底部给底部 Tab 让位 */
  .content { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
}

/* ===== 今日速览条 ===== */
.today-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: linear-gradient(90deg,#eef2fd,#f0f9eb); border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; margin-bottom: 14px; font-size: 13px; }
.today-bar b { color: var(--primary); }
.hb-progress { flex: 1; min-width: 100px; height: 8px; background: #e8ecf3; border-radius: 6px; overflow: hidden; }
.hb-progress div { height: 100%; background: var(--success); border-radius: 6px; transition: width .3s; }
.hol-name-inline { color: var(--danger); font-weight: 500; }

/* ===== 节假日标识 ===== */
.hol-badge { display: inline-block; font-size: 10px; line-height: 1; padding: 2px 3px; border-radius: 4px; font-weight: 600; vertical-align: middle; }
.hol-badge.rest { background: #fdeeee; color: #e74c3c; }
.hol-badge.work { background: #f0f1f3; color: #7f8c9b; }
.cal-cell .day-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.cal-cell .day-num.weekend { color: #e74c3c; }
.cal-cell .day-num.holiday-text { color: #e74c3c; font-weight: 600; }
.cal-cell.other-month .day-num.weekend, .cal-cell.other-month .day-num.holiday-text { color: #d9a7a7; }
.hol-name { font-size: 10px; color: #e74c3c; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-week-header .wknd-mark { color: #e74c3c; font-size: 10px; margin-left: 2px; }
.cal-week-header .wh-today { color: var(--primary); font-weight: 600; }

/* ===== 事件胶囊（月视图）===== */
.cal-event { display: flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 6px; border-radius: 5px; margin-bottom: 2px; overflow: hidden; white-space: nowrap; cursor: pointer; border-left: 3px solid transparent; }
.cal-event .ev-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.cal-event b { font-weight: 600; flex: none; }
.cal-event .ev-title { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.cal-event .ev-repeat { font-style: normal; font-size: 10px; flex: none; }
.cal-abs-event { border-left: 3px solid transparent; }

/* ===== 优先级 ===== */
.pr-tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; }
.pr-high { background: #fdeeee; color: #e74c3c; }
.pr-medium { background: #fdf6ec; color: #e6a23c; }
.pr-low { background: #ecf5ff; color: #409eff; }
.tag.repeat { background: #f4ecfd; color: #9b59b6; }
.tag.cat { background: #eef2fd; color: #4f6ef7; }

/* ===== 学习成长 ===== */
.prog-bar { display: inline-flex; align-items: center; gap: 6px; }
.prog-bar > div:first-child { width: 60px; height: 6px; background: #e8ecf3; border-radius: 4px; overflow: hidden; }
.prog-bar > div:first-child > div { height: 100%; }
.prog-bar.big { display: block; }
.prog-bar.big > div:first-child { width: 100%; height: 14px; border-radius: 8px; }

/* ===== 习惯打卡 ===== */
.habit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
.habit-card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 4px rgba(30,50,90,.06); border-top: 3px solid var(--hc, var(--primary)); }
.habit-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.habit-icon { font-size: 26px; }
.habit-info { flex: 1; min-width: 0; }
.habit-name { font-weight: 600; font-size: 14px; }
.habit-streak { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.hm { display: flex; gap: 6px; }
.hm-row-labels { display: grid; grid-template-rows: repeat(7, 14px); font-size: 9px; color: var(--text-light); text-align: right; padding-right: 2px; }
.hm-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); gap: 3px; flex: 1; }
.hm-cell { background: #eef0f4; border-radius: 3px; min-width: 8px; }
.hm-cell.on { background: var(--hc, var(--primary)); }
.hm-cell.today { outline: 2px solid var(--warning); outline-offset: 1px; }
.hm-cell.future { opacity: .35; }

/* ===== 同步状态表 ===== */
.sync-table td { border-bottom: 1px solid var(--border); padding: 8px 10px; }
.sync-table td:first-child { color: var(--text-light); width: 130px; }
.sync-table code { background: #f0f2f7; padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* ===== 移动端顶栏 / 抽屉导航（桌面隐藏） ===== */
.topbar { display: none; }
.nav-overlay { display: none; }

@media (max-width: 900px) {
  /* --- 顶栏 --- */
  .topbar {
    display: flex; align-items: center; gap: 10px;
    position: fixed; top: 0; left: 0; right: 0;
    height: calc(52px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 12px 0;
    background: #fff; border-bottom: 1px solid var(--border); z-index: 30;
  }
  .topbar-btn { flex: 0 0 38px; width: 38px; height: 38px; border: 1px solid var(--border); background: #fff; border-radius: 9px; font-size: 17px; line-height: 1; color: var(--text); cursor: pointer; }
  .topbar-btn:active { background: #f0f3ff; }
  .topbar-title { flex: 1; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* --- 侧栏 → 抽屉 --- */
  .sidebar {
    display: flex; width: 244px; z-index: 40;
    transform: translateX(-104%); transition: transform .22s ease;
    padding: calc(14px + env(safe-area-inset-top)) 12px 14px;
    overflow-y: auto; overscroll-behavior: contain;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(20,30,60,.28); }
  .nav-overlay { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(20,30,50,.42); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .nav-overlay.show { opacity: 1; pointer-events: auto; }
  body.nav-lock { overflow: hidden; }
  #nav a { padding: 12px 14px; font-size: 15px; }

  /* --- 内容区：铺满屏宽 + 给顶栏让位 + 刘海安全区 --- */
  .content {
    margin-left: 0; max-width: 100%;
    padding: calc(64px + env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
  }

  /* --- 栅格降级 --- */
  .chart-grid, .balance-grid, .habit-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric { padding: 12px 14px; }
  .metric .value { font-size: 19px; }
  .form-row, .form-row3 { grid-template-columns: 1fr; gap: 0; }

  /* --- 表格：窄屏下自身可横滑，别把整页撑宽 --- */
  .content table { display: block; overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
  .content .table-wrap > table { display: table; overflow: visible; }
  /* 「键-值」两列表在手机上改为上下堆叠、长内容换行（不横向滚动） */
  .content table.sync-table { overflow: visible; }
  .sync-table tbody, .sync-table tr, .sync-table td { display: block; width: auto; }
  .sync-table tr { padding: 7px 0; border-bottom: 1px solid var(--border); }
  .sync-table tr:last-child { border-bottom: 0; }
  .sync-table td { border-bottom: 0; padding: 2px 0; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
  .sync-table td:first-child { width: auto; font-size: 12px; }

  /* --- 键盘/输入 --- */
  input, select, textarea { font-size: 16px; }
  .btn { padding: 9px 14px; }
  .btn.sm { padding: 6px 10px; font-size: 12px; }
  input[type=checkbox] { width: 18px; height: 18px; }

  /* --- 卡片 / 标题 --- */
  .card { padding: 14px; }
  .page-title { font-size: 18px; flex-wrap: wrap; gap: 8px; }
  .filter-inline { float: none; display: block; margin-top: 6px; }
  .sync-table td:first-child { width: 92px; }
  .empty { padding: 24px 10px; }

  /* --- 弹窗 --- */
  .modal { width: 94vw; max-width: 94vw; max-height: 86vh; }
  .modal.wide { width: 94vw; }
  .modal-head, .modal-foot { padding: 12px 14px; }
  .modal-body { padding: 14px; }

  /* --- toast 移到顶栏下方 --- */
  #toast-wrap { top: calc(62px + env(safe-area-inset-top)); max-width: 92vw; }

  /* --- 日历 --- */
  .cal-toolbar { flex-wrap: wrap; gap: 8px; }
  .cal-toolbar .cal-title { flex: 1 1 100%; order: -1; min-width: 0; text-align: center; font-size: 15px; }
  .cal-cell { min-height: 64px; padding: 3px; }
  .cal-cell .day-num { font-size: 11px; }
  .cal-event { font-size: 10px; padding: 1px 3px; }
  .cal-time-grid { grid-template-columns: 38px 1fr; }
  .cal-time-label { font-size: 10px; padding-right: 4px; }
  /* 周视图在手机上：表头折成「周一 / 9/14 休」两行，事件块收小，避免 7 列挤在一行显示不下 */
  .cal-week-header div { font-size: 10px; padding: 6px 0; line-height: 1.4; }
  .cal-week-header .wh-date { display: block; }
  .cal-week-header .hol-badge, .cal-week-header .wknd-mark { font-size: 9px; margin-left: 1px; }
  .cal-abs-event { font-size: 10px; padding: 1px 3px; left: 1px; right: 1px; }
  .chart-box { height: 260px; }

  /* --- 凭证分录 / 报表 / 导入 --- */
  .entry-row { grid-template-columns: 1fr 1fr 40px; gap: 6px; }
  .entry-row > :nth-child(1), .entry-row > :nth-child(2) { grid-column: 1 / -1; }
  .entry-row select, .entry-row input { font-size: 16px; padding: 7px 8px; }
  .report-tabs, .import-steps { flex-wrap: wrap; }
  .dropzone { padding: 22px; }

  /* --- 学习 / 习惯 --- */
  .tn-title { max-width: 128px; }
  .hm { overflow-x: auto; padding-bottom: 4px; }
}

@media (max-width: 560px) {
  .metric .value { font-size: 17px; }
  .nw-value { font-size: 26px; }
  .nw-sub { gap: 12px; font-size: 12px; }
  .card-title { font-size: 14px; }
  th, td { padding: 8px; font-size: 12.5px; }
  .cat-chip { min-width: 0; flex: 1 1 calc(50% - 8px); }
  .topic-grid { grid-template-columns: 1fr; }
  .pager { flex-wrap: wrap; justify-content: center; }
}

/* ===== 资产管理 ===== */
.net-worth-bar { background: linear-gradient(120deg,#4f6ef7,#7c5cff); color:#fff; border-radius: var(--radius); padding: 20px 24px; margin-bottom: 16px; box-shadow: 0 6px 18px rgba(79,110,247,.25); }
.nw-label { font-size: 13px; opacity:.85; }
.nw-value { font-size: 34px; font-weight: 700; letter-spacing:.5px; line-height:1.2; }
.nw-sub { display:flex; gap:22px; margin-top:10px; font-size:13px; opacity:.92; flex-wrap:wrap; }
.nw-sub b { font-weight:600; }
.cat-summary { display:flex; gap:12px; flex-wrap:wrap; }
.cat-chip { background: var(--card); border:1px solid var(--border); border-radius:12px; padding:12px 16px; min-width:140px; }
.cat-name { font-size:13px; color: var(--text-light); }
.cat-mv { font-size:18px; font-weight:700; margin:4px 0 2px; }
.cat-pnl { font-size:12px; }
.filter-inline { float:right; font-weight:400; }
.filter-inline select { padding:4px 8px; border-radius:8px; border:1px solid var(--border); }
.pnl-up { color:#e53935; font-weight:600; }   /* 盈利：红 */
.pnl-down { color:#2e9e57; font-weight:600; } /* 亏损：绿 */
.small { font-size:12px; }
