/* Money — responsive personal ledger interface */

:root {
  color-scheme: light;
  --bg: #f3f3f0;
  --surface: #ffffff;
  --surface-2: #f8f8f6;
  --surface-3: #ecece8;
  --border: #deded9;
  --border-strong: #b8b8b1;
  --text: #0a0a0a;
  --muted: #64645e;
  --faint: #989891;
  --primary: #0a0a0a;
  --primary-soft: #e8e8e3;
  --primary-ink: #ffffff;
  --income: #0a0a0a;
  --income-soft: #eeeeea;
  --expense: #5d5d57;
  --expense-soft: #e6e6e1;
  --warn: #494943;
  --warn-soft: #eeeeea;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 0 rgba(0, 0, 0, .04);
  --shadow: 0 22px 60px -44px rgba(0, 0, 0, .48);
  --tab-h: 72px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation;
  font-family: var(--font-apple, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--text); color: var(--surface); }
a { color: var(--text); text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
button, input, select, textarea { font-family: inherit; }

h1, h2, h3 {
  color: var(--text);
  line-height: 1.35;
  margin: 0 0 .55rem;
  letter-spacing: -.025em;
  font-weight: 600;
}
h1 { font-size: clamp(1.55rem, 3vw, 2.25rem); }
h2 { font-size: 1.08rem; }
h3 { font-size: .98rem; }

code {
  background: var(--surface-3);
  border-radius: 4px;
  padding: .08rem .38rem;
  color: var(--text);
  font: .84em ui-monospace, SFMono-Regular, Menlo, monospace;
}

.muted { color: var(--muted); }
.small { font-size: .86rem; }
.tiny { font-size: .76rem; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: .8rem; }

/* Shell */
.wrap {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.5rem) clamp(1rem, 3vw, 1.75rem) calc(var(--tab-h) + 2rem);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.app-header-inner {
  width: min(100%, 1040px);
  min-height: 74px;
  margin: 0 auto;
  padding: .8rem clamp(1rem, 3vw, 1.75rem);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.brand {
  margin-right: auto;
  display: inline-flex;
  align-items: center;
  gap: .72rem;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid var(--text);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--text);
  color: var(--bg);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
}
.brand-copy { display: flex; flex-direction: column; line-height: 1.08; font-size: .98rem; font-weight: 600; }
.brand-copy small { margin-top: .27rem; color: var(--faint); font-size: .49rem; font-weight: 500; letter-spacing: .18em; }

.nav { display: flex; align-items: center; gap: .1rem; }
.nav a {
  position: relative;
  padding: .55rem .8rem;
  color: var(--muted);
  font-size: .87rem;
  white-space: nowrap;
  text-decoration: none;
}
.nav a::after {
  content: "";
  position: absolute;
  right: .8rem;
  bottom: .25rem;
  left: .8rem;
  height: 1px;
  background: transparent;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); font-weight: 600; }
.nav a.active::after { background: var(--text); }

.tabbar { display: none; }

.eyebrow {
  display: block;
  margin-bottom: .55rem;
  color: var(--muted);
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .18em;
}
/* Cards */
.card,
.hero {
  margin: 0 0 1rem;
  padding: clamp(1rem, 2.3vw, 1.4rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-flat { box-shadow: none; }
.card:hover { border-color: color-mix(in srgb, var(--border-strong) 72%, var(--border)); }

.quick-card {
  position: relative;
  overflow: hidden;
  padding: clamp(1.15rem, 3vw, 1.65rem);
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
}
.quick-card::after {
  content: "฿";
  position: absolute;
  top: -3.2rem;
  right: 1.25rem;
  color: color-mix(in srgb, var(--bg) 7%, transparent);
  font-family: inherit;
  font-size: 9rem;
  line-height: 1;
  pointer-events: none;
}
.quick-heading { position: relative; z-index: 1; margin-bottom: .9rem; }
.quick-heading h2 { margin: 0; color: var(--bg); font-family: inherit; font-size: clamp(1.2rem, 3vw, 1.55rem); }
.quick-heading .eyebrow { color: color-mix(in srgb, var(--bg) 62%, transparent); }

.section-title {
  margin: 2rem 0 .65rem;
  color: var(--muted);
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
}

/* Forms */
label { display: block; margin: .75rem 0; color: var(--muted); font-size: .86rem; }
label > input, label > select, label > textarea { margin-top: .35rem; }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=month], input[type=search], input[type=tel], select, textarea {
  width: 100%;
  min-height: 46px;
  padding: .68rem .78rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
textarea { min-height: 3rem; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 12%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
select { appearance: none; background-image: none; }
input[type=checkbox], input[type=radio] { accent-color: var(--text); }

.btn {
  min-height: 44px;
  padding: .58rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  background: var(--surface);
  color: var(--text);
  font-size: .91rem;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s ease, background .16s ease, border-color .16s ease, color .16s ease;
}
.btn:hover { background: var(--surface-3); border-color: var(--text); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--surface); font-weight: 600; }
.btn.primary:hover { background: var(--muted); border-color: var(--muted); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.danger { border-color: var(--border-strong); background: transparent; color: var(--muted); }
.btn.danger:hover { border-color: var(--text); background: var(--surface-3); color: var(--text); }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: .3rem .66rem; border-radius: 5px; font-size: .81rem; }
.btn.lg { min-height: 52px; padding: .78rem 1.35rem; font-size: 1rem; }
.btn:disabled { opacity: .42; cursor: not-allowed; }

.row { display: flex; flex-wrap: wrap; gap: .8rem; }
.row > * { flex: 1 1 180px; }
.row.tight { gap: .45rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-top: .7rem; }
.inline-form { display: inline; }

.quick { position: relative; z-index: 1; display: flex; gap: .55rem; }
.quick input {
  flex: 1;
  min-width: 0;
  min-height: 58px;
  margin: 0;
  padding: .9rem 1rem;
  border-color: color-mix(in srgb, var(--bg) 26%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--bg) 10%, transparent);
  color: var(--bg);
  font-size: 1.03rem;
}
.quick input::placeholder { color: color-mix(in srgb, var(--bg) 50%, transparent); }
.quick input:focus { border-color: var(--bg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bg) 16%, transparent); }
.quick button { min-height: 58px; padding: .85rem 1.4rem; border-color: var(--bg); background: var(--bg); color: var(--text); }
.quick button:hover { border-color: var(--bg); background: color-mix(in srgb, var(--bg) 86%, transparent); color: var(--text); }
.hints { position: relative; z-index: 1; margin: .8rem 0 0; color: color-mix(in srgb, var(--bg) 58%, transparent); font-size: .8rem; line-height: 2.25; }
.hints code { border: 1px solid color-mix(in srgb, var(--bg) 18%, transparent); background: transparent; color: color-mix(in srgb, var(--bg) 82%, transparent); cursor: pointer; }
.hints code:hover { border-color: var(--bg); color: var(--bg); }

/* Feedback */
.note {
  margin: 0 0 1rem;
  padding: .8rem .9rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--text);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: .9rem;
}
.note.ok, .note.error, .note.warn { border-color: var(--border); border-left-color: var(--text); background: var(--surface-2); }

/* Financial overview */
.hero { padding: 1.25rem 1.35rem; box-shadow: var(--shadow); }
.hero .label, .stat .label { color: var(--muted); font-size: .73rem; letter-spacing: .04em; }
.hero .amount { margin: .12rem 0; font-family: inherit; font-size: clamp(2rem, 6vw, 3rem); font-weight: 600; letter-spacing: -.04em; }
.hero .sub { color: var(--muted); font-size: .83rem; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; margin-bottom: 1rem; }
.stat {
  min-height: 112px;
  padding: .95rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.stat:last-child { background: var(--text); border-color: var(--text); color: var(--surface); }
.stat:last-child .label { color: color-mix(in srgb, var(--surface) 58%, transparent); }
.stat:last-child .value { color: var(--surface); }
.stat .value { margin-top: .65rem; color: var(--text); font-family: inherit; font-size: clamp(1.25rem, 3vw, 1.62rem); font-weight: 600; letter-spacing: -.035em; }
.stat .value.income { color: var(--income); }
.stat .value.expense { color: var(--expense); }

/* Transactions */
.tx-list { list-style: none; margin: 0; padding: 0; }
.tx {
  min-height: 67px;
  padding: .72rem .1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid var(--border);
}
.tx:last-child { border-bottom: 0; }
.tx .icon {
  width: 39px;
  height: 39px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-size: 1rem;
  filter: grayscale(1);
}
.tx .body { flex: 1; min-width: 0; }
.tx .title { display: block; overflow: hidden; color: var(--text); font-size: .93rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.tx .meta { display: block; overflow: hidden; color: var(--muted); font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.tx .amt { color: var(--text); font-size: .94rem; font-weight: 600; white-space: nowrap; }
.tx .amt.expense { color: var(--expense); }
.tx .amt.income { color: var(--income); }
.tx .amt.transfer { color: var(--muted); }
.tx .go { padding: 0 .15rem; color: var(--faint); font-size: 1.35rem; text-decoration: none; }
.tx .go:hover { color: var(--text); text-decoration: none; }

.date-head { padding: 1.05rem .1rem .35rem; display: flex; justify-content: space-between; color: var(--faint); font-size: .7rem; font-weight: 500; letter-spacing: .04em; }
.tx-list .date-head:first-child { padding-top: .2rem; }
.date-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: .42rem; }
.day-totals { color: var(--expense); font-size: .65rem; font-weight: 750; letter-spacing: 0; }

.badge {
  display: inline-block;
  margin-left: .3rem;
  padding: .05rem .38rem;
  vertical-align: middle;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .64rem;
  font-weight: 500;
}
.badge.info, .badge.good { border-color: var(--border-strong); background: var(--surface-2); color: var(--muted); }
.tag { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; }

/* Charts */
.bars { list-style: none; margin: .65rem 0 0; padding: 0; }
.bars li { margin-bottom: .95rem; }
.bars li:last-child { margin-bottom: 0; }
.bars .lbl { margin-bottom: .32rem; display: flex; justify-content: space-between; gap: .6rem; color: var(--text); font-size: .84rem; }
.track { height: 6px; overflow: hidden; display: block; border-radius: 0; background: var(--surface-3); }
.fill { height: 100%; display: block; border-radius: 0; filter: grayscale(1) contrast(1.25); }
.fill.warn, .fill.over { background: var(--text) !important; }
.chart { width: 100%; height: auto; display: block; color: var(--text); filter: grayscale(1) contrast(1.15); }
.legend { list-style: none; margin: .8rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .45rem 1rem; font-size: .82rem; }
.legend li { display: flex; align-items: center; gap: .38rem; }
.dot { width: 9px; height: 9px; flex: none; display: inline-block; border-radius: 50%; filter: grayscale(1) contrast(1.2); }

/* Tables */
.table-scroll { overflow-x: auto; margin: 0 -.25rem; padding: 0 .25rem; scrollbar-width: thin; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .7rem .45rem; vertical-align: top; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--faint); font-size: .66rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }

/* Authentication and onboarding */
.auth-page {
  min-height: 100vh;
  padding: 1.5rem 1rem;
  display: grid;
  place-items: center;
  background: #080808;
}
.auth-card {
  width: 100%;
  max-width: 390px;
  padding: clamp(1.5rem, 5vw, 2.15rem);
  border: 1px solid color-mix(in srgb, var(--surface) 16%, transparent);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: 0 28px 90px -38px rgba(0, 0, 0, .78);
}
.auth-card h1 { text-align: center; font-family: inherit; font-size: 1.42rem; }
.auth-logo {
  width: 58px;
  height: 58px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--text);
  color: var(--surface);
  font-family: inherit;
  font-size: 1.45rem;
  font-weight: 700;
}

.pin-dots { min-height: 18px; margin: 1.35rem 0 1.55rem; display: flex; justify-content: center; gap: .72rem; }
.pin-dots span { width: 12px; height: 12px; border: 1px solid var(--border-strong); border-radius: 50%; background: transparent; transition: transform .12s ease, background .12s ease; }
.pin-dots span.on { border-color: var(--text); background: var(--text); transform: scale(1.08); }
.pin-dots.shake { animation: shake .38s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.keypad button {
  min-height: 56px;
  padding: .65rem 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 1.32rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s ease, transform .06s ease;
}
.keypad button:hover { background: var(--surface-3); border-color: var(--border-strong); }
.keypad button:active { transform: scale(.97); }
.keypad button.util { border-color: transparent; background: transparent; color: var(--muted); font-size: .88rem; }

/* Setup */
.steps { display: flex; gap: .4rem; margin-bottom: 1.25rem; }
.steps .step { height: 3px; flex: 1; background: var(--surface-3); }
.steps .step.done { background: var(--text); }
.step-label { margin-bottom: .3rem; color: var(--muted); font-size: .76rem; }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .55rem; }
.pick { margin: 0; padding: .6rem .68rem; display: flex; align-items: center; gap: .5rem; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font-size: .87rem; cursor: pointer; }
.pick:hover { border-color: var(--text); }
.pick input { width: auto; margin: 0; flex: none; }
.pick.on { border-color: var(--text); background: var(--primary-soft); }

.setup-link { padding: .82rem .1rem; display: flex; align-items: center; gap: .8rem; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.setup-link:last-child { border-bottom: 0; }
.setup-link:hover { text-decoration: none; }
.setup-link .ico { width: 39px; height: 39px; flex: none; border: 1px solid var(--border); border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 1rem; filter: grayscale(1); }
.setup-link .body { flex: 1; min-width: 0; }
.setup-link .name { display: block; font-size: .93rem; font-weight: 500; }
.setup-link .desc { display: block; color: var(--muted); font-size: .77rem; line-height: 1.45; }
.setup-link .go { color: var(--faint); font-size: 1.25rem; }
.pager { margin-top: 1rem; display: flex; align-items: center; justify-content: center; gap: .5rem; }

.amt-box { flex: none; display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.amt-box .running { margin-top: 1px; color: var(--faint); font-size: .66rem; line-height: 1.4; white-space: nowrap; }
.amt-box .running b { color: var(--muted); font-weight: 500; }
.opening-note { margin: .8rem 0 0; padding-top: .8rem; border-top: 1px dashed var(--border); color: var(--faint); font-size: .72rem; line-height: 1.9; }
.opening-note .lead, .opening-note b { color: var(--muted); font-weight: 500; }
.opening-note .bit { white-space: nowrap; }
.opening-note .bit::before { content: " · "; color: var(--border-strong); }
.opening-note .sum b { color: var(--text); }

@media (max-width: 719px) {
  .nav { display: none; }
  .app-header-inner { min-height: 64px; }
  .brand .mark { width: 34px; height: 34px; }
  .brand-copy small { display: none; }
  .tabbar {
    position: fixed;
    right: .75rem;
    bottom: max(.75rem, env(safe-area-inset-bottom));
    left: .75rem;
    z-index: 40;
    display: block;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--surface) 14%, transparent);
    border-radius: 14px;
    background: color-mix(in srgb, var(--text) 94%, transparent);
    box-shadow: 0 18px 55px -26px rgba(0, 0, 0, .8);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
  .tabbar-inner { display: flex; }
  .tabbar a {
    min-height: 60px;
    padding: .48rem .15rem .42rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .1rem;
    color: color-mix(in srgb, var(--surface) 58%, transparent);
    font-size: .64rem;
    line-height: 1.2;
    text-decoration: none;
  }
  .tabbar a .ico { min-height: 17px; color: inherit; font-size: 1rem; font-weight: 400; line-height: 1; letter-spacing: -.08em; }
  .tabbar a.active { color: var(--surface); font-weight: 500; }
  .tabbar a.active .ico { transform: scale(1.08); }
}

@media (min-width: 720px) {
  .wrap { padding-bottom: 3.5rem; }
}

@media (max-width: 560px) {
  .wrap { padding-top: 1rem; }
  .quick { flex-direction: column; }
  .quick button { width: 100%; }
  .hints { line-height: 2.4; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { min-height: 98px; }
  .stat:last-child { grid-column: 1 / -1; min-height: 88px; flex-direction: row; align-items: flex-end; }
  .stat:last-child .value { margin-top: 0; }
  .tx { gap: .58rem; }
  .tx .icon { width: 35px; height: 35px; }
  .tx .go { display: none; }
  .tx .amt { font-size: .88rem; }
  .bars .lbl { align-items: flex-end; font-size: .78rem; }
}

@media (max-width: 390px) {
  .stats { grid-template-columns: 1fr; }
  .stat, .stat:last-child { min-height: 82px; grid-column: auto; flex-direction: row; align-items: flex-end; }
  .stat .value { margin-top: 0; }
  .tx .meta { max-width: 145px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ==================================================================
   Money — warm color edition
   Apple-style system typography, richer hierarchy, clearer mobile nav.
   ================================================================== */

:root {
  color-scheme: light;
  --font-apple: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "SF Pro TH", "Helvetica Neue", Helvetica, Arial, "Noto Sans Thai", sans-serif;
  --bg: #f7f4eb;
  --surface: #fffdf8;
  --surface-2: #f1eee5;
  --surface-3: #e8e3d8;
  --border: #dcd8cd;
  --border-strong: #bcb6aa;
  --text: #17212b;
  --muted: #68717a;
  --faint: #8b9298;
  --primary: #6c5ce7;
  --primary-soft: #d9d3ff;
  --primary-ink: #ffffff;
  --income: #178a67;
  --income-soft: #c9f1e4;
  --expense: #c34e3b;
  --expense-soft: #ffd8ce;
  --warn: #8c6500;
  --warn-soft: #ffeab4;
  --violet: #6c5ce7;
  --violet-light: #d9d3ff;
  --coral: #ff8066;
  --coral-light: #ffd8ce;
  --mint: #4fc7a4;
  --mint-light: #c9f1e4;
  --sky: #58b8e8;
  --sky-light: #ccecff;
  --sun: #f4be45;
  --sun-light: #ffeab4;
  --r-sm: 11px;
  --r: 20px;
  --r-lg: 25px;
  --shadow-sm: 0 12px 34px -28px rgba(51, 43, 30, .35);
  --shadow: 0 24px 60px -38px rgba(51, 43, 30, .38);
  --tab-h: 92px;
}

html { background: var(--bg); }
body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 4% 2%, rgba(244, 190, 69, .16), transparent 26%),
    radial-gradient(circle at 96% 8%, rgba(108, 92, 231, .11), transparent 28%),
    var(--bg);
  font-family: var(--font-apple);
  font-synthesis: none;
  line-height: 1.5;
  -moz-osx-font-smoothing: grayscale;
}

body, button, input, select, textarea,
h1, h2, h3, .brand .mark, .quick-heading h2,
.hero .amount, .stat .value, .auth-card h1, .auth-logo {
  font-family: var(--font-apple);
}

::selection { background: var(--violet-light); color: var(--text); }
a { color: var(--violet); text-decoration-color: color-mix(in srgb, var(--violet) 45%, transparent); }
.btn:focus-visible, a:focus-visible { outline-color: var(--sky); }

.app-header {
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  border-bottom-color: rgba(23, 33, 43, .12);
}
.app-header-inner { min-height: 82px; }
.brand .mark {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 13px;
  background: var(--violet);
  color: #fff;
  font-size: 1.28rem;
  font-weight: 750;
  box-shadow: 7px 7px 0 var(--sun);
}
.brand-copy { color: var(--text); font-weight: 700; }
.brand-copy small { color: var(--muted); font-weight: 650; }
.nav { gap: .2rem; }
.nav a { border-radius: 999px; padding: .58rem .88rem; }
.nav a::after { display: none; }
.nav a:hover { background: var(--surface); }
.nav a.active { background: var(--text); color: #fff; }

.wrap { width: min(100%, 1120px); padding-top: clamp(1.15rem, 3vw, 2.35rem); }
.card, .hero {
  border-color: var(--border);
  border-radius: var(--r);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  box-shadow: var(--shadow-sm);
}
.card:hover { border-color: var(--border-strong); }

.quick-card {
  padding: clamp(1.35rem, 4vw, 2.7rem);
  border: 0;
  border-radius: 28px;
  background: var(--violet);
  color: #fff;
  box-shadow: 0 26px 70px -35px rgba(74, 53, 181, .65);
}
.quick-card::after {
  top: -5.2rem;
  right: 1.8rem;
  color: rgba(255,255,255,.08);
  font-family: var(--font-apple);
  font-size: 15rem;
  font-weight: 750;
}
.quick-heading h2 { color: #fff; font-size: clamp(1.35rem, 3vw, 2rem); font-weight: 700; line-height: 1.35; }
.quick-heading .eyebrow { color: var(--sun-light); font-weight: 800; }
.quick input {
  min-height: 64px;
  padding: .95rem 1.15rem;
  border-color: rgba(255,255,255,.4);
  border-radius: 15px;
  background: var(--surface);
  color: var(--text);
  caret-color: var(--text);
  -webkit-text-fill-color: var(--text);
}
.quick input::placeholder { color: var(--muted); opacity: 1; }
.quick input:focus { border-color: var(--text); box-shadow: 0 0 0 3px rgba(244,190,69,.55); }
.quick button, .quick .btn.primary {
  min-height: 64px;
  min-width: 132px;
  border: 0;
  border-radius: 15px;
  background: var(--sun);
  color: var(--text);
  font-weight: 800;
}
.quick button:hover, .quick .btn.primary:hover { background: #ffd163; color: var(--text); }
.hints { color: rgba(255,255,255,.68); }
.hints code { border-color: rgba(255,255,255,.28); border-radius: 999px; color: #fff; }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=month], input[type=search], input[type=tel], select, textarea {
  border-color: var(--border-strong);
  border-radius: var(--r-sm);
  background-color: var(--surface);
}
input:focus, select:focus, textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(108,92,231,.16); }
input[type=checkbox], input[type=radio] { accent-color: var(--violet); }

.btn { border-color: var(--border); border-radius: 11px; background: var(--surface); font-weight: 650; }
.btn:hover { border-color: var(--violet); background: var(--violet-light); }
.btn.primary { border-color: var(--violet); background: var(--violet); color: #fff; }
.btn.primary:hover { border-color: #5847d3; background: #5847d3; }
.btn.danger { border-color: var(--coral-light); color: var(--expense); }
.btn.danger:hover { border-color: var(--coral); background: var(--coral-light); color: #9c382c; }
.btn.sm { border-radius: 9px; }

.section-title { color: var(--violet); font-weight: 800; }
.stats { gap: clamp(.7rem, 2vw, 1.1rem); }
.stat {
  min-height: 145px;
  padding: clamp(1rem, 2.5vw, 1.45rem);
  border: 0;
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.stat:nth-child(1) { background: var(--mint-light); }
.stat:nth-child(2) { background: var(--coral-light); }
.stat:last-child { background: var(--text); color: #fff; }
.stat:last-child .label { color: rgba(255,255,255,.64); }
.stat:last-child .value { color: #fff; }
.stat .label { color: color-mix(in srgb, var(--text) 70%, transparent); font-weight: 700; }
.stat .value { font-family: var(--font-apple); font-size: clamp(1.45rem, 3.5vw, 2.25rem); font-weight: 750; line-height: 1.15; }

.note { border: 0; border-left: 4px solid var(--violet); border-radius: 12px; background: var(--violet-light); }
.note.ok { border-left-color: var(--mint); background: var(--mint-light); }
.note.warn { border-left-color: var(--sun); background: var(--sun-light); }
.note.error { border-left-color: var(--coral); background: var(--coral-light); }

.tx { min-height: 72px; }
.tx .icon {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 13px;
  filter: none;
  font-size: 1rem;
}
.tx:nth-child(5n+1) .icon { background: var(--coral-light); }
.tx:nth-child(5n+2) .icon { background: var(--sky-light); }
.tx:nth-child(5n+3) .icon { background: var(--mint-light); }
.tx:nth-child(5n+4) .icon { background: var(--violet-light); }
.tx:nth-child(5n+5) .icon { background: var(--sun-light); }
.tx .title { font-weight: 650; }
.tx .amt { font-weight: 750; }
.tx-bank-logo {
  width: 42px;
  height: 30px;
  padding: 4px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
}
.tx-bank-logo img { display: block; max-width: 33px; max-height: 21px; object-fit: contain; }

.account-name-line { display: flex; align-items: center; gap: .7rem; }
.bank-logo {
  width: 52px;
  height: 36px;
  padding: 5px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.bank-logo img { display: block; max-width: 41px; max-height: 25px; object-fit: contain; }

.track { height: 10px; border-radius: 999px; background: var(--surface-3); }
.fill { border-radius: inherit; filter: none; }
.fill.warn { background: var(--sun) !important; }
.fill.over { background: var(--coral) !important; }
.chart, .dot { filter: none; }
.dot { width: 10px; height: 10px; }

.auth-page {
  background:
    radial-gradient(circle at 15% 10%, rgba(244,190,69,.35), transparent 30%),
    radial-gradient(circle at 90% 90%, rgba(88,184,232,.28), transparent 33%),
    var(--violet);
}
.auth-card { border: 0; border-radius: 26px; background: var(--surface); box-shadow: 0 32px 90px -35px rgba(23,33,43,.68); }
.auth-card h1 { font-family: var(--font-apple); font-weight: 750; }
.auth-logo {
  border-radius: 17px;
  background: var(--violet);
  color: #fff;
  font-family: var(--font-apple);
  box-shadow: 8px 8px 0 var(--sun);
}
.pin-dots span.on { border-color: var(--violet); background: var(--violet); }
.keypad button { border: 0; border-radius: 13px; background: var(--surface-2); }
.keypad button:hover { background: var(--violet-light); }

.steps .step.done { background: var(--violet); }
.pick { border-color: var(--border); border-radius: 12px; }
.pick:hover, .pick.on { border-color: var(--violet); }
.pick.on { background: var(--violet-light); }
.setup-link .ico { border: 0; border-radius: 13px; filter: none; }
.setup-link:nth-child(5n+1) .ico { background: var(--violet-light); }
.setup-link:nth-child(5n+2) .ico { background: var(--sky-light); }
.setup-link:nth-child(5n+3) .ico { background: var(--mint-light); }
.setup-link:nth-child(5n+4) .ico { background: var(--coral-light); }
.setup-link:nth-child(5n+5) .ico { background: var(--sun-light); }

@media (max-width: 719px) {
  .app-header-inner { min-height: 70px; }
  .brand .mark { width: 38px; height: 38px; border-radius: 12px; box-shadow: 6px 6px 0 var(--sun); }
  .tabbar {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    height: 78px;
    padding: 7px;
    overflow: visible;
    border: 1px solid rgba(23,33,43,.12);
    border-radius: 22px;
    background: rgba(255,253,248,.96);
    box-shadow: 0 20px 50px -20px rgba(23,33,43,.48), 0 3px 10px rgba(23,33,43,.08);
  }
  .tabbar-inner { height: 100%; }
  .tabbar a {
    min-width: 0;
    min-height: 64px;
    padding: 5px 2px;
    gap: 4px;
    border-radius: 15px;
    color: #4f5963;
    font-size: .62rem;
    font-weight: 700;
    transition: transform .16s ease, background .16s ease, color .16s ease;
  }
  .tabbar a .ico {
    width: 34px;
    height: 30px;
    min-height: 30px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0;
  }
  .tabbar a:nth-child(1) .ico { background: var(--violet-light); color: #4939ba; }
  .tabbar a:nth-child(2) .ico { background: var(--sky-light); color: #167eae; }
  .tabbar a:nth-child(3) .ico { background: var(--mint-light); color: #147a5e; }
  .tabbar a:nth-child(4) .ico { background: var(--coral-light); color: #b94534; }
  .tabbar a:nth-child(5) .ico { background: var(--sun-light); color: #8c6500; }
  .tabbar a.active { background: #f0ece3; color: var(--text); font-weight: 750; transform: translateY(-3px); }
  .tabbar a:nth-child(1).active .ico { background: var(--violet); color: #fff; box-shadow: 0 7px 16px rgba(108,92,231,.28); }
  .tabbar a:nth-child(2).active .ico { background: var(--sky); color: #fff; box-shadow: 0 7px 16px rgba(88,184,232,.3); }
  .tabbar a:nth-child(3).active .ico { background: var(--mint); color: var(--text); box-shadow: 0 7px 16px rgba(79,199,164,.3); }
  .tabbar a:nth-child(4).active .ico { background: var(--coral); color: #fff; box-shadow: 0 7px 16px rgba(255,128,102,.3); }
  .tabbar a:nth-child(5).active .ico { background: var(--sun); color: var(--text); box-shadow: 0 7px 16px rgba(244,190,69,.32); }
}

@media (max-width: 560px) {
  .quick-card { border-radius: 22px; }
  .quick button { width: 100%; }
  .stat { min-height: 124px; }
  .stat:last-child { min-height: 106px; }
  .tx-bank-logo { display: none; }
}
