:root {
  --bg: #FFFFFF;
  --bg-soft: #F1F4FD;
  --line: #E3E8F6;
  --line-soft: #ECEFFA;
  --line-strong: #D2D9F0;
  --text: #0F1535;
  --text-2: #5A6385;
  --accent: #3B63F0;
  --accent-press: #2C4DD6;
  --accent-soft: #E9EFFF;
  --accent-ink: #2340C0;
  --danger: #B42318;
  --shadow: 0 6px 24px rgba(30, 50, 170, 0.10);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-soft);
  color: var(--text);
  font-family: 'Kanit', system-ui, sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
body.noscroll { overflow: hidden; }

h1, h2, h3, p { margin: 0; }
button, input { font-family: inherit; }
a { color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.num { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { flex-shrink: 0; }

/* ---------- layout ---------- */
.shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
}
@media (min-width: 520px) {
  .shell { box-shadow: 0 0 0 1px var(--line); }
}
.page {
  padding: 20px 20px calc(112px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.page.no-nav { padding-bottom: calc(32px + var(--safe-b)); }
.section { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title { font-size: 16px; font-weight: 500; }
.label { font-size: 14px; color: var(--text-2); }

.topbar { display: flex; align-items: center; gap: 8px; }
.topbar h1 { font-size: 20px; font-weight: 500; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.topbar-split { justify-content: space-between; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: none;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .08s;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: .55; cursor: default; transform: none; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 8px 20px rgba(59, 99, 240, 0.28); }
.btn-primary:hover:not([disabled]) { background: var(--accent-press); }
.btn-secondary { background: #fff; border-color: var(--line-strong); }
.btn-secondary:hover:not([disabled]) { background: var(--bg-soft); }
.btn-ghost { color: var(--accent); padding: 0 14px; }
.btn-danger { color: var(--danger); }
.btn-fill-danger { background: var(--danger); color: #fff; }
.btn-fill-danger:hover:not([disabled]) { background: #8E1C12; }
.sheet-form { display: flex; flex-direction: column; gap: 16px; }

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}
.icon-btn:hover { background: #E3EAFF; }
.icon-btn[disabled] { opacity: .4; cursor: default; }

.link-btn { border: 0; background: none; padding: 8px 0; color: var(--accent); font-size: 14px; cursor: pointer; text-decoration: none; text-align: left; }
.link-btn:hover { text-decoration: underline; }

/* ---------- chips / options ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.chip.soft[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.opt {
  min-height: 48px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  overflow-wrap: anywhere;
}
.opt[aria-pressed="true"] { border: 1.5px solid var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; }
.opt-add { border-style: dashed; border-color: #B4BFE0; color: var(--text-2); justify-content: flex-start; }

.seg {
  padding: 4px;
  border-radius: 999px;
  background: var(--bg-soft);
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.seg-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-size: 15px;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: #fff; color: var(--text); font-weight: 500; box-shadow: 0 2px 8px rgba(20, 34, 110, 0.10); }

/* ---------- inputs ---------- */
.input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
}
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-error { font-size: 14px; color: var(--danger); }

.amount { display: flex; flex-direction: column; gap: 4px; padding-bottom: 14px; border-bottom: 2px solid var(--accent); }
.amount:focus-within { box-shadow: 0 8px 12px -10px rgba(59, 99, 240, 0.6); }
.amount-row { display: flex; align-items: baseline; gap: 8px; }
.amount input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 44px;
  font-weight: 600;
  line-height: 1.2;
}
.amount input::placeholder { color: #B4BFE0; }
.amount .unit { font-size: 16px; color: var(--text-2); }
.date-note { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 8px; }
.date-btn {
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

/* ---------- home ---------- */
.group-btn {
  min-height: 44px;
  max-width: calc(100% - 60px);
  padding: 0 14px 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.group-btn span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balance { display: flex; flex-direction: column; gap: 4px; }
.balance-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.balance-amt { font-size: 40px; font-weight: 600; line-height: 1.15; overflow-wrap: anywhere; }
.wallets { display: flex; gap: 8px; overflow-x: auto; margin: 0 -20px; padding: 0 20px 2px; scrollbar-width: none; }
.wallets::-webkit-scrollbar { display: none; }
.wcard {
  flex: 0 0 auto;
  min-width: 112px;
  max-width: 200px;
  padding: 12px;
  border: 0;
  border-radius: 14px;
  background: var(--bg-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wcard .n { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wcard .v { font-size: 15px; font-weight: 500; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { padding: 14px 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat + .stat { padding-left: 16px; border-left: 1px solid var(--line); }
.stat .k { font-size: 13px; color: var(--text-2); }
.stat .v { font-size: 18px; font-weight: 500; overflow-wrap: anywhere; }
.in-color { color: var(--accent); }

/* ---------- rows ---------- */
.rows { display: flex; flex-direction: column; }
.day-head { font-size: 13px; color: var(--text-2); padding: 12px 0 2px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: none;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.row:last-child { border-bottom: 0; }
.ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--text);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.ico.in { background: var(--accent-soft); color: var(--accent); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-amt { font-size: 15px; font-weight: 500; white-space: nowrap; }
.row-chev { color: var(--text-2); }
.card-row { border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; min-height: 64px; }
.card-list { display: flex; flex-direction: column; gap: 8px; }
.card-list .row { border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.empty { padding: 36px 0; text-align: center; color: var(--text-2); display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ---------- list page ---------- */
.monthnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.monthnav .m { font-size: 17px; font-weight: 500; }
.searchbar { display: flex; gap: 8px; }
.search-wrap { position: relative; flex: 1; min-width: 0; }
.search-wrap svg { position: absolute; left: 14px; top: 14px; color: var(--text-2); pointer-events: none; }
.search-wrap .input { padding-left: 42px; }
.filter-btn { position: relative; }
.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}
.notice { font-size: 13px; color: var(--text-2); text-align: center; padding: 8px 0; }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 20;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(10px + var(--safe-b));
  display: grid;
  grid-template-columns: 1fr 1fr 72px 1fr 1fr;
  align-items: center;
}
.nav a.tab {
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  text-decoration: none;
  color: var(--text-2);
}
.nav a.tab[aria-current="page"] { color: var(--accent); font-weight: 500; }
.fab {
  justify-self: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(59, 99, 240, 0.32);
}
.fab:hover { background: var(--accent-press); }

/* ---------- sheet ---------- */
.sheet-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20, 34, 110, 0.4); animation: fade .18s ease-out; }
.sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(20px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: rise .22s ease-out;
}
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); align-self: center; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head h2 { font-size: 18px; font-weight: 500; overflow-wrap: anywhere; }
.sheet-text { font-size: 15px; color: var(--text-2); }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; }
.pick-list { display: flex; flex-direction: column; gap: 8px; }
.pick {
  width: 100%;
  min-height: 52px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pick small { display: block; font-size: 13px; color: var(--text-2); }
.pick[aria-checked="true"] { border: 1.5px solid var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.pick[aria-checked="true"] small { color: var(--accent-ink); }

@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-head .m { font-size: 17px; font-weight: 500; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 13px; color: var(--text-2); text-align: center; padding: 4px 0; }
.cal-day {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}
.cal-day:hover { background: var(--bg-soft); }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-day[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 500; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 10px 10px 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 28px rgba(20, 34, 110, 0.28);
  animation: rise .2s ease-out;
}
.toast button { border: 0; background: none; color: #A9BDFF; font-size: 15px; font-weight: 500; min-height: 36px; padding: 0 12px; border-radius: 999px; cursor: pointer; }
.toast button:hover { background: rgba(255, 255, 255, 0.1); }

/* ---------- login ---------- */
body:has(.login) { background: var(--bg); }
.login { max-width: 380px; margin: 0 auto; min-height: 100vh; padding: 14vh 24px 32px; background: var(--bg); display: flex; flex-direction: column; gap: 16px; }
.login-mark { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.login h1 { font-size: 30px; font-weight: 600; line-height: 1.2; }
.login-lead { color: var(--text-2); }
.login-error { color: var(--danger); font-size: 15px; padding: 10px 14px; border-radius: 14px; background: #FDEDEB; }
.login-note { font-size: 13px; color: var(--text-2); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- budget ---------- */
.bcard {
  width: 100%;
  padding: 16px;
  border: 0;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bcard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; color: var(--text-2); }
.bcard-title { font-size: 16px; font-weight: 500; color: var(--text); overflow-wrap: anywhere; }
.bar-row { display: flex; flex-direction: column; gap: 6px; }
.bar-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.bar { height: 8px; border-radius: 999px; background: #E3EAFF; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.bar.over i { background: var(--danger); }
.over-text { color: var(--danger); }
.bar-note { font-size: 13px; }

/* ---------- กิจวัตร / เป้าหมาย ---------- */
.row-off { opacity: 0.55; }
.label.sub { font-size: 13px; margin-top: 8px; }

/* ---------- หน้าเอกสาร (นโยบาย) ---------- */
.doc h2 { font-size: 17px; font-weight: 500; margin: 24px 0 8px; }
.doc p, .doc li { font-size: 15px; line-height: 1.7; color: var(--text-2); }
.doc ul { padding-left: 20px; margin: 0; }
.doc a { color: var(--accent); }
.login-note a { color: var(--accent); }

/* ---------- สรุป / กราฟ ---------- */
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-3 .stat { padding-left: 12px; }
.stats-3 .stat:first-child { padding-left: 0; }
.stats-3 .stat .v { font-size: 16px; }
.chart { width: 100%; height: auto; display: block; margin-top: 8px; }
.chart text { fill: var(--text-2); font-size: 10px; font-family: inherit; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar-main { fill: var(--accent); }
.chart .bar-in { fill: #7AA2FF; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-main { background: var(--accent); }
.sw-in { background: #7AA2FF; }
.cat-list { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.cat-row { display: flex; flex-direction: column; gap: 6px; }
.cat-head { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.cat-name { overflow-wrap: anywhere; }
.danger-text { color: var(--danger); }
.row-btn { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; color: inherit; }

/* ---------- เอฟเฟกต์ตอนชี้และตอนกด ---------- */
.btn, .chip, .opt, .pick, .row, .wcard, .bcard, .icon-btn, .seg button, .date-btn, .cal-day, .fab, .nav a.tab, .link-btn, .toast button {
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .12s ease, color .16s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not([disabled]), .chip:active, .opt:active, .pick:active, .date-btn:active { transform: scale(0.97); }
.wcard:active, .bcard:active { transform: scale(0.98); }
.icon-btn:active { transform: scale(0.92); background: #D3DEFB; }
.fab:active { transform: scale(0.92); box-shadow: 0 4px 10px rgba(59, 99, 240, 0.3); }
.cal-day:active { transform: scale(0.9); background: var(--accent-soft); }
.nav a.tab:active { transform: scale(0.94); }
.nav a.tab .ico, .nav a.tab svg { transition: transform .16s ease; }
.row:active { background: var(--bg-soft); }
.seg button:active { transform: scale(0.96); }
.link-btn:active { opacity: .6; }
.toast button:active { background: rgba(255, 255, 255, 0.2); }

@media (hover: hover) {
  .btn-primary:hover:not([disabled]) { box-shadow: 0 10px 24px rgba(59, 99, 240, 0.38); transform: translateY(-1px); }
  .btn-secondary:hover:not([disabled]) { border-color: var(--accent); color: var(--accent-ink); }
  .btn-danger:hover:not([disabled]) { background: #FCEDEB; border-color: #E9B7B2; }
  .btn-ghost:hover:not([disabled]) { background: var(--accent-soft); }
  .chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
  .chip[aria-pressed="true"]:hover { background: var(--accent-press); border-color: var(--accent-press); color: #fff; }
  .chip.soft[aria-pressed="true"]:hover { background: var(--accent-soft); color: var(--accent-ink); }
  .opt:hover { border-color: var(--accent); background: #F4F7FF; }
  .opt[aria-pressed="true"]:hover { background: var(--accent-soft); }
  .pick:hover { border-color: var(--accent); background: #F4F7FF; }
  .pick[aria-checked="true"]:hover { background: var(--accent-soft); }
  .row:hover { background: var(--bg-soft); }
  .card-list .row:hover { border-color: var(--line-strong); }
  .wcard:hover { background: #E3EAFF; transform: translateY(-2px); }
  .bcard:hover { box-shadow: 0 10px 28px rgba(20, 34, 110, 0.12); transform: translateY(-2px); }
  .date-btn:hover { border-color: var(--accent); }
  .seg button:hover:not([aria-pressed="true"]) { background: rgba(255, 255, 255, 0.6); }
  .fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 26px rgba(59, 99, 240, 0.42); }
  .nav a.tab:hover { color: var(--accent); }
  .nav a.tab:hover svg { transform: translateY(-2px); }
  .group-btn:hover { border-color: var(--accent); }
}

/* =====================================================================
   ตกแต่งเพิ่ม: ฮีโร่ยอดเงิน, แอนิเมชันเข้าหน้า, คลื่นตอนกด, เมนูกระจก
   ===================================================================== */
:root { --ease-out: cubic-bezier(.2, .8, .2, 1); --spring: cubic-bezier(.3, 1.4, .5, 1); --accent-light: #6C92FF; --accent-deep: #2A40D0; }

/* ---------- เข้าหน้า ---------- */
@keyframes fxIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.fx-in { animation: fxIn .55s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes growx { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes growy { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.bar i { transform-origin: left; animation: growx .9s var(--ease-out) .2s both; }
.chart rect { transform-box: fill-box; transform-origin: bottom; animation: growy .8s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 14ms + .1s); }

/* ---------- ฮีโร่ยอดเงิน ---------- */
.hero {
  --mx: 78%; --my: 0%;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border-radius: 28px;
  padding: 22px 20px 6px;
  color: #fff;
  background:
    radial-gradient(120% 90% at 100% 0%, var(--accent-light) 0%, transparent 55%),
    radial-gradient(90% 80% at 0% 100%, rgba(36, 56, 230, 0.9) 0%, transparent 62%),
    linear-gradient(135deg, #4D7CFF 0%, #2B47E0 100%);
  box-shadow: 0 18px 40px -12px rgba(47, 79, 184, 0.55), 0 2px 0 rgba(255, 255, 255, 0.25) inset;
}
.hero::before { /* แสงตามเมาส์ */
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(220px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.22), transparent 70%);
}
.hero::after { /* ลำแสงพาดผ่านเป็นระยะ */
  content: ''; position: absolute; top: -40%; bottom: -40%; width: 38%; left: -60%; z-index: -1; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.20), transparent);
  transform: skewX(-18deg);
  animation: sheen 7s ease-in-out 1.2s infinite;
}
@keyframes sheen { 0%, 62% { left: -60%; } 100% { left: 130%; } }
.hero .label { color: rgba(255, 255, 255, 0.8); }
.hero .balance-amt { font-size: 44px; text-shadow: 0 2px 18px rgba(20, 30, 160, 0.35); }
.hero .muted { color: rgba(255, 255, 255, 0.8); }
.hero .stats { border: 0; margin: 14px -20px 0; padding: 0 20px; background: rgba(24, 40, 190, 0.38); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.hero .stat .k { color: rgba(255, 255, 255, 0.75); }
.hero .stat + .stat { border-left-color: rgba(255, 255, 255, 0.2); }
.hero .in-color { color: #D8E6FF; }
.hero .stat .v { font-size: 17px; }
.hero .stat { padding: 12px 0 14px; }

/* ---------- ปุ่ม ---------- */
.btn, .fab, .chip, .opt, .pick { position: relative; overflow: hidden; }
.btn-primary { background: linear-gradient(135deg, #5A86FF 0%, #3B63F0 55%, #2C4DD6 100%); }
.btn-primary:hover:not([disabled]) { background: linear-gradient(135deg, #6C94FF 0%, #3B63F0 55%, #2742C8 100%); }
.btn-primary::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent); transform: skewX(-18deg);
}
@media (hover: hover) { .btn-primary:hover::after { left: 130%; transition: left .7s ease; } }
.ripple { position: absolute; border-radius: 50%; pointer-events: none; background: currentColor; opacity: .18; transform: scale(0); animation: ripple .6s ease-out forwards; }
.btn-primary .ripple, .fab .ripple { background: #fff; opacity: .35; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* ---------- เมนูล่างแบบกระจก ---------- */
.nav { background: rgba(255, 255, 255, 0.82); backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px); }
.nav a.tab { position: relative; }
.nav a.tab svg { position: relative; }
.nav a.tab::before {
  content: ''; position: absolute; top: 5px; left: 50%; width: 52px; height: 30px; margin-left: -26px; border-radius: 999px;
  background: var(--accent-soft); transform: scale(0); transition: transform .35s var(--spring);
}
.nav a.tab[aria-current="page"]::before { transform: scale(1); }
.nav a.tab[aria-current="page"] svg { animation: tabPop .5s var(--spring); }
@keyframes tabPop { 0% { transform: scale(.6) translateY(4px); } 100% { transform: none; } }
.fab { background: linear-gradient(135deg, #6C94FF 0%, #3B63F0 50%, #2C4DD6 100%); animation: ring 3.2s ease-out 1.5s infinite; }
@keyframes ring { 0% { box-shadow: 0 8px 20px rgba(59, 99, 240, 0.32), 0 0 0 0 rgba(59, 99, 240, 0.45); } 60%, 100% { box-shadow: 0 8px 20px rgba(59, 99, 240, 0.32), 0 0 0 22px rgba(59, 99, 240, 0); } }
.fab svg { transition: transform .3s var(--spring); }
@media (hover: hover) { .fab:hover svg { transform: rotate(90deg); } }

/* ---------- แผ่น / toast ---------- */
.sheet-backdrop { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet { animation: sheetUp .42s var(--spring); box-shadow: 0 -12px 40px rgba(20, 34, 110, 0.18); }
@keyframes sheetUp { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast { animation: toastIn .45s var(--spring); }
@keyframes toastIn { from { transform: translate(-50%, 24px) scale(.9); opacity: 0; } to { transform: translate(-50%, 0) scale(1); opacity: 1; } }

/* ---------- รายการและการ์ด ---------- */
.ico { transition: transform .25s var(--spring), background-color .2s ease; }
@media (hover: hover) { .row:hover .ico { transform: scale(1.1) rotate(-5deg); } }
.wcard { background: linear-gradient(160deg, #F6F8FF 0%, #EDF1FC 100%); box-shadow: inset 0 0 0 1px var(--line); }
.bcard { background: linear-gradient(180deg, #fff 0%, #F9FAFF 100%); box-shadow: var(--shadow), inset 0 0 0 1px var(--line-soft); }
.bar { background: linear-gradient(90deg, #E3EAFF, #EAEFFF); }
.bar i { background: linear-gradient(90deg, var(--accent-light), var(--accent)); box-shadow: 0 0 12px rgba(59, 99, 240, 0.45); }
.bar.over i { background: linear-gradient(90deg, #E4503F, var(--danger)); box-shadow: 0 0 12px rgba(180, 35, 24, 0.45); }
.chart .bar-main { fill: url(#gMain); }
.group-btn { background: linear-gradient(180deg, #fff, #F6F8FF); box-shadow: 0 2px 8px rgba(20, 34, 110, 0.06); }
.amount:focus-within { border-bottom-color: var(--accent-light); }
.seg button[aria-pressed="true"] { animation: segPop .35s var(--spring); }
@keyframes segPop { from { transform: scale(.94); } to { transform: none; } }
.chip[aria-pressed="true"], .opt[aria-pressed="true"], .pick[aria-checked="true"] { animation: segPop .3s var(--spring); }

/* ---------- พลุ ---------- */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 80; }

/* ---------- หน้าล็อกอิน ---------- */
body:has(.login)::before, body:has(.login)::after { content: ''; position: fixed; border-radius: 50%; filter: blur(60px); pointer-events: none; z-index: 0; }
body:has(.login)::before { width: 340px; height: 340px; top: -90px; right: -80px; background: rgba(59, 99, 240, 0.28); animation: drift 14s ease-in-out infinite alternate; }
body:has(.login)::after { width: 300px; height: 300px; bottom: -80px; left: -90px; background: rgba(111, 142, 245, 0.28); animation: drift 17s ease-in-out infinite alternate-reverse; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(-40px, 50px) scale(1.2); } }
.login { position: relative; z-index: 1; background: transparent; }
.login > * { animation: fxIn .7s var(--ease-out) both; }
.login > :nth-child(2) { animation-delay: .08s; } .login > :nth-child(3) { animation-delay: .16s; }
.login > :nth-child(4) { animation-delay: .24s; } .login > :nth-child(5) { animation-delay: .32s; } .login > :nth-child(6) { animation-delay: .4s; }
.login-mark { background: linear-gradient(135deg, #6C94FF, #2C4DD6); color: #fff; box-shadow: 0 14px 30px -8px rgba(47, 79, 184, 0.6); animation: float 4s ease-in-out infinite, fxIn .7s var(--ease-out) both; }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
.login h1 { background: linear-gradient(120deg, var(--text) 30%, var(--accent) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav a.tab span { position: relative; }
.nav a.tab::before { top: 3px; height: 28px; }

/* ---------- สลับโหมดยอดเงินบนฮีโร่ / กระเป๋าเงินเก็บ ---------- */
.balance-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; }
.spin-btn { width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.18); color: #fff; display: grid; place-items: center; cursor: pointer; transition: background-color .15s, transform .12s; flex-shrink: 0; }
.spin-btn:hover { background: rgba(255, 255, 255, 0.3); }
.spin-btn:active { transform: scale(0.88); }
.spin-btn.turn svg { animation: spin360 .55s var(--spring); }
@keyframes spin360 { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.label.flip { animation: flipIn .35s var(--ease-out); }
@keyframes flipIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.mode-dots { display: flex; gap: 6px; margin-top: 4px; }
.mode-dots i { width: 6px; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.35); transition: width .3s var(--spring), background-color .2s; }
.mode-dots i.on { width: 18px; background: #fff; }
.wcard.savings { background: linear-gradient(160deg, #EAF1FF 0%, #DCE8FF 100%); }
.wcard.savings .n { color: var(--accent-ink); }
