@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0B1220;
  --card: #131C2E;
  --border: #1E2A40;
  --nav: #0E1626;
  --text: #E8EEF7;
  --muted: #8A97AD;
  --soft: #C9D3E3;
  --mint: #34E0A1;
  --mint-ink: #06281B;
  --mint-bg: #123227;
  --red: #FF8080;
  --red-bg: #3A1E25;
  --yellow: #FFCB5C;
  --yellow-bg: #33290F;
  --track: #22304A;
  --line2: #2A3852;
  --nav-h: calc(64px + env(safe-area-inset-bottom));
  --top: calc(env(safe-area-inset-top) + 14px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--text);
  font-family: 'Vazirmatn', Tahoma, sans-serif; font-size: 14px; line-height: 1.6;
  direction: rtl; overscroll-behavior-y: none;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--mint); text-decoration: none; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

#app { max-width: 520px; margin: 0 auto; position: relative; min-height: 100vh; min-height: 100dvh; }
.page { padding: var(--top) 20px calc(var(--nav-h) + 96px); animation: fade .18s ease-out; }
.page.full { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- primitives (from design mockups) ---------- */
.i { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; width: 20px; height: 20px; flex-shrink: 0; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; }
.mut { color: var(--muted); }
.soft { color: var(--soft); }
.n { direction: ltr; unicode-bidi: isolate; display: inline-block; }
div.n { display: table; }
.pos { color: var(--mint); }
.neg { color: var(--red); }
.warn { color: var(--yellow); }
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.ic { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ic.sm { width: 26px; height: 26px; border-radius: 8px; }
.ic.sm .i { width: 14px; height: 14px; }
.ic.lg { width: 48px; height: 48px; border-radius: 14px; }
.ic.lg .i { width: 24px; height: 24px; }
.hb { width: 44px; height: 44px; border-radius: 12px; background: var(--card); border: 1px solid var(--border); color: var(--text); display: flex; align-items: center; justify-content: center; padding: 0; position: relative; flex-shrink: 0; }
.hb.sm { width: 34px; height: 34px; border-radius: 10px; }
.hb.sm .i { width: 16px; height: 16px; }
.hb:active, .btn:active, .btn2:active, .k:active, .cat:active, .pill:active { transform: scale(.97); }
.dot { position: absolute; top: 9px; left: 10px; width: 8px; height: 8px; border-radius: 4px; background: var(--red); }
.bar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; transition: width .4s ease; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 20px; white-space: nowrap; border: 0; }
.chip.lg { height: 32px; padding: 0 10px; font-size: 12px; }
.chip.t { font-size: 10px; padding: 1px 7px; margin-right: 4px; gap: 3px; }
.c-mint { background: var(--mint-bg); color: var(--mint); }
.c-red { background: var(--red-bg); color: var(--red); }
.c-yellow { background: var(--yellow-bg); color: var(--yellow); }
.c-blue { background: #172A42; color: #5AB0FF; }
.c-purple { background: #252040; color: #A98BFF; }
.c-gray { background: #1E2738; color: var(--soft); }
.lbl { font-size: 12px; color: var(--muted); }
.sec { font-size: 15px; font-weight: 700; }
.h1 { font-size: 20px; font-weight: 800; }
.h1s { font-size: 19px; font-weight: 800; }
.amt { font-weight: 700; font-size: 14px; }
.big { font-size: 32px; font-weight: 800; line-height: 1.4; }
.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; }
.center { text-align: center; }
.spacer { flex: 1; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
.head .tools { display: flex; align-items: center; gap: 8px; }
.subhead { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.subhead h1 { flex: 1; font-size: 19px; font-weight: 800; }
.sec-head { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
.sec-head a, .link { font-size: 12px; color: var(--mint); background: none; border: 0; padding: 6px 0; }

/* list rows */
.list { padding: 2px 14px; }
.tx { display: flex; align-items: center; gap: 12px; padding: 11px 0; width: 100%; background: none; border: 0; text-align: right; color: inherit; }
.tx + .tx { border-top: 1px solid var(--border); }
.tx .t1 { display: block; font-weight: 600; }
.tx .end { text-align: left; flex-shrink: 0; }
.grp { font-size: 12px; color: var(--muted); margin: 14px 2px 8px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; font-size: 13px; line-height: 2; }
.empty .i { width: 34px; height: 34px; color: #3A4A66; display: block; margin: 0 auto 6px; }

/* segmented */
.seg { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; text-align: center; padding: 8px 0; border-radius: 10px; border: 0; background: transparent; color: var(--muted); font-size: 13px; min-height: 36px; }
.seg button.on { background: var(--mint); color: var(--mint-ink); font-weight: 700; }
.seg button.on.expense { background: var(--red); color: #2A0B0B; }
.mini-seg { display: inline-flex; gap: 2px; background: var(--nav); border-radius: 10px; padding: 3px; font-size: 12px; }
.card .mini-seg, .st .mini-seg { background: var(--nav); }
.mini-seg.on-card { background: var(--card); border: 1px solid var(--border); }
.mini-seg button { padding: 4px 12px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); min-height: 30px; }
.mini-seg button.on { background: var(--mint); color: var(--mint-ink); font-weight: 700; }

/* buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 52px; border-radius: 16px; background: var(--mint); color: var(--mint-ink); font-weight: 700; font-size: 16px; border: 0; width: 100%; }
.btn[disabled] { opacity: .45; }
.btn.red { background: var(--red); color: #2A0B0B; }
.btn2 { display: flex; align-items: center; justify-content: center; gap: 6px; height: 52px; border-radius: 16px; background: transparent; color: var(--text); font-weight: 600; font-size: 15px; border: 1px solid var(--line2); width: 100%; }
.btn2.danger { color: var(--red); border-color: #5A2A33; }
.btn-sm { height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid #2A5A47; background: #10241E; color: var(--mint); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.btn-sm.gray { border-color: var(--line2); background: transparent; color: var(--soft); }
.btn-sm.red { border-color: #5A2A33; background: transparent; color: var(--red); }
.btn-row { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.btn-row.eq { grid-template-columns: 1fr 1fr; }

/* nav + fab */
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: var(--nav-h); background: var(--nav); border-top: 1px solid var(--border); display: flex; justify-content: center; z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
.nav .in { display: flex; justify-content: space-around; align-items: flex-start; width: 100%; max-width: 520px; padding: 10px 6px 0; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: #7F8CA3; width: 68px; min-height: 44px; position: relative; }
.nav a.on { color: var(--mint); font-weight: 700; }
.nav .i { width: 22px; height: 22px; }
.nav .badge { position: absolute; top: -4px; left: 16px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--red); color: #2A0B0B; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.fab { position: fixed; bottom: calc(var(--nav-h) + 16px); left: max(20px, calc(50% - 240px)); width: 58px; height: 58px; border-radius: 29px; background: var(--mint); color: var(--mint-ink); display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(52, 224, 161, .3); z-index: 21; border: 0; }
.fab .i { width: 26px; height: 26px; stroke-width: 2.5; }
.fab:active { transform: scale(.94); }

/* forms */
.inp { height: 48px; border-radius: 14px; background: var(--card); border: 1px solid var(--border); color: var(--text); font-size: 15px; padding: 0 14px; outline: none; width: 100%; }
.inp:focus { border-color: var(--mint); }
textarea.inp { height: auto; min-height: 120px; padding: 12px 14px; line-height: 1.9; resize: vertical; }
.inp.ltr { direction: ltr; text-align: left; }
select.inp { appearance: none; -webkit-appearance: none; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.field > label, .field > .lab { font-size: 13px; font-weight: 700; }
.field .hint { font-size: 12px; color: var(--muted); line-height: 1.8; }
.money-wrap { position: relative; }
.money-wrap .u { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; pointer-events: none; }
.money-wrap .inp { direction: ltr; text-align: left; padding-left: 56px; font-weight: 700; }
.pill { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--border); color: var(--text); font-size: 13px; width: 100%; text-align: right; min-width: 0; }
.pill span.v { flex: 1; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* switch */
.sw { width: 46px; height: 28px; border-radius: 14px; border: 0; background: var(--line2); position: relative; padding: 0; flex-shrink: 0; transition: background .2s; }
.sw::after { content: ''; position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 10px; background: var(--soft); transition: right .2s, background .2s; }
.sw[aria-checked="true"] { background: var(--mint); }
.sw[aria-checked="true"]::after { right: 22px; background: var(--mint-ink); }

/* settings rows */
.st { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 0 2px; color: var(--text); font-size: 14px; width: 100%; background: none; border: 0; text-align: right; }
.st + .st { border-top: 1px solid var(--border); }
.st .i.lead { color: var(--muted); }
.st .t { flex: 1; }
.tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; height: 96px; color: var(--text); font-size: 13px; font-weight: 600; }
.tool span { width: 42px; height: 42px; border-radius: 13px; display: flex; align-items: center; justify-content: center; }

/* categories grid */
.cat { display: flex; flex-direction: column; align-items: center; gap: 6px; background: transparent; border: 0; padding: 0; font-size: 12px; color: var(--soft); min-width: 0; }
.cat .t { width: 50px; height: 50px; border-radius: 16px; display: flex; align-items: center; justify-content: center; border: 2px solid transparent; }
.cat.big .t { width: 54px; height: 54px; }
.cat .nm { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat[aria-pressed="true"] .t { border-color: var(--mint); }
.cat[aria-pressed="true"] .nm { color: var(--text); font-weight: 700; }
.cats5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.cats4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 8px; }

/* keypads */
.k { height: 50px; border-radius: 14px; background: var(--card); border: 1px solid var(--border); color: var(--text); font-size: 22px; display: flex; align-items: center; justify-content: center; padding: 0; user-select: none; -webkit-user-select: none; }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; direction: ltr; }
.pinpad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 26px; width: 100%; max-width: 300px; direction: ltr; }
.pinpad .k { height: 72px; border-radius: 36px; font-size: 26px; font-weight: 500; }
.pinpad .k.ghost { background: transparent; border-color: transparent; }
.pin-dots { display: flex; gap: 18px; direction: ltr; }
.pin-dots span { width: 14px; height: 14px; border-radius: 7px; border: 2px solid #3A4A66; transition: background .15s; }
.pin-dots span.on { background: var(--mint); border-color: var(--mint); }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pin-boxes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; direction: ltr; position: relative; }
.pin-boxes .card { height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.pin-boxes .card.on { border-color: var(--mint); }
.pin-boxes .card.on::after { content: ''; width: 12px; height: 12px; border-radius: 6px; background: var(--text); }
.pin-boxes input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; font-size: 16px; }

/* amount display */
.amount-big { font-size: 40px; font-weight: 800; border-bottom: 2px solid var(--mint); line-height: 1.3; min-width: 40px; text-align: center; }

/* home */
.nw-card { padding: 16px 18px 10px; margin-top: 16px; }
.banner { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 14px; border-radius: 18px; background: #10241E; border: 1px solid #22493B; color: var(--text); width: 100%; text-align: right; }
.banner.warn { background: #2A2210; border-color: #4A3B14; }
.banner.danger { background: #2A1418; border-color: #4A2129; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

/* budget */
.bi { padding: 11px 0; }
.bi + .bi { border-top: 1px solid var(--border); }
.bi .ic { width: 38px; height: 38px; }

/* assets */
.lg { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.lg b { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.subbox { background: var(--nav); border-radius: 12px; padding: 8px 10px; }

/* goals */
.need { display: flex; align-items: center; gap: 8px; margin-top: 12px; background: var(--nav); border-radius: 12px; padding: 9px 12px; font-size: 12px; }
.av { width: 40px; height: 40px; border-radius: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-weight: 700; }

/* report */
.cr { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: 13px; }
.cr + .cr { border-top: 1px solid var(--border); }
.cr b { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.dl { font-size: 11px; width: 64px; text-align: left; }

/* sms */
.smsbox { background: var(--nav); border-radius: 12px; padding: 10px 12px; font-size: 12px; color: var(--muted); line-height: 1.8; white-space: pre-wrap; word-break: break-word; }
.sample { background: var(--nav); border: 1px dashed var(--line2); border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 2.2; white-space: pre-wrap; word-break: break-word; }
.tok { border-radius: 6px; padding: 1px 3px; cursor: pointer; }
.tok.num, .tok.date { background: #1A2438; }
.hl { border-radius: 6px; padding: 1px 5px; font-weight: 700; }
.r-amount { background: var(--mint-bg) !important; color: var(--mint); }
.r-type { background: #3A2A14 !important; color: #FFB766; }
.r-balance { background: #172A42 !important; color: #5AB0FF; }
.r-date { background: #252040 !important; color: #A98BFF; }
.dr { display: flex; align-items: center; gap: 10px; min-height: 46px; font-size: 13px; }
.dr + .dr { border-top: 1px solid var(--border); }
.dr b { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.dr .k2 { width: 52px; color: var(--muted); }
.dr .v { flex: 1; font-weight: 600; }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 14px; }
.steps span { height: 5px; border-radius: 3px; background: var(--track); }
.steps span.on { background: var(--mint); }
.progress { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.progress div { height: 100%; background: var(--mint); border-radius: 3px; transition: width .3s; }

/* sheet (bottom modal) */
.backdrop { position: fixed; inset: 0; background: rgba(3, 7, 15, .62); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .15s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet { background: #111A2B; border: 1px solid var(--border); border-bottom: 0; border-radius: 22px 22px 0 0; width: 100%; max-width: 520px; max-height: 90vh; max-height: 90dvh; overflow-y: auto; padding: 8px 20px calc(env(safe-area-inset-bottom) + 20px); animation: up .22s cubic-bezier(.2, .8, .2, 1); overscroll-behavior: contain; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line2); margin: 2px auto 10px; }
.sheet .sh-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.sheet .sh-head h3 { font-size: 17px; font-weight: 800; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; background: none; border: 0; color: var(--text); text-align: right; padding: 6px 2px; font-size: 14px; }
.opt + .opt { border-top: 1px solid var(--border); }
.opt.on { color: var(--mint); font-weight: 700; }
.opt .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.cal .wd { font-size: 11px; color: var(--muted); padding: 4px 0; }
.cal button { height: 42px; border-radius: 12px; border: 0; background: transparent; color: var(--text); font-size: 14px; }
.cal button.today { border: 1px solid var(--mint); }
.cal button.on { background: var(--mint); color: var(--mint-ink); font-weight: 700; }
.months { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.months button { height: 48px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); }
.months button.on { background: var(--mint); color: var(--mint-ink); font-weight: 700; border-color: var(--mint); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches button { width: 36px; height: 36px; border-radius: 12px; border: 2px solid transparent; }
.swatches button.on { border-color: var(--text); }
.icon-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.icon-grid button { height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--soft); display: flex; align-items: center; justify-content: center; }
.icon-grid button.on { border-color: var(--mint); color: var(--mint); }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 90px); transform: translateX(-50%); background: #22304A; color: var(--text); padding: 10px 16px; border-radius: 14px; font-size: 13px; z-index: 80; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); animation: up .2s; max-width: calc(100% - 40px); display: flex; gap: 10px; align-items: center; }
.toast.err { background: #4A2129; }
.toast button { background: none; border: 0; color: var(--mint); font-weight: 700; padding: 4px; }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.code { direction: ltr; text-align: left; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.note { font-size: 12px; color: var(--muted); line-height: 1.9; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; font-size: 13px; }
.kv + .kv { border-top: 1px solid var(--border); }
.danger-txt { color: var(--red); }

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