/* ===== بانك نوت — design system ===== */
:root {
  --brand: #3b1b87;
  --brand-2: #6c36d9;
  --brand-3: #a66bff;
  --brand-soft: #efe9ff;
  --gold: #f2b01e;
  --gold-soft: #fff5db;
  --ink: #181233;
  --ink-2: #3c3560;
  --muted: #6e6790;
  --bg: #f5f2fb;
  --card: #ffffff;
  --line: #e9e3f7;
  --income: #0e8c6c;
  --income-soft: #e3f7f0;
  --expense: #d93a2b;
  --expense-soft: #fdeceb;
  --net: #1b49c8;
  --net-soft: #e8eeff;
  --r: 18px;
  --shadow: 0 10px 26px rgba(43, 16, 99, 0.08);
  --shadow-sm: 0 4px 12px rgba(43, 16, 99, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; }
a { color: var(--brand-2); }

/* numbers: always isolated LTR so "1,250.00" never gets reordered inside RTL text */
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

/* ===== top bar ===== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(115deg, #2b1063 0%, #4b1fa8 55%, #6c36d9 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(43, 16, 99, 0.28);
}
.topbar-inner {
  max-width: 1040px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 42px; height: 42px; border-radius: 13px; flex: 0 0 auto;
  background: linear-gradient(160deg, #ffffff22, #ffffff08);
  border: 1px solid #ffffff33;
  display: grid; place-items: center;
}
.logo svg { width: 26px; height: 26px; display: block; }
.brand-txt { display: flex; flex-direction: column; min-width: 0; }
.brand-txt b { font-size: 19px; font-weight: 900; letter-spacing: 0; }
.brand-txt small { font-size: 11.5px; color: #e3d9ff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: #ffffff1a; border: 1px solid #ffffff33; color: #fff;
  width: 36px; height: 36px; border-radius: 50%; font-weight: 900; font-size: 16px;
  display: grid; place-items: center; flex: 0 0 auto;
}

/* ===== layout ===== */
.wrap { max-width: 1040px; margin: 0 auto; padding: 16px 16px 108px; }
.card {
  background: var(--card); border-radius: var(--r); padding: 16px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.card + .card { margin-top: 14px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 10px; margin: 22px 2px 10px; }
@media (max-width: 640px) { .section-head { display: block; } .section-head .sub { display: block; margin-top: 2px; } }
.section-head h2 { font-size: 16.5px; font-weight: 800; }
.section-head .sub { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.hint { font-size: 11.5px; color: var(--muted); font-weight: 600; margin: 8px 2px 0; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ===== period bar ===== */
.periodbar { margin-bottom: 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1.5px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.period-line {
  display: flex; min-width: 0; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--brand-soft); border: 1px solid #ded2ff; border-radius: 14px;
  padding: 9px 12px; font-size: 12.5px; font-weight: 700; color: #3a1c7a;
}
.period-line .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-2); flex: 0 0 auto; }
.custom-range { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.custom-range label { flex: 1 1 140px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.custom-range input { width: 100%; margin-top: 4px; }

/* ===== KPI cards ===== */
.kpis { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 680px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
.kpi { position: relative; overflow: hidden; border-radius: var(--r); padding: 15px 16px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }
.kpi::after { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 6px; }
.kpi.inc::after { background: var(--income); }
.kpi.exp::after { background: var(--expense); }
.kpi.net::after { background: var(--net); }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi .kpi-label { font-size: 13px; font-weight: 800; color: var(--ink-2); }
.kpi .kpi-badge { font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: #f1edfd; color: #4a2a9b; }
.kpi .kpi-value { margin-top: 8px; font-size: 27px; font-weight: 900; letter-spacing: -0.4px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.kpi.inc .kpi-value { color: var(--income); }
.kpi.exp .kpi-value { color: var(--expense); }
.kpi.net .kpi-value { color: var(--net); }
.kpi.net.neg .kpi-value { color: var(--expense); }
.kpi .kpi-cur { font-size: 13px; font-weight: 800; color: var(--muted); }
.kpi .kpi-period { margin-top: 6px; font-size: 11px; font-weight: 600; color: var(--muted); display: flex; gap: 5px; align-items: flex-start; }
.kpi .kpi-period svg { width: 12px; height: 12px; flex: 0 0 auto; margin-top: 3px; }

/* ===== per project ===== */
.proj-list { display: grid; gap: 10px; }
@media (min-width: 760px) { .proj-list { grid-template-columns: repeat(2, 1fr); } }
.proj-row { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm); }
.proj-badge { width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto; display: grid; place-items: center; font-weight: 900; font-size: 15px; color: #fff; }
.proj-main { flex: 1 1 auto; min-width: 0; }
.proj-name { font-weight: 800; font-size: 14.5px; }
.proj-meta { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.proj-figs { display: flex; gap: 14px; margin-top: 8px; flex-wrap: wrap; }
.fig { display: flex; flex-direction: column; }
.fig .fig-l { font-size: 10.5px; font-weight: 700; color: var(--muted); }
.fig .fig-v { font-size: 13.5px; font-weight: 800; }
.fig.inc .fig-v { color: var(--income); }
.fig.exp .fig-v { color: var(--expense); }
.fig.net .fig-v { color: var(--net); }
.fig.net.neg .fig-v { color: var(--expense); }

/* ===== chart ===== */
.chart { width: 100%; max-width: 620px; height: auto; display: block; margin: 6px auto 0; }
.legend { display: flex; gap: 16px; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-inline-end: 6px; }

/* ===== category bars ===== */
.cat { margin-top: 12px; }
.cat-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin-bottom: 12px; }
.cat-row .cat-name { font-size: 13px; font-weight: 700; }
.cat-row .cat-val { font-size: 12.5px; font-weight: 800; color: var(--expense); white-space: nowrap; }
.cat-track { grid-column: 1 / -1; height: 9px; background: #f2eefb; border-radius: 999px; overflow: hidden; }
.cat-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #f06a52, #d93a2b); }
.cat-sub { grid-column: 1 / -1; font-size: 10.5px; color: var(--muted); font-weight: 600; }

/* ===== tables ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 9px 8px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl th { font-size: 11.5px; color: var(--muted); font-weight: 800; background: #faf8ff; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl td.amount { font-weight: 800; white-space: nowrap; }
table.tbl td.inc { color: var(--income); }
table.tbl td.exp { color: var(--expense); }
table.tbl tr.total td { background: #f7f3ff; font-weight: 900; border-top: 2px solid #ded2ff; }
.unit-note { font-size: 11px; color: var(--muted); font-weight: 700; }

/* ===== transactions list ===== */
.filters { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; margin-top: 10px; }
.filters > div { min-width: 0; }
select, input, textarea { max-width: 100%; }
.filters .full { grid-column: 1 / -1; }
.search { display: flex; align-items: center; gap: 8px; background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 9px 12px; }
.search input { border: none; outline: none; width: 100%; min-width: 0; background: transparent; font-weight: 600; }
.search svg { width: 17px; height: 17px; color: var(--muted); flex: 0 0 auto; }
select, input[type='text'], input[type='date'], input[type='month'], input[type='number'], textarea {
  width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 13px; padding: 10px 12px;
  font-weight: 600; outline: none;
}
select:focus, input:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px #6c36d91f; }
textarea { resize: vertical; min-height: 64px; }
.field-label { font-size: 12px; font-weight: 800; color: var(--ink-2); margin-bottom: 5px; display: block; }

.tx-day { margin-top: 16px; }
.tx-day-head { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 800; color: var(--muted); margin: 0 2px 8px; }
.tx {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff;
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm); margin-bottom: 8px;
  width: 100%; text-align: right;
}
.tx-ico { width: 38px; height: 38px; border-radius: 12px; flex: 0 0 auto; display: grid; place-items: center; font-weight: 900; font-size: 17px; }
.tx.inc .tx-ico { background: var(--income-soft); color: var(--income); }
.tx.exp .tx-ico { background: var(--expense-soft); color: var(--expense); }
.tx-body { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.tx-title { display: block; font-weight: 800; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-body { min-width: 0; }
.tx-sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amt { font-weight: 900; font-size: 15px; white-space: nowrap; }
.tx.inc .tx-amt { color: var(--income); }
.tx.exp .tx-amt { color: var(--expense); }

/* ===== buttons ===== */
.btn {
  border: none; border-radius: 14px; padding: 12px 18px; font-weight: 800; font-size: 14px;
  background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 6px 16px rgba(59, 27, 135, 0.24);
}
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--brand); border: 1.5px solid #ded2ff; box-shadow: none; }
.btn.gold { background: var(--gold); color: #3a2600; box-shadow: 0 6px 16px rgba(242, 176, 30, 0.3); }
.btn.danger { background: #fff; color: var(--expense); border: 1.5px solid #f7cfca; box-shadow: none; }
.btn.sm { padding: 8px 13px; font-size: 12.5px; border-radius: 11px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 140px; }

/* ===== tabbar ===== */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 45;
  background: #fffffff7; backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex; padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 20px rgba(43, 16, 99, 0.07);
}
.tabbar button {
  flex: 1 1 0; background: none; border: none; padding: 5px 2px; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: #8b84a8; font-size: 10.5px; font-weight: 800;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.active { color: var(--brand); background: var(--brand-soft); }
.fab {
  position: fixed; right: 18px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 46;
  width: 56px; height: 56px; border-radius: 50%; border: none; color: #3a2600;
  background: linear-gradient(150deg, #ffd166, var(--gold));
  font-size: 30px; font-weight: 700; line-height: 1; display: grid; place-items: center;
  box-shadow: 0 10px 22px rgba(242, 176, 30, 0.45);
}
@media (min-width: 760px) { .fab { right: 28px; left: auto; transform: none; bottom: 92px; } .tabbar { justify-content: center; } .tabbar button { flex: 0 0 150px; } }

/* ===== sheet / modal ===== */
.overlay { position: fixed; inset: 0; background: #1a103080; z-index: 60; display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 680px) { .overlay { align-items: center; padding: 24px; } }
.sheet {
  background: #fff; width: 100%; max-width: 560px; border-radius: 22px 22px 0 0;
  max-height: 92vh; overflow-y: auto; padding: 18px 16px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(24, 18, 51, 0.28);
}
@media (min-width: 680px) { .sheet { border-radius: 22px; max-height: 88vh; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h3 { font-size: 17px; font-weight: 900; }
.sheet-close { background: #f3efff; border: none; width: 34px; height: 34px; border-radius: 50%; font-size: 18px; color: var(--ink-2); }
.form-grid { display: grid; gap: 12px; }
.form-grid .two { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.seg { display: flex; background: #f3efff; border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1 1 0; border: none; background: transparent; border-radius: 11px; padding: 9px 6px; font-weight: 800; font-size: 13.5px; color: var(--ink-2); }
.seg button.on.inc { background: var(--income); color: #fff; }
.seg button.on.brand { background: var(--brand); color: #fff; }
.seg button.on.exp { background: var(--expense); color: #fff; }
.amount-wrap { position: relative; }
.amount-wrap input { padding-left: 46px; font-weight: 900; font-size: 17px; }
.amount-wrap .cur { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 800; font-size: 12.5px; color: var(--muted); }
.err { color: var(--expense); font-size: 11.5px; font-weight: 700; margin-top: 4px; display: none; }
.err.show { display: block; }

/* ===== empty state ===== */
.empty { text-align: center; padding: 26px 14px; }
.empty .em-ico { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 12px; background: var(--brand-soft); display: grid; place-items: center; }
.empty .em-ico svg { width: 32px; height: 32px; color: var(--brand-2); }
.empty h3 { font-size: 16px; font-weight: 900; margin-bottom: 6px; }
.empty p { font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 0 0 16px; }

/* ===== toast ===== */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px); bottom: 96px; z-index: 80;
  background: #241a4d; color: #fff; font-weight: 700; font-size: 13px; padding: 11px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity 0.22s, transform 0.22s; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== reports ===== */
.report-paper {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px;
  box-shadow: var(--shadow); max-width: 820px; margin: 0 auto; overflow-x: auto;
}
.r-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.report { color: #16112e; font-size: 13px; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 3px solid var(--brand); padding-bottom: 12px; }
.report-brand { display: flex; align-items: center; gap: 10px; }
.report-brand .rlogo { width: 44px; height: 44px; border-radius: 13px; background: linear-gradient(150deg, #2b1063, #6c36d9); display: grid; place-items: center; }
.report-brand .rlogo svg { width: 26px; height: 26px; }
.report-brand b { font-size: 19px; font-weight: 900; display: block; line-height: 1.2; }
.report-brand small { font-size: 11px; color: var(--muted); font-weight: 700; }
.report-meta { text-align: left; font-size: 11px; color: var(--muted); font-weight: 700; line-height: 2.05; }
.report-meta b { color: #2b1063; }
.report h1 { font-size: 20px; font-weight: 900; margin: 16px 0 2px; }
.report .r-sub { font-size: 12.5px; color: var(--ink-2); font-weight: 700; }
.report .r-boxes { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); margin: 16px 0 4px; }
.report .r-box { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.report .r-box .l { font-size: 10.5px; font-weight: 800; color: var(--muted); }
.report .r-box .v { font-size: 17px; font-weight: 900; margin-top: 3px; }
.report .r-box .p { font-size: 9.5px; color: var(--muted); font-weight: 600; margin-top: 3px; }
.report .r-box.inc .v { color: var(--income); }
.report .r-box.exp .v { color: var(--expense); }
.report .r-box.net .v { color: var(--net); }
.report h2 { font-size: 14px; font-weight: 900; margin: 20px 0 8px; padding-inline-start: 9px; border-inline-start: 4px solid var(--brand-2); }
.report table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.report th, .report td { padding: 6px 7px; text-align: right; border-bottom: 1px solid #eee9f9; }
.report th { background: #f6f2ff; font-weight: 800; font-size: 10.5px; color: #4a3f6e; }
.report tr.total td { background: #f6f2ff; font-weight: 900; border-top: 2px solid #d9cffb; }
.report td.n { font-weight: 800; white-space: nowrap; }
.report .r-foot { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 8px; font-size: 10px; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; gap: 10px; }
.report .r-note { font-size: 10.5px; color: var(--muted); font-weight: 700; margin-top: 6px; }

/* ===== print ===== */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 13mm 12mm; }
  html, body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  .report { font-size: 11.2px; }
  .report h1 { font-size: 18px; }
  .report h2 { font-size: 12.5px; margin: 14px 0 6px; }
  .report .r-box .v { font-size: 15px; }
  .report table { font-size: 10.2px; }
  .report th, .report td { padding: 4px 6px; }
  .report tr, .report .r-box { page-break-inside: avoid; }
  .report h2 { page-break-after: avoid; }
  .report thead { display: table-header-group; }
}

/* ===== report preview on small screens (kept last so it wins) ===== */
@media (max-width: 700px) {
  .report-paper { padding: 14px; }
  .report-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .report-meta { text-align: right; line-height: 1.9; }
  .report .r-boxes { grid-template-columns: 1fr; }
  .report table { min-width: 500px; }
  .report h1 { font-size: 17px; }
  .report .r-box .v { font-size: 16px; }
}
