:root {
  --paper: #f4f1eb;
  --ink: #17201d;
  --muted: #68716d;
  --line: rgba(23, 32, 29, .12);
  --card: #fffefa;
  --green: #1f604b;
  --green-deep: #163e33;
  --green-soft: #dce9df;
  --blue: #577a94;
  --orange: #c9733c;
  --danger: #a33f35;
  --radius: 22px;
  --shadow: 0 12px 36px rgba(30, 44, 38, .08);
}

* { box-sizing: border-box; }
html { background: var(--paper); -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Noto Sans SC", sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 11px; font-weight: 750; letter-spacing: .15em; text-transform: uppercase; }
.muted { color: rgba(255,255,255,.64); }

.splash-screen { position: fixed; z-index: 100; inset: 0; min-height: 100svh; overflow: hidden; background: #e8f0fa url("hudadou-loading.png") center center / cover no-repeat; color: #fff; opacity: 1; transition: opacity .32s ease; }
.splash-screen.exit { opacity: 0; pointer-events: none; }
.splash-progress { position: absolute; left: 27px; right: 27px; bottom: calc(29px + env(safe-area-inset-bottom)); height: 3px; overflow: hidden; border-radius: 3px; background: rgba(17,50,116,.16); }
.splash-progress i { display: block; width: 100%; height: 100%; background: #123477; transform: translateX(-100%); animation: splash-loading 2s linear forwards; }
@keyframes splash-loading { to { transform: translateX(0); } }

.login-screen { min-height: 100svh; padding: max(48px, env(safe-area-inset-top)) 28px max(34px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; justify-content: flex-end; background: linear-gradient(to bottom, rgba(7,15,20,.03) 25%, rgba(7,15,20,.28) 54%, rgba(10,27,24,.94) 100%), url("thor-iphone-loading-1179x2556.jpg") center center / cover no-repeat; color: #fff; }
.login-screen .eyebrow { color: #a9c9b8; }
.login-mark { width: 45px; height: 45px; margin-bottom: 18px; border: 1px solid rgba(255,255,255,.42); border-radius: 50%; display: grid; place-items: center; font: 27px/1 Georgia, serif; backdrop-filter: blur(8px); }
.login-screen h1 { max-width: 540px; margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(34px, 9vw, 58px); font-weight: 500; line-height: 1.08; letter-spacing: -.04em; text-shadow: 0 2px 18px rgba(0,0,0,.34); }
.login-form { width: 100%; max-width: 480px; margin-top: 25px; }
.login-form label { display: block; margin-bottom: 10px; color: #b7cdc2; font-size: 13px; }
.field-row { display: flex; gap: 10px; }
.field-row input { min-width: 0; flex: 1; border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.08); color: #fff; }
.field-row input::placeholder { color: rgba(255,255,255,.44); }
.round-button { width: 54px; flex: 0 0 54px; border: 0; border-radius: 17px; background: #f2e9d8; color: var(--green-deep); font-size: 24px; }
.form-error { min-height: 22px; color: #ffb2a6; font-size: 13px; }

.app { max-width: 1180px; min-height: 100svh; margin: 0 auto; padding: 0 18px calc(94px + env(safe-area-inset-bottom)); }
.topbar { padding: max(24px, env(safe-area-inset-top)) 2px 22px; display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 32px; font-weight: 500; letter-spacing: -.03em; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 20px; }
.view { display: none; animation: appear .25s ease; }
.view.active { display: block; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } }

.year-control { margin: -8px 0 10px; display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.year-control label { color: var(--muted); font-size: 12px; }
.year-control select { border: 0; background: transparent; color: var(--green); font-weight: 700; }
.balance-card { position: relative; overflow: hidden; min-height: 205px; padding: 23px; border-radius: 28px; color: #fff; background: linear-gradient(135deg, #285f4c 0%, #183c32 72%); box-shadow: 0 18px 40px rgba(21, 58, 47, .18); }
.balance-card::after { content: ""; position: absolute; width: 230px; height: 230px; right: -80px; top: -110px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 34px rgba(255,255,255,.025), 0 0 0 68px rgba(255,255,255,.02); }
.balance-head, .balance-foot { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.balance-value { position: relative; z-index: 1; margin: 31px 0 26px; font: 500 clamp(42px, 13vw, 64px)/1 Georgia, serif; letter-spacing: -.04em; }
.balance-foot { color: #bbd0c5; }
.text-button { padding: 0; border: 0; background: transparent; color: #fff; font-weight: 650; }

.metrics-grid { margin-top: 13px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
.metric-card { min-height: 132px; padding: 18px; border: 1px solid rgba(23,32,29,.06); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.metric-card span { display: block; color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin: 17px 0 7px; font-family: Georgia, serif; font-size: 26px; font-weight: 500; white-space: nowrap; }
.metric-card small { color: #929a96; font-size: 10px; }
.metric-card.accent-blue { background: #dfe8ed; }
.metric-card.accent-orange { background: #eee3d7; }

.pending-card { margin-top: 13px; padding: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid #e5c2a7; border-radius: var(--radius); background: #f4e7da; }
.pending-card strong { font-size: 14px; }
.pending-card p { margin: 5px 0 0 17px; color: #86644d; font-size: 11px; }
.status-dot { display: inline-block; width: 9px; height: 9px; margin-right: 7px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 4px rgba(201,115,60,.12); }
.pill-button { flex: 0 0 auto; padding: 9px 13px; border: 0; border-radius: 99px; background: #fff; color: #8e4d27; font-size: 12px; font-weight: 700; }

.panel { margin-top: 13px; padding: 21px 18px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.panel-heading, .section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.panel h2, .section-heading h2, .monthly-summary h2, .entry-hero h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 23px; font-weight: 500; }
.chart-average { color: var(--muted); font-size: 11px; }
.chart { min-height: 210px; margin-top: 21px; overflow: hidden; }
.chart svg { width: 100%; height: 210px; overflow: visible; }
.chart .grid-line { stroke: #e7e7e1; stroke-width: 1; }
.chart .area { fill: url(#areaGradient); }
.chart .line { fill: none; stroke: var(--green); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { fill: var(--card); stroke: var(--green); stroke-width: 2; }
.chart text { fill: #8a928e; font-size: 9px; }
.legend { display: flex; align-items: center; gap: 7px; margin-top: 7px; color: var(--muted); font-size: 10px; }
.legend i { width: 18px; height: 3px; border-radius: 2px; background: var(--green); }

.entry-hero { padding: 25px 21px; border-radius: 28px; background: #e2e9e2; }
.entry-hero > p:not(.eyebrow) { margin: 8px 0 26px; color: var(--muted); font-size: 13px; }
form label { display: block; margin: 17px 0 8px; color: var(--muted); font-size: 12px; font-weight: 650; }
form label em { color: #9aa29e; font-style: normal; font-weight: 400; }
input, select { min-height: 50px; width: 100%; padding: 0 15px; border: 1px solid var(--line); border-radius: 14px; outline: none; background: rgba(255,255,255,.82); font-size: 16px; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,96,75,.1); }
.money-input { height: 75px; display: flex; align-items: center; gap: 7px; padding: 0 15px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.82); }
.money-input:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,96,75,.1); }
.money-input span { color: var(--green); font: 24px Georgia, serif; }
.money-input input { height: 70px; min-height: 0; padding: 0; border: 0; box-shadow: none; background: transparent; font: 36px Georgia, serif; }
.money-input input:focus { box-shadow: none; }
.money-input.compact { height: 56px; border-radius: 14px; }
.money-input.compact input { height: 52px; font-size: 27px; }
.primary-button, .secondary-button, .danger-button, .quiet-button { min-height: 52px; width: 100%; margin-top: 20px; border-radius: 15px; font-weight: 720; }
.primary-button { border: 0; background: var(--green); color: #fff; box-shadow: 0 10px 24px rgba(31,96,75,.2); }
.secondary-button { margin-top: 10px; border: 1px solid var(--green); background: transparent; color: var(--green); }
.quiet-button { min-height: 38px; margin-top: 8px; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.danger-button { margin-top: 10px; border: 1px solid rgba(163,63,53,.25); background: transparent; color: var(--danger); }

.section-heading { margin: 31px 3px 14px; align-items: flex-end; }
.download-link { color: var(--green); font-size: 12px; font-weight: 700; text-decoration: none; }
.history-list { display: grid; gap: 9px; }
.history-item { padding: 15px 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; border: 1px solid rgba(23,32,29,.07); border-radius: 17px; background: var(--card); }
.history-main { min-width: 0; display: flex; align-items: center; gap: 11px; }
.history-date { width: 49px; height: 49px; flex: 0 0 49px; display: grid; place-items: center; border-radius: 13px; background: #edf0eb; line-height: 1.05; text-align: center; }
.history-date strong { display: block; font: 19px Georgia, serif; }
.history-date small { color: var(--muted); font-size: 9px; }
.history-copy { min-width: 0; }
.history-copy strong { display: block; font-size: 15px; }
.history-copy small { display: block; overflow: hidden; margin-top: 4px; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.history-amount { align-self: center; font: 19px Georgia, serif; }
.edit-button { grid-column: 2; align-self: center; padding: 5px 0 0; border: 0; background: transparent; color: var(--green); font-size: 11px; }
.recharge-badge { display: inline-block; margin-left: 5px; padding: 3px 6px; border-radius: 99px; background: #f0ddd0; color: #965327; font-size: 9px; font-weight: 700; vertical-align: middle; }
.empty { padding: 28px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; font-size: 13px; }

.monthly-summary { padding: 25px 22px; border-radius: 25px; background: var(--green-deep); color: #fff; }
.monthly-summary .eyebrow { color: #a9c9b8; }
.monthly-summary p:last-child { margin: 11px 0 0; color: #b8cbc3; font-size: 12px; line-height: 1.65; }
.month-cards { margin-top: 13px; display: grid; gap: 10px; }
.month-card { padding: 17px; border: 1px solid rgba(23,32,29,.07); border-radius: 19px; background: var(--card); }
.month-top { display: flex; justify-content: space-between; align-items: baseline; }
.month-top h3 { margin: 0; font: 21px Georgia, "Songti SC", serif; font-weight: 500; }
.month-top strong { font: 21px Georgia, serif; font-weight: 500; }
.month-details { margin-top: 13px; padding-top: 12px; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.month-details div { padding-right: 8px; }
.month-details span { display: block; color: var(--muted); font-size: 9px; }
.month-details b { display: block; margin-top: 5px; font-size: 12px; }

.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); width: calc(100% - 28px); max-width: 440px; height: 68px; padding: 5px 8px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid rgba(255,255,255,.45); border-radius: 23px; background: rgba(250,249,245,.88); box-shadow: 0 15px 40px rgba(23,32,29,.18); backdrop-filter: blur(18px); transform: translateX(-50%); }
.nav-item { border: 0; background: transparent; color: #78817d; font-size: 10px; }
.nav-item span { display: block; }
.nav-icon { margin-bottom: 3px; font-size: 21px; line-height: 24px; }
.nav-item.active { color: var(--green); font-weight: 750; }
.nav-add .nav-icon { width: 37px; height: 37px; margin: -18px auto 1px; display: grid; place-items: center; border: 5px solid var(--paper); border-radius: 50%; background: var(--green); color: #fff; box-sizing: content-box; }

.modal { width: calc(100% - 28px); max-width: 460px; padding: 0; border: 0; border-radius: 27px; background: var(--card); color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(12,25,20,.56); backdrop-filter: blur(5px); }
.modal form { position: relative; padding: 27px 22px 22px; }
.modal h2 { margin: 0; font: 28px Georgia, "Songti SC", serif; font-weight: 500; }
.modal-close { position: absolute; right: 16px; top: 14px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #eeeee9; font-size: 21px; }
.modal-symbol { width: 47px; height: 47px; margin-bottom: 24px; display: grid; place-items: center; border-radius: 50%; background: #ecdfd3; color: var(--orange); font-size: 23px; }
.modal-copy { color: var(--muted); font-size: 13px; line-height: 1.65; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); padding: 11px 16px; border-radius: 99px; background: #17201d; color: #fff; box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 720px) {
  .app { padding-left: 28px; padding-right: 28px; }
  #dashboardView { grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); gap: 16px; }
  #dashboardView.active { display: grid; }
  .year-control { grid-column: 1 / -1; }
  .balance-card { grid-column: 1; }
  .metrics-grid { grid-column: 1; }
  .pending-card { grid-column: 1; }
  .chart-panel { grid-column: 2; grid-row: 2 / span 3; margin-top: 0; }
  .chart { margin-top: 55px; }
  .month-cards { grid-template-columns: repeat(2, 1fr); }
  .entry-hero { max-width: 680px; margin: 0 auto; padding: 34px; }
  .history-list { grid-template-columns: repeat(2, 1fr); }
  .section-heading { margin-left: auto; margin-right: auto; max-width: 1020px; }
}
