/* ============================================================
   我的工作台 —— 设计系统
   ============================================================ */
* { box-sizing: border-box; }

:root {
  --bg: #f4f5f7;
  --bg-soft: #eef0f3;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --text: #14181f;
  --muted: #6a7280;
  --faint: #9aa1ad;
  --line: #e3e6ea;
  --line-strong: #d3d8de;
  --brand: #2563eb;
  --brand-soft: rgba(37, 99, 235, .1);
  --brand-ink: #ffffff;
  --income: #0f9d74;
  --income-soft: rgba(15, 157, 116, .1);
  --expense: #e5484d;
  --expense-soft: rgba(229, 72, 77, .1);
  --warn: #d97706;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 60px rgba(16, 24, 40, .22);
  --sidebar-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg: #0e1116;
  --bg-soft: #141920;
  --panel: #171c24;
  --panel-2: #1c222b;
  --text: #e8eaee;
  --muted: #98a1ae;
  --faint: #6d7683;
  --line: #262d38;
  --line-strong: #333c49;
  --brand: #4c8dff;
  --brand-soft: rgba(76, 141, 255, .16);
  --brand-ink: #0b1220;
  --income: #34d399;
  --income-soft: rgba(52, 211, 153, .14);
  --expense: #fb7185;
  --expense-soft: rgba(251, 113, 133, .14);
  --warn: #fbbf24;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, .6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --bg-soft: #141920;
    --panel: #171c24;
    --panel-2: #1c222b;
    --text: #e8eaee;
    --muted: #98a1ae;
    --faint: #6d7683;
    --line: #262d38;
    --line-strong: #333c49;
    --brand: #4c8dff;
    --brand-soft: rgba(76, 141, 255, .16);
    --brand-ink: #0b1220;
    --income: #34d399;
    --income-soft: rgba(52, 211, 153, .14);
    --expense: #fb7185;
    --expense-soft: rgba(251, 113, 133, .14);
    --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 30px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, .6);
  }
}

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: var(--brand-soft); }

/* ----------------------------- 布局 ----------------------------- */
.shell { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 18px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 16px;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(145deg, var(--brand), #7c3aed);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; letter-spacing: .01em; }
.brand-text span { font-size: 11px; color: var(--faint); }

.nav-label {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 14px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
  transition: background .15s, color .15s;
  font-size: 14px;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item .ico { font-size: 16px; width: 20px; text-align: center; flex: 0 0 20px; }
.nav-item .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--faint);
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 6px;
}
.nav-item.active .count { background: var(--panel); color: var(--brand); }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar h1 { font-size: 16px; font-weight: 650; letter-spacing: .01em; }
.topbar .spacer { flex: 1; }

.content {
  padding: 22px 26px 60px;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  flex: 1;
}

.tabbar { display: none; }

/* ----------------------------- 通用块 ----------------------------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h2 { font-size: 22px; font-weight: 680; letter-spacing: -.01em; }
.page-head p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.card-hd h3 { font-size: 14.5px; font-weight: 650; }
.card-hd .sub { color: var(--muted); font-size: 12px; }
.card-bd { padding: 16px; }
.card-bd.tight { padding: 8px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.section { margin-bottom: 18px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.mono { font-family: var(--mono); font-size: 13px; letter-spacing: .01em; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

/* ----------------------------- 按钮 ----------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  transition: transform .06s, background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
  min-height: 38px;
}
.btn:hover { background: var(--bg-soft); }
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--brand); border-color: var(--brand); color: var(--brand-ink);
  box-shadow: 0 2px 8px rgba(37, 99, 235, .28);
}
.btn.primary:hover { filter: brightness(1.06); background: var(--brand); }
.btn.danger { color: var(--expense); border-color: color-mix(in srgb, var(--expense) 40%, var(--line)); }
.btn.danger:hover { background: var(--expense-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 12.5px; }
.btn.icon { padding: 0; width: 36px; height: 36px; min-height: 36px; border-radius: 9px; font-size: 15px; }
.btn.icon.sm { width: 30px; height: 30px; min-height: 30px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 0; min-height: 0; }

/* ----------------------------- 表单 ----------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.field .hint { font-size: 11.5px; color: var(--faint); }
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  font-size: 16px;
  transition: border-color .15s, box-shadow .15s;
  min-height: 40px;
  appearance: none;
}
@media (min-width: 861px) { .input, .select, .textarea { font-size: 14px; min-height: 38px; } }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-group { display: flex; gap: 8px; align-items: center; }
.input-group .input { flex: 1; }

.search {
  position: relative;
  flex: 1;
  min-width: 160px;
}
.search .input { padding-left: 34px; }
.search::before {
  content: "🔍";
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: .5;
  pointer-events: none;
}

.switch {
  position: relative;
  width: 42px; height: 24px;
  border-radius: 999px;
  background: var(--line-strong);
  border: 0;
  cursor: pointer;
  flex: 0 0 42px;
  transition: background .18s;
  padding: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s;
}
.switch[aria-checked="true"] { background: var(--brand); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

.segmented {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  border: 0;
  background: none;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 550;
  white-space: nowrap;
}
.segmented button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.on { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); color: var(--brand); font-weight: 600; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}
.tag.income { background: var(--income-soft); color: var(--income); }
.tag.expense { background: var(--expense-soft); color: var(--expense); }
.tag.brand { background: var(--brand-soft); color: var(--brand); }

/* ----------------------------- 统计卡 ----------------------------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat .lbl { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.stat .val { font-size: 24px; font-weight: 680; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .val.income { color: var(--income); }
.stat .val.expense { color: var(--expense); }
.stat .foot { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.stat .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

/* ----------------------------- 列表 ----------------------------- */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: none;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  text-align: left;
  cursor: default;
}
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--panel-2); }
.avatar {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: var(--bg-soft);
  font-size: 16px;
  font-weight: 650;
  color: var(--muted);
  overflow: hidden;
}
.avatar.brand { background: var(--brand-soft); color: var(--brand); }
.avatar.income { background: var(--income-soft); color: var(--income); }
.avatar.expense { background: var(--expense-soft); color: var(--expense); }
.list-main { flex: 1; min-width: 0; }
.list-title { font-size: 14px; font-weight: 550; display: flex; align-items: center; gap: 7px; }
.list-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.list-amount { font-variant-numeric: tabular-nums; font-weight: 620; font-size: 14.5px; }
.list-amount.income { color: var(--income); }
.list-amount.expense { color: var(--expense); }
.list-actions { display: flex; gap: 4px; align-items: center; }
.list-actions .btn { opacity: .75; }
@media (hover: hover) { .list-actions .btn:hover { opacity: 1; } }

.day-head {
  padding: 9px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

/* ----------------------------- 模块卡片 ----------------------------- */
.mod-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 15px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s, border-color .15s, box-shadow .15s;
  text-align: left;
}
.mod-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.mod-card .ico { font-size: 22px; }
.mod-card .nm { font-weight: 620; font-size: 14.5px; }
.mod-card .ds { font-size: 12px; color: var(--muted); line-height: 1.4; }
.mod-card .meta { font-size: 11.5px; color: var(--faint); margin-top: auto; }

/* ----------------------------- 图表 ----------------------------- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 132px; padding-top: 8px; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-pair { display: flex; align-items: flex-end; gap: 3px; width: 100%; height: 100%; justify-content: center; }
.bar {
  width: 11px;
  max-width: 16px;
  border-radius: 4px 4px 2px 2px;
  min-height: 2px;
  transition: height .3s ease;
}
.bar.income { background: var(--income); opacity: .9; }
.bar.expense { background: var(--expense); opacity: .9; }
.bar-group .cap { font-size: 10.5px; color: var(--faint); white-space: nowrap; }

.cat-bar { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.cat-bar .nm { width: 84px; flex: 0 0 84px; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-bar .track { flex: 1; height: 7px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.cat-bar .fill { height: 100%; border-radius: 999px; background: var(--brand); }
.cat-bar .fill.expense { background: var(--expense); }
.cat-bar .fill.income { background: var(--income); }
.cat-bar .amt { width: 76px; flex: 0 0 76px; text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ----------------------------- 空状态 ----------------------------- */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.empty .ico { font-size: 34px; margin-bottom: 8px; opacity: .75; }
.empty p { font-size: 13.5px; }
.empty .sub { font-size: 12px; color: var(--faint); margin-top: 4px; }

/* ----------------------------- 弹窗 ----------------------------- */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 16, 24, .45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98) } to { opacity: 1; transform: none } }

.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  max-height: min(88dvh, 760px);
  display: flex;
  flex-direction: column;
  animation: pop .16s ease;
  overflow: hidden;
}
.modal.wide { max-width: 620px; }
.modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.modal-hd h3 { font-size: 16px; font-weight: 650; }
.modal-bd { padding: 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-ft {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
  background: var(--panel-2);
}
.modal-ft .btn { min-width: 78px; }

@media (max-width: 640px) {
  .backdrop { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 92dvh;
    animation: slideUp .2s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  @keyframes slideUp { from { transform: translateY(24px); opacity: .6 } to { transform: none; opacity: 1 } }
  .modal-ft { position: sticky; bottom: 0; }
  .modal-ft .btn { flex: 1; }
}

/* 底部选择面板 */
.sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 6px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  background: none;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  text-align: left;
  font-size: 14.5px;
}
.sheet-item:last-child { border-bottom: 0; }
.sheet-item .ico { font-size: 18px; width: 24px; text-align: center; }

/* ----------------------------- Toast ----------------------------- */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}
.toast {
  background: #1b2027;
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .3);
  animation: toastIn .2s ease;
  display: flex;
  align-items: center;
  gap: 7px;
}
:root[data-theme="dark"] .toast { background: #e8eaee; color: #12161c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .toast { background: #e8eaee; color: #12161c; }
}
.toast.error { background: var(--expense); color: #fff; }
.toast.ok { background: var(--income); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
@media (min-width: 861px) { .toast-root { bottom: 28px; } }

/* ----------------------------- 登录页 ----------------------------- */
.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 15% -10%, var(--brand-soft), transparent 60%),
    radial-gradient(800px 400px at 100% 0%, rgba(124, 58, 237, .10), transparent 55%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 384px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 26px 24px;
  box-shadow: var(--shadow-lg);
}
.auth-card .brand-mark { width: 46px; height: 46px; border-radius: 14px; font-size: 20px; margin-bottom: 16px; }
.auth-card h1 { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin: 4px 0 20px; line-height: 1.5; }
.auth-err { color: var(--expense); font-size: 12.5px; min-height: 18px; margin-top: -4px; margin-bottom: 8px; }
.auth-foot { margin-top: 16px; font-size: 11.5px; color: var(--faint); text-align: center; line-height: 1.6; }

/* ----------------------------- 手机端 ----------------------------- */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar { display: flex; }
  .content { padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:first-child { grid-column: span 2; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .page-head h2 { font-size: 19px; }
  .page-head { margin-bottom: 14px; }
  .stat .val { font-size: 21px; }
  .form-row { grid-template-columns: 1fr; }
  .tabbar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 5px 2px;
    background: none;
    border: 0;
    color: var(--faint);
    font-size: 10.5px;
    cursor: pointer;
    border-radius: 10px;
    min-width: 0;
  }
  .tab .ico { font-size: 19px; line-height: 1.1; }
  .tab .lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab.active { color: var(--brand); }
  .fab {
    position: fixed;
    right: 16px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--brand);
    color: var(--brand-ink);
    border: 0;
    font-size: 24px;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 24px rgba(37, 99, 235, .4);
    z-index: 35;
    cursor: pointer;
  }
  .fab:active { transform: scale(.94); }
}
@media (min-width: 861px) {
  .fab { display: none; }
  .mobile-only { display: none !important; }
}
@media (max-width: 860px) { .desktop-only { display: none !important; } }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* 金额/密码展示 */
.secret-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  padding: 7px 11px;
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
}
.secret-box .val { flex: 1; min-width: 0; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--panel-2) 37%, var(--bg-soft) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 8px;
  height: 16px;
}
@keyframes shimmer { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }

.loading-page { display: grid; place-items: center; min-height: 60dvh; color: var(--muted); font-size: 13px; gap: 10px; }
.spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ----------------------------- 图标与细节 ----------------------------- */
.svg-ico { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.svg-ico svg { display: block; }

.topbar .brand-mark {
  width: 26px; height: 26px;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: none;
}

@media (max-width: 860px) {
  .page-head h2.dup { display: none; }
  .page-head p { margin-top: 0; }
  .empty { padding: 26px 16px; }
  .empty .ico { font-size: 28px; }
}

/* ----------------------------- 修正 ----------------------------- */
.cat-bar .fill { display: block; }

.chips-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 860px) {
  .chips-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding-right: 64px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .chips-row::-webkit-scrollbar { display: none; }
  .tab .ico { display: flex; align-items: center; justify-content: center; height: 20px; }
}

/* ----------------------------- 进度条 / 打卡 / 热力图 ----------------------------- */
.progress {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress.tall { height: 12px; }
.progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width .3s ease;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.check-item:last-child { border-bottom: 0; }
.check-item:hover { background: var(--panel-2); }

.check {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  display: grid;
  place-items: center;
  color: #fff;
  transition: background .15s, border-color .15s, transform .1s;
}
.check .svg-ico { opacity: 0; transition: opacity .15s; }
.check.on { background: var(--income); border-color: var(--income); }
.check.on .svg-ico { opacity: 1; }
.check-item:active .check { transform: scale(.9); }

.done-title { text-decoration: line-through; color: var(--faint); font-weight: 450; }

.heatmap { display: flex; gap: 6px; }
.heat-cell { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.heat { width: 100%; aspect-ratio: 1; border-radius: 5px; background: var(--bg-soft); }
.heat-lb { font-size: 9.5px; color: var(--faint); line-height: 1; }

.todo-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  transition: background .15s, border-color .15s, color .15s;
  max-width: 100%;
}
.todo-chip:hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.todo-chip.on {
  background: var(--income-soft);
  border-color: color-mix(in srgb, var(--income) 32%, transparent);
  color: var(--income);
  text-decoration: line-through;
}
.todo-dot {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  display: grid;
  place-items: center;
  background: transparent;
  color: #fff;
}
.todo-chip.on .todo-dot { background: var(--income); border-color: var(--income); }

.bar-mini { height: 6px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.bar-mini-fill { height: 100%; border-radius: 999px; transition: width .3s ease; }

@media (max-width: 860px) {
  .heatmap { gap: 4px; }
  .heat-lb { font-size: 9px; }
  .check-item { padding: 12px 14px; }
}

.heatmap { max-width: 470px; }

/* ----------------------------- 羊毛收益 ----------------------------- */
.stats.stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) and (min-width: 861px) {
  .stats.stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .stats.stats-4 { grid-template-columns: 1fr 1fr; }
  .stats.stats-4 .stat:first-child { grid-column: auto; }
  .stats.stats-4 .stat .val { font-size: 18px; }
}

.tag.warn { background: rgba(217, 119, 6, .14); color: var(--warn); }
.bar.expected { background: var(--brand); opacity: .3; }

/* ----------------------------- 多币种 ----------------------------- */
.currency-block { display: flex; flex-direction: column; gap: 8px; }
.cur-head { display: flex; align-items: center; gap: 8px; }
.stat .val.warn { color: var(--warn); }

/* ----------------------------- 记事本 ----------------------------- */
.note-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .15s, transform .12s;
}
.note-card:hover { border-color: color-mix(in srgb, var(--brand) 32%, var(--line)); transform: translateY(-1px); }
.note-hd { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.note-pin { font-size: 12px; }
.note-title { flex: 1; min-width: 0; font-weight: 650; font-size: 15px; }
.note-body {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.65;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.notes-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  align-items: start;
}
.notes-grid .empty { grid-column: 1 / -1; }
@media (max-width: 860px) {
  .notes-grid { grid-template-columns: 1fr; }
}

.note-inline {
  margin-top: 10px;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}
.note-inline strong { color: var(--text); }
.note-inline code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

/* ----------------------------- 记事本提醒 ----------------------------- */
.note-remind {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  white-space: nowrap;
}
.note-remind.due { background: var(--expense-soft); color: var(--expense); }
.note-remind.done { background: var(--bg-soft); color: var(--faint); }

.reminder-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--brand-soft);
  border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
  font-size: 13px;
  color: var(--text);
  margin-bottom: 12px;
}
.reminder-banner .grow { flex: 1; min-width: 0; }

.stats.stats-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
