:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #7b8794;
  --line: #e4e7eb;
  --teal: #2bb3a3;
  --teal-d: #1f9c8e;
  --orange: #f2a35e;
  --red: #e56363;
  --blue: #4a90d9;
  --shadow: 0 6px 20px rgba(31, 60, 80, .1);
  --radius: 16px;
}
[data-theme="dark"] {
  --bg: #12161c;
  --card: #1e252e;
  --text: #e8ecf0;
  --muted: #9aa5b1;
  --line: #2c3540;
  --teal: #35c7b6;
  --teal-d: #2bb3a3;
  --orange: #f5b276;
  --red: #ef7b7b;
  --blue: #6aa9e8;
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.55;
  max-width: 480px; margin: 0 auto; position: relative;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 15px; }

#app { min-height: 100vh; padding-bottom: 86px; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; }
.topbar .title { font-size: 19px; font-weight: 700; }
.topbar .back { font-size: 22px; color: var(--text); padding: 4px 10px 4px 0; }
.topbar .actions { display: flex; gap: 10px; }

/* cards */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin: 12px 16px; box-shadow: var(--shadow); }
.card h3 { font-size: 16px; }
.row { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 999px; padding: 11px 20px; font-size: 15px; background: var(--teal); color: #fff; cursor: pointer; }
.btn:active { opacity: .85; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-block { width: 100%; }
.btn-orange { background: var(--orange); }
.btn-danger { background: var(--red); }
.btn-lg { padding: 13px 22px; font-size: 16px; }

/* forms */
.field { margin: 14px 18px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; color: var(--text); outline: none;
}
.input:focus { border-color: var(--teal); }

/* segmented tabs */
.tabs { display: flex; gap: 4px; padding: 6px 16px; overflow-x: auto; }
.tab { padding: 8px 14px; border-radius: 8px; color: var(--muted); font-size: 15px; white-space: nowrap; cursor: pointer; }
.tab.active { color: var(--teal); font-weight: 700; background: color-mix(in srgb, var(--teal) 12%, transparent); }

/* bottom nav */
.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: var(--card); border-top: 1px solid var(--line); display: flex; align-items: center; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); z-index: 30; }
.nav-item { flex: 1; text-align: center; color: var(--muted); font-size: 12px; cursor: pointer; }
.nav-item .ico { display: block; font-size: 20px; margin-bottom: 2px; }
.nav-item.active { color: var(--teal); font-weight: 700; }
.nav-fab { flex: 1; text-align: center; }
.nav-fab .fab { width: 54px; height: 54px; border-radius: 50%; background: var(--orange); color: #fff; font-size: 28px; display: inline-flex; align-items: center; justify-content: center; margin-top: -22px; box-shadow: var(--shadow); }

/* list */
.list-item { display: flex; align-items: center; gap: 14px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.avatar { width: 44px; height: 44px; border-radius: 14px; background: color-mix(in srgb, var(--teal) 16%, transparent); display: flex; align-items: center; justify-content: center; font-size: 20px; flex: none; }
.list-main { flex: 1; min-width: 0; }
.list-main h4 { font-size: 15px; }
.list-main p { font-size: 13px; color: var(--muted); }
.row h4 { font-size: 15px; }
.amount-exp { color: var(--teal); font-weight: 700; }
.amount-inc { color: var(--red); font-weight: 700; }

/* stats hero */
.stats-hero { background: linear-gradient(135deg, var(--teal), #5fd6c7); color: #fff; border-radius: var(--radius); margin: 12px 16px; padding: 22px; }
[data-theme="dark"] .stats-hero { background: linear-gradient(135deg, #1f7d72, #2bb3a3); }
.stats-hero .label { opacity: .9; font-size: 14px; }
.stats-hero .big { font-size: 34px; font-weight: 800; margin: 6px 0; }
.stats-hero .sub { display: flex; gap: 22px; font-size: 14px; opacity: .95; }

/* category grid */
.cat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px 6px; padding: 10px 18px; }
.cat-cell { text-align: center; cursor: pointer; }
.cat-cell .cico { width: 48px; height: 48px; margin: 0 auto 6px; border-radius: 16px; background: color-mix(in srgb, var(--teal) 14%, transparent); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.cat-cell.active .cico { background: var(--teal); color: #fff; }
.cat-cell .cname { font-size: 12px; color: var(--muted); }
.cat-cell.active .cname { color: var(--text); font-weight: 700; }

/* keypad */
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 10px 16px 12px; }
.key { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 0; font-size: 17px; text-align: center; cursor: pointer; }
.key.op { color: var(--teal); }
.key.cancel { color: var(--muted); }
.key.enter { background: var(--orange); color: #fff; border-color: var(--orange); }

/* modal */
.mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; display: flex; align-items: flex-end; }
.sheet { width: 100%; max-width: 480px; margin: 0 auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); }
.sheet h3 { margin-bottom: 14px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); background: rgba(0,0,0,.78); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; }
.toast.show { opacity: 1; }

/* bars */
.bar-row { margin: 12px 0; }
.bar-row .bar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.bar-track { height: 8px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--teal); }
.bar-fill.inc { background: var(--red); }

/* badge */
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); margin-left: 6px; }
.badge.teal { background: color-mix(in srgb, var(--teal) 16%, transparent); color: var(--teal); }

/* auth dialog */
.auth-dialog { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 22px; overflow: hidden; background: linear-gradient(160deg, #d9f3ef 0%, #eef6fb 55%, #f5f7fa 100%); }
[data-theme="dark"] .auth-dialog { background: linear-gradient(160deg, #0f201e 0%, #141a22 60%, #12161c 100%); }
.auth-dialog::before { content: ""; position: absolute; width: 340px; height: 340px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--teal) 22%, transparent), transparent 70%); top: -110px; right: -90px; }
.auth-dialog::after { content: ""; position: absolute; width: 280px; height: 280px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--orange) 16%, transparent), transparent 70%); bottom: -100px; left: -80px; }
.auth-modal { position: relative; width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 30px 24px 26px; box-shadow: var(--shadow); animation: dialogIn .28s ease; }
@keyframes dialogIn { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
.auth-logo { width: 64px; height: 64px; border-radius: 20px; background: linear-gradient(135deg, var(--teal), #5fd6c7); margin: 0 auto 18px; }
.auth-title { text-align: center; font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 26px; }
.auth-switch { text-align: center; margin-top: 16px; color: var(--muted); font-size: 14px; }
.auth-switch a { color: var(--teal); }

/* chart svg */
.chart-box { padding: 8px 4px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14px; }

/* settings menu */
.menu-item { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.menu-item:last-child { border-bottom: 0; }
.menu-item .mi { font-size: 20px; }
.menu-item .arrow { color: var(--muted); }

/* home section label */
.section-label { font-size: 15px; font-weight: 700; }

/* lock screen */
.lock-modal { max-width: 320px; }
.lock-dots { display: flex; justify-content: center; gap: 18px; margin: 10px 0 28px; }
.lock-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--teal); background: transparent; }
.lock-dot.filled { background: var(--teal); }
.lock-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.lock-key { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 15px 0; font-size: 20px; text-align: center; cursor: pointer; }
.lock-key:active { opacity: .85; }
.lock-key-op { color: var(--teal); font-size: 17px; }
.lock-dots-6 { gap: 12px; }

/* 模板宫格 */
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 12px 16px; }
.tpl-cell { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 10px; text-align: center; cursor: pointer; box-shadow: var(--shadow); }
.tpl-cell:active { opacity: .85; }
.tpl-icon { font-size: 32px; }
.tpl-name { margin-top: 8px; font-size: 13px; color: var(--text); }

/* 头像选择 */
.avatar-edit { position: relative; cursor: pointer; }
.avatar-badge { position: absolute; right: -4px; bottom: -4px; font-size: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.avatar-pick { width: 44px; height: 44px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 22px; cursor: pointer; }
.avatar-pick.active { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 14%, transparent); }
.avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar-upload { color: var(--teal); }

/* 记一笔吸底区 */
.entry-form { padding-bottom: 190px; }
.entry-pick { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.input-sm { font-size: 14px; padding: 10px 12px; }
.entry-bottom { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: var(--card); border-top: 1px solid var(--line); z-index: 25; padding-bottom: env(safe-area-inset-bottom); }
.entry-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px 0; }
.entry-info { flex: 1; min-width: 0; }
.entry-amount { text-align: left; font-size: 24px; font-weight: 800; color: var(--teal); }
.entry-bottom.is-inc .entry-amount { color: var(--red); }
.entry-cur { font-size: 16px; margin-right: 4px; }
.entry-meta { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-fold { color: var(--muted); font-size: 16px; padding: 0 4px; flex: none; }
.keypad-5 { grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 8px 14px 10px; }
.keypad-5 .key { padding: 8px 0; font-size: 16px; border-radius: 9px; }
.tab.active.inc-tab { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.more-opts { margin: 4px 18px 0; border-top: 1px dashed var(--line); }
.more-opts summary { padding: 12px 0; color: var(--muted); font-size: 14px; cursor: pointer; }
.more-opts .field { margin: 0 0 14px; }

/* 账本密码面板 */
.lock-panel { padding: 30px 22px; }

/* 关于信息 */
.about-card { text-align: center; }
.about-brand { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.about-link { display: inline-block; color: var(--teal); font-size: 13px; margin-bottom: 8px; }
.about-card .small { line-height: 1.7; }
