/* ───────────── Fonts (self-hosted so it works without internet) ───────────── */
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap;
  src: url(fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap;
  src: url(fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap;
  src: url(fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap;
  src: url(fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+20AA, U+2212, U+2013-2014, U+2190-2193; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+20AA, U+2212, U+2013-2014, U+2190-2193; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+20AA, U+2212, U+2013-2014, U+2190-2193; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+20AA, U+2212, U+2013-2014, U+2190-2193; }
@font-face { font-family: "Amiri"; font-weight: 400; font-display: swap; src: url(fonts/amiri-arabic-400-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Amiri"; font-weight: 700; font-display: swap; src: url(fonts/amiri-arabic-700-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Amiri"; font-weight: 700; font-display: swap; src: url(fonts/amiri-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF; }

/* ───────────── Tokens ───────────── */
:root {
  color-scheme: light;
  --page: #F4ECDA;
  --surface: #FFFCF5;
  --surface-2: #FAF3E3;
  --surface-3: #F3E8D0;
  --ink: #2B1B15;
  --ink-2: #5A463B;
  --muted: #7D6A5E;
  --line: #E7DABF;
  --line-2: #D6C29A;

  --crimson: #8E1726;
  --crimson-2: #A61E2F;
  --crimson-deep: #5E0D18;
  --gold: #C9962E;
  --gold-2: #E2B85A;
  --gold-soft: #F6E7BE;

  --income: #0A8F6F;        /* chart + button fill */
  --income-ink: #07634D;    /* text */
  --income-soft: #E2F2EA;
  --expense: #B4232C;
  --expense-ink: #97161F;
  --expense-soft: #FBE6E4;
  --balance: #A8740F;

  --grid: #EADFC7;
  --axis: #CDB98F;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 0 rgba(94, 13, 24, .04), 0 8px 24px -12px rgba(94, 13, 24, .18);
  --shadow-lg: 0 24px 60px -20px rgba(43, 27, 21, .45);
  --focus: 0 0 0 3px var(--surface), 0 0 0 6px var(--gold);

  --font: "Plex Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-display: "Amiri", "Plex Arabic", serif;
  --nav-h: 74px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 19px;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(201, 150, 46, .16), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(142, 23, 38, .07), transparent 55%),
    var(--page);
  background-attachment: fixed;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 10px; }
.num { font-variant-numeric: tabular-nums; unicode-bidi: isolate; direction: ltr; display: inline-block; }
.big-num { unicode-bidi: isolate; direction: ltr; display: inline-block; }
/* English month name beside the Arabic one */
.en {
  unicode-bidi: isolate; direction: ltr; display: inline-block; margin-inline: .35em;
  font-family: var(--font); font-weight: 500; font-size: max(13px, .68em); letter-spacing: .01em; color: var(--muted);
}
.en-block { display: block; margin: 0; }
.tbl thead th .en-block { font-size: 12.5px; font-weight: 500; line-height: 1.2; }
.chart .tick-en { fill: var(--muted); font-size: 11.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* icons */
[data-icon] { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; }
[data-icon] svg { width: 100%; height: 100%; }

/* ───────────── Masthead ───────────── */
.masthead {
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), transparent 40%),
    repeating-linear-gradient(135deg, rgba(255,255,255,.025) 0 2px, transparent 2px 14px),
    var(--crimson);
  color: #fff;
  position: relative;
}
.masthead-inner {
  max-width: 1200px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 24px; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; min-width: 0; }
.brand-logo {
  width: 62px; height: 62px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 3px var(--gold), 0 0 0 5px rgba(255,255,255,.2);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 27px; }
.brand-sub { color: var(--gold-soft); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.masthead-rule {
  height: 10px; position: relative;
  background:
    linear-gradient(var(--gold), var(--gold)) 0 3px / 100% 2px no-repeat,
    linear-gradient(var(--crimson-deep), var(--crimson-deep)) 0 7px / 100% 3px no-repeat,
    var(--crimson);
}
.rule-cross {
  position: absolute; left: 50%; top: -10px; width: 30px; height: 30px; transform: translateX(-50%);
  border-radius: 50%; background: var(--crimson) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath d='M12 3h6v9h9v6h-9v9h-6v-9H3v-6h9z' fill='%23C9962E' stroke='%235E0D18' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") center / 24px no-repeat;
}
.nav { display: flex; gap: 6px; }
.nav a {
  display: flex; align-items: center; gap: 8px;
  color: #fff; text-decoration: none; font-weight: 600; font-size: 18px;
  padding: 10px 18px; border-radius: 999px; white-space: nowrap;
  transition: background .15s ease;
}
.nav a:hover { background: rgba(255,255,255,.12); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--crimson); }
.nav-ico { width: 22px; height: 22px; }
/* small laptops: five menu items beside the parish name, each on one line */
@media (min-width: 861px) and (max-width: 1100px) {
  .masthead-inner { gap: 16px; }
  .nav { gap: 2px; }
  .nav a { padding: 10px 11px; gap: 6px; font-size: 17px; }
}

/* ───────────── Layout ───────────── */
.view { max-width: 1200px; margin: 0 auto; padding: 28px 20px 60px; outline: none; }
.view.is-loading { opacity: .55; transition: opacity .2s; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 20px; margin-bottom: 22px; }
.page-title { font-family: var(--font-display); font-weight: 700; font-size: 36px; line-height: 1.25; margin: 0; color: var(--crimson-deep); }
.page-sub { margin: 2px 0 0; color: var(--ink-2); font-size: 18px; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; position: relative; min-width: 0;
}
.card-title {
  font-family: var(--font-display); font-weight: 700; font-size: 25px; line-height: 1.3;
  margin: 0 0 4px; color: var(--ink); display: flex; align-items: center; gap: 10px;
}
.card-title::before {
  content: ""; width: 14px; height: 14px; flex: none;
  background:
    linear-gradient(var(--gold), var(--gold)) center / 4px 14px no-repeat,
    linear-gradient(var(--gold), var(--gold)) center / 14px 4px no-repeat;
}
.card-sub { margin: 0 0 14px; color: var(--muted); font-size: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }

/* ───────────── Buttons ───────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 10px 22px; border-radius: 14px; border: 2px solid transparent;
  font-weight: 600; font-size: 19px; line-height: 1.2; cursor: pointer; text-decoration: none;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-lg { min-height: 58px; font-size: 20px; padding: 12px 26px; }
.btn-xl { min-height: 64px; font-size: 22px; padding: 14px 28px; width: 100%; }
.btn-primary { background: var(--crimson); color: #fff; box-shadow: 0 6px 16px -8px rgba(142, 23, 38, .7); }
.btn-primary:hover { background: var(--crimson-2); }
.btn-income { background: var(--income); color: #fff; box-shadow: 0 6px 16px -8px rgba(10, 143, 111, .8); }
.btn-income:hover { background: #087D61; }
.btn-expense { background: var(--expense); color: #fff; box-shadow: 0 6px 16px -8px rgba(180, 35, 44, .8); }
.btn-expense:hover { background: #A11E27; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-soft { background: var(--gold-soft); color: var(--crimson-deep); border-color: #EBD49A; }
.btn-soft:hover { background: #F1DDA6; }
.btn-danger { background: var(--expense); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--expense-ink); border-color: #E9B9B6; }
.btn-danger-ghost:hover { background: var(--expense-soft); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn .plus-badge {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.2);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn {
  width: 52px; height: 52px; border-radius: 14px; border: 2px solid var(--line-2);
  background: var(--surface); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink); flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn [data-icon] { width: 26px; height: 26px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.link { color: var(--crimson); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.link:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ───────────── Home ───────────── */
.greet { color: var(--ink-2); margin: 0 0 18px; font-size: 19px; }
.greet strong { color: var(--crimson-deep); font-family: var(--font-display); font-size: 30px; font-weight: 700; display: block; line-height: 1.3; }

.hero {
  background:
    radial-gradient(500px 220px at 100% 0%, rgba(201, 150, 46, .22), transparent 70%),
    linear-gradient(160deg, #FFFDF8, #FBF1DB);
  border: 1px solid #EBD9AE;
  overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; inset: auto -40px -60px auto; width: 220px; height: 220px;
  background: url(img/logo-192.png) center / contain no-repeat; opacity: .07; pointer-events: none;
}
.hero-label { font-size: 20px; font-weight: 600; color: var(--ink-2); margin: 0; }
.hero-value { font-size: clamp(46px, 7vw, 68px); font-weight: 700; line-height: 1.15; margin: 6px 0 4px; color: var(--ink); letter-spacing: -.5px; }
.hero-value .cur { font-size: .55em; color: var(--muted); margin-inline-start: 6px; font-weight: 600; }
.hero-note { color: var(--muted); font-size: 16px; margin: 0; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.chip-stat {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 16px; color: var(--ink-2);
}
.chip-stat b { color: var(--ink); font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.dot-in { background: var(--income); } .dot-ex { background: var(--expense); } .dot-bal { background: var(--balance); }

.actions-card { display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.actions-card .btn { width: 100%; min-height: 80px; font-size: 24px; justify-content: center; padding-inline: 18px; }
.actions-card .btn small { display: block; font-weight: 400; font-size: 15px; opacity: .9; }
.actions-card .btn .txt { display: flex; flex-direction: column; align-items: flex-start; text-align: start; }

/* the balance equation */
.equation { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1.15fr; align-items: stretch; gap: 10px; }
.eq-tile { background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; min-width: 0; }
.eq-tile .eq-label { font-size: 16px; color: var(--ink-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.eq-tile .eq-value { font-size: clamp(22px, 2.4vw, 30px); font-weight: 700; margin-top: 4px; white-space: nowrap; }
.eq-tile.in { background: var(--income-soft); border-color: #BFE3D3; }
.eq-tile.ex { background: var(--expense-soft); border-color: #F1C4C0; }
.eq-tile.close { background: var(--gold-soft); border-color: #E7CF8F; }
.eq-tile.close .eq-value { color: var(--crimson-deep); }
.eq-op {
  align-self: center; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 2px solid var(--line-2); font-weight: 700; font-size: 24px; color: var(--ink-2);
}
.eq-sign { display: none; width: 26px; height: 26px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--line-2); align-items: center; justify-content: center; font-weight: 700; font-size: 17px; line-height: 1; flex: none; }
.eq-hint { margin: 14px 0 0; color: var(--muted); font-size: 16px; display: flex; gap: 8px; align-items: flex-start; }
.eq-hint [data-icon] { color: var(--gold); margin-top: 3px; }

/* ───────────── Charts ───────────── */
.chart { position: relative; width: 100%; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .tick { font-size: 14px; fill: var(--muted); font-family: var(--font); }
.chart .tick-x { font-size: 14px; fill: var(--ink-2); font-family: var(--font); }
.chart .val-label { font-size: 14px; fill: var(--ink-2); font-weight: 600; font-family: var(--font); }
.chart .hl { fill: var(--ink); opacity: 0; transition: opacity .12s; }
.chart .band:hover .hl, .chart .band:focus .hl, .chart .band.is-active .hl { opacity: .045; }
.chart .band.is-selected .hl { opacity: .07; }
.chart .band.is-selected:hover .hl { opacity: .09; }
.chart .band { outline: none; cursor: pointer; }
.chart .band:focus-visible .hl { opacity: .08; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 8px; font-size: 16px; color: var(--ink-2); padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.legend .sw { width: 14px; height: 14px; border-radius: 4px; }
.legend .ln { width: 18px; height: 3px; border-radius: 2px; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 170px;
  background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 14px;
  box-shadow: var(--shadow-lg); font-size: 16px; line-height: 1.45; opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .12s;
}
.tip.show { opacity: 1; transform: none; }
.tip-title { color: var(--gold-soft); font-size: 15px; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip-row .k { display: inline-flex; align-items: center; gap: 8px; color: #E9DFD6; }
.tip-row .k i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.tip-row b { font-weight: 700; }
.chart .tick-x.is-cur { fill: var(--crimson-deep); font-weight: 700; }
.hb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.hb-row { outline: none; border-radius: 10px; padding: 4px 6px; margin: 0 -6px; cursor: default; }
.hb-row:hover, .hb-row:focus-visible { background: var(--surface-2); }
.hb-name { font-size: 16px; color: var(--ink-2); line-height: 1.35; margin-bottom: 4px; }
.hb-track { display: flex; align-items: center; gap: 10px; }
.hb-bar { height: 18px; border-radius: 0 4px 4px 0; min-width: 3px; }
[dir="rtl"] .hb-bar { border-radius: 4px 0 0 4px; }
.hb-val { font-size: 16px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.chart-empty { color: var(--muted); padding: 30px 0; text-align: center; }
details.table-view { margin-top: 10px; }
details.table-view summary { cursor: pointer; color: var(--crimson); font-weight: 600; font-size: 16px; padding: 6px 0; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.table-view summary::-webkit-details-marker { display: none; }
details.table-view summary::before { content: "▸"; transition: transform .15s; display: inline-block; }
details.table-view[open] summary::before { transform: rotate(-90deg); }

/* ───────────── Tables ───────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 17px; }
.tbl th, .tbl td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl thead th { background: var(--surface-3); color: var(--ink-2); font-weight: 600; font-size: 16px; white-space: nowrap; position: sticky; top: 0; }
.tbl td.n, .tbl th.n { text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl td.n { direction: ltr; unicode-bidi: isolate; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tfoot td { background: var(--surface-2); font-weight: 700; border-top: 2px solid var(--line-2); border-bottom: 0; }
.tbl .in { color: var(--income-ink); font-weight: 600; }
.tbl .ex { color: var(--expense-ink); font-weight: 600; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: #FFF8E8; }
.tbl .muted { color: var(--muted); }
.tbl .cat-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.tbl .edit-btn { width: 44px; height: 44px; border-radius: 12px; }
.tbl .edit-btn [data-icon] { width: 22px; height: 22px; }

/* annual table */
.annual { font-size: 15px; }
.annual th, .annual td { padding: 9px 10px; }
.annual th:first-child, .annual td:first-child { position: sticky; right: 0; background: var(--surface); z-index: 1; min-width: 230px; font-weight: 600; box-shadow: -1px 0 0 var(--line); }
.annual thead th:first-child { background: var(--surface-3); z-index: 2; }
.annual tr.sec td { background: var(--surface-3) !important; font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--crimson-deep); }
.annual tr.tot td { background: var(--surface-2); font-weight: 700; }
.annual tr.net td { background: var(--gold-soft); font-weight: 700; }
.annual tr.bal td { background: #FFF6DC; }
.annual td.zero { color: #BBAA9C; }
.annual td.neg { color: var(--expense-ink); }

/* ───────────── Month ───────────── */
.month-switch { display: flex; align-items: center; gap: 10px; }
.month-label {
  min-width: 240px; min-height: 64px; padding: 6px 18px; border-radius: 14px; border: 2px solid var(--line-2);
  background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 25px; color: var(--crimson-deep);
}
.month-label:hover { background: var(--surface-2); }
.ml-text { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.month-label .en-block { font-size: 15px; margin-top: 2px; }
.month-label [data-icon] { width: 20px; height: 20px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 14px; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button {
  border: 0; background: transparent; padding: 10px 18px; min-height: 46px; border-radius: 11px; cursor: pointer;
  font-weight: 600; color: var(--ink-2); font-size: 17px;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(43,27,21,.15); }
.notice {
  display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: 14px;
  background: var(--gold-soft); border: 1px solid #E7CF8F; color: var(--ink); margin-bottom: 18px;
}
.notice [data-icon] { color: var(--crimson); width: 26px; height: 26px; margin-top: 2px; }
.empty {
  text-align: center; padding: 46px 20px; color: var(--ink-2);
}
.empty img { width: 92px; height: 92px; margin: 0 auto 12px; opacity: .85; border-radius: 50%; }
.empty h3 { font-family: var(--font-display); font-size: 26px; margin: 0 0 6px; color: var(--ink); }
.empty p { margin: 0 0 18px; }
.empty .btn-row { justify-content: center; }

/* transaction list (mobile) */
.tx-list { list-style: none; margin: 0; padding: 0; display: none; }
.tx-item {
  display: block; padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; width: 100%; text-align: start;
}
.tx-ico { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; }
.tx-ico.in { background: var(--income-soft); color: var(--income-ink); }
.tx-ico.ex { background: var(--expense-soft); color: var(--expense-ink); }
.tx-ico [data-icon] { width: 22px; height: 22px; }
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: start; }
.tx-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-weight: 600; overflow: hidden; line-height: 1.4; }
.tx-meta { display: block; font-size: 15px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.tx-amt { font-weight: 700; white-space: nowrap; flex: none; }
.tx-amt.in { color: var(--income-ink); } .tx-amt.ex { color: var(--expense-ink); }

/* dashboard */
.dash-head { align-items: flex-end; }
.dash-head .greet { margin: 0; }
.notice.viewing { align-items: center; }
.notice.viewing .link { margin-inline-start: 8px; }
.scope-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 -4px; }
.scope-label { font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--ink); }

/* entry rows with edit / delete */
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.recent li:last-child { border-bottom: 0; }
.tx-row { display: flex; align-items: center; gap: 12px; cursor: pointer; min-width: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.recent .row-actions, .tx-item .row-actions { margin-top: 10px; padding-inline-start: 54px; }
.btn-sm { min-height: 44px; padding: 6px 14px; font-size: 16px; border-radius: 12px; gap: 6px; }
.btn-sm [data-icon] { width: 18px; height: 18px; }
.tbl .edit-col { white-space: nowrap; width: 1%; }
.recent.wide li { display: flex; align-items: center; gap: 16px; }
.recent.wide .tx-row { flex: 1; }
.recent.wide .row-actions { margin: 0; padding: 0; flex-wrap: nowrap; }
.tbl .row-actions { flex-wrap: nowrap; }

/* ───────────── Reports ───────────── */
.year-switch { display: flex; align-items: center; gap: 10px; }
.year-label { font-family: var(--font-display); font-weight: 700; font-size: 30px; min-width: 110px; text-align: center; color: var(--crimson-deep); }
.download-hero {
  display: flex; gap: 22px; align-items: center; flex-wrap: wrap;
  background: linear-gradient(160deg, #FFFDF8, #FBF1DB); border-color: #EBD9AE;
}
.xl-badge {
  width: 76px; height: 76px; border-radius: 20px; background: #1D6F42; color: #fff; flex: none;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 30px;
  box-shadow: 0 10px 20px -10px rgba(29, 111, 66, .8);
}
.download-hero .txt { flex: 1; min-width: 240px; }
.download-hero h2 { font-family: var(--font-display); font-size: 28px; margin: 0; }
.download-hero p { margin: 4px 0 0; color: var(--ink-2); }
.months-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.m-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.m-tile.is-current { border: 2px solid var(--gold); box-shadow: 0 0 0 4px rgba(201,150,46,.15); }
.m-tile.is-off { opacity: .55; }
.m-name { font-family: var(--font-display); font-weight: 700; font-size: 22px; display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.m-name small { font-family: var(--font); font-weight: 500; font-size: 14px; color: var(--muted); }
.m-row { display: flex; justify-content: space-between; font-size: 15px; color: var(--ink-2); gap: 6px; }
.m-row b { color: var(--ink); }
.m-row .pos { color: var(--income-ink); } .m-row .neg { color: var(--expense-ink); }
.m-actions { display: flex; gap: 8px; margin-top: 6px; }
.m-actions .btn { min-height: 44px; font-size: 16px; padding: 6px 12px; flex: 1; }

/* ───────────── Settings & forms ───────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 18px; border: 0; padding: 0; min-width: 0; }
.field-label { font-weight: 600; font-size: 18px; color: var(--ink); padding: 0; }
.field-label small { font-weight: 400; color: var(--muted); font-size: 15px; }
.field input, .field select, .field textarea, .pw-wrap input {
  width: 100%; min-height: 56px; padding: 12px 16px; border-radius: 14px;
  border: 2px solid var(--line-2); background: #fff; font-size: 19px; color: var(--ink);
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(201,150,46,.2); outline: none; }
.field input[aria-invalid="true"] { border-color: var(--expense); }
.field-error, .form-error { color: var(--expense-ink); font-size: 16px; font-weight: 600; min-height: 0; margin: 0; }
.form-error:empty, .field-error:empty { display: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.help { color: var(--muted); font-size: 16px; margin: 0 0 16px; }
.help .path { direction: ltr; unicode-bidi: isolate; display: inline-block; font-size: 14px; color: var(--ink-2); word-break: break-all; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-inline-end: 60px; }
.pw-toggle {
  position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
  width: 46px; height: 46px; border: 0; background: transparent; cursor: pointer; color: var(--muted); border-radius: 10px;
}
.pw-toggle svg { width: 24px; height: 24px; }

/* ───────────── Entry sheet ───────────── */
dialog { border: 0; padding: 0; color: var(--ink); background: transparent; }
dialog::backdrop { background: rgba(43, 27, 21, .55); backdrop-filter: blur(2px); }
.sheet { width: min(680px, 100vw - 32px); max-height: calc(100vh - 40px); }
.sheet form {
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; max-height: calc(100vh - 40px); overflow: hidden;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-family: var(--font-display); font-size: 28px; color: var(--ink); }
.sheet[data-kind="income"] .sheet-head { background: var(--income-soft); border-bottom-color: #BFE3D3; }
.sheet[data-kind="income"] .sheet-head h2 { color: var(--income-ink); }
.sheet[data-kind="expense"] .sheet-head { background: var(--expense-soft); border-bottom-color: #F1C4C0; }
.sheet[data-kind="expense"] .sheet-head h2 { color: var(--expense-ink); }
.sheet-body { padding: 20px; overflow-y: auto; }
.sheet-foot { display: flex; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.sheet-foot .btn-xl { flex: 1 1 220px; width: auto; }
.sheet-foot #entry-delete { margin-inline-start: auto; }
.sheet[data-kind="income"] #entry-save { background: var(--income); }
.sheet[data-kind="expense"] #entry-save { background: var(--expense); }

.kind-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.kind-opt input { position: absolute; opacity: 0; pointer-events: none; }
.kind-opt > span {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 58px; border-radius: 14px;
  border: 2px solid var(--line-2); font-weight: 700; font-size: 21px; cursor: pointer; background: #fff; color: var(--ink-2);
}
.kind-opt input:focus-visible + span { box-shadow: var(--focus); }
.kind-income input:checked + span { background: var(--income); border-color: var(--income); color: #fff; }
.kind-expense input:checked + span { background: var(--expense); border-color: var(--expense); color: #fff; }

.amount-wrap { position: relative; display: block; }
.amount-wrap input { font-size: 36px !important; font-weight: 700; min-height: 76px !important; padding-right: 62px !important; padding-left: 16px !important; direction: ltr; text-align: right; }
.amount-wrap input::placeholder { color: #C9B9A6; }
/* the ₪ sits just right of the typed number, like "1,250 ₪" */
.amount-cur { position: absolute; inset-inline-start: 20px; top: 50%; transform: translateY(-50%); font-size: 28px; color: var(--muted); font-weight: 600; pointer-events: none; }
.date-sel { display: grid; grid-template-columns: 0.8fr 1.5fr 1fr; gap: 8px; }
.date-sel select { min-height: 56px; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--line-2); background: #fff; font-size: 19px; width: 100%; }
.date-sel select:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(201,150,46,.2); outline: none; }

.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: flex; align-items: center; min-height: 54px; padding: 8px 14px; border-radius: 12px; border: 2px solid var(--line-2);
  background: #fff; cursor: pointer; font-size: 17px; line-height: 1.35; font-weight: 500;
}
.chip span::before {
  content: ""; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-2); margin-inline-end: 10px; flex: none; background: #fff;
}
.chip input:checked + span { border-color: var(--crimson); background: #FFF6F3; font-weight: 700; }
.chip input:checked + span::before { border: 6px solid var(--crimson); }
.sheet[data-kind="income"] .chip input:checked + span { border-color: var(--income); background: var(--income-soft); }
.sheet[data-kind="income"] .chip input:checked + span::before { border-color: var(--income); }
.sheet[data-kind="expense"] .chip input:checked + span { border-color: var(--expense); background: var(--expense-soft); }
.sheet[data-kind="expense"] .chip input:checked + span::before { border-color: var(--expense); }
.chip input:focus-visible + span { box-shadow: var(--focus); }

.confirm { width: min(460px, 100vw - 32px); }
.confirm form { background: var(--surface); border-radius: 22px; padding: 26px; box-shadow: var(--shadow-lg); }
.confirm h2 { font-family: var(--font-display); font-size: 28px; margin: 0 0 8px; }
.confirm p { margin: 0 0 20px; color: var(--ink-2); }
.confirm-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.confirm-actions .btn { flex: 1; }
.picker { width: min(560px, 100vw - 32px); }
.picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.picker-head h2 { margin: 0; }
.picker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.picker-grid button {
  min-height: 64px; border-radius: 14px; border: 2px solid var(--line-2); background: #fff; cursor: pointer;
  font-weight: 600; font-size: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.3;
}
.picker-grid button small { font-weight: 400; color: var(--muted); font-size: 14px; }
.picker-grid button:hover { background: var(--surface-2); }
.picker-grid button[aria-current="true"] { border-color: var(--crimson); background: #FFF6F3; color: var(--crimson-deep); }
.picker-grid button[disabled] { opacity: .4; cursor: not-allowed; }

/* ───────────── Toast ───────────── */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); z-index: 50;
  background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 16px; font-weight: 600; font-size: 18px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast [data-icon] { color: #7FE0B9; width: 24px; height: 24px; }
.toast.has-action { pointer-events: auto; }
.toast-btn {
  margin-inline-start: 8px; min-height: 42px; padding: 6px 16px; border-radius: 10px; cursor: pointer;
  background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.55); font-weight: 700; font-size: 17px;
}
.toast-btn:hover { background: rgba(255,255,255,.12); }
.toast.err [data-icon] { color: #FFB4AE; }

/* ───────────── Login ───────────── */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card {
  width: min(460px, 100%); background: var(--surface); border-radius: 26px; padding: 34px 30px 30px;
  border: 1px solid var(--line); box-shadow: var(--shadow-lg); text-align: center;
  border-top: 6px solid var(--crimson);
}
.login-logo { width: 150px; height: 150px; margin: -4px auto 12px; border-radius: 50%; box-shadow: 0 0 0 4px var(--gold-soft); }
.login-title { font-family: var(--font-display); font-size: 36px; margin: 0; color: var(--crimson-deep); }
.login-sub { color: var(--ink-2); margin: 4px 0 24px; font-size: 17px; }
.login-card .field { text-align: start; }
.login-card .form-error { margin-bottom: 12px; }

/* ───────────── Responsive ───────────── */
@media (max-width: 1020px) {
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; }
  .months-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .equation { grid-template-columns: 1fr 1fr; }
  .equation .eq-op { display: none; }
  .eq-sign { display: inline-flex !important; }
}
@media (max-width: 860px) {
  body { font-size: 18px; }
  .masthead-inner { padding: 12px 16px; }
  .brand-logo { width: 52px; height: 52px; }
  .brand-name { font-size: 23px; }
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px -10px rgba(43,27,21,.25);
    padding: 6px 6px env(safe-area-inset-bottom); gap: 2px; justify-content: space-around;
  }
  .nav a { flex: 1; flex-direction: column; gap: 2px; color: var(--ink-2); font-size: 14px; padding: 6px 4px; border-radius: 12px; }
  .nav a:hover { background: transparent; }
  .nav a[aria-current="page"] { background: var(--gold-soft); color: var(--crimson-deep); }
  .nav-ico { width: 26px; height: 26px; }
  .view { padding: 20px 16px calc(var(--nav-h) + 40px); }
  .page-title { font-size: 31px; }
  .grid { gap: 16px; }
  .card { padding: 18px; border-radius: 16px; }
  .settings-grid { grid-template-columns: 1fr; }
  .months-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toast { bottom: calc(var(--nav-h) + 20px); }
  .table-desktop { display: none; }
  .tx-list { display: block; }
}
@media (max-width: 560px) {
  .brand-sub { display: none; }
  .equation { grid-template-columns: 1fr; gap: 8px; }
  .eq-tile { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  .eq-tile .eq-value { margin: 0; font-size: 23px; }
  .month-switch { width: 100%; }
  .month-label { flex: 1; min-width: 0; font-size: 22px; }
  .chips { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .sheet { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; }
  .sheet form { border-radius: 0; max-height: 100dvh; height: 100dvh; }
  .toolbar .btn-row { width: 100%; }
  .toolbar .btn-row .btn { flex: 1 1 140px; white-space: nowrap; }
  .toolbar .btn-row:first-child .btn { flex-basis: 100%; min-height: 64px; font-size: 21px; }
  .toolbar .btn-row:last-child .btn { min-height: 50px; font-size: 17px; padding-inline: 12px; }
  .seg { width: 100%; } .seg button { flex: 1; padding: 10px 8px; }
  .months-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .m-tile { padding: 12px; }
  .m-name { font-size: 20px; flex-wrap: wrap; row-gap: 0; }
  .m-row { flex-direction: column; gap: 0; }
  .m-row b { font-size: 17px; }
  .m-actions { flex-direction: column; }
  .actions-card .btn { min-height: 72px; font-size: 22px; }
  .recent.wide li { display: block; }
  .recent.wide .row-actions { margin-top: 10px; padding-inline-start: 54px; }
}

/* ───────────── Print ───────────── */
.print-head { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 13pt; }
  .masthead, .nav, .btn, .icon-btn, .toolbar .seg, .no-print, .toast, details.table-view summary { display: none !important; }
  .view { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .print-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; border-bottom: 2px solid var(--crimson); padding-bottom: 10px; }
  .print-head img { width: 64px; height: 64px; }
  .print-head b { font-family: var(--font-display); font-size: 20pt; display: block; }
  .table-desktop { display: block !important; }
  .tx-list { display: none !important; }
  .equation { grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr !important; }
  .equation .eq-op { display: flex !important; }
  .eq-sign { display: none !important; }
  .eq-tile { display: block !important; }
  .tbl { font-size: 11pt; }
  .tbl .edit-col { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* entrance */
.rise { animation: rise .45s cubic-bezier(.2,.7,.2,1) both; }
.rise:nth-child(2) { animation-delay: .05s; } .rise:nth-child(3) { animation-delay: .1s; }
.rise:nth-child(4) { animation-delay: .15s; } .rise:nth-child(5) { animation-delay: .2s; } .rise:nth-child(6) { animation-delay: .25s; }
.no-anim .rise { animation: none; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
