:root {
  --bg: #FCFAEF;
  --bg-raised: #FFFFFF;
  --bg-sunken: #F3EFD9;
  --text: #23291F;
  --text-soft: #656F5B;
  --text-faint: #99A38C;
  --accent: #2FAE60;
  --accent-soft: #E1F5E7;
  --accent-2: #F0A63C;
  --accent-2-soft: #FDEDD4;
  --good: #2FAE60;
  --good-soft: #E1F5E7;
  --bad: #E2574C;
  --bad-soft: #FCEAE8;
  --border: #ECE6CD;
  --shadow: 0 1px 2px rgba(35,41,31,.06), 0 10px 28px -10px rgba(35,41,31,.16);
  --radius: 16px;
  --blue: #3E6FE0;
  --blue-soft: #E7EDFC;
  --pink: #DD5580;
  --pink-soft: #FBE6ED;
  --orange: #F0A63C;
  --orange-soft: #FDEDD4;
  --green: #2FAE60;
  --green-soft: #E1F5E7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131C13; --bg-raised: #1C271B; --bg-sunken: #0F160E;
    --text: #ECEEDD; --text-soft: #ABB59E; --text-faint: #6D7864;
    --accent: #5FD98A; --accent-soft: rgba(95,217,138,.14);
    --accent-2: #F5BE5C; --accent-2-soft: rgba(245,190,92,.14);
    --good: #5FD98A; --good-soft: rgba(95,217,138,.14);
    --bad: #F08277; --bad-soft: rgba(240,130,119,.14);
    --border: rgba(236,238,221,.12);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 28px -10px rgba(0,0,0,.55);
    --blue: #6E93F5; --blue-soft: rgba(110,147,245,.14);
    --pink: #EC7DA0; --pink-soft: rgba(236,125,160,.14);
    --orange: #F5BE5C; --orange-soft: rgba(245,190,92,.14);
    --green: #5FD98A; --green-soft: rgba(95,217,138,.14);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Rubik", "Segoe UI", -apple-system, BlinkMacSystemFont, "Arial Hebrew", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  direction: rtl;
}
#app { display: flex; flex-direction: column; min-height: 100vh; max-width: 480px; margin: 0 auto; }

.screen { display: none; flex-direction: column; flex: 1; min-height: 0; }
.screen.active { display: flex; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 8px; flex-shrink: 0; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-raised); border: 1px solid var(--border); color: var(--text); cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.scroll { overflow-y: auto; flex: 1; padding: 0 18px 40px; }
h1.title { font-size: 20px; font-weight: 700; margin: 0; }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; }

.login-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 32px 26px; gap: 22px; }
.brandmark { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.brandmark .mark {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(155deg, var(--accent), color-mix(in srgb, var(--accent) 65%, black 10%));
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.brandmark h1 { font-size: 22px; margin: 0; font-weight: 700; }
.brandmark p { margin: 0; color: var(--text-soft); font-size: 13.5px; }

.field { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; background: var(--bg-raised); }
.field input { border: none; background: none; outline: none; font-family: inherit; font-size: 15px; color: var(--text); width: 100%; }
.btn { border: none; border-radius: 10px; padding: 13px; font-family: inherit; font-weight: 700; font-size: 14.5px; cursor: pointer; text-align: center; width: 100%; }
.btn.primary { background: var(--accent); color: #fff; }
.error-msg { color: var(--bad); font-size: 13px; text-align: center; min-height: 16px; }

.month-switch { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 2px 0 14px; }
.month-switch button { background: none; border: none; color: var(--text-soft); cursor: pointer; padding: 6px; }
.month-switch .m-label { font-size: 15px; font-weight: 700; }

.type-head { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 2px 10px; }
.type-head .name { font-size: 13px; font-weight: 700; color: var(--text-soft); }
.type-head .total { font-size: 12.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.pill { display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 100px; margin-inline-start: 8px; }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

.rcard { background: var(--bg-raised); border: 1px solid var(--border); border-radius: 16px; margin-bottom: 12px; overflow: hidden; cursor: pointer; }
.rcard-top { display: flex; justify-content: space-between; align-items: flex-start; padding: 14px 16px 12px; }
.rcard-name { font-size: 15px; font-weight: 700; }
.rcard-stats { display: flex; justify-content: space-between; padding: 0 16px; gap: 12px; }
.rstat { display: flex; flex-direction: column; gap: 3px; }
.rstat:last-child { align-items: flex-end; }
.rstat .k { font-size: 11px; color: var(--text-faint); }
.rstat .v { font-size: 14.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rcard-bar-wrap { padding: 10px 16px 0; }
.bar-track { height: 6px; border-radius: 100px; background: var(--bg-sunken); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 100px; }
.rcard-remain { padding: 7px 16px 14px; font-size: 11.5px; color: var(--text-faint); }

.detail-hero { padding: 4px 18px 18px; flex-shrink: 0; border-bottom: 1px solid var(--border); }
.detail-hero .env-name-lg { font-size: 20px; font-weight: 700; margin: 2px 0 14px; }
.detail-figs { display: flex; gap: 10px; }
.fig-box { flex: 1; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.fig-box .k { font-size: 11px; color: var(--text-faint); margin-bottom: 3px; }
.fig-box .v { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }

.txn-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.txn-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.txn-merchant { font-size: 14px; font-weight: 600; }
.txn-meta { font-size: 11.5px; color: var(--text-faint); }

.sheet-overlay { position: fixed; inset: 0; background: rgba(10,16,14,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.sheet-overlay.show { opacity: 1; pointer-events: auto; }
.sheet { width: 100%; max-width: 480px; background: var(--bg); border-radius: 22px 22px 0 0; max-height: 82%; display: flex; flex-direction: column; transform: translateY(100%); transition: transform .22s cubic-bezier(.22,.9,.32,1); }
.sheet-overlay.show .sheet { transform: translateY(0); }
.sheet-head { padding: 16px 18px 12px; }
.sheet-head h2 { font-size: 15.5px; margin: 0 0 3px; }
.sheet-list { overflow-y: auto; padding: 2px 18px 22px; }
.sheet-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }

.loading, .empty-state { text-align: center; color: var(--text-faint); padding: 40px 0; font-size: 13.5px; }
