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

:root {
  font-family: Anuphan, system-ui, sans-serif;
  color: #10251f;
  background: #f5f7f6;
  font-synthesis: none;
  --canvas: #f5f7f6;
  --paper: #ffffff;
  --ink: #10251f;
  --muted: #566c64;
  --line: #dce5e0;
  --green: #0d7f68;
  --green-dark: #075c4a;
  --green-pale: #e5f2eb;
  --expense: #bb3e1d;
  --income: #0a8068;
  --shadow: 0 14px 30px -24px rgba(13, 42, 31, .34);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: #bbdfd0; color: #062e25; }
:focus-visible { outline: 3px solid #54b69c; outline-offset: 3px; }
input, textarea { caret-color: var(--green); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.ui-icon { width: 22px; height: 22px; display: inline-block; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.app-shell { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 30px 18px 18px; background: var(--paper); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; margin: 0 10px 40px; font-size: 21px; font-weight: 800; letter-spacing: -.04em; }
.brand small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0; }
.brand-mark { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 11px; background: var(--green); color: #fff; font-size: 27px; }
.side-nav { display: grid; gap: 6px; }
.nav-link { display: flex; align-items: center; gap: 13px; min-height: 48px; padding: 10px 14px; border-radius: 12px; color: var(--muted); font-size: 14px; font-weight: 600; }
.nav-link:hover { background: #f1f5f2; color: var(--ink); }
.nav-link.active { background: var(--green-pale); color: var(--green-dark); }
.nav-link > span { display: grid; place-items: center; width: 24px; }
.sidebar-bottom { display: flex; align-items: flex-start; gap: 8px; margin-top: auto; padding: 10px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.status-dot { width: 8px; height: 8px; flex: none; margin-top: 4px; border-radius: 50%; background: #2ba98d; box-shadow: 0 0 0 3px #d8f2e8; }
.main-content { width: 100%; max-width: 1320px; min-width: 0; margin: 0 auto; padding: 0 46px 90px; }
.topbar { display: flex; align-items: center; justify-content: space-between; height: 72px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.topbar span:first-child { color: var(--ink); font-size: 17px; font-weight: 700; }
.view { display: none; }
.view.active-view { display: block; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 31px; line-height: 1.35; font-weight: 800; letter-spacing: -.035em; }
h2 { font-size: 18px; line-height: 1.4; font-weight: 700; letter-spacing: -.025em; }
h3 { font-size: 14px; font-weight: 700; }
.page-heading, .home-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 34px 0 22px; }
.home-head h1 { font-size: 30px; }
.month-picker { position: relative; display: flex; align-items: center; gap: 8px; flex: none; min-height: 42px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 24px; background: var(--paper); font-size: 13px; font-weight: 600; white-space: nowrap; }
.month-picker svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.month-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.home-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, .83fr); gap: 34px; align-items: start; }
.home-primary, .home-secondary { min-width: 0; }
.balance-card { min-width: 0; padding: 26px; border-radius: 22px; background: #14231e; color: #fff; }
.balance-card > p { color: #d5eee5; font-size: 13px; font-weight: 500; }
.balance-card > strong { display: block; margin: 7px 0 24px; font-size: clamp(35px, 4vw, 51px); font-weight: 700; line-height: 1.15; letter-spacing: -.04em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.balance-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.balance-split > div { min-width: 0; padding: 13px 16px; border-radius: 14px; background: #20352d; }
.balance-split span, .balance-split small { display: block; color: #d5eee5; font-size: 12px; }
.balance-split strong { display: block; margin: 4px 0; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.balance-split > div:first-child strong { color: #4cddb1; }
.balance-split > div:last-child strong { color: #ff907d; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.section-link { color: var(--green-dark); font-size: 13px; font-weight: 700; }
.section-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.section-hint { color: var(--muted); font-size: 12px; }
.recent-section { margin-top: 30px; }
.recent-section .transaction-list { margin-top: 12px; }
.date-group { padding: 16px 0 5px; color: var(--muted); font-size: 12px; font-weight: 500; }
.date-group:first-child { padding-top: 6px; }
.transaction-list { min-width: 0; }
.transaction-row { display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; padding: 8px 0; border: 0; background: transparent; color: var(--ink); text-align: left; }
.transaction-row:is(button):hover .tx-title { color: var(--green-dark); }
.tx-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 13px; background: #e3eee8; color: #17392e; }
.tx-icon.income { background: #d8f1e7; color: #0b7860; }
.tx-icon .ui-icon { width: 21px; height: 21px; }
.tx-main { display: grid; gap: 1px; flex: 1; min-width: 0; }
.tx-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.tx-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.tx-amount { flex: none; white-space: nowrap; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.income-text { color: var(--income); }
.expense-text { color: var(--expense); }
.empty-state { padding: 38px 16px; color: var(--muted); text-align: center; font-size: 13px; line-height: 1.7; }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 15px; }
.calendar-section { margin-top: 4px; }
.calendar-panel, .day-panel { margin-top: 15px; padding: 18px; border: 1px solid var(--line); border-radius: 17px; background: var(--paper); }
.calendar-controls { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 16px; }
.calendar-controls strong { font-size: 13px; font-weight: 700; white-space: nowrap; }
.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font-size: 22px; line-height: 1; }
.icon-btn:hover, .text-btn:hover { background: var(--green-pale); }
.text-btn { min-height: 34px; padding: 6px 8px; border: 0; border-radius: 9px; background: transparent; color: var(--green-dark); font-size: 12px; font-weight: 700; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.calendar-weekdays span { margin-bottom: 4px; color: var(--muted); font-size: 12px; text-align: center; }
.calendar-day, .calendar-blank { min-width: 0; min-height: 48px; border-radius: 8px; }
.calendar-day { display: flex; flex-direction: column; align-items: center; padding: 3px; border: 1px solid #ecf1ed; background: #fff; color: var(--ink); }
.calendar-day:hover { background: #eff7f2; }
.calendar-day.selected { border-color: var(--green); background: #e4f4ea; }
.calendar-day.today .calendar-day-number { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--green); color: #fff; }
.calendar-day-number { font-size: 12px; font-weight: 700; line-height: 22px; }
.calendar-day-amounts { display: none; }
.calendar-blank { background: #f7f9f7; }
.calendar-dots { display: flex; gap: 3px; margin-top: auto; margin-bottom: 3px; min-height: 6px; }
.calendar-dots i { width: 5px; height: 5px; border-radius: 50%; }
.income-dot, .legend-income { background: var(--income); }
.expense-dot, .legend-expense { background: var(--expense); }
.calendar-legend { display: flex; gap: 13px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.calendar-legend span { display: flex; align-items: center; gap: 6px; }
.calendar-legend i { width: 7px; height: 7px; border-radius: 50%; }
.day-panel-head { display: flex; justify-content: space-between; align-items: flex-start; }
.day-panel-head h3 { font-size: 15px; }
.day-panel-head p { color: var(--muted); font-size: 12px; }
.day-totals { display: flex; gap: 18px; margin: 16px 0 8px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.day-totals strong { display: block; color: var(--ink); font-size: 14px; }
.day-panel .transaction-row { gap: 7px; }
.day-panel .tx-icon { width: 34px; height: 34px; border-radius: 9px; }
.day-panel .tx-icon .ui-icon { width: 17px; height: 17px; }
.day-panel .tx-title, .day-panel .tx-amount { font-size: 12px; }
.report-nav { display: flex; align-items: center; gap: 8px; }
.report-nav strong { min-width: 95px; text-align: center; font-size: 13px; font-weight: 600; white-space: nowrap; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 4px; border-radius: 14px; background: #e2eae5; }
.segmented button { min-height: 41px; border: 0; border-radius: 10px; background: transparent; color: #4f665d; font-size: 13px; font-weight: 500; }
.segmented button.active { background: #fff; color: var(--ink); font-weight: 700; box-shadow: 0 7px 14px -12px #284438; }
.report-segmented { max-width: 460px; }
.report-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(310px, .85fr); gap: 34px; margin-top: 35px; align-items: start; }
.category-section { min-width: 0; }
.donut-chart { display: grid; place-items: center; width: 190px; height: 190px; margin: 0 auto 26px; border-radius: 50%; }
.donut-center { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 140px; height: 140px; border-radius: 50%; background: var(--canvas); text-align: center; }
.donut-center span { color: var(--muted); font-size: 12px; }
.donut-center strong { font-size: 24px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.category-report { display: grid; gap: 2px; }
.cat-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) 48px minmax(75px, auto); align-items: center; gap: 9px; min-height: 42px; font-size: 13px; }
.cat-color { width: 11px; height: 11px; border-radius: 3px; }
.cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-percent { color: var(--muted); text-align: right; font-size: 12px; }
.cat-row strong { justify-self: end; font-size: 13px; font-variant-numeric: tabular-nums; }
.week-chart-card { padding: 17px 18px 13px; border: 1px solid var(--line); border-radius: 17px; background: #fff; }
.week-chart-card h2 { font-size: 14px; }
.week-bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); align-items: end; gap: 8px; margin-top: 13px; }
.week-bar { min-width: 0; text-align: center; }
.bar-track { display: flex; align-items: end; height: 82px; }
.bar-track span { width: 100%; min-height: 4px; border-radius: 6px 6px 4px 4px; background: #bfdbcf; }
.bar-track span.current { background: var(--green); }
.week-bar small { display: block; overflow: hidden; margin-top: 5px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.report-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.report-summary > div { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.report-summary span { display: block; color: var(--muted); font-size: 12px; }
.report-summary strong { display: block; margin-top: 4px; font-size: 19px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.period-list { margin-top: 25px; }
.period-list h2 { font-size: 15px; }
.period-list .transaction-list { margin-top: 12px; }
.primary-btn, .secondary-btn, .danger-btn { min-height: 45px; padding: 10px 18px; border: 0; border-radius: 12px; font-size: 13px; font-weight: 700; }
.primary-btn { display: inline-flex; justify-content: center; align-items: center; gap: 7px; background: var(--green); color: #fff; }
.primary-btn:hover { background: var(--green-dark); }
.secondary-btn { background: var(--green-pale); color: var(--green-dark); }
.secondary-btn:hover { background: #d5eadf; }
.danger-btn { background: #fff0eb; color: var(--expense); }
.danger-btn:hover { background: #ffe3db; }
.add-trigger .ui-icon { width: 19px; height: 19px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 17px; }
.filter-row select, .filter-row > input, .search-wrap { min-height: 42px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink); }
.filter-row select, .filter-row > input { padding: 8px 11px; }
.search-wrap { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 220px; padding-left: 12px; }
.search-icon { color: var(--muted); font-size: 22px; }
.search-wrap input { width: 100%; min-width: 0; height: 38px; border: 0; background: transparent; outline: none; }
.full-list .transaction-row { border-bottom: 1px solid var(--line); padding: 12px 0; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-card { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: 17px; background: #fff; }
.settings-card h2 { margin-bottom: 8px; }
.settings-card p { color: var(--muted); font-size: 13px; line-height: 1.7; }
.notice { margin: 19px 0; padding: 13px 14px; border-radius: 11px; background: #edf5ef; color: #315b4d; font-size: 12px; line-height: 1.7; }
.settings-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 14px; }
.import-label { display: inline-flex; align-items: center; cursor: pointer; }
.settings-form { display: grid; gap: 14px; margin-top: 19px; }
.settings-form label { display: grid; gap: 7px; color: var(--ink); font-size: 12px; font-weight: 600; }
.settings-form input { width: 100%; min-height: 45px; padding: 10px 12px; border: 1px solid #cbd8d0; border-radius: 10px; background: #fff; color: var(--ink); font-size: 13px; outline: 0; }
.settings-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px #d7eee4; }
.settings-form input::placeholder, .entry-dialog textarea::placeholder, .amount-field input::placeholder { color: #61756c; }
.auth-area { margin-top: 19px; padding-top: 18px; border-top: 1px solid var(--line); }
.auth-area > p { color: var(--green-dark); font-weight: 600; }
.help-text { margin-top: 18px; font-size: 12px !important; }
.upload-btn { margin-top: 14px; }
.floating-add { position: fixed; z-index: 7; right: 30px; bottom: 30px; display: grid; place-items: center; width: 58px; height: 58px; border: 0; border-radius: 50%; background: var(--green); color: #fff; box-shadow: 0 14px 24px -12px rgba(4, 82, 62, .65); }
.floating-add:hover { background: var(--green-dark); }
.floating-add .ui-icon { width: 27px; height: 27px; }
body[data-view="settings"] .floating-add { display: none; }
.mobile-nav { display: none; }
.entry-dialog { width: min(470px, calc(100vw - 24px)); max-height: min(96dvh, 850px); padding: 0; border: 0; border-radius: 20px; background: var(--canvas); box-shadow: 0 25px 70px -22px rgba(1, 24, 14, .3); }
.entry-dialog::backdrop { background: rgba(9, 31, 22, .65); }
.entry-dialog form { display: flex; flex-direction: column; gap: 13px; padding: 22px; }
.dialog-head { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; min-height: 38px; }
.dialog-head h2 { text-align: center; font-size: 17px; }
.close-btn { width: 34px; height: 34px; border: 0; background: transparent; color: var(--ink); font-size: 30px; line-height: 1; }
.entry-type { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: #e3eae6; }
.entry-type button { min-height: 42px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: 14px; }
.entry-type button.active { background: #fff; color: var(--ink); font-weight: 700; }
.amount-label { margin: 0; color: var(--muted); font-size: 12px; text-align: center; }
.amount-field { display: flex; align-items: center; justify-content: center; margin: -5px 0 0; color: var(--expense); font-size: 45px; font-weight: 800; line-height: 1.15; }
.entry-dialog[data-type="income"] .amount-field { color: var(--green); }
.amount-field input { width: min(260px, 75%); padding: 0; border: 0; background: transparent; color: inherit; outline: none; font-size: inherit; font-weight: inherit; line-height: inherit; text-align: left; font-variant-numeric: tabular-nums; }
.category-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.category-chips button { min-height: 41px; padding: 7px 14px; border: 1px solid #d7e1da; border-radius: 24px; background: #fff; color: var(--ink); font-size: 12px; font-weight: 600; }
.category-chips button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.entry-info label { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 12px; font-weight: 600; }
.entry-info label span { color: var(--muted); font-weight: 500; }
.entry-info input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.note-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.entry-dialog textarea { width: 100%; min-height: 46px; max-height: 80px; resize: vertical; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); outline: none; font-size: 13px; }
.entry-dialog textarea:focus, .entry-info:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px #d7eee4; }
.amount-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.amount-keypad button { min-height: 47px; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: var(--ink); font-size: 18px; font-weight: 700; }
.amount-keypad button:hover { background: var(--green-pale); }
.dialog-actions { display: flex; gap: 9px; margin-top: 1px; }
.dialog-actions .primary-btn { flex: 1; min-height: 51px; font-size: 15px; }
#toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: calc(100vw - 40px); padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 1060px) {
  .app-shell { grid-template-columns: 205px minmax(0, 1fr); }
  .main-content { padding-right: 28px; padding-left: 28px; }
  .home-columns, .report-layout { gap: 20px; }
}
@media (max-width: 880px) {
  .sidebar { display: none; }
  .app-shell { display: block; }
  .main-content { padding: 0 20px calc(105px + env(safe-area-inset-bottom)); }
  .topbar { display: none; }
  .home-head, .page-heading { margin-top: 27px; }
  .home-columns, .report-layout, .settings-grid { grid-template-columns: 1fr; }
  .home-secondary { margin-top: 30px; }
  .calendar-section { margin-top: 0; }
  .mobile-nav { position: fixed; z-index: 8; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(4, 1fr); min-height: calc(70px + env(safe-area-inset-bottom)); padding: 4px 8px max(4px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 55px; color: #66746d; font-size: 12px; font-weight: 600; }
  .mobile-nav a.active { color: var(--green-dark); font-weight: 700; }
  .mobile-nav .ui-icon { width: 22px; height: 22px; }
  .floating-add { right: 19px; bottom: calc(83px + env(safe-area-inset-bottom)); }
  #toast { right: 15px; bottom: calc(145px + env(safe-area-inset-bottom)); left: 15px; max-width: none; text-align: center; }
}
@media (max-width: 520px) {
  .main-content { padding-right: 19px; padding-left: 19px; }
  h1, .home-head h1 { font-size: 24px; }
  .month-picker { min-height: 41px; }
  .home-head { margin-bottom: 16px; }
  .balance-card { padding: 19px; border-radius: 21px; }
  .balance-card > strong { margin-bottom: 23px; font-size: 39px; }
  .balance-split { gap: 10px; }
  .balance-split > div { padding: 11px 12px; }
  .balance-split strong { font-size: 15px; }
  .recent-section { margin-top: 26px; }
  .report-layout { margin-top: 34px; }
  .report-nav strong { min-width: 82px; font-size: 12px; }
  .page-heading { margin-bottom: 19px; }
  .page-heading .add-trigger { display: none; }
  .filter-row .search-wrap { flex-basis: 100%; }
  .filter-row select, .filter-row > input { flex: 1; min-width: 0; }
  .settings-card { padding: 18px; }
  .entry-dialog { position: fixed; inset: 0; width: 100vw; max-width: 100vw; height: 100dvh; max-height: none; margin: 0; border-radius: 0; overflow-y: auto; }
  .entry-dialog form { min-height: 100%; padding: max(18px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); gap: 11px; }
  .amount-field { font-size: 45px; }
  .amount-keypad button { min-height: 48px; }
  .dialog-actions { margin-top: 3px; }
}
@media (max-width: 350px) {
  .main-content { padding-right: 13px; padding-left: 13px; }
  .tx-icon { width: 39px; height: 39px; }
  .balance-card > strong { font-size: 34px; }
  .category-chips button { padding: 6px 10px; }
  .amount-keypad { gap: 6px; }
  .amount-keypad button { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  #toast { transition: none; }
}
