:root {
  color-scheme: light;
  --bg: #f5f2e9;
  --paper: #fffdf8;
  --ink: #193a2e;
  --muted: #687b70;
  --green: #14583f;
  --green-dark: #0d4934;
  --green-soft: #e8f1e7;
  --coral: #dc6f5a;
  --coral-soft: #fff0e9;
  --line: #e6e4da;
  --warning: #835317;
  --shadow: 0 14px 32px rgba(39,55,43,.08);
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--bg); }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--bg); }
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #78ab8d; outline-offset: 3px; }
::selection { color: white; background: #35785b; }
.app-shell { width: min(100%, 540px); min-height: 100vh; margin: 0 auto; padding-bottom: calc(88px + env(safe-area-inset-bottom)); background: var(--bg); position: relative; }
.auth-screen { min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at 50% 0%, #e5efe4 0, var(--bg) 62%); }
.auth-screen[hidden], .auth-form[hidden], .app-shell[hidden] { display: none; }
.auth-card { width: min(100%, 440px); padding: 25px 20px 18px; border: 1px solid rgba(25,58,46,.08); border-radius: 23px; background: var(--paper); box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; }
.auth-logo { display: block; width: min(190px, 86%); aspect-ratio: 2.7; border-radius: 9px; object-fit: cover; object-position: center 20%; }
.auth-title { margin: 22px 0 4px; font-size: 23px; line-height: 1.3; font-weight: 850; }
.auth-subtitle { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 20px 0 15px; border-radius: 13px; background: #edf0e8; }
.auth-tabs button { min-height: 40px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 750; cursor: pointer; }
.auth-tabs button[aria-pressed="true"] { color: var(--green); background: white; box-shadow: 0 2px 6px rgba(25,58,46,.08); }
.auth-form { display: grid; gap: 8px; }
.auth-form .field-label { margin: 3px 0 0; }
.auth-form .field { min-height: 48px; }
.auth-form .button { min-height: 49px; margin-top: 10px; }
.auth-notice { margin: 0 0 12px; }
.auth-footnote { margin: 15px 0 0; color: var(--muted); text-align: center; font-size: 11px; line-height: 1.5; }
.topbar { height: 68px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; color: var(--ink); background: var(--paper); border-bottom: 1px solid #e4e8df; }
.brand { min-width: 0; display: inline-flex; align-items: center; text-decoration: none; }
.brand-logo { display: block; width: clamp(128px, 42vw, 170px); aspect-ratio: 2.7; border-radius: 8px; object-fit: cover; object-position: center 20%; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border: 1.5px solid rgba(255,255,255,.8); border-radius: 10px; font-size: 18px; }
.profile-button { display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px 5px 5px; border: 1px solid rgba(20,88,63,.25); border-radius: 99px; color: var(--green-dark); background: var(--paper); font-size: 12px; font-weight: 700; cursor: pointer; }
.profile-avatar { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; color: var(--green-dark); background: #e1edda; }
.chevron { width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); }
.main-content { min-height: calc(100vh - 154px); padding: 20px 17px 26px; }
.screen[hidden] { display: none; }
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-title { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 800; letter-spacing: -.025em; }
.page-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.month-switch { display: inline-flex; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); font-size: 12px; font-weight: 700; white-space: nowrap; }
.month-switch button { width: 19px; height: 20px; padding: 0; border: 0; background: transparent; color: var(--green); font-size: 18px; line-height: 1; cursor: pointer; }
.overview { padding: 16px; border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.overview-top { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.metric { min-width: 0; padding: 12px; border-radius: 14px; background: var(--green-soft); }
.metric.expense { background: var(--coral-soft); }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-value { margin-top: 4px; color: var(--green); font-size: clamp(20px, 6.8vw, 26px); line-height: 1.2; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric.expense .metric-value { color: var(--coral); }
.net-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 2px 9px; }
.net-row span { color: var(--muted); font-size: 13px; font-weight: 700; }
.net-value { color: var(--green); font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.net-value.negative { color: var(--coral); }
.bar-chart { height: 100px; display: flex; align-items: flex-end; justify-content: space-between; gap: 9px; padding: 4px 4px 0; border-bottom: 1px solid var(--line); }
.chart-month { height: 100%; min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; color: var(--muted); font-size: 10px; }
.bars { height: 70px; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.bar { width: min(13px, 34%); min-height: 4px; border-radius: 5px 5px 2px 2px; background: #4d9b6c; }
.bar.out { background: #e98972; }
.chart-legend { display: flex; justify-content: center; gap: 16px; padding-top: 8px; color: var(--muted); font-size: 11px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 3px; background: #4d9b6c; }
.legend-dot.out { background: #e98972; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 14px 0 23px; }
.button { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 14px; border: 1px solid transparent; border-radius: 14px; background: var(--green); color: white; font-weight: 800; cursor: pointer; transition: background .16s ease, transform .16s ease; }
.button svg { width: 18px; height: 18px; }
.button:hover { background: var(--green-dark); transform: translateY(-1px); }
.button:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.button.secondary { border-color: var(--line); background: var(--paper); color: var(--green); }
.button.secondary:hover { background: var(--green-soft); }
.button.full { width: 100%; }
.button.small { min-height: 38px; padding: 8px 11px; border-radius: 11px; font-size: 13px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 20px 0 10px; }
.section-head h2 { margin: 0; font-size: 17px; line-height: 1.3; font-weight: 800; }
.text-button { display: inline-flex; align-items: center; gap: 4px; padding: 4px 0; border: 0; color: var(--green); background: transparent; font-size: 12px; font-weight: 800; cursor: pointer; }
.text-button svg { width: 17px; height: 17px; }
.transaction-list { display: flex; flex-direction: column; gap: 8px; }
.transaction-row { display: flex; align-items: center; gap: 10px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.transaction-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; color: var(--green); background: var(--green-soft); }
.transaction-icon.out { color: var(--coral); background: var(--coral-soft); }
.transaction-icon svg { width: 20px; height: 20px; }
.transaction-main { min-width: 0; flex: 1; }
.transaction-name { overflow: hidden; font-size: 13px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.transaction-meta { margin-top: 3px; color: var(--muted); font-size: 11px; }
.transaction-amount { color: var(--coral); font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.transaction-amount.income { color: var(--green); }
.transaction-delete { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; }
.transaction-delete:hover { color: var(--coral); background: var(--coral-soft); }
.transaction-delete svg { width: 17px; height: 17px; }
.empty-state { padding: 24px 17px; border: 1px dashed #bcc8be; border-radius: 16px; color: var(--muted); background: rgba(255,253,248,.65); text-align: center; font-size: 13px; line-height: 1.6; }
.empty-icon { width: 40px; height: 40px; display: grid; place-items: center; margin: 0 auto 9px; border-radius: 13px; color: var(--green); background: var(--green-soft); }
.empty-icon svg { width: 21px; height: 21px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 15px 0; border-radius: 13px; background: #eae9df; }
.segmented button { min-height: 40px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-size: 14px; font-weight: 800; cursor: pointer; }
.segmented button[aria-pressed="true"] { color: var(--green); background: var(--paper); box-shadow: 0 2px 8px rgba(30,54,39,.08); }
.upload-panel { min-height: 174px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 17px; border: 1.5px dashed #a9bcae; border-radius: 17px; background: rgba(255,253,248,.74); text-align: center; }
.upload-icon { width: 45px; height: 45px; display: grid; place-items: center; margin-bottom: 8px; border-radius: 14px; color: var(--green); background: var(--green-soft); }
.upload-icon svg { width: 24px; height: 24px; }
.upload-title { font-size: 15px; font-weight: 800; }
.upload-copy { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.upload-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 13px; }
.upload-actions label { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; color: var(--green); background: var(--paper); font-size: 12px; font-weight: 800; cursor: pointer; }
.upload-actions label svg { width: 17px; height: 17px; }
.label-icon, .inline-icon { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: 0 0 auto; }
.label-icon svg, .inline-icon svg { width: 100%; height: 100%; }
.upload-actions input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.file-preview { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 10px; padding: 8px; margin-top: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.file-preview img { width: 64px; height: 72px; object-fit: cover; border-radius: 9px; background: #efeee7; }
.file-name { max-width: 100%; overflow: hidden; font-size: 12px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.file-size { margin-top: 4px; color: var(--muted); font-size: 11px; }
.category-title { margin: 18px 0 9px; font-size: 15px; font-weight: 800; }
.category-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.category-tile { min-height: 51px; display: flex; align-items: center; gap: 7px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); text-align: left; cursor: pointer; }
.category-tile:hover { border-color: #9bb6a2; }
.category-tile[aria-pressed="true"] { border: 1.5px solid var(--green); background: var(--green-soft); }
.category-check { width: 16px; height: 16px; display: grid; place-items: center; flex: 0 0 auto; border: 1.5px solid #aebbb0; border-radius: 5px; color: transparent; background: white; }
.category-tile[aria-pressed="true"] .category-check { border-color: var(--green); color: white; background: var(--green); }
.category-check svg { width: 12px; height: 12px; }
.category-icon { width: 18px; height: 18px; flex: 0 0 auto; color: var(--green); }
.category-icon svg { width: 100%; height: 100%; }
.category-label { min-width: 0; color: var(--ink); font-size: 12px; line-height: 1.25; font-weight: 700; }
.custom-head { justify-content: flex-start; margin: 8px 0 0; }
.custom-category { display: grid; grid-template-columns: 1fr auto; gap: 7px; margin-top: 8px; }
.field { width: 100%; min-height: 45px; padding: 10px 12px; border: 1px solid #d7d8cf; border-radius: 12px; outline: none; color: var(--ink); background: var(--paper); font-size: 16px; }
.field::placeholder { color: #718276; opacity: 1; }
.field:focus { border-color: #589071; box-shadow: 0 0 0 3px rgba(88,144,113,.14); }
.field-label { display: block; margin: 13px 0 6px; color: var(--ink); font-size: 12px; font-weight: 800; }
.money-input { position: relative; }
.money-input .currency { position: absolute; top: 50%; left: 13px; transform: translateY(-50%); color: var(--green); font-size: 18px; font-weight: 800; }
.money-input input { padding-left: 40px; font-size: 20px; font-weight: 800; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.privacy-note { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.privacy-note svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--green); }
.privacy-note [data-svg-icon] { display: inline-grid; width: 16px; height: 16px; flex: 0 0 auto; color: var(--green); }
.privacy-note [data-svg-icon] svg { width: 100%; height: 100%; }
.form-actions { position: sticky; bottom: calc(84px + env(safe-area-inset-bottom)); padding-top: 12px; background: var(--bg); }
.notice { padding: 11px 12px; margin: 11px 0; border-radius: 12px; color: var(--warning); background: #fff3d8; font-size: 12px; line-height: 1.45; }
.notice.error { color: #943d31; background: #fff0eb; }
.progress-track { height: 6px; overflow: hidden; margin: 8px 0; border-radius: 99px; background: #dfe7de; }
.progress-bar { width: 8%; height: 100%; border-radius: inherit; background: var(--green); transition: width .18s ease; }
.review-summary { display: flex; align-items: center; gap: 10px; padding: 12px; margin-bottom: 14px; border-radius: 14px; background: var(--green-soft); }
.review-summary .upload-icon { width: 39px; height: 39px; margin: 0; }
.review-summary strong { display: block; font-size: 13px; }
.review-summary span:not(.upload-icon) { color: var(--muted); font-size: 11px; }
.review-summary .status-pill { margin-left: auto; padding: 5px 8px; border-radius: 99px; color: var(--green); background: white; font-size: 10px; font-weight: 800; white-space: nowrap; }
.review-category { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.review-category strong { font-size: 13px; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 12px 0 14px; color: var(--muted); font-size: 12px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--green); }
.back-button { margin-top: 8px; }
.filters { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 8px; scrollbar-color: #a7b7a7 transparent; }
.filter-chip { min-height: 34px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); background: var(--paper); font-size: 12px; font-weight: 800; white-space: nowrap; cursor: pointer; }
.filter-chip[aria-pressed="true"] { border-color: var(--green); color: white; background: var(--green); }
.search-field { margin: 2px 0 9px; }
.summary-switch { display: flex; gap: 8px; margin: 13px 0; }
.small-stat { flex: 1; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.small-stat span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.small-stat strong { display: block; margin-top: 5px; color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; }
.breakdown { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); }
.breakdown-row { display: grid; grid-template-columns: 85px 1fr auto; align-items: center; gap: 8px; font-size: 11px; }
.breakdown-label { color: var(--ink); font-weight: 700; }
.breakdown-track { height: 8px; overflow: hidden; border-radius: 99px; background: #eeeee7; }
.breakdown-fill { height: 100%; border-radius: inherit; background: #60a076; }
.breakdown-row.expense .breakdown-fill { background: #e68770; }
.breakdown-value { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 800; }
.settings-form { padding: 13px; margin: 3px 0 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); }
.settings-save { margin-top: 9px; }
.settings-list { display: flex; flex-direction: column; gap: 8px; }
.setting-item { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.setting-icon { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: var(--green); background: var(--green-soft); }
.setting-icon svg { width: 19px; height: 19px; }
.setting-copy { min-width: 0; flex: 1; }
.setting-copy strong { display: block; font-size: 13px; }
.setting-copy span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.bottom-nav { position: fixed; z-index: 10; right: 0; bottom: 0; left: 0; width: min(100%, 540px); height: calc(77px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; margin: 0 auto; padding: 6px 7px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); }
.nav-item { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 4px 2px; border: 0; border-radius: 11px; color: #5d7165; background: transparent; font-size: 10px; font-weight: 700; cursor: pointer; }
.nav-item[aria-current="page"] { color: var(--green); }
.nav-icon { width: 22px; height: 22px; display: grid; place-items: center; }
.nav-icon svg { width: 21px; height: 21px; }
.plus-icon { width: 34px; height: 34px; position: relative; display: grid; place-items: center; margin-top: -14px; border-radius: 50%; background: var(--green); box-shadow: 0 5px 12px rgba(20,88,63,.2); }
.plus-icon::before, .plus-icon::after { content: ""; position: absolute; width: 15px; height: 2px; border-radius: 3px; background: white; }
.plus-icon::after { transform: rotate(90deg); }
.nav-add { color: var(--green); font-weight: 800; }
.toast { position: fixed; z-index: 30; right: 17px; bottom: calc(91px + env(safe-area-inset-bottom)); left: 17px; max-width: 500px; margin: 0 auto; padding: 12px 15px; border-radius: 13px; color: white; background: #173f31; box-shadow: var(--shadow); text-align: center; font-size: 13px; font-weight: 700; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #983d31; }
@media (min-width: 700px) {
  body { padding: 24px 0; }
  .app-shell { min-height: calc(100vh - 48px); border: 1px solid #e3e0d5; border-radius: 28px; overflow: hidden; box-shadow: 0 18px 55px rgba(40,52,40,.12); }
  .bottom-nav { bottom: 24px; border-radius: 0 0 28px 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

