/* ميزانيتي — موبايل أولًا، RTL، فاتح/داكن */
:root {
  --bg: #f4f6f2; --surface: #ffffff; --surface2: #eef2ec; --text: #25322e; --muted: #6a7a74; --border: #e2e8e1;
  --primary: #4f8f7e; --primary-2: #6aa896; --primary-ink: #ffffff; --soft: #e3efe9; --soft-ink: #2f6a5a;
  --income: #4a9677; --expense: #de7f69; --debt: #7788cc; --warn: #d19a3d; --danger: #cf5b52;
  --shadow: 0 1px 2px rgba(40, 60, 50, .05), 0 6px 20px rgba(40, 60, 50, .06);
  --radius: 18px; --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: "Segoe UI", "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, system-ui, sans-serif;
  color-scheme: light dark;
}
:root[data-theme="dark"] {
  --bg: #111917; --surface: #1a2522; --surface2: #243230; --text: #e5eee9; --muted: #92a39c; --border: #2a3935;
  --primary: #5fae98; --primary-2: #78c1ac; --primary-ink: #0d1815; --soft: #20332d; --soft-ink: #9bd6c3;
  --income: #6bc19c; --expense: #ee9580; --debt: #8e9ee0; --warn: #e0ae55; --danger: #e5766d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111917; --surface: #1a2522; --surface2: #243230; --text: #e5eee9; --muted: #92a39c; --border: #2a3935;
    --primary: #5fae98; --primary-2: #78c1ac; --primary-ink: #0d1815; --soft: #20332d; --soft-ink: #9bd6c3;
    --income: #6bc19c; --expense: #ee9580; --debt: #8e9ee0; --warn: #e0ae55; --danger: #e5766d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; font-size: 15px; transition: background .3s, color .3s; }
body.noscroll { overflow: hidden; }
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: .45; cursor: default; }
small { font-size: .8rem; color: var(--muted); }
svg { width: 22px; height: 22px; flex: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px; }
.muted { color: var(--muted); }
.pos { color: var(--income); } .neg { color: var(--expense); } .warn-text { color: var(--warn); }
.strong { font-weight: 700; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--primary)); flex: none; }
.dot.inc { --c: var(--income); } .dot.exp { --c: var(--expense); }

/* ---------- الهيكل ---------- */
.app { min-height: 100vh; }
.sidebar { display: none; }
#view { padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; outline: none; }
.page-in { animation: pageIn .45s var(--ease) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }

.tabbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--border); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: .7rem; color: var(--muted); border-radius: 12px; transition: color .2s, transform .2s; }
.tabbar a svg { transition: transform .3s var(--ease); }
.tabbar a.active { color: var(--primary); font-weight: 600; }
.tabbar a.active svg { transform: translateY(-2px) scale(1.12); }
.tabbar a:active { transform: scale(.94); }
.tab-add { justify-self: center; width: 56px; height: 56px; margin-top: -26px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--primary-2), var(--primary)); color: var(--primary-ink); box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 45%, transparent);
  transition: transform .25s var(--ease); }
.tab-add svg { width: 26px; height: 26px; stroke-width: 2.4; }
.tab-add:active { transform: scale(.9) rotate(90deg); }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 250px minmax(0, 1fr); }
  .tabbar { display: none; }
  #view { padding: 28px 32px 48px; max-width: 980px; width: 100%; }
  .sidebar { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; padding: 24px 16px;
    background: var(--surface); border-inline-end: 1px solid var(--border); }
  .brand { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; padding: 0 6px; }
  .sidebar nav { display: flex; flex-direction: column; gap: 4px; }
  .sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px; color: var(--muted); transition: background .2s, color .2s, transform .2s; }
  .sidebar nav a:hover { background: var(--surface2); color: var(--text); }
  .sidebar nav a.active { background: var(--soft); color: var(--soft-ink); font-weight: 600; }
  .add-btn { width: 100%; justify-content: center; }
  .side-theme { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; color: var(--muted); }
  .side-theme:hover { background: var(--surface2); }
}

/* ---------- عناصر عامة ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
.card.pad { padding: 16px; margin-bottom: 14px; }
.card.pad h3 { font-size: .95rem; margin-bottom: 12px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h2 { font-size: 1.45rem; }
.sub-head { display: flex; justify-content: center; margin: 14px 0; }
.section-title { font-size: 1rem; margin: 20px 0 10px; }
.section-row { display: flex; align-items: center; justify-content: space-between; }
.section-row a { color: var(--primary); font-size: .88rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 14px; font-weight: 600;
  transition: transform .15s var(--ease), box-shadow .2s, background .2s, opacity .2s; }
.btn:active:not(:disabled) { transform: scale(.96); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: linear-gradient(145deg, var(--primary-2), var(--primary)); color: var(--primary-ink); box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 30%, transparent); }
.btn.soft { background: var(--soft); color: var(--soft-ink); }
.btn.ghost { background: var(--surface2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-ghost { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.btn.sm { padding: 8px 14px; font-size: .88rem; border-radius: 12px; }
.btn.wide { width: 100%; margin-top: 8px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); transition: background .2s, transform .15s; }
.icon-btn:hover:not(:disabled) { background: var(--surface2); }
.icon-btn:active:not(:disabled) { transform: scale(.9); }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; } .row-btns .btn { flex: 1; }
.link-btn { color: var(--primary); font-size: .9rem; margin: 12px 0; padding: 6px 2px; }

.seg { display: inline-flex; background: var(--surface2); padding: 4px; border-radius: 14px; gap: 2px; position: relative; }
.seg.wide { display: flex; margin-bottom: 14px; } .seg.wide button { flex: 1; }
.seg button { padding: 9px 16px; border-radius: 11px; font-weight: 600; color: var(--muted); transition: background .25s, color .25s, box-shadow .25s; }
.seg.small button { padding: 6px 12px; font-size: .85rem; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .1); }

.month-nav { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border-radius: 16px; padding: 3px; box-shadow: var(--shadow); }
.month-label { padding: 6px 10px; min-width: 112px; font-weight: 700; border-radius: 10px; transition: background .2s; }
.month-label:hover { background: var(--surface2); }

select, input[type=text], input[type=number], input[type=date], input[type=password], input[type=search], input:not([type]) {
  width: 100%; padding: 12px 14px; background: var(--surface2); border: 1.5px solid transparent; border-radius: 13px; transition: border-color .2s, background .2s; min-width: 0; }
input[type=color] { width: 100%; height: 46px; padding: 4px; border-radius: 13px; border: 0; background: var(--surface2); cursor: pointer; }
select:focus, input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
input[type=date] { text-align: right; }
.field { display: flex; flex-direction: column; gap: 6px; } .field > span { font-size: .82rem; color: var(--muted); font-weight: 600; }
.form { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; font-size: .9rem; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
.amount-field input { font-size: 2rem; font-weight: 700; text-align: center; padding: 16px; direction: ltr; }
.inline-form { display: flex; gap: 10px; } .inline-form input { max-width: 160px; }
.merge { display: flex; gap: 8px; align-items: center; } .merge select { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 99px; background: var(--surface2); border: 1.5px solid transparent;
  cursor: pointer; font-size: .9rem; transition: all .2s var(--ease); user-select: none; }
.chip span i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip input:checked + span { background: color-mix(in srgb, var(--c) 24%, var(--surface)); border-color: var(--c); font-weight: 700; transform: scale(1.04); }
.chip input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- الإحصائيات ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats.two { grid-template-columns: 1fr 1fr; }
.stat { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset-inline-start: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 4px; background: var(--muted); opacity: .5; }
.stat.income::before { background: var(--income); opacity: 1; } .stat.expense::before { background: var(--expense); opacity: 1; }
.stat.balance::before { background: var(--primary); opacity: 1; } .stat.balance.neg::before { background: var(--danger); }
.stat.debt::before { background: var(--c, var(--debt)); opacity: 1; }
.stat span { font-size: .76rem; color: var(--muted); padding-inline-start: 6px; }
.stat b { font-size: 1.2rem; padding-inline-start: 6px; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.stat.income b { color: var(--income); } .stat.expense b { color: var(--expense); } .stat.balance.neg b { color: var(--danger); }
@media (min-width: 520px) { .stat b { font-size: 1.5rem; } }
.stats.compact { margin-bottom: 14px; }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding: 12px 16px; border-radius: 14px;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--soft-ink); font-size: .9rem; animation: rise .5s .2s var(--ease) both; }
.notice.warn { background: color-mix(in srgb, var(--warn) 16%, var(--surface)); color: var(--warn); }
.notice span { font-weight: 700; white-space: nowrap; }

/* ---------- البنود والأشرطة ---------- */
.cat-list { display: grid; gap: 10px; }
@media (min-width: 640px) { .cat-list { grid-template-columns: 1fr 1fr; } }
.cat-card { display: flex; flex-direction: column; gap: 9px; padding: 14px 16px; transition: transform .2s var(--ease), box-shadow .2s; }
.cat-card:hover { transform: translateY(-2px); }
.cat-card:active { transform: scale(.98); }
.cat-top { display: flex; align-items: center; gap: 9px; }
.cat-top b { flex: 1; font-size: 1rem; }
.bal { font-weight: 800; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 99px; background: var(--surface2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--c, var(--primary)); border-radius: inherit; transition: width 1s var(--ease); }
.cat-card.over .bar i { background: var(--expense); }
.cat-card small em { font-style: normal; opacity: .85; }

.list { display: flex; flex-direction: column; overflow: hidden; }
.tx { display: flex; align-items: center; gap: 12px; padding: 13px 16px; width: 100%; text-align: start; transition: background .15s; }
.tx + .tx { border-top: 1px solid var(--border); }
.tx:hover { background: var(--surface2); } .tx:active { background: var(--soft); }
.tx-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tx-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amt { font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; }
.amt.income { color: var(--income); } .amt.expense { color: var(--expense); }
.day { margin-bottom: 14px; animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }
.day h4 { font-size: .82rem; color: var(--muted); margin: 0 6px 6px; font-weight: 600; }
.sum-line { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin: 4px 4px 12px; }
.sum-line b { font-variant-numeric: tabular-nums; }
.filters { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-bottom: 14px; align-items: center; }
.filters input { grid-column: 1 / -1; }

.empty { display: grid; justify-items: center; gap: 10px; padding: 36px 16px; color: var(--muted); text-align: center; }
.empty svg { width: 44px; height: 44px; opacity: .5; }
.skeleton-wrap { display: grid; gap: 10px; }
.skeleton { height: 74px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton.short { height: 50px; width: 60%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- المخصصات ---------- */
.alloc-head { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px; margin-bottom: 12px; text-align: center; }
.alloc-head div { display: flex; flex-direction: column; gap: 2px; }
.alloc-head span { font-size: .74rem; color: var(--muted); } .alloc-head b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; } .toolbar .btn { flex: 1; font-size: .85rem; padding: 10px 12px; }
.alloc-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; animation: rise .4s var(--ease) both; animation-delay: calc(var(--i, 0) * 30ms); }
.alloc-row + .alloc-row { border-top: 1px solid var(--border); }
.alloc-row label { flex: 1; font-weight: 600; min-width: 0; }
.alloc-row input { width: 110px; text-align: center; direction: ltr; font-weight: 700; padding: 10px; }
.hint { font-size: .72rem; color: var(--soft-ink); background: var(--soft); padding: 4px 9px; border-radius: 99px; white-space: nowrap; transition: transform .15s; }
.hint:active { transform: scale(.92); }

/* ---------- التقارير ---------- */
.chart-card, .tbl-card { padding: 16px; margin-bottom: 14px; }
.chart-card h3, .tbl-card h3 { font-size: .95rem; margin-bottom: 12px; }
.donut-wrap { display: grid; gap: 14px; align-items: center; justify-items: center; }
@media (min-width: 560px) { .donut-wrap { grid-template-columns: 220px 1fr; } }
.donut { width: 210px; height: 210px; }
.donut .seg { transition: stroke-dasharray 1s var(--ease); }
.d-lab { font-size: 7px; fill: var(--muted); } .d-val { font-size: 12px; font-weight: 800; fill: var(--text); }
.legend { list-style: none; padding: 0; margin: 0; width: 100%; display: grid; gap: 7px; }
.legend li { display: flex; align-items: center; gap: 9px; font-size: .88rem; } .legend span { flex: 1; }
.legend b { font-variant-numeric: tabular-nums; } .legend em { font-style: normal; color: var(--muted); width: 38px; text-align: end; font-size: .78rem; }
.bars { width: 100%; height: auto; display: block; }
.bars .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; } .bars .axis { stroke: var(--border); stroke-width: 1.5; }
.bars .ax { font-size: 11px; fill: var(--muted); }
.bar-rect { transform: scaleY(0); transform-origin: center bottom; transform-box: fill-box; transition: transform .8s var(--ease), opacity .2s; }
.bar-rect.in { transform: scaleY(1); }
.bar-rect.inc { fill: var(--income); } .bar-rect.exp { fill: var(--expense); }
.bar-grp { cursor: pointer; } .bar-grp:hover .bar-rect, .bar-grp.sel .bar-rect { opacity: .78; filter: brightness(1.08); }
.bar-grp.sel .ax { fill: var(--text); font-weight: 800; }
.chart-tip { font-size: .85rem; color: var(--muted); min-height: 24px; margin-bottom: 4px; }
.legend-inline { display: flex; gap: 16px; justify-content: center; font-size: .82rem; color: var(--muted); margin-top: 6px; }
.legend-inline span { display: flex; align-items: center; gap: 6px; }

.tbl-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; -webkit-overflow-scrolling: touch; }
.tbl { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .85rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 9px 10px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--border); }
.tbl thead th { color: var(--muted); font-weight: 600; font-size: .78rem; }
.tbl tr > :first-child { position: sticky; inset-inline-start: 0; background: var(--surface); text-align: start; font-weight: 600; z-index: 1; }
.tbl tr > :first-child .dot { margin-inline-end: 8px; }
.tbl tfoot th, .tbl tfoot td { font-weight: 800; border-bottom: 0; border-top: 2px solid var(--border); }
.tbl .grp th { background: var(--surface2); color: var(--muted); font-size: .76rem; text-align: start; position: static; }
.tbl .total td, .tbl .total th { font-weight: 700; background: color-mix(in srgb, var(--surface2) 55%, var(--surface)); }
.tbl .net td, .tbl .net th { font-weight: 800; }
.tbl .zero { color: var(--muted); opacity: .45; }

/* ---------- الديون ---------- */
.debt-list { display: grid; gap: 10px; margin-top: 12px; } .debt-list.closed { opacity: .72; }
@media (min-width: 640px) { .debt-list { grid-template-columns: 1fr 1fr; } }
.debt-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 9px; }
.debt-top { display: flex; justify-content: space-between; align-items: baseline; width: 100%; text-align: start; }
.debt-top b { font-size: 1.05rem; } .debt-top .big { font-size: 1.3rem; font-weight: 800; color: var(--c); font-variant-numeric: tabular-nums; }
.debt-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { font-size: .72rem; padding: 3px 10px; border-radius: 99px; background: var(--surface2); color: var(--muted); font-weight: 600; }
.badge.bad { background: color-mix(in srgb, var(--danger) 15%, var(--surface)); color: var(--danger); }
.badge.ok { background: color-mix(in srgb, var(--income) 16%, var(--surface)); color: var(--income); }
.debt-card .btn { align-self: flex-start; } .debt-card .note { color: var(--muted); }
.hint-line { margin-top: 10px; font-size: .85rem; color: var(--muted); }
.detail-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-bottom: 12px; }
.detail-sum div { background: var(--surface2); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; }
.detail-sum span { font-size: .74rem; color: var(--muted); } .detail h4 { margin: 14px 0 8px; font-size: .9rem; }
.detail .row-btns { margin-top: 16px; }
.pay-list { list-style: none; padding: 0; margin: 0; }
.pay-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); } .pay-list li span { flex: 1; font-size: .88rem; color: var(--muted); }

/* ---------- المزيد والإعدادات ---------- */
.more-list { display: grid; gap: 10px; }
.more-item { display: flex; align-items: center; gap: 14px; padding: 16px; transition: transform .2s var(--ease); }
.more-item:active { transform: scale(.98); } .more-item svg { width: 26px; height: 26px; color: var(--primary); }
.more-item span { display: flex; flex-direction: column; }
.cat-manage { list-style: none; margin: 0; padding: 0; }
.cat-manage li { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.cat-manage li:last-child { border-bottom: 0; } .cat-manage li.is-hidden { opacity: .5; }
.cat-name { flex: 1; text-align: start; padding: 10px 4px; font-weight: 600; }
.card.pad .btn.wide { margin-top: 0; }
#logout { margin-top: 6px; }

/* ---------- نافذة سفلية + إشعارات ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15, 25, 22, 0); display: flex; align-items: flex-end; justify-content: center; transition: background .25s; }
.backdrop.show { background: rgba(15, 25, 22, .5); }
.sheet { width: 100%; max-width: 520px; max-height: 92dvh; overflow: hidden; display: flex; flex-direction: column; background: var(--surface); border-radius: 26px 26px 0 0;
  transform: translateY(100%); transition: transform .32s var(--ease); box-shadow: 0 -10px 40px rgba(0, 0, 0, .2); }
.backdrop.show .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 4px; }
.sheet-head h3 { font-size: 1.05rem; }
.sheet-body { padding: 10px 18px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; }
.confirm-msg { margin: 6px 0 16px; line-height: 1.7; }
@media (min-width: 640px) {
  .backdrop { align-items: center; } .sheet { border-radius: 26px; transform: translateY(24px) scale(.97); opacity: 0; transition: transform .3s var(--ease), opacity .25s; }
  .backdrop.show .sheet { transform: none; opacity: 1; }
}
#toasts { position: fixed; z-index: 100; inset-inline: 0; top: calc(12px + env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-radius: 99px; background: var(--text); color: var(--bg); font-weight: 600; font-size: .9rem;
  box-shadow: var(--shadow); animation: toastIn .35s var(--ease) both; max-width: 100%; }
.toast svg { width: 18px; height: 18px; color: var(--income); } .toast.err svg { color: var(--expense); }
.toast.out { animation: toastOut .3s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(.95); } }

/* ---------- تسجيل الدخول ---------- */
.login-root { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 500px at 80% -10%, color-mix(in srgb, var(--primary) 18%, transparent), transparent), var(--bg); }
.login { width: 100%; max-width: 360px; padding: 30px 24px; display: flex; flex-direction: column; gap: 14px; text-align: center; align-items: stretch; }
.login h1 { font-size: 1.6rem; } .login .field { text-align: start; } .login .btn.wide { margin-top: 4px; }
.logo { width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center; color: var(--primary-ink);
  background: linear-gradient(145deg, var(--primary-2), var(--primary)); box-shadow: 0 10px 26px color-mix(in srgb, var(--primary) 35%, transparent); animation: pop .6s var(--ease) both; }
.logo svg { width: 32px; height: 32px; } .logo.sm { width: 38px; height: 38px; margin: 0; border-radius: 12px; animation: none; } .logo.sm svg { width: 20px; height: 20px; }
@keyframes pop { from { transform: scale(.5) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
.form-err { color: var(--danger); font-size: .85rem; min-height: 1.3em; }
.shake { animation: shake .4s; } @keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.boot { display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface2); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .bar i { width: var(--w, 0); }
}

/* الأرقام: تفضل LTR علشان علامة السالب تيجي قبل الرقم */
.bal, .amt, .big, .alloc-head b, .detail-sum b, .pay-list b, .legend b, .sum-line b { direction: ltr; unicode-bidi: isolate; }
.bal, .big { text-align: left; }
.tbl td { direction: ltr; unicode-bidi: isolate; }
#view, .card { min-width: 0; }
#year { width: auto; min-width: 120px; text-align: center; font-weight: 700; }
