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

:root {
  --bg: #070B10;
  --gold: #D4AF77;
  --gold-soft: #F0D9A8;
  --emerald: #10B981;
  --emerald-dim: #064E3B;
  --teal: #2DD4BF;
  --text: #F5F0E8;
  --muted: #9AA3B2;
  --faint: #6B7380;
  --danger: #F87171;
  --rose: #FB7185;
  --line: rgba(255, 255, 255, 0.08);
  --glass: rgba(16, 22, 30, 0.62);
  --tabbar-h: 68px;
  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
html { height: 100%; }
body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: "Vazirmatn", "Tahoma", "Segoe UI", sans-serif;
  font-weight: 400;
  overflow: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; }
button { touch-action: manipulation; }

#app {
  position: relative;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1;
}

/* —— Aurora background —— */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: var(--bg);
}
.aurora span {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: drift 18s ease-in-out infinite alternate;
}
.aurora span:nth-child(1) {
  width: 68vw; height: 68vw; max-width: 420px; max-height: 420px;
  background: rgba(16, 185, 129, 0.32);
  top: -12%; right: -18%;
  animation-duration: 22s;
}
.aurora span:nth-child(2) {
  width: 60vw; height: 60vw; max-width: 380px; max-height: 380px;
  background: rgba(212, 175, 119, 0.2);
  top: 8%; left: -20%;
  animation-duration: 26s;
  animation-delay: -6s;
}
.aurora span:nth-child(3) {
  width: 72vw; height: 72vw; max-width: 460px; max-height: 460px;
  background: rgba(13, 148, 136, 0.28);
  bottom: -18%; left: 10%;
  animation-duration: 20s;
  animation-delay: -3s;
}
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-8%, 6%) scale(1.18); }
}

.app-header {
  position: relative;
  z-index: 2;
  padding: calc(var(--safe-top) + 14px) 20px 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-shrink: 0;
}
.app-header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff8ea 0%, var(--gold-soft) 70%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.app-header .today {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
}

.views {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow: hidden;
}
.view {
  display: none;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px calc(var(--tabbar-h) + var(--safe-bot) + 88px);
  overscroll-behavior: contain;
}
.view.active { display: block; }

/* —— Cards —— */
.bank-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bank-card {
  position: relative;
  border-radius: 24px;
  padding: 18px 18px 16px;
  overflow: hidden;
  isolation: isolate;
  min-height: 132px;
  cursor: pointer;
}
.bank-card::after {
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  width: 180px; height: 180px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
.bank-card.melli {
  background: linear-gradient(145deg, #1c160c 0%, #0c0a07 52%, #181208 100%);
  border: 1px solid rgba(212, 175, 119, 0.38);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(240, 217, 168, 0.18);
}
.bank-card.melli::after { background: rgba(212, 175, 119, 0.12); }
.bank-card.iranzamin {
  background: linear-gradient(145deg, #07241c 0%, #07110f 52%, #0a1c18 100%);
  border: 1px solid rgba(16, 185, 129, 0.38);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(167, 243, 208, 0.14);
}
.bank-card.iranzamin::after { background: rgba(16, 185, 129, 0.12); }
.bank-card .row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bank-card .name {
  font-size: 14px;
  font-weight: 650;
}
.bank-card.melli .name { color: var(--gold-soft); }
.bank-card.iranzamin .name { color: #b7f7de; }
.chip {
  width: 28px; height: 20px;
  border-radius: 5px;
  opacity: 0.85;
}
.bank-card.melli .chip { background: linear-gradient(135deg, #f0d9a8, #b8944a); }
.bank-card.iranzamin .chip { background: linear-gradient(135deg, #a7f3d0, #059669); }
.bank-card .balance {
  position: relative;
  z-index: 1;
  margin-top: 22px;
  font-size: 28px;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: #fff;
}
.bank-card .hint {
  position: relative;
  z-index: 1;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.total-card {
  margin-top: 12px;
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 8px 28px rgba(0,0,0,0.2);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}
.total-card .label { font-size: 12px; color: var(--muted); }
.total-card .value {
  margin-top: 4px;
  font-size: 24px;
  font-weight: 750;
  color: var(--gold-soft);
}

.month-pills {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.pill {
  border-radius: 16px;
  padding: 10px 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  text-align: center;
}
.pill .k { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.pill .v { display: block; font-size: 13px; font-weight: 700; }
.pill.in .v { color: var(--emerald); }
.pill.out .v { color: var(--rose); }
.pill.net .v { color: var(--gold-soft); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 4px 10px;
}
.section-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.section-head .link {
  background: none; border: 0; color: var(--gold); font-size: 12px; font-weight: 600; padding: 0;
}

/* —— Transaction rows —— */
.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  cursor: pointer;
}
.tx-row .badge {
  width: 42px; height: 42px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.tx-row .badge.in { background: rgba(16, 185, 129, 0.14); }
.tx-row .badge.out { background: rgba(251, 113, 133, 0.12); }
.tx-row .meta { flex: 1; min-width: 0; }
.tx-row .title {
  font-size: 13.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-row .sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-row .amt { font-weight: 750; font-size: 13.5px; white-space: nowrap; }
.tx-row .amt.in { color: var(--emerald); }
.tx-row .amt.out { color: var(--rose); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 36px 16px;
  font-size: 13px;
  line-height: 1.8;
}
.empty .big { font-size: 32px; display: block; margin-bottom: 8px; }

/* —— Filters —— */
.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip-btn, .icon-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.chip-btn.active {
  color: #07110c;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border-color: transparent;
}
.search {
  width: 100%;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
}
.search:focus { border-color: rgba(212, 175, 119, 0.45); }

/* —— Stats —— */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.month-nav button {
  width: 40px; height: 40px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 16px;
}
.month-nav .label { font-weight: 700; font-size: 15px; }
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.stat-box {
  border-radius: 18px;
  padding: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
}
.stat-box .k { font-size: 11px; color: var(--muted); }
.stat-box .v { margin-top: 6px; font-size: 16px; font-weight: 750; }
.stat-box.wide { grid-column: 1 / -1; }
.chart-card {
  border-radius: 18px;
  padding: 14px 14px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.chart-card h3 { margin: 0 0 12px; font-size: 13px; font-weight: 700; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.bar-row .lab { width: 72px; font-size: 11px; color: var(--muted); flex-shrink: 0; }
.bar-track { flex: 1; height: 9px; background: rgba(255,255,255,0.06); border-radius: 99px; overflow: hidden; }
.bar-track > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--emerald), var(--gold)); }
.bar-row .num { width: 84px; text-align: left; font-size: 11px; color: var(--text); font-weight: 600; }
.cmp { display: flex; align-items: flex-end; gap: 18px; height: 140px; padding: 8px 20px 0; }
.cmp .col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.cmp .shaft {
  flex: 1; width: 100%;
  display: flex; align-items: flex-end;
}
.cmp .shaft i {
  display: block; width: 100%;
  border-radius: 12px 12px 6px 6px;
  min-height: 4px;
}
.cmp .col.in i { background: linear-gradient(180deg, #6ee7b7, #059669); }
.cmp .col.out i { background: linear-gradient(180deg, #fda4af, #e11d48); }
.cmp .col span { margin-top: 8px; font-size: 11px; color: var(--muted); }

/* —— Settings —— */
.settings-list { display: flex; flex-direction: column; gap: 8px; }
.setting-card {
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
}
.setting-card h3 { margin: 0 0 6px; font-size: 14px; font-weight: 700; }
.setting-card p, .guide p, .guide li { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.8; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle {
  --on: var(--emerald);
  width: 48px; height: 28px;
  border-radius: 99px;
  border: 0;
  background: #2a313a;
  position: relative;
  flex-shrink: 0;
  padding: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px; right: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s ease;
}
.toggle.on { background: var(--emerald); }
.toggle.on::after { transform: translateX(-20px); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}
.btn.gold {
  background: linear-gradient(180deg, #f0d9a8, #c9a05a);
  color: #1a1408;
}
.btn.emerald {
  background: linear-gradient(180deg, #34d399, #059669);
  color: #04211a;
}
.btn.ghost {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.danger { background: rgba(248, 113, 113, 0.12); color: var(--danger); border: 1px solid rgba(248,113,113,0.25); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.guide { margin-top: 8px; }
.guide ol { margin: 8px 0 0; padding-right: 18px; color: var(--muted); font-size: 12.5px; line-height: 1.9; }
.guide code, .mono {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  display: block;
  direction: ltr;
  text-align: left;
  color: var(--gold-soft);
  overflow-x: auto;
  margin-top: 8px;
  word-break: break-all;
  white-space: pre-wrap;
}

/* —— Tab bar + FAB —— */
.tabbar {
  position: fixed;
  z-index: 20;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 430px;
  padding: 8px 8px calc(var(--safe-bot) + 8px);
  background: linear-gradient(180deg, rgba(7,11,16,0.72), rgba(7,11,16,0.94));
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.tab {
  background: none;
  border: 0;
  color: var(--faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 6px 0;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--gold-soft); }
.tab.active svg { stroke: var(--gold); }

.fab {
  position: fixed;
  z-index: 25;
  right: calc(50% - min(215px, 50vw) + 18px);
  bottom: calc(var(--tabbar-h) + var(--safe-bot) + 12px);
  width: 60px; height: 60px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #f0d9a8, #c9a05a);
  color: #1a1408;
  font-size: 32px;
  font-weight: 500;
  line-height: 1;
  box-shadow: 0 10px 28px rgba(201, 160, 90, 0.38);
  display: grid;
  place-items: center;
}
.fab span { margin-top: -2px; }

/* —— Overlays / sheets —— */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.overlay.show { display: flex; }
.sheet {
  width: 100%;
  max-width: 430px;
  max-height: min(92dvh, 860px);
  overflow: auto;
  background: linear-gradient(180deg, #121821, #0b1016);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  padding: 10px 18px calc(var(--safe-bot) + 20px);
  box-shadow: 0 -20px 60px rgba(0,0,0,0.45);
}
.sheet .grab {
  width: 42px; height: 4px;
  border-radius: 99px;
  background: rgba(255,255,255,0.16);
  margin: 4px auto 12px;
}
.sheet h2 { margin: 0 0 14px; font-size: 18px; font-weight: 750; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  resize: vertical;
}
.field textarea { min-height: 120px; line-height: 1.7; }
.field input:focus, .field textarea:focus { border-color: rgba(212,175,119,0.45); }
.choice {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.preview {
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(16, 185, 129, 0.07);
  border: 1px solid rgba(16, 185, 129, 0.22);
  font-size: 13px;
  line-height: 1.9;
  margin-bottom: 12px;
}
.preview.err {
  background: rgba(248, 113, 113, 0.07);
  border-color: rgba(248, 113, 113, 0.25);
  color: #fecaca;
}
.preview b { font-weight: 700; color: var(--gold-soft); }

/* —— PIN —— */
#pin-lock {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #070B10;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#pin-lock.show { display: flex; }
#pin-lock h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 750;
  background: linear-gradient(180deg, #fff8ea, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#pin-lock .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.pin-dots { display: flex; gap: 14px; margin-bottom: 28px; }
.pin-dots i {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: transparent;
}
.pin-dots i.on { background: var(--gold); }
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 78px);
  gap: 12px;
}
.numpad button {
  width: 78px; height: 78px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 26px;
  font-weight: 650;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.numpad button:active { background: rgba(255,255,255,0.14); }
.numpad button.ghost { font-size: 13px; color: var(--muted); }
#pin-lock.shake .pin-dots { animation: shake .35s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(8px); }
  75% { transform: translateX(-8px); }
}

/* —— Toast —— */
#toast {
  position: fixed;
  z-index: 90;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--tabbar-h) + var(--safe-bot) + 84px);
  max-width: 90vw;
  background: rgba(16, 22, 28, 0.94);
  border: 1px solid rgba(212,175,119,0.3);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }
