/* EZ Money Manager — modern white notebook theme */
:root {
  --ink: #24303c;
  --ink-soft: #5c6b7a;
  --ink-faint: #93a1b0;
  --paper: #fdfdfc;
  --grid: #e7edf4;          /* very light grid line */
  --rule: #e3eaf2;          /* ruled line inside cards */
  --margin-red: #f2b8c0;    /* notebook margin line */
  --card: #ffffff;
  --border: #e4e9ef;
  --shadow: 0 1px 2px rgba(36, 48, 60, .05), 0 6px 18px rgba(36, 48, 60, .06);
  --green: #2e9e5b;
  --green-soft: #e5f5ec;
  --red: #d9534a;
  --red-soft: #fdecea;
  --blue: #3566c4;
  --blue-soft: #e9f0fc;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  /* notebook grid background */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  min-height: 100vh;
  padding-bottom: 60px;
}

h1 { font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; }
h2 {
  font-family: 'Caveat', cursive;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .6rem;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .8rem 1.6rem;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #35c46f, #1f8f56);
  color: #fff; font-weight: 800; font-size: 1.35rem;
  display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(46, 158, 91, .35);
}
.tagline { font-family: 'Caveat', cursive; font-size: 1rem; color: var(--ink-faint); line-height: 1; }

.tabs { display: flex; gap: .25rem; flex: 1; }
.tab {
  border: none; background: none; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--ink-soft);
  padding: .5rem .95rem; border-radius: 10px;
  transition: .15s;
}
.tab:hover { background: var(--blue-soft); color: var(--blue); }
.tab.active { background: var(--ink); color: #fff; }

.month-nav {
  display: flex; align-items: center; gap: .4rem;
  font-weight: 700; min-width: 190px; justify-content: flex-end;
}
.month-nav span { min-width: 118px; text-align: center; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 1.05rem; color: var(--ink-soft);
}
.icon-btn:hover { background: var(--blue-soft); color: var(--blue); }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.3rem;
}

main { max-width: 1200px; margin: 0 auto; padding: 0 1.6rem; }
.view { display: none; }
.view.active { display: block; }

/* ---------- total asset ---------- */
.total-asset {
  width: min(1200px, calc(100% - 3.2rem));
  margin: 1.1rem auto 0;
  background: linear-gradient(135deg, #ffffff 0%, #f4faf6 100%);
  border-color: #d7eade;
}
.ta-head { display: flex; align-items: center; justify-content: space-between; }
.ta-head h2 { margin-bottom: 0; }
.ta-values { display: flex; align-items: baseline; gap: 2.2rem; flex-wrap: wrap; margin: .35rem 0 .2rem; }
.ta-item { display: flex; flex-direction: column; gap: .1rem; }
.ta-cur { font-size: .72rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); }
.ta-num { font-weight: 800; letter-spacing: -.02em; font-size: 1.45rem; color: var(--ink); }
.ta-main .ta-num { font-size: 2.15rem; color: var(--green); }
.ta-rateline { font-size: .78rem; color: var(--ink-faint); font-style: italic; }

/* ---------- quick add ---------- */
.quick-add {
  width: min(1200px, calc(100% - 3.2rem));
  margin: 1.1rem auto;
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
}

.type-toggle { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.tt-btn {
  border: none; background: #fff; cursor: pointer; font: inherit;
  font-weight: 700; padding: .55rem .9rem; color: var(--ink-faint);
}
.tt-btn.tt-expense.active { background: var(--red-soft); color: var(--red); }
.tt-btn.tt-income.active { background: var(--green-soft); color: var(--green); }

.qa-amount { width: 150px; font-weight: 700; font-size: 1.05rem; }
.qa-received { width: 130px; }
.qa-field.hidden, .qa-note.hidden { display: none; }
.qa-arrow { display: grid; place-items: center; color: var(--ink-faint); font-weight: 700; padding: 0 .1rem; border: none; background: none; }
.tt-btn.tt-transfer.active { background: var(--blue-soft); color: var(--blue); }
.tt-btn.tt-topup.active { background: #eef7f0; color: var(--green); }
input, select {
  font: inherit; color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px;
  padding: .55rem .7rem; background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
#qaNote { flex: 1; min-width: 140px; }

.btn-primary {
  border: none; cursor: pointer; font: inherit; font-weight: 700;
  background: var(--ink); color: #fff;
  padding: .6rem 1.15rem; border-radius: 10px;
  transition: .15s;
}
.btn-primary:hover { background: #3a4a5a; }
.btn-ghost {
  border: 1px solid var(--border); background: #fff; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--ink-soft);
  padding: .5rem .9rem; border-radius: 10px;
}
.btn-ghost:hover { background: var(--blue-soft); color: var(--blue); }
.btn-danger {
  border: none; cursor: pointer; font: inherit; font-weight: 700;
  background: var(--red-soft); color: var(--red);
  padding: .55rem 1rem; border-radius: 10px;
}
.btn-danger:hover { background: var(--red); color: #fff; }

/* ---------- wallet overview ---------- */
.wallet-overview { margin-bottom: .9rem; }
.wo-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .8rem; }
.wo-grand { font-size: .9rem; font-weight: 700; color: var(--ink-soft); display: flex; gap: .8rem; flex-wrap: wrap; }
.wo-grand span { white-space: nowrap; }
.wallet-bars { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 2rem; }
@media (max-width: 900px) { .wallet-bars { grid-template-columns: 1fr; } }
.wallet-group { padding: .2rem 0; }
.wg-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: .78rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-faint); border-bottom: 1px solid var(--rule); padding-bottom: .25rem; margin-bottom: .45rem;
}
.wg-sub { color: var(--ink-soft); }
.wallet-bar-row { display: grid; grid-template-columns: 130px 1fr auto auto; align-items: center; gap: .7rem; padding: .2rem 0; font-size: .84rem; }
.wbr-fix {
  border: none; background: none; cursor: pointer; font-size: .85rem;
  color: var(--ink-faint); padding: .1rem .3rem; border-radius: 6px; opacity: .55;
}
.wallet-bar-row:hover .wbr-fix, .wbr-fix:focus { opacity: 1; }
.wbr-fix:hover { background: var(--blue-soft); color: var(--blue); }
.adjust-btn { display: none; } /* desktop uses the per-row ⚖ icons */
.wbr-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; color: var(--ink); }
.wbr-track { height: 14px; background: #f0f4f8; border-radius: 7px; overflow: hidden; }
.wbr-fill { height: 100%; border-radius: 7px; min-width: 2px; transition: width .35s; }
.wbr-val { font-weight: 700; white-space: nowrap; text-align: right; }
.wbr-val.neg { color: var(--red); }

/* ---------- currency scope ---------- */
.scope-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .7rem; flex-wrap: wrap; }
.scope-label { font-size: .8rem; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; }
.scope-note { font-size: .82rem; color: var(--ink-faint); }
.cur-scope { display: inline-flex; gap: .3rem; }
.cur-scope button {
  font: inherit; font-weight: 700; cursor: pointer; font-size: .85rem;
  border: 1.5px solid var(--border); background: #fff; color: var(--ink-soft);
  padding: .3rem .8rem; border-radius: 999px;
}
.cur-scope button.active { border-color: var(--ink); background: var(--ink); color: #fff; }

/* ---------- dashboard ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .9rem; margin-bottom: .9rem; }
.stat { display: flex; flex-direction: column; gap: .25rem; }
.stat-label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.stat-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.stat-income .stat-value { color: var(--green); }
.stat-expense .stat-value { color: var(--red); }
.stat-balance .stat-value { color: var(--blue); }

.dash-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: .9rem; margin-bottom: .9rem; }
.chart-wide { grid-column: 1 / -1; }
.chart-card svg { width: 100%; height: auto; }
.donut-wrap { display: flex; align-items: center; gap: 1.2rem; }
#donut { flex: 0 0 200px; }
.donut-legend { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; max-height: 210px; overflow-y: auto; flex: 1; }
.donut-legend .row { display: flex; align-items: center; gap: .5rem; }
.donut-legend .row .amt { margin-left: auto; font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.dot-inc { background: var(--green); }
.dot-exp { background: var(--red); }
.trend-legend { display: flex; gap: 1.2rem; font-size: .82rem; color: var(--ink-soft); margin-top: .3rem; }
.trend-legend span { display: inline-flex; align-items: center; gap: .4rem; }

.empty { color: var(--ink-faint); font-style: italic; padding: 1.2rem 0; text-align: center; }

/* ---------- ledger (notebook page) ---------- */
.filter-bar { display: flex; gap: .6rem; margin-bottom: .9rem; align-items: center; }
#fltSearch { flex: 1; }

.notebook-page { padding: 0; overflow: hidden; }
.page-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 1rem 1.4rem .4rem;
  font-family: 'Caveat', cursive; font-size: 1.6rem; font-weight: 700;
}
.page-count { font-size: 1rem; color: var(--ink-faint); font-family: 'Inter', sans-serif; font-weight: 500; }

.ledger-lines { position: relative; }
/* red margin line like a real notebook */
.ledger-lines.margin-line::before {
  content: ''; position: absolute; left: 86px; top: 0; bottom: 0;
  width: 1.5px; background: var(--margin-red);
}
.ledger-row {
  display: flex; align-items: center; gap: .8rem;
  padding: .55rem 1.4rem;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background .12s;
  line-height: 1.3;
}
.ledger-row:hover { background: #f7fafd; }

/* date banding — each calendar day gets its own pastel page tint */
.ledger-row.banded { background: var(--band); }
.ledger-row.banded:hover { background: var(--band-hover); }
.ledger-row.banded[data-band="0"] { --band: #fff6e9; --band-hover: #ffeed6; }
.ledger-row.banded[data-band="1"] { --band: #ecf6f1; --band-hover: #ddefe6; }
.ledger-row.banded[data-band="2"] { --band: #eef3fd; --band-hover: #e0eafb; }
.ledger-row.banded[data-band="3"] { --band: #fdeef1; --band-hover: #fbe0e6; }
.ledger-row.banded[data-band="4"] { --band: #f4effb; --band-hover: #eae1f7; }
.ledger-row.banded[data-band="5"] { --band: #f6f8e9; --band-hover: #eef2d8; }
/* run the tint to the card edges instead of floating inside its padding */
.recent-card { overflow: hidden; }
.recent-card .ledger-lines { margin: 0 -1.3rem -1.1rem; }
.recent-card .ledger-row:last-child { border-bottom: none; }
.lr-date { width: 52px; flex: none; font-size: .78rem; color: var(--ink-faint); font-weight: 600; text-align: right; }
.lr-cat {
  flex: none; display: inline-flex; align-items: center; gap: .45rem;
  font-weight: 600; font-size: .88rem; width: 190px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lr-note { flex: 1; color: var(--ink-soft); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: 'Caveat', cursive; font-size: 1.15rem; }
.lr-wallet {
  flex: none; font-size: .74rem; font-weight: 600; color: var(--ink-soft);
  background: #f1f5f9; border-radius: 6px; padding: .12rem .5rem; white-space: nowrap;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis;
}
.lr-amount { font-weight: 700; flex: none; min-width: 96px; text-align: right; }
.lr-kip { font-style: normal; font-weight: 600; font-size: .78em; color: var(--ink-faint); white-space: nowrap; }
.lr-amount.exp { color: var(--red); }
.lr-amount.inc { color: var(--green); }
.lr-amount.topup { color: var(--blue); }
.lr-amount.transfer { color: var(--ink-soft); }
.lr-amount.adjust { color: #8a6fbf; }
.lr-cat.transfer i, .lr-cat.topup i, .lr-cat.adjust i { display: none; }

.page-total {
  display: flex; justify-content: space-between; padding: .8rem 1.4rem;
  font-weight: 800; border-top: 2px solid var(--ink);
  background: #fbfcfe;
}

/* ---------- report ---------- */
.report-head-card { margin-bottom: .9rem; }
.rep-head { display: flex; align-items: center; justify-content: space-between; }
.rep-head h2 { margin-bottom: 0; }
.rep-scope { margin: .5rem 0 0; }
.rep-topcats { display: flex; flex-direction: column; gap: .55rem; padding: .2rem 0; }
.rep-cat-row { display: grid; grid-template-columns: 190px 1fr auto; align-items: center; gap: .8rem; font-size: .86rem; }
.rep-cat-name { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rep-cat-amt { font-weight: 700; white-space: nowrap; }
.rep-cat-amt em { font-style: normal; color: var(--ink-faint); font-weight: 600; font-size: .78rem; margin-left: .4rem; }
.rep-table-wrap { overflow-x: auto; padding: .4rem 1.4rem 1rem; }
.rep-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.rep-table th { text-align: right; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); padding: .4rem .6rem; border-bottom: 2px solid var(--ink); }
.rep-table th:first-child { text-align: left; }
.rep-table td { padding: .42rem .6rem; border-bottom: 1px solid var(--rule); }
.rep-table td.num { text-align: right; font-weight: 600; white-space: nowrap; }
.rep-table td.num.inc { color: var(--green); }
.rep-table td.num.exp { color: var(--red); }
.rep-table tr.rep-dim td { color: var(--ink-faint); }
.rep-table tr.rep-dim td.num { color: var(--ink-faint); font-weight: 400; }
.rep-table tr.rep-now td { background: var(--blue-soft); }
.rep-table tr.rep-now td:first-child { font-weight: 800; }
.rep-table tr.rep-total td { border-top: 2px solid var(--ink); border-bottom: none; font-weight: 800; }

/* ---------- financial planning ---------- */
.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;
}
.plan-amount-row { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.plan-amount-row label { font-weight: 600; color: var(--ink-soft); }
.plan-amount-field {
  display: flex; align-items: center; gap: .1rem;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
  padding-left: .7rem;
}
.plan-amount-field:focus-within { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.plan-cur { font-weight: 700; color: var(--ink-soft); }
#planCopyPrev.hidden { display: none; }
#planAmount {
  width: 200px; border: none; outline: none; background: none;
  font-weight: 800; font-size: 1.15rem; padding-left: .25rem;
}

.plan-card { margin-top: 1.1rem; }
.plan-table-wrap { overflow-x: auto; padding: .3rem 1.4rem .2rem; }
.plan-table { width: 100%; border-collapse: collapse; }
.plan-table th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-faint); padding: .4rem .5rem; border-bottom: 2px solid var(--ink);
}
.plan-table th.th-num { text-align: right; }
.plan-table th.th-del { width: 40px; }
.plan-table td { padding: .35rem .5rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.plan-table tr:last-child td { border-bottom: none; }
.plan-cat { display: flex; align-items: center; gap: .5rem; }
.plan-cat .dot { flex: none; }
.plan-name { width: 100%; max-width: 340px; min-width: 120px; font-weight: 600; border-color: transparent; background: transparent; }
.plan-name:hover { border-color: var(--border); background: #fff; }
.plan-num { text-align: right; white-space: nowrap; }
.plan-num input { width: 100%; text-align: right; font-weight: 700; }
.pct-wrap { display: flex; align-items: center; justify-content: flex-end; gap: .2rem; }
.pct-wrap input { flex: 1; min-width: 0; }
.plan-unit { color: var(--ink-faint); font-weight: 700; flex: none; }
.plan-del { text-align: right; }
/* category name gets the slack; the number columns stay fixed */
.plan-table th:nth-child(2), .plan-table td:nth-child(2) { width: 120px; }
.plan-table th:nth-child(3), .plan-table td:nth-child(3) { width: 168px; }
.row-del {
  border: none; background: none; cursor: pointer; font: inherit;
  color: var(--ink-faint); padding: .3rem .45rem; border-radius: 8px; line-height: 1;
}
.row-del:hover { background: var(--red-soft); color: var(--red); }
.plan-empty td { color: var(--ink-faint); font-style: italic; text-align: center; padding: 1.4rem 0; }
.plan-add { display: flex; gap: .5rem; padding: .9rem 1.4rem 1.1rem; border-top: 1px solid var(--rule); }
.plan-add input { flex: 1; }

.plan-summary { margin-top: 1.1rem; }
.ps-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.ps-block { display: flex; flex-direction: column; gap: .15rem; }
.ps-block.ps-right { text-align: right; }
.ps-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); font-weight: 700; }
.ps-num { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.ps-of { font-size: 1.15rem; font-weight: 700; color: var(--ink-soft); }
.ps-bar { height: 14px; border-radius: 7px; background: #eef2f7; overflow: hidden; margin: .9rem 0 .6rem; }
.ps-fill { height: 100%; border-radius: 7px; background: var(--green); }
.ps-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.ps-pct { font-weight: 700; font-size: .9rem; color: var(--ink-soft); flex: none; }
.ps-status { font-size: .85rem; color: var(--ink-faint); text-align: right; flex: 1; }
.plan-summary.left .ps-num { color: var(--blue); }
.plan-summary.left .ps-fill { background: var(--blue); }
.plan-summary.left .ps-status { color: var(--blue); font-weight: 600; }
.plan-summary.ok .ps-num { color: var(--green); }
.plan-summary.ok .ps-status { color: var(--green); font-weight: 600; }
.plan-summary.over { border-color: var(--red); background: var(--red-soft); }
.plan-summary.over .ps-num { color: var(--red); }
.plan-summary.over .ps-fill { background: var(--red); }
.plan-summary.over .ps-status { color: var(--red); font-weight: 700; }
.plan-summary.idle .ps-num { color: var(--ink-faint); }

/* ---------- budgets ---------- */
.hint { color: var(--ink-faint); font-size: .85rem; margin-bottom: 1rem; }
.budget-list { display: flex; flex-direction: column; gap: .9rem; }
.budget-row { display: grid; grid-template-columns: 200px 130px 1fr 150px; align-items: center; gap: 1rem; }
.budget-name { font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.budget-input { width: 100%; text-align: right; }
.budget-bar { height: 12px; border-radius: 6px; background: #eef2f7; overflow: hidden; }
.budget-fill { height: 100%; border-radius: 6px; background: var(--green); transition: width .3s; }
.budget-fill.warn { background: var(--red); }
.budget-status { font-size: .82rem; color: var(--ink-soft); text-align: right; }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; align-items: start; margin-top: .9rem; }
.wallet-settings-list { display: flex; flex-direction: column; gap: .45rem; margin-bottom: .8rem; }
.wallet-set-row { display: grid; grid-template-columns: auto 1fr 120px auto; align-items: center; gap: .6rem; }
.wallet-set-row .dot { width: 12px; height: 12px; }
.wallet-set-row input { width: 100%; }
.wallet-set-row .cat-del { border: none; background: none; cursor: pointer; color: var(--ink-faint); font-size: .95rem; padding: .2rem .4rem; border-radius: 6px; }
.wallet-set-row .cat-del:hover { background: var(--red-soft); color: var(--red); }
.wallet-add { margin-top: .2rem; }
.wallet-add input { flex: 1; }
.wallet-add select { width: 110px; }
.cat-list { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .8rem; }
.cat-row { display: flex; align-items: center; gap: .55rem; font-size: .9rem; }
.cat-row .cat-del {
  margin-left: auto; border: none; background: none; cursor: pointer;
  color: var(--ink-faint); font-size: .95rem; padding: .15rem .35rem; border-radius: 6px;
}
.cat-row .cat-del:hover { background: var(--red-soft); color: var(--red); }
.cat-add { display: flex; gap: .5rem; }
.cat-add input { flex: 1; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(36, 48, 60, .35);
  display: grid; place-items: center;
}
.modal.hidden { display: none; }
.modal-card { width: 420px; max-width: calc(100vw - 2rem); display: flex; flex-direction: column; gap: .7rem; }
.modal-card label { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.modal-card label.hidden { display: none; }
.modal-actions { display: flex; gap: .5rem; margin-top: .4rem; }
.spacer { flex: 1; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-weight: 600;
  padding: .65rem 1.3rem; border-radius: 12px;
  box-shadow: var(--shadow); z-index: 200;
  transition: opacity .3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

/* ---------- install button ---------- */
.install-btn { white-space: nowrap; }
.install-btn.hidden { display: none; }

/* ---------- cloud sync ---------- */
.cloud-card { margin-bottom: .9rem; }
.cloud-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .3rem; }
.sync-badge { font-size: .74rem; font-weight: 800; padding: .18rem .55rem; border-radius: 999px; letter-spacing: .02em; }
.sync-badge.local { background: #f1f5f9; color: var(--ink-soft); }
.sync-badge.cloud { background: var(--blue-soft); color: var(--blue); }
.sync-badge.ok { background: var(--green-soft); color: var(--green); }
.cloud-card .btn-ghost.hidden { display: none; }

/* ---------- bottom nav (mobile only) ---------- */
.bottom-nav { display: none; }

/* ---------- auth gate ---------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 300;
  background: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  display: grid; place-items: center; padding: 1.2rem;
}
.auth-gate.hidden { display: none; }
.auth-card { width: 380px; max-width: 100%; display: flex; flex-direction: column; gap: .7rem; text-align: center; }
.auth-mark { width: 54px; height: 54px; font-size: 1.7rem; margin: 0 auto; }
.auth-card label { display: flex; flex-direction: column; gap: .25rem; text-align: left; font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.auth-actions { display: flex; gap: .5rem; margin-top: .3rem; }
.auth-actions .btn-primary, .auth-actions .btn-ghost { flex: 1; }
.auth-error { color: var(--red); font-size: .82rem; min-height: 1rem; text-align: left; }
.auth-link { border: none; background: none; color: var(--blue); cursor: pointer; font: inherit; font-size: .82rem; text-decoration: underline; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .budget-row { grid-template-columns: 1fr 110px; grid-auto-rows: auto; }
  .topbar { flex-wrap: wrap; gap: .6rem; }
}

/* ---------- phone layout ---------- */
@media (max-width: 720px) {
  :root { font-size: 15px; }
  body { padding-bottom: 76px; background-size: 24px 24px; } /* room for bottom nav */

  .topbar { position: sticky; padding: .6rem .9rem; gap: .5rem; align-items: center; }
  .topbar .tabs { display: none; }               /* replaced by bottom nav */
  .install-btn { display: none !important; }      /* Android shows its own install UI; iOS uses Share */
  .brand h1 { font-size: 1rem; }
  .tagline { display: none; }
  .month-nav { margin-left: auto; min-width: 0; }
  .month-nav span { min-width: 96px; font-size: .92rem; }

  main { padding: 0 .8rem; }

  /* total asset: first thing on screen */
  .total-asset { width: auto; margin: .8rem .8rem 0; padding: .9rem 1.1rem; }
  .ta-values { gap: 1.2rem; row-gap: .4rem; }
  .ta-main { flex-basis: 100%; }
  .ta-main .ta-num { font-size: 1.9rem; }
  .ta-num { font-size: 1.15rem; }

  /* quick add: stack into a tidy card */
  .quick-add { width: auto; margin: .8rem .8rem; flex-direction: column; align-items: stretch; gap: .5rem; }
  .type-toggle { width: 100%; }
  .tt-btn { flex: 1; padding: .6rem .2rem; font-size: .85rem; }
  .qa-amount, .qa-received, .qa-field, #qaNote, #qaDate { width: 100%; }
  .qa-arrow { display: none; }
  #qaSave { width: 100%; padding: .75rem; font-size: 1rem; }

  .stat-row { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .stat-value { font-size: 1.25rem; }
  .wallet-bars { grid-template-columns: 1fr; gap: 0; }
  .wallet-bar-row { grid-template-columns: 110px 1fr auto; font-size: .8rem; }
  .wo-grand { font-size: .8rem; gap: .5rem; }

  .rep-cat-row { grid-template-columns: 110px 1fr auto; gap: .5rem; font-size: .8rem; }
  .rep-cat-amt em { display: none; }
  .rep-table-wrap { padding: .3rem .8rem .8rem; }

  /* phone: no per-row ⚖ (it wraps ugly) — use the Adjustment button instead */
  .wbr-fix { display: none; }
  .adjust-btn { display: block; width: 100%; margin-top: .7rem; padding: .65rem; font-size: .9rem; }

  .filter-bar { flex-wrap: wrap; }
  .filter-bar #fltSearch { flex-basis: 100%; }
  .filter-bar select, .filter-bar .btn-ghost { flex: 1; }

  .ledger-row { gap: .5rem; padding: .55rem .8rem; flex-wrap: wrap; }
  .lr-note { flex-basis: 100%; order: 5; font-size: 1rem; }
  .ledger-lines.margin-line::before { display: none; }
  .page-head, .page-total { padding-left: 1rem; padding-right: 1rem; }

  /* planning: a phone cannot hold name + % + 8-digit amount on one line,
     so each row stacks — category on its own line, numbers underneath */
  .plan-amount-row { flex-direction: column; align-items: stretch; gap: .6rem; }
  .plan-amount-field { width: 100%; }
  #planAmount { width: 100%; }
  #planCopyPrev { width: 100%; }
  .plan-table-wrap { padding: .3rem .9rem .2rem; }
  .plan-table thead { display: none; }
  .plan-table, .plan-table tbody { display: block; }
  .plan-table tr {
    display: grid;
    grid-template-columns: 104px 1fr auto;
    align-items: center;
    gap: .3rem .5rem;
    padding: .55rem 0;
    border-bottom: 1px solid var(--rule);
  }
  .plan-table tr:last-child { border-bottom: none; }
  .plan-table td { display: block; border: none; padding: 0; width: auto !important; }
  .plan-table td.plan-cat { grid-column: 1 / -1; display: flex; align-items: center; gap: .45rem; }
  .plan-name { min-width: 0; max-width: none; border-color: var(--border); }
  .plan-num input { min-width: 0; padding-left: .4rem; padding-right: .5rem; }
  .plan-empty { display: block !important; padding: 0 !important; }
  .plan-add { flex-wrap: wrap; padding: .8rem .9rem 1rem; }
  .plan-add input { flex-basis: 100%; }
  .plan-add .btn-primary { width: 100%; }
  .ps-num { font-size: 1.5rem; }
  .ps-status { text-align: left; flex-basis: 100%; }

  .budget-row { grid-template-columns: 1fr auto; gap: .4rem .8rem; }
  .budget-bar { grid-column: 1 / -1; }
  .budget-status { grid-column: 1 / -1; text-align: left; }

  .wallet-set-row { grid-template-columns: auto 1fr auto; gap: .4rem; }
  .wallet-set-row .wallet-cur-input { grid-column: 2 / 3; width: 100%; }

  .modal { align-items: flex-end; }
  .modal-card { width: 100%; border-radius: 18px 18px 0 0; }

  /* bottom nav */
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 80;
    background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom));
  }
  .bn-btn {
    flex: 1; border: none; background: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: .12rem;
    font: inherit; font-size: .66rem; font-weight: 700; color: var(--ink-faint);
    padding: .3rem 0; border-radius: 10px;
  }
  .bn-btn .bn-ico { font-size: 1.25rem; line-height: 1; filter: grayscale(.4) opacity(.7); }
  .bn-btn.active { color: var(--green); }
  .bn-btn.active .bn-ico { filter: none; }

  .auth-card { width: 100%; }
}
