@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Patrick+Hand&display=swap');

:root {
  --paper: #f5f0e8;
  --paper-deep: #e9dfd1;
  --surface: #fffdf8;
  --surface-strong: #fffaf0;
  --ink: #33322f;
  --muted: #89847d;
  --line: #ddd2c3;
  --coral: #e97568;
  --coral-dark: #bd5149;
  --coral-soft: #f8ddd7;
  --mint: #89b9a6;
  --mint-soft: #dfeee6;
  --yellow: #f5c866;
  --blue: #78a2be;
  --shadow: 0 8px 20px rgba(92, 73, 53, 0.09);
  --radius: 18px;
  --font-body: 'Nunito', 'Microsoft YaHei', sans-serif;
  --font-hand: 'Patrick Hand', 'KaiTi', cursive;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(92, 73, 53, .06) .7px, transparent .7px);
  background-size: 8px 8px;
}
button, input { font: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(120, 162, 190, .55); outline-offset: 2px; }

.app-shell, .login-shell { width: min(100%, 620px); margin: 0 auto; padding: 24px 18px 110px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 3px 0 22px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { letter-spacing: .01em; }
h1 { font-size: 26px; line-height: 1.1; font-weight: 800; }
h2 { font-size: 25px; line-height: 1.1; }
h3 { font-size: 17px; }
.eyebrow, .section-kicker { color: var(--coral-dark); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.eyebrow { margin-bottom: 7px; }
.section-kicker { margin-bottom: 8px; }
.muted-label { color: var(--muted); font-size: 13px; margin-bottom: 2px; }
.muted-label, .page-subtitle, .group-heading p, .settings-note p { line-height: 1.55; }
.page-subtitle { color: var(--muted); font-size: 14px; margin-top: 10px; }
.icon-button { width: 38px; height: 38px; border-radius: 50%; color: var(--coral-dark); background: var(--coral-soft); font-size: 20px; display: inline-grid; place-items: center; transition: transform .18s ease, background .18s ease; }
.icon-button:hover { transform: rotate(-5deg) scale(1.04); background: #f5c9c1; }

.date-strip { display: flex; align-items: center; gap: 10px; margin: 0 1px 14px; font-size: 13px; color: var(--muted); }
.day-stamp { background: var(--yellow); color: #76541b; font-weight: 800; padding: 4px 10px; transform: rotate(-2deg); border-radius: 5px 8px 4px 7px; }
.sync-dot { margin-left: auto; color: #6c9c83; font-size: 11px; }
.sync-dot::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--mint); margin-right: 5px; vertical-align: 1px; }

.paper-card { background: var(--surface); border: 1px solid rgba(182, 160, 135, .38); box-shadow: var(--shadow); }
.budget-sheet { position: relative; overflow: hidden; padding: 24px 20px 16px; border-radius: 8px 18px 15px 12px; transform: rotate(-.25deg); }
.budget-sheet::after { content: ''; position: absolute; right: -28px; bottom: -42px; width: 128px; height: 128px; border: 2px solid rgba(233, 117, 104, .14); border-radius: 50%; transform: rotate(18deg); }
.tape { position: absolute; top: -9px; width: 74px; height: 22px; background: rgba(245, 200, 102, .46); transform: rotate(-6deg); }
.tape-left { left: 17px; }.tape-right { right: 18px; transform: rotate(8deg); background: rgba(137, 185, 166, .42); }
.budget-row { display: flex; align-items: end; justify-content: space-between; gap: 16px; position: relative; z-index: 1; }
.budget-amount { margin-top: 2px; font-family: var(--font-hand); font-size: 56px; line-height: .95; color: var(--coral-dark); letter-spacing: .01em; }
.budget-amount::first-letter { font-size: .55em; }
.primary-button, .save-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 46px; padding: 0 17px; border-radius: 12px 15px 11px 14px; color: #fffdf8; background: var(--coral); box-shadow: 0 4px 0 var(--coral-dark); font-weight: 800; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.primary-button:hover, .save-button:hover { transform: translateY(-2px) rotate(-.5deg); box-shadow: 0 6px 0 var(--coral-dark); background: #df665c; }
.primary-button:active, .save-button:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--coral-dark); }
.button-spark { font-size: 18px; line-height: 1; }
.budget-metrics { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 24px; padding-top: 13px; border-top: 1px dashed var(--line); }
.budget-metrics div:not(.metric-divider) { display: flex; flex-direction: column; gap: 4px; }
.budget-metrics div:last-child { text-align: right; }
.budget-metrics span { color: var(--muted); font-size: 12px; }
.budget-metrics strong { font-size: 17px; }
.budget-metrics strong.negative { color: var(--coral-dark); }
.metric-divider { width: 1px; height: 28px; background: var(--line); }
.budget-events { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; min-height: 0; }
.budget-event { color: var(--muted); font-size: 11px; background: var(--paper); padding: 3px 7px; border-radius: 20px; }

.ledger-section { margin-top: 29px; }
.section-heading, .history-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.round-button { width: 45px; height: 45px; border-radius: 50%; color: #fff; background: var(--mint); font-size: 30px; line-height: 1; box-shadow: 0 4px 0 #5f967f; transition: transform .18s ease; }
.round-button:hover { transform: rotate(7deg) scale(1.05); }
.expense-list { display: grid; gap: 10px; margin-top: 15px; }
.expense-item { display: grid; grid-template-columns: 43px minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 12px 13px; background: rgba(255, 253, 248, .8); border-bottom: 1px solid var(--line); }
.expense-item.voided { opacity: .45; }
.expense-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 13px 10px 12px 9px; background: var(--mint-soft); color: #4f8e76; font-size: 18px; }
.expense-icon.alipay { background: #e4eef4; color: #4f83a1; }.expense-icon.cash { background: #fff1cd; color: #9f7824; }
.expense-meta { min-width: 0; }.expense-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }.expense-meta small { color: var(--muted); font-size: 11px; }.expense-amount { color: var(--ink); font-weight: 800; font-size: 15px; }.expense-amount.voided { text-decoration: line-through; }
.expense-thumb { width: 34px; height: 34px; object-fit: cover; border-radius: 8px; margin-left: 5px; }
.empty-note { padding: 25px 10px; color: var(--muted); text-align: center; font-size: 13px; }

.page-heading { margin: 8px 1px 22px; }.page-heading h2 { font-size: 34px; font-family: var(--font-hand); font-weight: 400; }
.treasury-total { padding: 24px 21px; border-radius: 17px 9px 14px 11px; background: var(--mint-soft); border-color: rgba(95, 150, 127, .28); transform: rotate(.25deg); }.treasury-total span, .treasury-total small { display: block; color: #5e8a78; font-size: 12px; }.treasury-total strong { display: block; margin: 5px 0 3px; color: #4f8e76; font-family: var(--font-hand); font-size: 50px; line-height: 1; }.treasury-total strong.negative { color: var(--coral-dark); }.treasury-total small { color: var(--muted); }
.history-heading { margin-top: 31px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }.history-heading h3 { font-family: var(--font-hand); font-size: 22px; font-weight: 400; }.history-heading span { color: var(--muted); font-size: 12px; }
.history-list { display: grid; gap: 9px; margin-top: 12px; }.history-item { width: 100%; display: grid; grid-template-columns: 75px minmax(0,1fr) auto; gap: 12px; align-items: center; text-align: left; padding: 14px 12px; color: var(--ink); background: rgba(255,253,248,.76); border-bottom: 1px dashed var(--line); }.history-date { font-weight: 800; font-size: 13px; }.history-date small { display: block; color: var(--muted); font-size: 10px; font-weight: 400; margin-top: 3px; }.history-main { min-width: 0; }.history-main small { display: block; color: var(--muted); font-size: 11px; }.history-main strong { display: block; font-size: 15px; margin-top: 2px; }.history-main strong.negative, .history-balance.negative { color: var(--coral-dark); }.history-balance { color: #5c967c; font-weight: 800; font-size: 14px; text-align: right; }

.settings-group { padding: 19px 1px 22px; border-bottom: 1px dashed var(--line); }.group-heading { display: flex; gap: 11px; align-items: start; }.group-icon { width: 33px; height: 33px; display: grid; place-items: center; border-radius: 11px; color: var(--coral-dark); background: var(--coral-soft); font-size: 18px; }.group-heading h3 { margin: 2px 0 4px; }.group-heading p { color: var(--muted); font-size: 12px; }
.range-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 17px; }.range-grid label, .login-form label, .expense-dialog label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }.range-grid input, .login-form input, .expense-dialog input[type='text'], .expense-dialog input[type='date'], .expense-dialog input[type='number'], .add-method-row input { width: 100%; min-height: 43px; border: 1px solid var(--line); border-radius: 10px 8px 11px 9px; background: var(--surface); color: var(--ink); padding: 0 11px; font-size: 14px; }.range-grid input:focus, .login-form input:focus, .expense-dialog input:focus, .add-method-row input:focus { border-color: var(--blue); }
.save-button { min-height: 40px; margin-top: 14px; font-size: 12px; }.save-button.compact { margin-top: 0; min-width: 66px; }.method-list { display: grid; gap: 8px; margin-top: 15px; }.method-row { display: flex; align-items: center; gap: 10px; min-height: 45px; padding: 6px 9px; background: rgba(255,253,248,.65); border: 1px solid rgba(221,210,195,.7); border-radius: 10px; }.method-row span { flex: 1; font-size: 13px; }.method-row input { width: 17px; height: 17px; accent-color: var(--mint); }.method-edit { color: var(--blue); background: transparent; font-size: 12px; }.add-method-row { display: flex; gap: 8px; margin-top: 10px; }.add-method-row input { flex: 1; }.settings-note { margin-top: 20px; padding: 14px 15px; border-left: 3px solid var(--yellow); background: rgba(255, 250, 240, .7); }.settings-note strong { font-size: 13px; }.settings-note p { margin-top: 4px; color: var(--muted); font-size: 12px; }

.bottom-nav { position: fixed; z-index: 5; bottom: 12px; left: 50%; width: min(calc(100% - 30px), 480px); display: grid; grid-template-columns: repeat(3, 1fr); padding: 7px; transform: translateX(-50%); background: rgba(255,253,248,.93); border: 1px solid rgba(185,165,142,.46); border-radius: 19px 14px 18px 13px; box-shadow: 0 9px 30px rgba(92,73,53,.15); backdrop-filter: blur(12px); }.nav-item { display: grid; place-items: center; gap: 2px; min-height: 52px; color: var(--muted); background: transparent; border-radius: 13px; }.nav-item span { font-size: 21px; line-height: 1; }.nav-item small { font-size: 11px; }.nav-item.active { color: var(--coral-dark); background: var(--coral-soft); transform: rotate(-1deg); }

.login-shell { min-height: 100vh; display: grid; align-content: center; justify-items: center; text-align: center; padding: 30px 28px; }.login-shell h1 { font-family: var(--font-hand); font-size: 44px; font-weight: 400; }.login-copy { max-width: 290px; margin: 12px auto 27px; color: var(--muted); font-size: 14px; line-height: 1.7; }.login-doodle { position: relative; width: 142px; height: 86px; margin-bottom: 7px; color: var(--coral); font-family: var(--font-hand); }.login-doodle span { position: absolute; font-size: 37px; }.login-doodle span:first-child { top: 14px; left: 36px; transform: rotate(-16deg); }.login-doodle span:nth-child(2) { top: 0; right: 18px; color: var(--yellow); font-size: 27px; }.login-doodle span:last-child { bottom: 1px; left: 20px; color: var(--mint); font-size: 25px; }.login-form { width: min(100%, 340px); display: grid; gap: 13px; text-align: left; }.login-form .primary-button { margin-top: 6px; }.full-width { width: 100%; }.form-error { color: var(--coral-dark); font-size: 12px; text-align: center; }

dialog { border: 0; padding: 0; color: var(--ink); background: var(--surface); box-shadow: 0 20px 60px rgba(57, 42, 28, .25); }.expense-dialog { width: min(calc(100% - 28px), 470px); border-radius: 17px 11px 16px 12px; }.history-dialog { width: min(calc(100% - 28px), 520px); max-height: 84vh; overflow: auto; border-radius: 15px 10px 16px 12px; }.expense-dialog::backdrop, .history-dialog::backdrop { background: rgba(49, 40, 32, .36); backdrop-filter: blur(3px); }.expense-dialog form, .history-dialog { padding: 22px 19px 20px; }.dialog-top { display: flex; align-items: start; justify-content: space-between; margin-bottom: 20px; }.dialog-top h2 { font-family: var(--font-hand); font-size: 29px; font-weight: 400; }.close-dialog, .close-history { background: var(--paper); color: var(--muted); }.amount-field > span { display: flex; align-items: center; gap: 5px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-strong); }.amount-field b { font-family: var(--font-hand); font-size: 29px; color: var(--coral-dark); }.amount-field input { min-height: 60px !important; border: 0 !important; padding: 0 !important; background: transparent !important; font-family: var(--font-hand); font-size: 40px !important; }.expense-dialog form > label:not(.amount-field) { margin-top: 14px; }.field-label { margin-top: 15px; color: var(--muted); font-size: 12px; font-weight: 700; }.method-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 7px; }.method-chip { min-height: 37px; padding: 0 12px; border: 1px solid var(--line); border-radius: 20px; color: var(--muted); background: var(--surface); font-size: 12px; }.method-chip.selected { color: #477c68; background: var(--mint-soft); border-color: #93c5b1; font-weight: 800; }.upload-field { position: relative; display: flex !important; align-items: center; justify-content: space-between; margin-top: 15px; min-height: 42px; }.upload-field span:first-child { display: grid; gap: 3px; color: var(--muted); }.upload-field small { font-size: 10px; font-weight: 400; }.upload-field input { position: absolute; inset: 0; z-index: 2; opacity: 0; cursor: pointer; }.upload-button { padding: 7px 10px; color: var(--blue); background: #e4eef4; border-radius: 8px; font-size: 12px; }.image-preview { margin-top: 10px; }.image-preview img { width: 76px; height: 76px; border-radius: 9px; object-fit: cover; }.expense-dialog .primary-button { margin-top: 20px; }.danger-button { min-height: 40px; margin-top: 12px; color: var(--coral-dark); background: var(--coral-soft); border-radius: 10px; font-weight: 800; }.history-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 16px; }.history-summary div { padding: 10px 9px; background: var(--paper); border-radius: 9px; }.history-summary span { display: block; color: var(--muted); font-size: 10px; }.history-summary strong { display: block; margin-top: 4px; font-size: 14px; }.history-summary strong.negative { color: var(--coral-dark); }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 91px; max-width: calc(100% - 40px); padding: 10px 14px; color: #fff; background: rgba(51,50,47,.92); border-radius: 10px; font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .2s ease, transform .2s ease; }.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) { .app-shell { padding-top: 36px; }.bottom-nav { bottom: 22px; }.budget-amount { font-size: 64px; } }
@media (max-width: 390px) { .app-shell, .login-shell { padding-left: 14px; padding-right: 14px; }.budget-row { align-items: center; }.budget-amount { font-size: 49px; }.primary-button { padding: 0 13px; }.range-grid { gap: 6px; }.range-grid input { padding: 0 7px; font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }
