@font-face { font-family: Vazirmatn; src: url("fonts/Vazirmatn-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url("fonts/Vazirmatn-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url("fonts/Vazirmatn-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url("fonts/Vazirmatn-ExtraBold.woff2") format("woff2"); font-weight: 800; font-display: swap; }

:root {
  --bg: #0E1726; --card: #16223A; --card2: #1B2943; --line: #2A3A57; --nav: #111C2F;
  --text: #F3EEE3; --muted: #A9B4C7; --soft: #DCE3EE;
  --gold: #E7B94C; --gold2: #F3D27E; --expense: #F59E72; --income: #6CC4E8;
  --radius: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: Vazirmatn, Tahoma, system-ui, sans-serif; font-size: 15px; line-height: 1.6; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); }
/* every icon has a size; without it Safari draws an inline svg at full width */
svg { width: 20px; height: 20px; flex-shrink: 0; }
.donut svg { width: 160px; height: 160px; }
a.ghost { display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--text); }
.hidden { display: none !important; }
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding: 0 16px 110px; position: relative; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 24px 0 8px; gap: 12px; }
.top h1 { margin: 0; font-size: 20px; font-weight: 700; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--card);
  color: var(--gold); display: inline-flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; }
.icon-btn svg { width: 20px; height: 20px; }

/* cards */
.card { background: var(--card); border-radius: 22px; padding: 18px; }
.balance { border: 1px solid var(--gold); margin-top: 8px; display: flex; flex-direction: column; gap: 12px; }
.balance .big { font-size: 32px; font-weight: 800; letter-spacing: -0.3px; }
.balance .unit { color: var(--gold); font-size: 15px; }
.pill { display: inline-block; font-size: 13px; padding: 5px 12px; border-radius: 14px; background: var(--bg); color: var(--soft); }
.pill.gold { background: var(--gold); color: var(--bg); font-weight: 700; font-size: 12px; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line); }
.stat { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.stat b { font-size: 17px; }
.c-exp { color: var(--expense); } .c-inc { color: var(--income); }

.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.quick button { height: 76px; border-radius: 18px; border: 1px solid var(--line); background: var(--card);
  font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 0; }
.quick svg { width: 22px; height: 22px; }

.reminder { margin-top: 14px; background: var(--card2); border-radius: 18px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.badge { width: 40px; height: 40px; border-radius: 12px; background: #2E2A1E; color: var(--gold); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.badge svg { width: 20px; height: 20px; }

.section { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 6px; }
.section h2 { font-size: 16px; margin: 0; }
.link-btn { background: none; border: none; color: var(--gold); font-size: 13px; padding: 8px 4px; }

.tx { display: flex; align-items: center; gap: 12px; padding: 10px 0; width: 100%; background: none; border: none; text-align: start; }
.tx + .tx { border-top: 1px solid #1C2A44; }
.tx .ic { width: 42px; height: 42px; border-radius: 14px; background: var(--card); display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
.tx .t1 { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .t2 { font-size: 12px; color: var(--muted); }
.tx .amt { font-weight: 700; font-size: 14px; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }

/* bottom nav */
nav.bottom { position: fixed; left: 0; right: 0; bottom: 0; height: calc(72px + env(safe-area-inset-bottom)); background: var(--nav);
  border-top: 1px solid #22314C; display: flex; justify-content: space-around; align-items: flex-start; padding-top: 8px; z-index: 10; }
nav.bottom a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; text-decoration: none; color: var(--muted); min-width: 60px; padding: 2px 0; }
nav.bottom a.on { color: var(--gold); }
nav.bottom svg { width: 22px; height: 22px; }
nav.bottom a.fab { width: 56px; min-width: 56px; height: 56px; margin-top: -24px; border-radius: 28px; background: var(--gold); color: var(--bg);
  justify-content: center; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
nav.bottom a.fab svg { width: 26px; height: 26px; }

/* forms */
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 16px; background: var(--card); }
.seg.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.seg button { height: 42px; border: none; border-radius: 12px; background: transparent; color: var(--muted); }
.seg button.on { background: var(--gold); color: var(--bg); font-weight: 700; }
.seg button.on.exp { background: var(--expense); }
.seg button.on.inc { background: var(--income); }
.amount-box { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 22px 0 6px; }
.amount-box input { width: 100%; max-width: 280px; text-align: center; background: transparent; border: none; border-bottom: 2px solid var(--line);
  font-size: 38px; font-weight: 800; padding: 4px 0; outline: none; }
.amount-box input:focus { border-color: var(--gold); }
select.cur { height: 36px; border-radius: 18px; border: 1px solid var(--gold); background: var(--bg); color: var(--gold); padding: 0 12px; }
label.lbl { display: block; font-size: 14px; font-weight: 700; margin: 18px 0 8px; }
.cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cats button { min-height: 70px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); font-size: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px 2px; }
.cats button .e { font-size: 20px; line-height: 1; }
.cats button.on { border: 2px solid var(--gold); background: var(--card2); }
.field { width: 100%; height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); padding: 0 14px; outline: none; }
.field:focus { border-color: var(--gold); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dash { height: 52px; border-radius: 14px; border: 1px dashed var(--gold); background: transparent; color: var(--gold);
  display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; }
.dash svg { width: 20px; height: 20px; }
.dash.rec { background: #3A1F1F; border-style: solid; border-color: var(--expense); color: var(--expense); }
.primary { width: 100%; height: 56px; border-radius: 18px; border: none; background: var(--gold); color: var(--bg); font-size: 16px; font-weight: 800; margin-top: 18px; }
.primary:disabled { opacity: .55; }
.ghost { width: 100%; height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); margin-top: 10px; }
.danger { color: var(--expense); border-color: #5A3030; }
.notice { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: #2E2A1E; color: var(--gold2); font-size: 13px; }
.notice.err { background: #3A1F1F; color: #FFC4B0; }

/* reports */
.donut-wrap { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.donut { position: relative; width: 160px; height: 160px; flex-shrink: 0; }
.donut .mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.donut .mid b { font-size: 17px; }
.mini { padding: 12px; border-radius: 14px; background: var(--card); display: flex; flex-direction: column; }
.bars { display: flex; flex-direction: column; gap: 11px; margin-top: 18px; }
.bar-track { height: 6px; border-radius: 3px; background: #1F2D47; margin-top: 4px; }
.bar-fill { height: 6px; border-radius: 3px; }
.weeks { display: flex; align-items: flex-end; gap: 12px; height: 110px; margin-top: 8px; }
.weeks .w { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; font-size: 11px; }
.weeks .col { width: 100%; border-radius: 8px 8px 3px 3px; background: #2C3F62; min-height: 3px; }
.weeks .col.top { background: var(--gold); }

/* sheet + toast */
.sheet-bg { position: fixed; inset: 0; background: rgba(5,10,20,.6); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 480px; background: var(--bg); border-radius: 24px 24px 0 0; padding: 18px 18px calc(22px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 14px; z-index: 30; max-width: 90%; font-size: 14px; }

/* login */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 24px 4px; }
.logo { width: 96px; height: 96px; margin: 0 auto 4px; border-radius: 48px; border: 2px solid var(--gold); display: flex; align-items: center; justify-content: center; }
.logo img { width: 96px; height: 96px; border-radius: 48px; }
.login h1 { text-align: center; margin: 0; font-size: 24px; }
.code-input { letter-spacing: 10px; text-align: center; font-size: 26px; font-weight: 700; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
.loader { min-height: 60vh; display: flex; align-items: center; justify-content: center; }
.langs { display: flex; justify-content: center; gap: 6px; }
.langs .link-btn { color: var(--muted); }
.langs .link-btn.on { color: var(--gold); font-weight: 700; }
.amount-row { display: flex; align-items: center; gap: 6px; width: 100%; max-width: 320px; }
.amount-row input { flex: 1; min-width: 0; }
.clear-btn { width: 40px; height: 40px; border-radius: 20px; border: 1px solid var(--line); background: var(--card); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; }
.toast.with-action { display: flex; align-items: center; gap: 14px; }
.toast-btn { background: none; border: none; color: var(--gold); font-weight: 700; padding: 6px 4px; min-height: 36px; }
