* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: #f5f6f8; color: #222; font-size: 15px;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100vh; padding-bottom: 64px; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; font-size: 16px; }
input:focus, select:focus { outline: none; }

/* 顶栏 */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: #fff; border-bottom: 1px solid #eee; }
.brand { font-weight: 700; font-size: 16px; color: #00b578; flex: 1; white-space: nowrap; }
.top select { flex: 1; max-width: 190px; border: 1px solid #ddd; border-radius: 8px; padding: 5px 8px; background: #fff; font-size: 13px; }
.ledgerName { font-size: 13px; color: #666; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { color: #999; font-size: 13px; padding: 4px 8px; flex-shrink: 0; }

/* 底部导航 */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; max-width: 520px; margin: 0 auto; display: flex; background: #fff; border-top: 1px solid #eee; padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; color: #999; text-decoration: none; font-size: 11px; }
.tabbar a.on { color: #00b578; }
.tabbar .ni { font-size: 20px; line-height: 1; }

/* 主卡片 */
.hero { background: linear-gradient(135deg, #00b578, #00c48a); color: #fff; margin: 12px 14px; border-radius: 14px; padding: 16px; }
.heroRow { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; opacity: .95; }
.heroRow .big { font-size: 26px; font-weight: 700; }
.heroRow.sub { margin-top: 8px; opacity: .85; }
.monthNav { display: flex; justify-content: space-between; align-items: center; font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.monthNav button { font-size: 20px; color: #fff; padding: 0 10px; }

.formCard, .listCard { background: #fff; border-radius: 14px; margin: 0 14px 12px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.cardTitle { font-size: 14px; color: #888; margin-bottom: 10px; }

/* 记账表单 */
.typeTabs { display: flex; background: #f2f3f5; border-radius: 10px; padding: 3px; margin-bottom: 10px; }
.typeTabs button { flex: 1; padding: 8px 0; border-radius: 8px; font-size: 14px; color: #666; }
.typeTabs button.on { background: #fff; color: #00b578; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.amount { width: 100%; border: none; text-align: center; font-size: 34px; font-weight: 700; padding: 8px 0 4px; color: #222; }
.amount::placeholder { color: #ccc; }
.catGrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 10px 0; max-height: 150px; overflow-y: auto; }
.cat { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; border-radius: 10px; font-size: 11px; color: #555; }
.cat .ci { font-size: 22px; }
.cat.on { background: #e6f9f2; color: #00b578; font-weight: 600; }
.formRow { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid #f5f5f5; }
.formRow label { width: 56px; color: #888; font-size: 13px; flex-shrink: 0; }
.formRow input[type=text], .formRow input[type=date], .formRow select { flex: 1; border: none; background: #f7f8fa; border-radius: 8px; padding: 8px 10px; font-size: 15px; min-width: 0; }
.formRow input[type=checkbox] { width: 20px; height: 20px; accent-color: #00b578; }
.formBtns { display: flex; gap: 8px; margin-top: 12px; }
.formBtns button { flex: 1; padding: 11px 0; border-radius: 10px; font-size: 15px; background: #f2f3f5; color: #555; }
.formBtns .primary { background: #00b578; color: #fff; font-weight: 600; }
.formBtns .danger { background: #fff0f0; color: #e5484d; flex: 0 0 auto; padding: 11px 16px; }

/* 账单列表 */
.dayGroup { margin-bottom: 6px; }
.dayLabel { font-size: 12px; color: #999; padding: 8px 4px 4px; }
.dayLabel span { float: right; color: #ccc; }
.txRow { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid #f7f7f7; cursor: pointer; }
.txRow:last-child { border-bottom: none; }
.txi { width: 38px; height: 38px; border-radius: 50%; background: #f2f3f5; display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
.txMain { flex: 1; min-width: 0; }
.txTitle { font-size: 15px; }
.txSub { font-size: 12px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txAmount { font-weight: 600; font-size: 15px; flex-shrink: 0; }
.txAmount.income { color: #00b578; }
.txAmount.expense { color: #333; }
.txAmount.transfer { color: #999; font-weight: 400; }
.empty { text-align: center; color: #bbb; padding: 24px 0; font-size: 13px; }

/* 账户行 */
.accRow { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid #f7f7f7; cursor: pointer; }
.accRow:last-child { border-bottom: none; }
.accRow .txAmount { color: #222; }

/* 统计 */
.catBar { display: flex; align-items: center; gap: 8px; padding: 7px 0; font-size: 13px; }
.cbName { width: 92px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cbTrack { flex: 1; height: 8px; background: #f2f3f5; border-radius: 4px; overflow: hidden; }
.cbTrack i { display: block; height: 100%; background: #00b578; border-radius: 4px; }
.cbVal { width: 76px; text-align: right; color: #555; }

/* 登录 */
.loginPage { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #e6f9f2, #f5f6f8); }
.loginCard { width: 100%; max-width: 360px; background: #fff; border-radius: 18px; padding: 28px 24px; box-shadow: 0 6px 24px rgba(0,0,0,.06); }
.loginLogo { font-size: 52px; text-align: center; }
.loginCard h1 { text-align: center; color: #00b578; margin: 6px 0 2px; }
.sub { text-align: center; color: #999; font-size: 12px; margin-bottom: 18px; }
.loginCard .tabs { display: flex; background: #f2f3f5; border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.loginCard .tabs button { flex: 1; padding: 8px; border-radius: 8px; color: #666; font-size: 14px; }
.loginCard .tabs button.on { background: #fff; color: #00b578; font-weight: 600; }
.loginCard input { width: 100%; border: 1px solid #eee; background: #fafbfc; border-radius: 10px; padding: 11px 12px; margin-bottom: 10px; font-size: 15px; }
.loginCard .primary { width: 100%; padding: 12px; border-radius: 10px; background: #00b578; color: #fff; font-size: 16px; font-weight: 600; }
.tip { text-align: center; color: #bbb; font-size: 12px; margin-top: 12px; }

/* toast */
#toast { position: fixed; left: 50%; top: 14%; transform: translateX(-50%) translateY(-8px); background: rgba(0,0,0,.78); color: #fff; padding: 9px 18px; border-radius: 20px; font-size: 13px; opacity: 0; transition: all .25s; pointer-events: none; z-index: 99; max-width: 86%; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: rgba(229,72,77,.9); }
