:root {
  --page: #f4f4f1; --surface: #fcfcfb; --ink: #0b0b0b; --ink2: #52514e; --muted: #6f6d68;
  --hair: #e1e0d9; --base: #c3c2b7; --wash: #f0efec; --accent: #184f95; --accent-soft: #cde2fb;
  --nav: #14233b; --nav-active: #24395c; --nav-text: #c9d4e5;
  --income: #c62f2f; --expense: #0f7b3f; --warn-bg: #fff4d9; --warn-ink: #6b4a00;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--page); color: var(--ink);
  font: 15px/1.45 -apple-system, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; }
#app { height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; } /* iOS 小于 16px 会自动放大页面 */
h1 { font-size: 21px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 8px; }
.num { font-variant-numeric: tabular-nums; }
.income { color: var(--income); } .expense { color: var(--expense); }
.muted { color: var(--muted); } .small { font-size: 13px; } .bold { font-weight: 600; }
.right { text-align: right; }
.spacer { flex: 1; }

/* 框架：手机底部导航，平板左侧导航 */
.shell { display: flex; flex-direction: column; height: 100%; }
.main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--safe-t) + 10px) 14px 90px; }
.nav { display: flex; background: var(--nav); padding-bottom: var(--safe-b); flex: none; }
.nav button { flex: 1; min-height: 54px; background: none; border: 0; color: var(--nav-text); font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.nav button.on { color: #fff; background: var(--nav-active); font-weight: 600; }
.nav .ico { font-size: 18px; line-height: 1; }
.nav .brand { display: none; }
.top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; min-height: 40px; }
.fab { position: fixed; right: 16px; bottom: calc(var(--safe-b) + 68px); width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; border: 0; font-size: 28px; line-height: 1; box-shadow: 0 3px 10px rgba(0,0,0,.25); z-index: 5; }
@media (min-width: 768px) {
  .shell { flex-direction: row-reverse; }
  .nav { flex-direction: column; width: 132px; padding: calc(var(--safe-t) + 8px) 0 var(--safe-b); justify-content: flex-start; }
  .nav button { flex: none; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 0 18px; font-size: 15px; min-height: 48px; }
  .nav .brand { display: block; color: #fff; font-weight: 600; font-size: 17px; text-align: center; padding: 12px 0 14px; }
  .main { padding: calc(var(--safe-t) + 14px) 20px 40px; }
  .fab { bottom: calc(var(--safe-b) + 24px); right: 24px; }
  .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .cols > .card, .cols > div > .card { margin-bottom: 0; }
  .cols .span2 { grid-column: span 2; }
  .split { display: grid; grid-template-columns: minmax(300px, 38%) 1fr; gap: 12px; align-items: start; }
  .split .detail-back { display: none; }
}

/* 卡片和统计 */
.card { background: var(--surface); border: 1px solid var(--hair); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
.tile { background: var(--surface); border: 1px solid var(--hair); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.tile .k { font-size: 12px; color: var(--ink2); }
.tile .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.25; }
.tile .s { font-size: 11px; color: var(--muted); }
.tile.wide { grid-column: span 2; }
.tile.wide .v { font-size: 24px; }
@media (min-width: 768px) { .tiles { grid-template-columns: repeat(3, 1fr); } .tiles.four { grid-template-columns: repeat(4, 1fr); } .tile.wide { grid-column: auto; } .tile.wide .v { font-size: 18px; } }
.banner { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; }
.banner button { margin-left: 6px; }

/* 分币种 */
.ccy-row { border-top: 1px solid var(--hair); padding: 8px 0; }
.ccy-row:first-of-type { border-top: 0; }
.ccy-name { font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; }
.ccy-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 8px; margin-top: 4px; }
.ccy-grid .k { font-size: 11px; color: var(--muted); }
.ccy-grid .v { font-size: 13.5px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* 表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { background: var(--wash); color: var(--ink2); font-weight: 600; font-size: 12.5px; padding: 6px 8px; text-align: left; white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
th.r, td.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 600; background: var(--wash); }
tr.section td { font-weight: 600; background: #e7edf5; }
tr.group td { font-weight: 600; }
tr.grand td { font-weight: 600; background: var(--accent-soft); }
tr.hl td { background: var(--accent-soft); }

/* 条形 */
.bar-row { display: grid; grid-template-columns: 62px 1fr 76px; align-items: center; gap: 8px; min-height: 26px; font-size: 13px; }
.bar-track { height: 12px; }
.bar { height: 100%; border-radius: 0 3px 3px 0; min-width: 2px; }
.bar.expense-bg { background: var(--expense); } .bar.income-bg { background: var(--income); }
.bars-month { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; align-items: end; height: 110px; margin-top: 6px; }
.bars-month .m { display: flex; gap: 1px; align-items: flex-end; height: 100%; }
.bars-month .m i { flex: 1; display: block; border-radius: 2px 2px 0 0; min-height: 0; }
.bars-label { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; font-size: 10px; color: var(--muted); text-align: center; margin-top: 2px; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--ink2); justify-content: flex-end; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }

/* 标签：类型实心、分类浅底、账户描边，与电脑版相同 */
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 12px; line-height: 18px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; border: 1px solid transparent; }
.t-expense { background: #0f7b3f; color: #fff; } .t-income { background: #c62f2f; color: #fff; }
.t-transfer { background: #2a6fc4; color: #fff; } .t-adjust { background: #6f6d68; color: #fff; }
.c-income { background: #fde8e6; color: #a82b22; } .c-transfer { background: #e2edfb; color: #1c5fb0; }
.c-living { background: #fdeeda; color: #8f4f08; } .c-home { background: #f6f0cf; color: #665900; }
.c-travel { background: #dcf3f6; color: #0b6876; } .c-fun { background: #eee8fb; color: #5c3bb0; }
.c-care { background: #fbe6f3; color: #962872; } .c-family { background: #e5e8fa; color: #3a47a8; }
.c-other { background: #eceae5; color: #52514e; }
.a-D { background: #e8f7f9; color: #0b6876; border-color: #0b7285; }
.a-C { background: #fdf3e4; color: #96500a; border-color: #a8590b; }
.a-I { background: #f1ecfb; color: #6741b8; border-color: #6741b8; }

/* 按钮和表单 */
.btn { min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--base); background: var(--surface); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--income); border-color: var(--income); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 13px; color: var(--ink2); margin-bottom: 3px; }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--base); border-radius: 8px; background: #fff; }
.field input[type=checkbox] { width: auto; min-height: 0; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.amount-line { display: flex; gap: 6px; }
.amount-line input { text-align: right; font-size: 20px; font-variant-numeric: tabular-nums; }
.seg { display: flex; border: 1px solid var(--base); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { flex: 1; min-height: 38px; border: 0; background: none; border-left: 1px solid var(--base); padding: 0 8px; white-space: nowrap; }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--accent); color: #fff; }
.seg button.on-expense { background: var(--expense); color: #fff; }
.seg button.on-income { background: var(--income); color: #fff; }
.seg button.on-transfer { background: #2a6fc4; color: #fff; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; align-items: center; }
.filters select, .filters input { min-height: 38px; padding: 4px 8px; border: 1px solid var(--base); border-radius: 8px; background: #fff; max-width: 100%; font-size: 15px; }
.filters .grow { flex: 1; min-width: 100px; }
.period { display: flex; gap: 4px; align-items: center; }
.period button { width: 36px; min-height: 38px; border: 1px solid var(--base); background: var(--surface); border-radius: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px; }
.sheet-actions { position: sticky; bottom: calc(-14px - var(--safe-b)); background: var(--surface); margin: 0 -16px calc(-14px - var(--safe-b)); padding: 10px 16px calc(var(--safe-b) + 10px); border-top: 1px solid var(--hair); }
.chips button { border: 2px solid transparent; border-radius: 8px; padding: 0; background: none; }
.chips .tag { font-size: 14px; line-height: 26px; padding: 2px 10px; display: block; }
.chips button.on { border-color: var(--ink); }

/* 流水列表 */
.day { font-size: 12.5px; color: var(--muted); margin: 10px 2px 4px; }
.rows { background: var(--surface); border: 1px solid var(--hair); border-radius: 10px; overflow: hidden; }
.row { display: flex; gap: 8px; padding: 9px 12px; border-top: 1px solid var(--hair); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; align-items: center; }
.row:first-child { border-top: 0; }
.row .l { flex: 1; min-width: 0; }
.row .tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.row .note { font-size: 12.5px; color: var(--ink2); margin-top: 2px; overflow-wrap: anywhere; }
.row .amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.row .sub { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.row.on { background: var(--accent-soft); }
.chev { color: var(--base); }
.summary { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13.5px; margin-bottom: 8px; color: var(--ink2); }
.summary b { font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; font-size: 14px; }
.kind-head { font-weight: 600; background: var(--accent-soft); padding: 7px 12px; display: flex; justify-content: space-between; }
.group-head { font-weight: 600; background: var(--wash); padding: 6px 12px; display: flex; justify-content: space-between; font-size: 14px; }

/* 弹层 */
#sheet-layer, #dialog-layer { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
#dialog-layer { z-index: 30; align-items: center; padding: 20px; }
.sheet { background: var(--surface); width: 100%; max-height: 92%; overflow-y: auto; border-radius: 14px 14px 0 0; padding: 14px 16px calc(var(--safe-b) + 14px); }
.sheet-head { display: flex; align-items: center; margin-bottom: 10px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 17px; }
.close-x { width: 36px; height: 36px; background: none; border: 0; font-size: 22px; color: var(--muted); }
.dialog { background: var(--surface); border-radius: 12px; padding: 16px; width: 100%; max-width: 380px; max-height: 80%; overflow-y: auto; }
.dialog p { margin: 0 0 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.dialog .btn-row { justify-content: flex-end; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 76px); background: #222; color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 14px; z-index: 40; max-width: 88%; }
@media (min-width: 768px) {
  #sheet-layer { align-items: center; padding: 20px; }
  .sheet { max-width: 520px; border-radius: 14px; padding-bottom: 16px; }
}

/* 锁屏和首次设置 */
.gate { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--nav); }
.gate .box { background: var(--surface); border-radius: 14px; padding: 22px; width: 100%; max-width: 400px; }
.gate h1 { margin-bottom: 4px; }
.gate p { color: var(--ink2); font-size: 14px; margin: 0 0 14px; }
.steps { padding-left: 20px; margin: 6px 0 12px; font-size: 14px; color: var(--ink2); }
.log-item { border-top: 1px solid var(--hair); padding: 7px 0; font-size: 13.5px; overflow-wrap: anywhere; }
.log-item:first-child { border-top: 0; }
.dirty { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #eb6834; margin-left: 4px; }
.list-btn { display: flex; width: 100%; padding: 11px 2px; background: none; border: 0; border-top: 1px solid var(--hair); text-align: left; align-items: center; gap: 8px; min-height: 44px; }
.list-btn:first-of-type { border-top: 0; }
