:root {
  color-scheme: light;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-soft: #f7f8fb;
  --ink: #151923;
  --muted: #7b8496;
  --line: #e8ebf1;
  --primary: #335cff;
  --primary-dark: #2446dc;
  --navy: #121827;
  --success: #0f9f6e;
  --warning: #ee8b25;
  --danger: #e5484d;
  --radius: 22px;
  --shadow: 0 12px 34px rgba(25, 35, 62, .08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); min-height: 100%; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select { min-width: 0; }
.hidden { display: none !important; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon fill { fill: currentColor; stroke: none; }
.eyebrow { margin: 0 0 5px; color: var(--primary); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.eyebrow.light { color: rgba(255,255,255,.62); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; line-height: 1.15; letter-spacing: -.03em; }
h2 { margin-bottom: 0; font-size: 18px; letter-spacing: -.02em; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 16px; border-radius: 14px; background: #eef1f7;
  font-size: 14px; font-weight: 700; transition: transform .15s ease, background .15s ease, opacity .15s ease;
}
.button:active { transform: scale(.97); }
.button.primary { color: #fff; background: linear-gradient(135deg, #4269ff, #2748dd); box-shadow: 0 8px 20px rgba(51, 92, 255, .25); }
.button.secondary { color: var(--primary); background: #edf1ff; }
.button.light { color: var(--navy); background: #fff; }
.button.ghost-light { color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); }
.button.wide { width: 100%; }
.button.danger-text { color: var(--danger); background: #fff2f2; }
.icon-button {
  width: 42px; height: 42px; padding: 0; display: inline-grid; place-items: center;
  color: var(--ink); background: var(--surface); border-radius: 14px; box-shadow: 0 4px 14px rgba(24,33,55,.06);
}
.icon-button.filled { color: #fff; background: var(--primary); }
.text-button { padding: 7px 0; color: var(--primary); background: transparent; font-size: 13px; font-weight: 700; }
.text-button.centered { display: block; margin: 12px auto 0; }
.form-error { min-height: 20px; margin: 10px 0 0; color: #ffbdbd; font-size: 13px; text-align: center; }

.login-view {
  position: relative; min-height: 100vh; overflow: hidden; display: grid; place-items: center;
  padding: 28px 20px calc(28px + env(safe-area-inset-bottom)); color: #fff;
  background: radial-gradient(circle at 80% 10%, #293661 0, #121827 38%, #0b0f19 100%);
}
.login-orbit { position: absolute; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; }
.orbit-one { width: 420px; height: 420px; top: -210px; right: -180px; }
.orbit-two { width: 280px; height: 280px; bottom: -120px; left: -130px; }
.login-panel { position: relative; z-index: 1; width: 100%; max-width: 390px; text-align: center; }
.brand-mark { width: 38px; height: 38px; position: relative; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: linear-gradient(145deg, #466bff, #213fc7); box-shadow: 0 8px 24px rgba(51,92,255,.3); }
.brand-mark span { position: absolute; width: 17px; height: 11px; border: 2px solid #fff; border-radius: 3px; }
.brand-mark span:first-child { transform: translateY(-3px); opacity: .55; }
.brand-mark span:last-child { transform: translateY(3px); }
.brand-mark.large { width: 62px; height: 62px; margin-bottom: 26px; border-radius: 19px; }
.brand-mark.large span { width: 28px; height: 18px; border-width: 3px; border-radius: 5px; }
.brand-mark.large span:first-child { transform: translateY(-5px); }
.brand-mark.large span:last-child { transform: translateY(5px); }
.login-panel h1 { margin: 0 0 12px; font-size: 42px; font-weight: 800; letter-spacing: -.05em; }
.login-copy { margin-bottom: 34px; color: rgba(255,255,255,.66); font-size: 16px; line-height: 1.7; }
.login-form { padding: 20px; text-align: left; border: 1px solid rgba(255,255,255,.08); border-radius: 24px; background: rgba(255,255,255,.06); backdrop-filter: blur(20px); }
.login-form label { display: block; margin: 0 0 8px; color: rgba(255,255,255,.72); font-size: 12px; font-weight: 700; }
.input-with-icon { position: relative; margin-bottom: 14px; }
.input-with-icon .icon { position: absolute; left: 14px; top: 50%; width: 18px; transform: translateY(-50%); color: rgba(255,255,255,.42); }
.input-with-icon input { width: 100%; height: 50px; padding: 0 14px 0 43px; color: #fff; border: 1px solid rgba(255,255,255,.1); outline: 0; border-radius: 14px; background: rgba(0,0,0,.16); }
.input-with-icon input:focus { border-color: rgba(109,139,255,.8); box-shadow: 0 0 0 3px rgba(74,108,255,.18); }
.privacy-note { margin: 18px 0 0; color: rgba(255,255,255,.38); font-size: 11px; }

.app-shell { width: 100%; max-width: 520px; min-height: 100vh; margin: 0 auto; padding-bottom: calc(92px + var(--safe-bottom)); }
.topbar {
  position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 18px 12px; background: rgba(243,245,249,.86); backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand strong { display: block; font-size: 16px; letter-spacing: -.02em; }
.brand small { display: block; margin-top: -2px; color: var(--muted); font-size: 10px; }
.topbar-actions { display: flex; gap: 8px; }
#syncButton.spinning .icon { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page { display: none; padding: 8px 16px 20px; animation: pageIn .25s ease; }
.page.active { display: block; }
@keyframes pageIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.hero-card { position: relative; overflow: hidden; padding: 24px 22px 20px; color: #fff; border-radius: 28px; background: linear-gradient(145deg, #1b2440 0%, #111726 70%); box-shadow: 0 18px 40px rgba(18,24,39,.2); }
.hero-glow { position: absolute; width: 220px; height: 220px; right: -70px; top: -100px; border-radius: 50%; background: radial-gradient(circle, rgba(82,113,255,.65), rgba(82,113,255,0) 68%); }
.hero-amount { position: relative; display: flex; align-items: flex-start; gap: 6px; margin: 5px 0 9px; }
.hero-amount span { padding-top: 8px; color: rgba(255,255,255,.7); font-size: 20px; font-weight: 600; }
.hero-amount strong { font-size: clamp(40px, 12vw, 56px); line-height: 1; letter-spacing: -.055em; }
.hero-meta { position: relative; display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.62); font-size: 12px; }
.dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; }
.hero-actions { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 12px 0 24px; }
.metric-card { min-width: 0; padding: 13px 12px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.metric-card span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.metric-card strong { display: block; overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.metric-card.warning strong { color: var(--warning); }
.metric-card.danger strong { color: var(--danger); }
.metric-card.success strong { color: var(--success); }
.content-section { margin-top: 8px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin: 0 3px 12px; }
.bill-list { display: grid; gap: 11px; }
.bill-card {
  position: relative; display: block; width: 100%; padding: 17px; text-align: left; overflow: hidden;
  border: 1px solid var(--line); border-radius: 21px; background: var(--surface); box-shadow: 0 6px 20px rgba(26,34,54,.04);
  transition: transform .16s ease, box-shadow .16s ease;
}
.bill-card:active { transform: scale(.985); }
.bill-card.overdue { border-color: #ffd9d9; }
.bill-card.paid { opacity: .68; }
.bill-card::before { content: ''; position: absolute; left: 0; top: 20px; bottom: 20px; width: 3px; border-radius: 0 4px 4px 0; background: var(--bank-color, var(--primary)); }
.bill-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bill-identity { display: flex; align-items: center; min-width: 0; gap: 11px; }
.bank-logo { flex: 0 0 auto; width: 39px; height: 39px; display: grid; place-items: center; color: #fff; border-radius: 13px; background: var(--bank-color, #65708a); font-size: 12px; font-weight: 800; box-shadow: inset 0 -6px 12px rgba(0,0,0,.08); }
.bill-identity strong { display: block; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.bill-identity small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.due-pill { flex: 0 0 auto; padding: 5px 9px; color: var(--primary); border-radius: 999px; background: #eef1ff; font-size: 10px; font-weight: 800; }
.due-pill.warning { color: #a85e05; background: #fff2dd; }
.due-pill.danger { color: #c62f35; background: #ffe8e9; }
.due-pill.paid { color: #13835c; background: #e4f7ef; }
.bill-money { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 16px; }
.bill-money small { display: block; margin-bottom: 1px; color: var(--muted); font-size: 10px; }
.bill-money strong { font-size: 24px; letter-spacing: -.035em; }
.bill-money .paid-label { color: var(--success); font-size: 16px; }
.progress-track { width: 100%; height: 5px; margin-top: 14px; overflow: hidden; border-radius: 999px; background: #edf0f5; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #6c8bff); transition: width .35s ease; }
.bill-foot { display: flex; justify-content: space-between; margin-top: 9px; color: var(--muted); font-size: 10px; }
.empty-state { padding: 36px 20px; text-align: center; color: var(--muted); border: 1px dashed #dfe3eb; border-radius: 21px; background: rgba(255,255,255,.48); }
.empty-state .empty-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 12px; color: #8b95a9; border-radius: 18px; background: #e9edf4; }
.empty-state h3 { margin-bottom: 5px; color: #515b6e; font-size: 15px; }
.empty-state p { margin-bottom: 0; font-size: 12px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; margin: 10px 4px 20px; }
.filter-bar { display: flex; gap: 8px; margin: 0 -16px 15px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip { flex: 0 0 auto; min-height: 36px; padding: 0 14px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 12px; font-weight: 700; }
.filter-chip.active { color: #fff; border-color: var(--navy); background: var(--navy); }
.settings-group { margin-bottom: 14px; padding: 17px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 5px 18px rgba(25,35,62,.035); }
.settings-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.settings-title h2 { font-size: 16px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; min-height: 58px; padding: 10px 0; text-align: left; background: transparent; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row strong { display: block; font-size: 14px; }
.setting-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.setting-row.button-row { color: inherit; }
.button-row .icon.chevron { flex: 0 0 auto; color: #abb2c0; }
.row-icon { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center; color: var(--primary); border-radius: 13px; background: #eef1ff; }
.button-row > div:nth-child(2) { flex: 1; }
.stack-list { display: grid; gap: 9px; }
.mailbox-card { display: flex; align-items: center; gap: 12px; padding: 13px; border-radius: 16px; background: var(--surface-soft); }
.mailbox-card .row-icon { color: #fff; background: linear-gradient(145deg, #3f64fc, #2948d5); }
.mailbox-info { min-width: 0; flex: 1; }
.mailbox-info strong { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.mailbox-info small { display: block; overflow: hidden; margin-top: 2px; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.mailbox-card .text-button { flex: 0 0 auto; }
.helper { margin: 11px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.switch { position: relative; flex: 0 0 auto; width: 47px; height: 28px; }
.switch input { position: absolute; opacity: 0; }
.switch span { display: block; width: 100%; height: 100%; border-radius: 999px; background: #d9dee8; transition: .2s ease; }
.switch span::after { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 2px 7px rgba(0,0,0,.16); transition: .2s ease; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(19px); }
.compact-select { flex: 0 0 auto; padding: 8px 10px; border: 1px solid var(--line); outline: 0; border-radius: 11px; background: var(--surface-soft); font-size: 12px; }
.danger-zone { border-color: #f3dddf; }
.version { margin: 24px 0 8px; color: #a4acbb; font-size: 10px; text-align: center; }
.bottom-nav {
  position: fixed; z-index: 30; left: 50%; bottom: 0; width: min(100%, 520px); transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(3, 1fr); padding: 8px 16px calc(8px + var(--safe-bottom));
  border-top: 1px solid rgba(224,228,236,.8); background: rgba(255,255,255,.92); backdrop-filter: blur(20px);
}
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 50px; padding: 4px 0; color: #969eae; border-radius: 14px; background: transparent; font-size: 10px; font-weight: 700; }
.nav-item .icon { width: 21px; height: 21px; }
.nav-item.active { color: var(--primary); }
.nav-item.active .icon { filter: drop-shadow(0 3px 7px rgba(51,92,255,.27)); }

.backdrop { position: fixed; z-index: 40; inset: 0; background: rgba(8,12,22,.5); backdrop-filter: blur(3px); animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 50; left: 50%; bottom: 0; width: min(100%, 520px); max-height: 92vh; overflow-y: auto; transform: translateX(-50%);
  padding: 28px 20px calc(24px + var(--safe-bottom)); border-radius: 28px 28px 0 0; background: #fff; box-shadow: 0 -18px 50px rgba(15,22,38,.18);
  animation: sheetIn .25s cubic-bezier(.22,.75,.25,1);
}
@keyframes sheetIn { from { transform: translate(-50%, 30px); opacity: .4; } }
.sheet-handle { width: 38px; height: 4px; margin: -14px auto 18px; border-radius: 999px; background: #dfe3eb; }
.sheet-close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; box-shadow: none; background: #f1f3f7; }
.sheet > h2 { margin-right: 42px; font-size: 22px; }
.sheet-intro { margin: 8px 42px 20px 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.form-stack { display: grid; gap: 14px; margin-top: 20px; }
.form-stack label { display: grid; gap: 7px; color: #5c6576; font-size: 12px; font-weight: 700; }
.form-stack input, .form-stack select {
  width: 100%; height: 48px; padding: 0 13px; color: var(--ink); border: 1px solid #dfe3eb; outline: 0; border-radius: 13px; background: #f9fafc; font-size: 15px;
}
.form-stack input:focus, .form-stack select:focus { border-color: #7e96ff; background: #fff; box-shadow: 0 0 0 3px rgba(51,92,255,.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bill-sheet-banner { padding: 18px; color: #fff; border-radius: 21px; background: linear-gradient(145deg, var(--bank-color, #435bcc), #1b2339); }
.bill-sheet-banner small { color: rgba(255,255,255,.62); }
.bill-sheet-banner .amount { margin: 4px 0 13px; font-size: 34px; font-weight: 800; letter-spacing: -.045em; }
.bill-sheet-banner .meta { display: flex; justify-content: space-between; font-size: 11px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0 20px; }
.detail-item { padding: 12px; border-radius: 14px; background: #f6f7fa; }
.detail-item span { display: block; color: var(--muted); font-size: 10px; }
.detail-item strong { display: block; margin-top: 3px; font-size: 13px; }
.sheet-section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 11px; }
.sheet-section-title h3 { margin: 0; font-size: 15px; }
.payment-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.payment-row:last-child { border-bottom: 0; }
.payment-row .row-icon { width: 34px; height: 34px; color: var(--success); background: #e7f7f0; }
.payment-row .payment-info { flex: 1; }
.payment-row strong { display: block; font-size: 13px; }
.payment-row small { display: block; color: var(--muted); font-size: 10px; }
.payment-row .icon-button { width: 32px; height: 32px; color: #a2a9b7; box-shadow: none; background: #f4f5f8; }
.payment-form { display: grid; gap: 10px; padding: 14px; border-radius: 17px; background: #f6f7fa; }
.payment-form .form-row { grid-template-columns: 1.2fr .8fr; }
.payment-form input, .payment-form select { height: 43px; border: 1px solid #e1e5ec; border-radius: 12px; outline: 0; background: #fff; padding: 0 11px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.warn-box { margin: 12px 0; padding: 12px; color: #8c5a12; border-radius: 13px; background: #fff6e5; font-size: 11px; }
.parse-note { margin-top: 10px; color: var(--muted); font-size: 10px; }
.toast {
  position: fixed; z-index: 80; left: 50%; bottom: calc(102px + var(--safe-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 40px); padding: 11px 16px; color: #fff; border-radius: 13px; background: rgba(18,24,39,.92); box-shadow: 0 8px 30px rgba(0,0,0,.2); font-size: 12px; text-align: center;
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }
.loading { position: fixed; z-index: 70; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #fff; background: rgba(15,20,34,.72); backdrop-filter: blur(5px); font-size: 12px; }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.22); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }

@media (min-width: 700px) {
  body { background: #e9edf4; }
  .app-shell { margin-top: 16px; margin-bottom: 16px; min-height: calc(100vh - 32px); border-radius: 32px; overflow: hidden; background: var(--bg); box-shadow: 0 24px 70px rgba(23,31,52,.16); }
  .topbar { border-radius: 32px 32px 0 0; }
  .bottom-nav { bottom: 16px; border-radius: 0 0 28px 28px; }
}
@media (max-width: 360px) {
  .page { padding-left: 12px; padding-right: 12px; }
  .metric-card { padding: 11px 9px; }
  .metric-card strong { font-size: 14px; }
  .hero-card { padding-left: 18px; padding-right: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
/* Bank theme variables are classes so the strict CSP never needs inline styles. */
.bank-icbc { --bank-color: #d71920; }
.bank-ccb { --bank-color: #0066b3; }
.bank-abc { --bank-color: #008566; }
.bank-boc { --bank-color: #b01f24; }
.bank-cmb { --bank-color: #c4161c; }
.bank-bocom { --bank-color: #1b4f9c; }
.bank-citic { --bank-color: #d5252d; }
.bank-spdb { --bank-color: #254f9b; }
.bank-cmbc { --bank-color: #008b7b; }
.bank-cebbank { --bank-color: #7b2c8f; }
.bank-pingan { --bank-color: #f15a24; }
.bank-cib { --bank-color: #174c8b; }
.bank-cgb { --bank-color: #e62d36; }
.bank-hxb { --bank-color: #d51e2a; }
.bank-psbc { --bank-color: #006f3c; }
.bank-beijing { --bank-color: #004ea2; }
.bank-bosc { --bank-color: #0069aa; }
.bank-hcrcb { --bank-color: #00865a; }
.bank-other, .bank-manual { --bank-color: #5b6472; }
.success-box { color: #0b7a55; background: #e8f8f1; }
.progress-0 { width: 0%; }
.progress-5 { width: 5%; }
.progress-10 { width: 10%; }
.progress-15 { width: 15%; }
.progress-20 { width: 20%; }
.progress-25 { width: 25%; }
.progress-30 { width: 30%; }
.progress-35 { width: 35%; }
.progress-40 { width: 40%; }
.progress-45 { width: 45%; }
.progress-50 { width: 50%; }
.progress-55 { width: 55%; }
.progress-60 { width: 60%; }
.progress-65 { width: 65%; }
.progress-70 { width: 70%; }
.progress-75 { width: 75%; }
.progress-80 { width: 80%; }
.progress-85 { width: 85%; }
.progress-90 { width: 90%; }
.progress-95 { width: 95%; }
.progress-100 { width: 100%; }