/* tokens.css is loaded as its own <link rel="stylesheet"> in base.html,
   before this file — Fix Prompt #42 removed the `@import url("tokens.css")`
   that used to live here: an @import is a serial chain (the browser can't
   even start fetching tokens.css until this file has downloaded and been
   parsed far enough to find it), where a separate <link> lets both fetch
   in parallel with everything else in <head>. */

/* ==========================================================================
   Giti Pay — Fix Prompt #15: full design replacement.
   Component rules below match the 17 approved reference mockups in
   design-mockups/ literally (spacing/colors/radius/shadows/typography), not
   re-derived from prose. Selectors are adapted to this app's real
   one-screen-per-URL page structure, and hand-authored SVG decorative
   gradients replace the mockups' own enormous inlined base64 mask blobs
   (documented in BUILD_LOG as a deliberate, visually-equivalent
   simplification, not a restyle).
   ========================================================================== */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--stage);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body { min-height: 100dvh; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.mono {
  font-family: var(--font-mono), sans-serif;
  direction: ltr;
  unicode-bidi: isolate;
}

/* Fix Prompt #15 section 3 — critical تومان-layout rule: the number gets the
   ltr/mono treatment ALONE; "تومان" is always a separate sibling in normal
   RTL flow so it lands correctly to the left of the number. Never nest the
   unit word inside a .mono element. */
.amount-unit { font-weight: 400; color: var(--muted-text); }

/* ---- "Device" shell -------------------------------------------------- */
.app-shell {
  max-width: 428px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--surface);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Bug batch #1 item 5 — below 480px the shell is edge-to-edge, so the
   --stage color behind it is never meant to show. It did on iOS, on
   pages too short to scroll (تنظیمات, درخواست‌های وام): whenever WebKit
   computes 100dvh shorter than the real screen (standalone +
   viewport-fit=cover, or a stale value after the app resumes), the white
   shell ends early and a --stage strip opens directly above the dock —
   near-identical in color to the dock's --surface-2, so the dock looked
   hundreds of px tall. Painting the page itself the shell's color makes
   any such shortfall invisible, whatever the viewport math does. */
@media (max-width: 479px) {
  html, body { background: var(--surface); }
}

@media (min-width: 480px) {
  .app-shell {
    margin: 24px auto;
    min-height: 0;
    box-shadow: var(--shadow);
    overflow: hidden;
  }
}

.screen { padding: 24px 29.66px 122px; }

/* ---- Shared header (admin + customer) ----------------------------------
   Fix Prompt #16 section 5 — the reference mockups' outer wrapper is a
   single `padding:30px 29.66px 122px` div containing both the topbar and
   the content below it; this app splits that wrapper into a header
   partial + `.screen` sibling, so the same 30px/29.66px has to be carried
   by the topbar itself (top+sides) instead, with `.screen` picking up
   only the sides+bottom. */
/* Fix Prompt #43 items 1/3 — `padding-top` uses `max()` against
   `env(safe-area-inset-top)` (needs `viewport-fit=cover` on the viewport
   meta tag, already set in base.html) so a notch/Dynamic Island never
   overlaps this header and its buttons on iPhone: the inset wins when
   it's bigger than the design's normal 30px, and the normal 30px wins on
   any device with no inset (Android, older iPhones, desktop). This was
   also the reported "filter chips/search box flush to the screen edge"
   symptom on invoices/customers — same root cause, since the topbar
   sitting under the notch effectively hides itself, making whatever's
   directly below it look like the true top of the page. */
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 47px; padding: max(30px, env(safe-area-inset-top, 0px)) 29.66px 0; }
.topbar-nav-group { display: flex; align-items: center; gap: 6px; }
.topbar-end-group { display: flex; align-items: center; gap: 8px; }
.page-title { font-size: 18px; font-weight: 700; color: var(--text); }

/* Fix Prompt #26 section 1 — admin-only: icons (row 1) and the page
   title (row 2) stacked instead of one inline row, so a title long
   enough to wrap to two lines can never misalign the icons. Scoped to
   this modifier (not the bare `.topbar` above) since customer/public
   headers keep their original single-row layout untouched. */
.topbar.topbar-stacked { display: flex; flex-direction: column; align-items: stretch; min-height: 0; }
.topbar-stacked .topbar-row { display: flex; align-items: center; justify-content: space-between; min-height: 38px; }
.topbar-stacked .page-title { margin-top: 12px; text-align: center; line-height: 1.4; }
/* Fix Prompt 31 — an icon-only page action beside the title (the invoice
   page's «چاپ فاکتور»): a 44×44 target, muted, --ink on hover. */
.topbar-stacked .page-title--action { display: flex; align-items: center; justify-content: center; gap: 2px; padding-inline-start: 46px; }  /* start padding = button + gap: the title stays centred */
.title-action {
  width: 44px; height: 44px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted-text); border-radius: var(--radius-card); text-decoration: none;
}
.title-action:hover, .title-action:focus-visible { color: var(--ink); }

.icon-circle-btn {
  width: 38px; height: 38px; border-radius: 19px; background: var(--neutral-tint);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  border: none; cursor: pointer; color: var(--text); position: relative;
}
.icon-circle-btn svg { width: 16px; height: 16px; }
.bell-btn svg { width: 16px; height: 16px; }
.bell-dot {
  position: absolute; top: 8px; left: 10px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 1.5px var(--surface);
}
.header-avatar {
  width: 45px; height: 45px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(145deg, var(--ink), var(--ink-2));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 16px; font-weight: 600;
}

/* ---- Hamburger drawer --------------------------------------------------- */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(20,26,31,0); pointer-events: none;
  transition: background .3s ease; z-index: 40;
}
.drawer-overlay.open { background: rgba(20,26,31,.45); pointer-events: auto; }
.drawer {
  position: fixed; top: 0; bottom: 0; right: 0; width: 300px; max-width: 82vw;
  background: var(--surface); box-shadow: -10px 0 40px rgba(0,0,0,.15);
  transform: translateX(100%); transition: transform .35s cubic-bezier(.22,1,.36,1);
  z-index: 41; display: flex; flex-direction: column;
  /* Fix Prompt #43 item 3 — same fixed-top-of-viewport notch problem as
     .topbar: this panel starts at top:0 regardless of the notch, so its
     close button needs the same max(design-padding, safe-area-inset)
     treatment or it lands under the notch/Dynamic Island and becomes
     unclickable there too. */
  padding: max(26px, env(safe-area-inset-top, 0px)) 22px 26px;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; justify-content: flex-end; align-items: center; }
.drawer-close-btn { width: 36px; height: 36px; border-radius: 50%; }
.drawer-close-btn svg { width: 16px; height: 16px; }
.drawer-user {
  display: flex; align-items: center; gap: 12px; margin-top: 24px; padding-bottom: 20px;
  border-bottom: 1px solid rgba(164,169,174,.25);
}
.drawer-avatar {
  width: 45px; height: 45px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(145deg, var(--ink), var(--ink-2));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 16px; font-weight: 600;
}
.drawer-user-name { font-size: 15px; font-weight: 700; color: var(--text); }
.drawer-user-role { font-size: 12.5px; color: var(--muted-text); }
.drawer-nav { margin-top: 14px; overflow-y: auto; flex: 1; }
.drawer-item {
  display: flex; align-items: center; gap: 14px; padding: 13px 6px;
  color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
}
.drawer-item-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; background: var(--neutral-tint); color: var(--muted);
}
.drawer-item-icon.tint-danger { background: rgba(231,55,38,.1); color: var(--danger); }
.drawer-item-badge {
  margin-right: auto; background: var(--danger-text); color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 100px;
}
.drawer-divider { height: 1px; background: rgba(164,169,174,.25); margin: 10px 0; }
.drawer-logout { color: var(--danger-text); border-top: 1px solid rgba(164,169,174,.25); margin-top: 6px; }

/* ---- Bottom nav (admin: 5 icons / customer: 4 icons) -------------------- */
.admin-dock, .customer-dock {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 428px; height: 68px; background: var(--surface-2);
  box-shadow: 0 -8px 30px 10px rgba(0,0,0,.07); z-index: 20;
  display: flex; align-items: center; padding: 0 31.8px;
}
.admin-dock { justify-content: space-between; }
.customer-dock { justify-content: space-around; }
.admin-dock-tab, .customer-dock-tab {
  display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--muted); cursor: pointer;
}
.admin-dock-tab svg, .customer-dock-tab svg { width: 22px; height: 22px; }
.admin-dock-dot, .customer-dock-dot { width: 4.6px; height: 4.6px; border-radius: 50%; background: transparent; }
.admin-dock-tab.active, .customer-dock-tab.active { color: var(--ink); }
.admin-dock-tab.active .admin-dock-dot, .customer-dock-tab.active .customer-dock-dot { background: var(--ink); }

/* ---- Cards --------------------------------------------------------------- */
.card {
  background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px;
}
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.card .label { font-size: 12.5px; color: var(--muted-text); font-weight: 600; }
.card .value { font-size: 17px; font-weight: 700; color: var(--text); margin-top: 6px; }
.sub { font-size: 12.5px; color: var(--muted-text); margin-top: 4px; line-height: 1.7; }
.section-title { font-size: 16px; font-weight: 700; color: var(--text); margin: 22px 0 16px; display: flex; justify-content: space-between; align-items: center; }
.section-title .link { font-size: 12.5px; color: var(--ink-2); font-weight: 700; cursor: pointer; }

/* ---- Buttons --------------------------------------------------------------- */
.cta {
  width: 100%; border: none; border-radius: var(--radius-card); padding: 15px;
  background: var(--ink); color: #fff; font-family: inherit; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
}
.cta.ghost { background: var(--surface); color: var(--text-soft); border: 1px solid var(--border); }
.cta.on-ink { background: var(--surface); color: var(--ink-2); }
/* Fix Prompt 8.1 — white text needs 4.5:1, so these fills take the text-safe
   shade (white on --danger 4.2:1 / --emerald 2.1:1 → 5.4:1 / 5.2:1) */
.cta.danger { background: var(--danger-text); color: #fff; }
.cta.success { background: var(--emerald-text); color: #fff; }
/* Fix Prompt 8.1 — primary button hover */
.cta:not(.ghost):not(.on-ink):not(.danger):not(.success):not(.gold):hover { background: var(--ink-2); }
.cta.gold { background: var(--gold-2); color: var(--on-gold); }
.cta:disabled { opacity: .6; }

.cta-sm {
  border: none; border-radius: 9px; padding: 9px 14px; font-family: inherit;
  font-weight: 700; font-size: 12.5px; cursor: pointer; background: var(--ink-2); color: #fff;
}
.cta-sm.ghost { background: var(--surface); color: var(--text-soft); border: 1px solid var(--border); }
.cta-sm.danger { background: rgba(255,99,99,.08); color: var(--danger-text); border: 1px solid rgba(255,99,99,.4); }
.cta-sm.success { background: var(--emerald-soft); color: var(--emerald-text); border: 1px solid var(--emerald-line); }

.icon-btn {
  width: 28px; height: 28px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--neutral-tint); color: var(--text-soft); display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-btn svg { width: 13px; height: 13px; }
.icon-btn.danger { background: rgba(255,99,99,.12); color: var(--danger); }

/* Fix Prompt #20 section 3 — compact payment action, replacing the
   full-width "ثبت پرداخت" button that fought the row's text for space. */
.icon-btn-pay {
  width: 36px; height: 36px; border-radius: 50%; border: none; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn-pay svg { width: 17px; height: 17px; }
.icon-btn-pay.gold { background: rgba(248,199,78,.22); color: var(--gold); }
.icon-btn-pay.danger { background: rgba(255,99,99,.15); color: var(--danger); }
.icon-btn-pay.muted { background: var(--neutral-tint); color: var(--muted); }
.icon-btn-pay.emerald { background: var(--emerald-bg); color: var(--emerald); }

/* ---- Forms --------------------------------------------------------------- */
label, .field-label { font-size: 12.5px; font-weight: 600; color: var(--muted-text); display: block; margin-bottom: 6px; }
.field { margin-top: 14px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-card); padding: 13px 16px;
  font-family: inherit; color: var(--text); background: var(--surface-2);
  /* Fix Prompt #43 item 5 — iOS Safari auto-zooms the page on focus for
     any input/select/textarea computing under 16px, and doesn't reliably
     zoom back out on blur. 16px flat (not a smaller design size with the
     viewport meta hacked to disable zoom instead) is the fix that doesn't
     also disable pinch-zoom accessibility app-wide. */
  font-size: 16px;
}
textarea { resize: none; min-height: 80px; }
.form { display: flex; flex-direction: column; }
.date-hint { font-size: 11.5px; margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; }
.date-hint .due { color: var(--gold-text); font-weight: 700; }
.date-hint .picked { color: var(--ink-2); font-weight: 700; }
.amount-words { font-size: 11.5px; color: var(--muted-text); margin-top: 5px; line-height: 1.7; min-height: 1.2em; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); }
input.mono { text-align: left; }
input:disabled { opacity: .6; }

/* Segmented type-tab control */
.type-tab-row { display: flex; gap: 7px; }
.type-tab {
  flex: 1; text-align: center; padding: 11px 4px; border-radius: 9px; font-size: 13px; font-weight: 700;
  cursor: pointer; color: var(--text-soft); background: var(--neutral-tint); border: none;
}
.type-tab.active { background: var(--ink-2); color: #fff; }

/* Status filter chips */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 9px 16px; border-radius: 100px; background: var(--neutral-tint);
  color: var(--text-soft); font-size: 13px; font-weight: 600; cursor: pointer; border: none;
}
.chip.active { background: var(--ink-2); color: #fff; }
a.chip { text-decoration: none; }
/* Fix Prompt 15 — «مهمان» (a self-signed-up customer with no invoice yet); the same neutral pill as the list's
   invoice count */
.guest-badge { display: inline-block; font-size: 11px; font-weight: 700; color: var(--text-soft); background: var(--neutral-tint); padding: 2px 9px; border-radius: 100px; vertical-align: middle; }

/* 5-equal-width period-selector pills (Fix Prompt #15 sections 7, 8) —
   flex:1 on every pill, no horizontal scroll, flush with the card below. */
.period-row { display: flex; gap: 5px; }
.period-btn {
  flex: 1; text-align: center; padding: 9px 2px; border-radius: 100px; background: var(--neutral-tint);
  color: var(--text-soft); font-size: 11.5px; font-weight: 700; cursor: pointer; border: none;
}
.period-btn.active { background: var(--ink-2); color: #fff; }
.period-btn.active.gold-active { background: var(--gold-text); }

/* Status pill (invoice/installment/loan-request status labels) */
.status-pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 100px; display: inline-block; }
.status-pill.st-active { background: var(--ink-tint); color: var(--ink-2); }
.status-pill.st-overdue { background: rgba(255,99,99,.15); color: var(--danger-text); }
.status-pill.st-settled { background: var(--emerald-bg); color: var(--emerald-text); }
.status-pill.st-cancelled { background: rgba(164,169,174,.2); color: var(--muted-text); }
.status-pill.st-soon { background: rgba(248,199,78,.2); color: var(--gold-text); }
.status-pill.st-pending { background: var(--neutral-tint); color: var(--muted-text); }

/* Back-compat alias for pages not covered by one of the 17 reference
   mockups (no visual spec to redesign against) — same look as .status-pill,
   old 4-state modifier names (.due/.late/.soon/.pending) from before Fix
   Prompt #15. */
.status { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 100px; display: inline-block; }
.status.due { background: var(--emerald-bg); color: var(--emerald-text); }
.status.late { background: rgba(255,99,99,.15); color: var(--danger-text); }
.status.soon { background: rgba(248,199,78,.2); color: var(--gold-text); }
.status.pending { background: var(--neutral-tint); color: var(--muted-text); }

/* ---- Bottom-sheet modal + confirm dialog ----------------------------------
   Fix Prompt #18 section 9 — confirm-modal.js (the single shared component
   behind every `data-confirm` form and window.gitiConfirm() call: delete/
   undo/reject confirmations across the whole app) builds its markup with
   `.modal-overlay` / `.modal-box` / `.modal-message` / `.modal-actions`
   classes that had NO CSS anywhere in this file — every confirm dialog in
   the app was rendering as an unstyled, unpositioned, non-overlaid lump of
   default browser form controls. Sharing the exact same rules as the
   already-working `.sheet-modal`/`.sheet` bottom sheet (rather than
   duplicating them under new names, as the reference mockups do per-page)
   fixes every instance app-wide from this one place. */
.sheet-modal, .modal-overlay {
  position: fixed; inset: 0; background: rgba(20,26,31,0); pointer-events: none;
  /* z-index 70 (was 50): must sit above the fixed install/push prompt
     banners (partials/*_prompt.html, z-index 60) — found in Fix Prompt #45:
     on mobile the bottom-sheet's تأیید/انصراف row sat exactly under the
     push banner, which swallowed the tap, for anyone who hadn't yet
     answered the push-permission prompt. */
  transition: background .25s ease; z-index: 70; display: flex; align-items: flex-end; justify-content: center;
}
.sheet-modal.open, .modal-overlay.open { background: rgba(20,26,31,.5); pointer-events: auto; }
.sheet, .modal-box {
  width: 428px; max-width: 100%; background: var(--surface); border-radius: 20px 20px 0 0; padding: 22px;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.22,1,.36,1);
  max-height: 88vh; overflow-y: auto;
}
.sheet-modal.open .sheet, .modal-overlay.open .modal-box { transform: translateY(0); }
.sheet.confirm-sheet, .modal-box { border-radius: 20px; }
.sheet-title { font-size: 16px; font-weight: 700; color: var(--text); }
.sheet-sub { font-size: 12.5px; color: var(--muted-text); margin-top: 4px; }
.confirm-title { font-size: 16px; font-weight: 700; color: var(--text); text-align: center; }
.confirm-body, .modal-message { font-size: 13.5px; color: var(--muted-text); text-align: center; margin-top: 8px; line-height: 1.8; white-space: pre-line; }
.confirm-actions, .modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.confirm-actions button, .modal-actions button { flex: 1; margin-top: 0; }
/* Fix Prompt #45 — typed-word confirmation step (data-confirm-typed). */
.modal-typed { margin-top: 16px; text-align: center; }
.modal-typed[hidden] { display: none; }
.modal-typed-hint { font-size: 12px; color: var(--muted-text); }
.modal-typed-word { font-size: 18px; font-weight: 700; color: var(--danger-text); letter-spacing: .5px; margin-top: 6px; user-select: none; }
.modal-typed input { margin-top: 10px; text-align: center; font-size: 16px; width: 100%; }
.modal-actions button:disabled { opacity: .45; cursor: not-allowed; }
.sheet-note { font-size: 11.5px; color: var(--muted-text); margin-top: 14px; line-height: 1.9; }

/* ---- Toggle switch --------------------------------------------------------- */
.toggle-switch { width: 40px; height: 23px; border-radius: 100px; background: rgba(164,169,174,.35); position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0; }
.toggle-switch.on { background: var(--emerald); }
.toggle-switch .knob { position: absolute; top: 2.5px; right: 2.5px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: right .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle-switch.on .knob { right: 19.5px; }
/* Real <input type="checkbox"> variant (form-submitting toggles, e.g. the
   payment page's "penalty collected?" switch) — same look, driven by
   :checked instead of a JS-toggled .on class. */
.toggle-switch input[type="checkbox"] { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle-switch:has(input:checked) { background: var(--emerald); }
.toggle-switch:has(input:checked) .knob { right: 19.5px; }

/* ---- List rows (invoices/history/customers) ------------------------------- */
.row {
  display: flex; align-items: center; gap: 14px; border-radius: var(--radius-card); background: var(--surface);
  box-shadow: var(--shadow); padding: 15px 18px; margin-bottom: 16px; cursor: pointer;
}
.row-avatar {
  width: 44px; height: 44px; border-radius: var(--radius-card); flex-shrink: 0; display: flex; align-items: center;
  justify-content: center; font-size: 13px; font-weight: 700; background: var(--ink-tint); color: var(--ink-2);
}
.row-main { flex: 1; min-width: 0; }
.row-main .name { font-size: 14.5px; font-weight: 600; color: var(--text); }
.row-main .sub { font-size: 12.5px; color: var(--muted-text); margin-top: 2px; }
.row-end { text-align: left; }
.row-end .amt { font-size: 14px; font-weight: 700; color: var(--text); }

.row-link { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }

/* ---- Pagination ------------------------------------------------------------ */
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 34px; height: 34px; border-radius: 9px; background: var(--neutral-tint);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--text-soft);
  padding: 0 6px;
}
.pagination a.active { background: var(--ink-2); color: #fff; }
.pagination span.dots { background: transparent; color: var(--muted); }

/* ---- Empty / alert states --------------------------------------------------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted-text); font-size: 14px; }
.alert { padding: 12px 14px; border-radius: var(--radius-card); font-size: 13px; background: var(--danger-bg); color: var(--danger-text); margin-top: 18px; }
.alert-success { background: var(--emerald-bg); color: var(--emerald-text); }
/* Fix Prompt 30.2 — a standing caution (gold = attention, not an error): «ارسال خودکار به مشتری‌ها خاموش است» */
.alert-gold { background: var(--gold-tint); color: var(--gold-text); display: flex; gap: 8px; align-items: flex-start; }
.alert-gold .icon { flex: none; margin-top: 2px; }
.alert-gold a { color: var(--ink-2); font-weight: 600; }
/* Fix Prompt 19 — the thin «کارهای خودکار … اجرا نشده‌اند» banner at the top of every admin page */
.alert--jobs { margin: 0 0 var(--space-2); padding: 8px 12px; }
/* Fix Prompt #36 — inline per-field validation message (e.g. phone format),
   lighter-weight than .alert since it sits directly under one input. */
.field-error { font-size: 12px; color: var(--danger-text); }
.field-error:not(:empty) { margin-top: 4px; }

/* ---- Settings vertical menu (Fix Prompt #15 section 9) -------------------- */
.settings-view { display: none; }
.settings-view.active { display: block; }
.menu-row {
  display: flex; align-items: center; gap: 14px; border-radius: var(--radius-card); background: var(--surface);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; cursor: pointer;
}
.menu-row-icon {
  width: 42px; height: 42px; border-radius: var(--radius-card); flex-shrink: 0; background: var(--neutral-tint); color: var(--text-soft);
  display: flex; align-items: center; justify-content: center;
}
.menu-row-icon svg { width: 19px; height: 19px; }

/* ---- Combobox / typeahead --------------------------------------------------- */
.combo-wrap { position: relative; }
.combo-results {
  position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; left: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow);
  max-height: 260px; overflow-y: auto; padding: 6px;
}
.combo-results .combo-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.combo-results .combo-item:hover, .combo-results .combo-item.active { background: var(--surface-2); }
.combo-results .combo-empty { padding: 10px 12px; font-size: 12.5px; color: var(--muted-text); }
.combo-selected {
  margin-top: 8px; display: flex; align-items: center; justify-content: space-between;
  background: var(--ink-tint); border-radius: var(--radius-card); padding: 10px 12px; font-size: 13px; font-weight: 700; color: var(--ink-2);
}
.combo-selected button { border: none; background: transparent; color: var(--ink-2); font-weight: 800; cursor: pointer; font-size: 15px; }

/* ---- Jalali date picker (vendored @majidh1/jalalidatepicker library) ------- */
.jdp-wrap { position: relative; display: block; }
.jdp-display { cursor: pointer; }

/* Fix Prompt #38 section 5 — the library ships with its own generic
   default look (plain grays, flat blue, 4px corners); override its
   documented CSS custom properties (scoped to the `jdp-container` custom
   element, see jalalidatepicker.min.css) with this app's own design
   tokens so the popup reads as part of the app rather than a bolted-on
   widget. The library exposes color/size as variables but not radius/
   shadow/font, so those get explicit rules below instead. */
jdp-container {
  --jdp-day-size: 40px;
  --jdp-color-0: var(--surface);
  --jdp-color-1: var(--surface-2);
  --jdp-color-2: var(--neutral-tint);
  --jdp-color-3: var(--border);
  --jdp-color-4: var(--muted);
  --jdp-color-5: var(--text);
  --jdp-primary: var(--ink);
  --jdp-red: var(--danger);
  font-family: var(--font-body);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}
jdp-container .jdp-day:not(.disabled-day):hover { transform: none; }
jdp-container .jdp-day.today { border-color: var(--ink); }
jdp-container .jdp-btn-today,
jdp-container .jdp-btn-empty,
jdp-container .jdp-btn-close {
  border-radius: 8px;
  font-weight: 700;
}

/* ---- Search box with icon --------------------------------------------------- */
/* Fix Prompt "regressions after #44" item 3 — `.search-wrap` had no
   bottom spacing of its own; the invoices page happened to look fine
   only because .chip-row (the element right after it there) carries its
   own inline margin-top:14px, while the customers page's search box
   sits directly above `.list-grid` (its `.t-head` sibling is
   `display:none` below 1200px, so its own margin-top never counts),
   which had none at all — flush, 0px gap. Adding margin-bottom here
   fixes both at once without touching either page's own markup: normal
   block-flow adjacent margins collapse to whichever is larger, so this
   is a no-op wherever a bigger margin-top already existed (invoices'
   14px, customers' desktop-only 18px t-head gap) and only raises the
   gap where nothing did (customers on mobile/tablet). */
.search-wrap { position: relative; margin-bottom: 14px; }
.search-wrap input { padding-left: 40px; }
.search-wrap svg { width: 18px; height: 18px; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }

/* ---- Dashboard hero carousel (Fix Prompt #15 section 1) — a hand-authored
   gradient equivalent of the mockup's own giant inlined base64 gradient-mask
   blobs (documented here, not literally ported byte-for-byte). ------------ */
.hero-carousel {
  margin-top: 0; border-radius: var(--radius-card); overflow: hidden; position: relative; height: 228px;
  background: radial-gradient(120% 140% at 100% -20%, rgba(255,255,255,.22), transparent 55%),
              radial-gradient(90% 120% at -10% 120%, rgba(0,0,0,.12), transparent 55%);
}
.hero-carousel.tone-cash { background-color: var(--ink-2); background-blend-mode: overlay; }   /* Fix Prompt 8.1: was a decorative green */
.hero-carousel.tone-wc { background-color: var(--ink); background-blend-mode: overlay; }
.hero-viewport { position: relative; z-index: 2; height: 100%; overflow: hidden; direction: ltr; }
.hero-track { display: flex; direction: ltr; width: 200%; height: 100%; transition: transform .45s cubic-bezier(.22,1,.36,1); }
.hero-page {
  width: 50%; height: 100%; flex-shrink: 0; padding: 28px 24px 22px; display: flex; flex-direction: column; color: #fff;
  /* Fix Prompt #27 section 3 — .hero-viewport/.hero-track are forced ltr
     so the slide's translateX(-50%) math is predictable regardless of
     the page's own RTL context; without resetting it back here, every
     Persian text run and flex row *inside* each page (the label/eye-icon
     row, the footer row) inherited that ltr direction too, mirroring
     their layout left-to-right instead of right-to-left. */
  direction: rtl;
}
.hero-page-top { display: flex; align-items: flex-start; justify-content: space-between; }
.hero-eyebrow-label { font-size: 14px; font-weight: 600; color: #fff; padding-top: 9px; }
.hero-eye-btn { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: none; cursor: pointer; color: #fff; }
.hero-eye-btn svg { width: 15px; height: 15px; }
.hero-value-row { display: flex; align-items: baseline; gap: 6px; margin-top: 9px; }
.hero-value { font-size: 36px; font-weight: 600; letter-spacing: -.03em; color: #fff; }
.hero-value-unit { font-size: 14px; font-weight: 600; color: #fff; }
.hero-sub-line { font-size: 15px; font-weight: 600; color: #fff; margin-top: 9px; }
.hero-spacer { flex: 1; }
.hero-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.hero-foot-eyebrow { font-size: 14px; font-weight: 600; color: #fff; }
.hero-badge {
  display: flex; align-items: center; gap: 5px; background: var(--gold-2); border-radius: 5px;
  padding: 5px 9px; flex-shrink: 0; color: var(--on-gold); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.hero-dots { display: flex; justify-content: center; align-items: center; gap: 9px; margin-top: 12px; }
.hero-dot { width: 12px; height: 4.6px; border-radius: 50px; background: rgba(164,169,174,.25); cursor: pointer; border: none; transition: width .3s, background .3s; }
.hero-dot.active { width: 12px; background: var(--ink); }

/* ---- Dashboard quick actions ---------------------------------------------- */
.quick-actions-row { display: flex; gap: 14px; margin-top: 17px; }
.quick-action {
  flex: 1; height: 134px; border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 19px; cursor: pointer;
}
.quick-action-icon { width: 50px; height: 50px; border-radius: 5px; display: flex; align-items: center; justify-content: center; }
.quick-action-label { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; }

/* ---- Key-metrics grid ------------------------------------------------------ */
.metric-card { border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow); padding: 18px 17px; }
.metric-icon { width: 50px; height: 50px; border-radius: 5px; display: flex; align-items: center; justify-content: center; }
.metric-label { font-size: 13px; font-weight: 600; color: var(--muted-text); margin-top: 16px; white-space: nowrap; }
.metric-value { font-size: 19px; font-weight: 600; color: var(--text); margin-top: 5px; }
.metric-subvalue { font-size: 12px; font-weight: 600; color: var(--muted-text); margin-top: 2px; }
.metric-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }

/* ---- Receivables / collections rows ---------------------------------------- */
.info-row-card { border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow); padding: 15px 21px; display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.info-row-icon { width: 51px; height: 51px; border-radius: 5px; background: var(--neutral-tint); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text-soft); }
.info-row-main { flex: 1; }
.info-row-title { font-size: 16px; font-weight: 500; color: var(--text); }
.info-row-sub { font-size: 13px; font-weight: 400; color: var(--muted-text); margin-top: 1px; }
.info-row-value { font-size: 19px; font-weight: 600; color: var(--text); white-space: nowrap; }

.progress-card { border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow); padding: 19px 21px; margin-top: 14px; }
.progress-card-head { display: flex; align-items: baseline; justify-content: space-between; }
.progress-bar-track { height: 8px; border-radius: 50px; background: rgba(164,169,174,.25); margin-top: 15px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 50px; background: var(--emerald); }
.progress-split { display: flex; gap: 14px; margin-top: 16px; }
.progress-split > div:not(.progress-split-sep) { flex: 1; }
.progress-split-sep { flex: 0 0 auto; width: 1px; background: rgba(164,169,174,.3); }

/* ---- Chart card ------------------------------------------------------------- */
.chart-card { border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow); padding: 19px 17px 15px; margin-top: 16px; }
.chart-card-head { display: flex; justify-content: space-between; align-items: baseline; }
.mini-chart-wrap { overflow: visible; }
/* Bug batch #4 item 4.6 — the shared chart (static/js/mini-chart.js):
   tokens only, hairline grid, no borders/shadows on the plot. */
.gp-chart { position: relative; margin-top: 10px; outline: none; }
.gp-chart:focus-visible { box-shadow: 0 0 0 2px var(--ink-tint); border-radius: 6px; }
.gp-chart-svg { display: block; overflow: visible; touch-action: pan-y; }
.gp-chart-tick { font-size: 11px; font-family: var(--font-body); fill: var(--muted); }
.gp-chart-unit { font-size: 10.5px; font-family: var(--font-body); fill: var(--muted); }
.gp-chart-gridline { stroke: var(--border); stroke-width: 1; opacity: .55; shape-rendering: crispEdges; }
.gp-chart-baseline { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
.gp-chart-cross { stroke: var(--muted); stroke-width: 1; opacity: .6; shape-rendering: crispEdges; pointer-events: none; }
.gp-chart-hit { cursor: crosshair; }
.gp-chart-tip {
  position: absolute; z-index: 5; pointer-events: none; direction: rtl; text-align: right; white-space: nowrap;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font-size: 11.5px; line-height: 1.7; box-shadow: 0 4px 14px color-mix(in srgb, var(--text) 10%, transparent);
}
.gp-chart-tip-date { color: var(--muted-text); }
.gp-chart-tip-value { font-size: 13.5px; font-weight: 700; color: var(--text); }
.gp-chart-tip-change.up { color: var(--emerald-text); }
.gp-chart-tip-change.down { color: var(--danger-text); }
.gp-chart-tip-change.flat { color: var(--muted-text); }
.gp-chart-empty { padding: 28px 12px; text-align: center; font-size: 13px; color: var(--text-soft); }
.gp-chart-empty-sub { margin-top: 6px; font-size: 12px; color: var(--muted-text); }
.gp-chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: var(--muted-text); }
.gp-chart-legend i { display: inline-block; width: 14px; height: 2px; border-radius: 1px; margin-left: 5px; vertical-align: middle; }
.gp-chart-key { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted-text); }
.gp-chart-key i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
@media (prefers-reduced-motion: reduce) { .gp-chart-line { transition: none !important; } }
.chart-pct-badge { font-size: 12px; font-weight: 600; border-radius: 5px; padding: 3px 7px; }
.chart-pct-badge.up { color: var(--emerald-text); background: var(--emerald-bg); }
.chart-pct-badge.down { color: var(--danger-text); background: rgba(255,99,99,.12); }
.chart-pct-badge.flat { color: var(--muted-text); background: var(--neutral-tint); }
.chart-pct-badge.gold-badge { color: var(--gold-text); background: rgba(248,199,78,.2); }

.cash-hero {
  position: relative; overflow: hidden;
  margin-top: 20px; border-radius: var(--radius-card); padding: 20px; color: #fff;
  background: linear-gradient(160deg, var(--ink-2), var(--ink));
}

/* ---- Compare-with-virtual-asset boxes (dashboard + fund pages) ------------- */
.compare-grid { display: flex; gap: 10px; margin-top: 12px; }
.compare-box { flex: 1; border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow); padding: 16px; border-top: 3px solid var(--border); }
.compare-box.tone-bad { border-top-color: var(--danger); }
.compare-box.tone-good { border-top-color: var(--emerald); }
.compare-box-head { display: flex; align-items: center; gap: 8px; }
.compare-box-head .icon { width: 32px; height: 32px; border-radius: 5px; display: flex; align-items: center; justify-content: center; }
.compare-box-title { font-size: 13px; font-weight: 600; color: var(--text); }
.compare-box-value { font-size: 16px; font-weight: 700; margin-top: 12px; }
.compare-box-hint { font-size: 11px; font-weight: 600; margin-top: 4px; text-align: left; }
.compare-box-foot { font-size: 10.5px; color: var(--muted-text); margin-top: 8px; border-top: 1px solid rgba(164,169,174,.2); padding-top: 8px; }

/* ---- Dot-grid hero pattern (login + landing heroes, Fix Prompt #15
   sections 4, 14) — a hand-authored equivalent of the mockups' own
   radial-gradient dot pattern, masked to fade toward the bottom-left. ----- */
.dot-grid-pattern {
  position: absolute; inset: 0; opacity: .15; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.9) 1px, transparent 1.4px);
  background-size: 16px 16px;
  -webkit-mask-image: radial-gradient(85% 75% at 70% 0%, #000 40%, transparent 90%);
  mask-image: radial-gradient(85% 75% at 70% 0%, #000 40%, transparent 90%);
}

/* ---- Customer app hero (home page) ----------------------------------------- */
.customer-hero {
  position: relative; overflow: hidden; padding: max(26px, env(safe-area-inset-top, 0px)) 20px 32px;
  background: linear-gradient(160deg, var(--ink-2), var(--ink));
}
.customer-hero-avatar {
  width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px;
}

.landing-hero {
  position: relative; overflow: hidden; padding: max(24px, env(safe-area-inset-top, 0px)) 20px 26px;
  background: linear-gradient(160deg, var(--ink-2), var(--ink));
}

/* ---- Unified login page (Fix Prompt #15 section 4) ------------------------ */
.login-hero {
  position: relative; overflow: hidden; padding: max(26px, env(safe-area-inset-top, 0px)) 20px 40px; color: #fff;
  background: linear-gradient(160deg, var(--ink-2), var(--ink));
}
.login-back-btn { background: rgba(255,255,255,.15); color: #fff; position: relative; z-index: 2; }
.login-hero-brand { position: relative; z-index: 2; font-size: 19px; font-weight: 800; margin-top: 22px; display: flex; align-items: center; gap: 10px; }
.login-hero-sub { position: relative; z-index: 2; font-size: 14px; font-weight: 600; color: #fff; margin-top: 6px; }
.login-card {
  margin: -22px 20px 0; background: var(--surface); border-radius: 18px;
  box-shadow: 1px 10px 40px 8px rgba(110,117,136,0.12); padding: 24px; position: relative; z-index: 2;
}
.otp-row { display: flex; justify-content: center; gap: 8px; margin-top: 18px; }
.otp-box { width: 100%; max-width: 180px; height: 60px; text-align: center; font-size: 26px; font-weight: 700; letter-spacing: .3em; }
.otp-links { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.otp-links a { font-size: 12.5px; font-weight: 700; color: var(--muted-text); }
.link-btn { border: none; background: none; padding: 0; font-size: 12.5px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.link-btn:disabled { color: var(--muted-text); cursor: default; }
.login-hint { font-size: 11px; color: var(--muted-text); margin-top: 12px; text-align: center; line-height: 1.8; }
.login-footer { margin-top: auto; padding: 24px 30px; text-align: center; font-size: 11.5px; color: var(--muted-text); }

/* ==========================================================================
   Fix Prompt #17 — desktop layout using the same design system.
   Scoped entirely to `.app-shell.admin-shell` (the admin panel only — the
   customer app and public pages deliberately stay phone-frame-centered at
   every width per the brief). Three tiers: mobile <768px (unchanged),
   tablet 768-1199px (same off-canvas hamburger drawer as mobile, just a
   wider shell so 2-column grids have room), desktop >=1200px (the drawer
   becomes a persistent, non-overlay right-side sidebar; hamburger button
   and bottom dock hidden — every nav item is already in the sidebar so
   nothing is lost).
   ========================================================================== */

/* ---- Tablet: wider shell, same hamburger/overlay drawer + bottom dock --- */
@media (min-width: 768px) {
  .app-shell.admin-shell { max-width: 900px; }
  .app-shell.admin-shell .screen { max-width: 720px; margin: 0 auto; padding-bottom: 122px; }
  .app-shell.admin-shell .screen.screen-wide { max-width: 100%; }
  .app-shell.admin-shell .topbar { max-width: 720px; margin: 0 auto; padding-left: 29.66px; padding-right: 29.66px; }
  .app-shell.admin-shell:has(.screen.screen-wide) .topbar { max-width: 100%; }
}

/* ---- Desktop: the entire mobile shell (topbar/screen/drawer/dock) is
   replaced wholesale by `.dsk-shell` (see desktop.css + admin_sidebar_
   desktop.html) — a literal, separate copy of the reference mockups'
   shell, not a grid-ified reuse of the mobile one. That earlier approach
   (grid-template-columns turning `.app-shell` into a 2-column layout with
   `#menuDrawer` stretched into a sidebar) is what kept producing "close
   but not exact" results: sidebar background/position, icons, and
   spacing all had to be independently re-derived instead of just being
   the reference's own values. Here the mobile shell is simply hidden —
   `#page-content` (the actual per-page body) is relocated into
   `.dsk-shell` by the script in `_layout.html`, so every existing
   per-page desktop CSS rule below (`.dash-grid`, `.detail-grid`,
   `.data-table`, etc.) keeps applying unchanged, since it targets content
   *inside* `#page-content`, not the shell around it. */
@media (min-width: 1200px) {
  /* the tablet rule above caps `.app-shell` at 900px, and the base
     >=480px rule adds `margin:24px auto; box-shadow; overflow:hidden` —
     all of it meant for the phone-frame look. None of it was reset here
     after the retrofit approach (which used to `max-width:100%;
     width:100%; margin:0;` to turn `.app-shell` itself into the desktop
     grid) was replaced by `.dsk-shell` — so `.dsk-shell` was rendering
     correctly in isolation but squeezed inside a ~900px centered box
     instead of the full viewport width the reference expects. */
  .app-shell.admin-shell {
    max-width: none; width: 100%; margin: 0; min-height: 100vh;
    box-shadow: none; overflow: visible;
  }
  .app-shell.admin-shell > .topbar,
  .app-shell.admin-shell #mobile-screen-slot,
  .app-shell.admin-shell #menuOverlay,
  .app-shell.admin-shell #menuDrawer,
  .app-shell.admin-shell .admin-dock {
    display: none;
  }

  /* bottom-sheets read better as centered dialogs at this width */
  .app-shell.admin-shell .sheet-modal, .app-shell.admin-shell .modal-overlay { align-items: center; }
  .app-shell.admin-shell .sheet, .app-shell.admin-shell .modal-box {
    width: 480px; max-width: 90vw; border-radius: 18px; max-height: 82vh;
    transform: translateY(8px) scale(.97); opacity: 0; transition: transform .22s cubic-bezier(.22,1,.36,1), opacity .22s;
  }
  .app-shell.admin-shell .sheet-modal.open .sheet, .app-shell.admin-shell .modal-overlay.open .modal-box { transform: translateY(0) scale(1); opacity: 1; }
}

/* ---- List/grid pages: customers, invoices, loan-requests, history, ledger,
   payment history, cancellations, partner-capital history --
   plain stacked `.row`/`.card` sequences become a multi-column grid once
   there's room, without changing the row/card markup itself. */
@media (min-width: 768px) {
  .app-shell.admin-shell .list-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; align-content: start;
  }
  .app-shell.admin-shell .list-grid > .row,
  .app-shell.admin-shell .list-grid > .card { margin-bottom: 0; }
  .app-shell.admin-shell .list-grid > .pagination,
  .app-shell.admin-shell .list-grid > .empty-state,
  .app-shell.admin-shell .list-grid > .section-title { grid-column: 1 / -1; }
}
@media (min-width: 1200px) {
  .app-shell.admin-shell .list-grid { grid-template-columns: repeat(3, 1fr); }
  /* loan requests: giti-pay-desktop-loan-requests-reference.html wants a
     2-column card grid specifically, not the generic 3-column default. */
  .app-shell.admin-shell .lr-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}

/* ---- Real data-table layout (invoices/customers/history) — desktop only.
   `.t-head` is a plain sibling of the AJAX-refreshed list container (never
   replaced by a fragment reload); `.row-end` (amount+status, kept nested
   so mobile still stacks them exactly as before) is promoted out of the
   box tree with `display:contents` so its children become independent
   grid cells alongside the row's other columns — no mobile markup or
   mobile CSS touched. ------------------------------------------------- */
.app-shell.admin-shell .t-head { display: none; }
.app-shell.admin-shell .row-type { display: none; }
@media (min-width: 1200px) {
  .app-shell.admin-shell .list-grid.data-table { display: block; grid-template-columns: none; }
  .app-shell.admin-shell .data-table {
    background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 6px 0;
  }
  .app-shell.admin-shell .data-table > .row,
  .app-shell.admin-shell .data-table > a.row {
    display: grid; align-items: center; gap: 14px; border-radius: 0; box-shadow: none; background: transparent;
    margin-bottom: 0; padding: 15px 22px; border-bottom: 1px solid var(--border); cursor: pointer;
  }
  .app-shell.admin-shell .data-table > .row:last-child,
  .app-shell.admin-shell .data-table > a.row:last-child { border-bottom: none; }
  .app-shell.admin-shell .data-table > .row:hover,
  .app-shell.admin-shell .data-table > a.row:hover { background: var(--stage); }
  .app-shell.admin-shell .data-table > .pagination { margin-top: 20px; }
  .app-shell.admin-shell .data-table .row-end { display: contents; }
  .app-shell.admin-shell .data-table .row-end .amt { font-size: 14px; }
  .app-shell.admin-shell .data-table.dt-invoices .row-end .amt { text-align: center; }
  .app-shell.admin-shell .data-table .row-end .status-pill { margin-top: 0 !important; justify-self: start; }
  .app-shell.admin-shell .data-table .row-type { display: block; font-size: 13px; color: var(--muted-text); }

  .app-shell.admin-shell .t-head {
    display: grid; align-items: center; gap: 14px; padding: 14px 22px;
    font-size: 12px; font-weight: 700; color: var(--muted-text); border-bottom: 1px solid var(--border);
  }
  .app-shell.admin-shell .t-head.dt-invoices,
  .app-shell.admin-shell .data-table.dt-invoices > .row { grid-template-columns: 44px 2fr 1fr 1fr 1fr 1fr; }   /* + «پوشش وثیقه» (Fix Prompt 42) */

  .app-shell.admin-shell .data-table.dt-customers .row-link { display: contents; }
  .app-shell.admin-shell .t-head.dt-customers,
  .app-shell.admin-shell .data-table.dt-customers > .row { grid-template-columns: 44px 2fr 1fr 40px; }
  .app-shell.admin-shell .data-table.dt-customers .row-inv-count { justify-self: start; }

}

/* ---- Dashboard: metrics 2x2 (wider, right) beside the hero card
   (narrower, left) — matches the desktop reference's `.row.hero-row`
   (`grid-template-columns: 1.35fr 1fr`, metrics div before hero-card
   div, so metrics lands in the wider right-hand column under RTL grid
   placement); stats in two columns. ---------------------------------- */
@media (min-width: 1200px) {
  .app-shell.admin-shell .dash-grid {
    display: grid; column-gap: 20px;
    grid-template-columns: 1.35fr 1fr;
    grid-template-areas: "metrics hero" "quick quick" "stats stats";
  }
  /* `min-width: 0` — without it, a bare `1.35fr 1fr` track still floors
     each item at its own min-content width; the hero card's content is
     wide enough to blow that past its 1fr share (measured 561px/539px
     instead of the intended ~469/632 split — nearly inverted). Same
     pattern already used for `.detail-left`/`.detail-right` below. */
  /* `display:flex; flex-direction:column` + `flex:1` on the carousel
     (instead of the old `height:100%`) — `.dash-hero` is stretched by
     the grid to match `.dash-metrics`' taller natural height (~306px),
     and `height:100%` on `.hero-carousel` consumed ALL of that, leaving
     zero room for its `.hero-dots` sibling below it. The dots then
     rendered outside `.dash-hero`'s own box, under `.dash-quick` (the
     next grid row down) — which visually hid them AND intercepted their
     clicks (confirmed via `elementFromPoint`), so the slider looked
     entirely unresponsive to both manual dot-clicks and would have had
     the same problem for any future auto-advance. `flex:1` instead makes
     the carousel fill only whatever space is left after the dots. */
  .app-shell.admin-shell .dash-hero { grid-area: hero; min-width: 0; display: flex; flex-direction: column; }
  .app-shell.admin-shell .dash-metrics { grid-area: metrics; min-width: 0; }
  .app-shell.admin-shell .dash-quick { grid-area: quick; }
  .app-shell.admin-shell .dash-stats { grid-area: stats; }
  .app-shell.admin-shell .dash-hero .hero-carousel { margin-top: 0; flex: 1; min-height: 260px; }
  .app-shell.admin-shell .dash-metrics .cards { height: 100%; align-content: stretch; gap: 16px; }
  /* the reference's desktop metric-card is a noticeably more compact
     component than the mobile one reused here — smaller icon (36px vs
     50px), tighter padding, icon+text pinned to opposite ends via flex
     instead of stacked block flow. Reusing the mobile card as-is made
     every card ~190px tall instead of the reference's ~118-139px,
     which in turn over-stretched the hero card next to it (it fills
     100% of the row height). Scoped to `.dash-metrics` only — this
     class is dashboard-only, so nothing else is affected, mobile or
     desktop. */
  .app-shell.admin-shell .dash-metrics .metric-card {
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 18px; min-height: 118px; gap: 12px;
  }
  .app-shell.admin-shell .dash-metrics .metric-icon { width: 36px; height: 36px; border-radius: 10px; }
  .app-shell.admin-shell .dash-metrics .metric-icon svg { width: 18px; height: 18px; }
  .app-shell.admin-shell .dash-metrics .metric-label { font-size: 12.5px; margin-top: 0; }
  .app-shell.admin-shell .dash-metrics .metric-value { font-size: 18px; margin-top: 4px; }
  .app-shell.admin-shell .dash-metrics .metric-subvalue { margin-top: 1px; }
  /* quick-access cards: reference is a compact icon-beside-label row
     (~74px tall), not the mobile's centered icon-above-label column at a
     fixed 134px. Scoped to `.dash-quick` (dashboard-only) so nothing
     else — including this same `.quick-action` class if ever reused —
     is affected. */
  .app-shell.admin-shell .dash-quick .quick-actions-row { gap: 16px; }
  .app-shell.admin-shell .dash-quick .quick-action {
    height: auto; flex-direction: row; justify-content: flex-start; align-items: center;
    gap: 14px; padding: 18px;
  }
  .app-shell.admin-shell .dash-quick .quick-action-icon { width: 38px; height: 38px; border-radius: 10px; }
  .app-shell.admin-shell .dash-quick .quick-action-icon svg { width: 18px; height: 18px; }
  /* the reference's hero-row has no "شاخص‌های کلیدی" heading at all above
     the metrics grid (it sits directly beside the hero card) — this
     title is mobile-only content, hidden here rather than reinterpreted,
     and its removal is also what lets the row settle to the reference's
     ~294px height instead of being inflated by an extra heading. */
  .app-shell.admin-shell .dash-metrics > .section-title { display: none; }
  .app-shell.admin-shell .dash-metrics .cards { margin-top: 0; }
  /* dash-grid has no row-gap of its own — mobile relies on each
     section-title's own inline margin-top for spacing between the major
     blocks. Reference uses a consistent 20px here (its `.row{margin-
     bottom:20px}` rhythm), vs. the mobile title's 26px. */
  .app-shell.admin-shell .dash-quick > .section-title { margin-top: 20px !important; }
  .app-shell.admin-shell .dash-stats {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: stretch; margin-top: 20px;
  }
  .app-shell.admin-shell .dash-stats > * { margin-top: 0 !important; }
  /* the virtual-asset comparison section (title + two boxes) reads as its
     own full-width row below the two-column stats, per the reference,
     not squeezed into a single stats column. */
  .app-shell.admin-shell .dash-stats > .dash-compare { grid-column: 1 / -1; order: 5; }
  .app-shell.admin-shell .dash-stats > .dash-compare > .section-title { margin-top: 0 !important; }
  /* row 2 of dash-stats: the reference's `.row.two-col` puts
     "جمع وصولی تا تاریخ دلخواه" first (DOM order -> right column under
     RTL) and "روند سرمایه در گردش" second (left column) — the opposite
     of this markup's DOM order, so explicit `order` fixes the visual
     side without touching the mobile stacking order. */
  .app-shell.admin-shell .dash-stats > .info-row-card { order: 1; }
  .app-shell.admin-shell .dash-stats > .progress-card { order: 2; }
  .app-shell.admin-shell .dash-stats > #until-date-card { order: 3; }
  .app-shell.admin-shell .dash-stats > .dash-chart-wc { order: 4; }
}

/* ---- New-invoice form: Fix Prompt 46 R2.4 — laid out by redesign.css (.rd-nf). */

/* ---- Invoice detail: Fix Prompt #30 — two real columns matching the
   desktop reference (`giti-pay-desktop-invoice-detail-reference.html`):
   customer/amount/type-details/action buttons on the right, progress bar
   + penalty banner + installment table on the left. Fix Prompt #24's
   single-centered-column rule broke because the progress bar/penalty
   banner/installment table were plain siblings mixed into the mobile
   flow with no container to grab; Fix Prompt #30 wrapped them in
   `.detail-left`/`.detail-right`/`.detail-progress` containers in the
   template (mobile CSS untouched — those wrappers are unstyled blocks
   below 1200px, so the mobile column order/flow is identical to before). */
@media (min-width: 1200px) {
  .app-shell.admin-shell .detail-grid {
    display: grid; grid-template-columns: 360px 1fr; column-gap: 24px; align-items: start;
  }
  .app-shell.admin-shell .detail-left,
  .app-shell.admin-shell .detail-right { min-width: 0; }
  /* `.detail-info` (mobile: plain unstyled content, no card of its own)
     must become exactly `.card.pad` from the reference — its literal
     values, not this app's mobile `--radius-card`/`--shadow` tokens
     (10px / a much larger, softer mobile shadow), which are a visibly
     different, unrelated design token pair for a different component
     scale. */
  .app-shell.admin-shell .detail-info {
    background: #fff; border-radius: 14px; box-shadow: 0 2px 14px rgba(110,117,136,.06); padding: 22px;
  }
  .app-shell.admin-shell .detail-info > *:first-child { margin-top: 0 !important; }
  /* the reference card-wraps progress bar/legend/penalty banner together
     on desktop (mobile keeps them as plain in-flow content, unchanged). */
  .app-shell.admin-shell .detail-progress {
    background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 22px;
  }
  .app-shell.admin-shell .detail-progress > div:first-child { margin-top: 0 !important; }

  /* the reference's settle-early/cancel buttons are full-width, stacked
     (settle-early/blue on top, cancel/red-outline below) — the mobile
     `.cta-sm` row (side-by-side, cancel first) stays untouched below
     1200px; this only re-flows the same two elements at desktop. */
  .app-shell.admin-shell .detail-actions { flex-direction: column; flex-wrap: nowrap; }
  .app-shell.admin-shell .detail-actions .cta-sm {
    width: 100%; padding: 13px; font-size: 13.5px; border-radius: 10px; text-align: center;
  }
  .app-shell.admin-shell .detail-actions .cta-sm.success {
    order: -1; background: var(--ink-2); color: #fff; border: none;
  }
  .app-shell.admin-shell .detail-actions .cta-sm.ghost {
    background: rgba(231,55,38,.08); color: var(--danger-text); border: 1px solid rgba(231,55,38,.25);
  }
  /* Fix Prompt #45 — ویرایش stays neutral (the red-outline ghost look
     above is cancel's), and حذف's wrapping <form> must stretch like the
     sibling links do. */
  .app-shell.admin-shell .detail-actions .cta-sm.ghost.neutral {
    background: var(--surface); color: var(--text-soft); border: 1px solid var(--border);
  }
  .app-shell.admin-shell .detail-actions form { display: block !important; width: 100%; }
}

/* ---- Fund page: matches giti-pay-desktop-fund-reference.html — hero
   card (wider, right) beside the 2x2 metrics grid (narrower, left); 4
   growth charts as a 2x2 grid; capital-link + gold-ledger form side by
   side. The mobile `.section-narrow` 720px cap is left completely alone
   below 1200px (still active at tablet); these rules only widen the
   same containers back out once there's real room. ------------------- */
@media (min-width: 1200px) {
  /* same issue as `.fund-bottom-row` below: `.chart-card`'s own mobile
     `margin-top: 16px` (style.css:482) is what separates this row from
     `.period-row` above it on mobile: zeroing it per-card for the grid
     removes that gap entirely since `.chart-grid` itself has no margin.
     `margin-top: 16px` here restores it, matching the reference's
     `.period-tabs{margin-bottom:16px}`. */
  .app-shell.admin-shell .chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
  .app-shell.admin-shell .chart-grid > .chart-card { margin-top: 0; }

  .app-shell.admin-shell .fund-hero-row {
    display: grid; grid-template-columns: 1.35fr 1fr; column-gap: 20px; align-items: stretch;
  }
  .app-shell.admin-shell .fund-hero-col .cash-hero { height: 100%; margin-top: 0; }
  .app-shell.admin-shell .fund-metrics-col .cards {
    grid-template-columns: 1fr 1fr; height: 100%; align-content: stretch; gap: 16px;
  }

  .app-shell.admin-shell .fund-compare-wrap .compare-grid { max-width: none; }

  /* `.fund-capital-link`/`.fund-gold-form` carry their own mobile
     margin-top (16px/32px, inline in the template) for stacked spacing;
     zeroing those below for the side-by-side grid also removed the only
     thing separating this row from `.chart-grid` above it, since neither
     row itself had a margin — they were rendering flush against each
     other. `margin-top: 24px` here restores the reference's `.row`
     rhythm at the row level instead. */
  .app-shell.admin-shell .fund-bottom-row {
    margin-top: 24px;
    display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; align-items: start;
  }
  .app-shell.admin-shell .fund-bottom-row .fund-capital-link { margin-top: 0 !important; height: 100%; }
  .app-shell.admin-shell .fund-bottom-row .fund-gold-form { margin-top: 0 !important; }
}

/* ---- Partner accounts: matches giti-pay-desktop-partner-accounts-
   reference.html — event history on the right (wide), balance hero +
   stats + trend chart + actions in a narrower fixed column on the left.
   `grid-template-areas` (not DOM order) places them, so the mobile
   markup order — balance block first, history second — needs no change. */
@media (min-width: 1200px) {
  /* Bug batch #3 item 3.7 — «روند موجودی من» moved to the wide column
     (right, in RTL) above the history; the narrow column keeps the balance
     cards, then the actions and the comparison card.
     Bug report #6 item 6.2 — the flexible row is the LAST of the history's
     rows now (it was the middle one, which grew with the history and pushed
     the actions and the comparison card to the bottom): the balance column
     ends where its content ends and «side» starts right under it, 12px
     below (the gap between its cards); the history takes the rest. Both
     columns stack top-down (align-items:start). Not sticky: balance and
     side are two separate grid items, so a sticky pair would overlap. */
  .app-shell.admin-shell .pc-grid {
    display: grid; column-gap: 24px; align-items: start;
    grid-template-columns: 1fr 340px; grid-template-rows: auto auto 1fr auto;
    grid-template-areas: "chart balance" "history balance" "history side" "monthly monthly";
  }
  .app-shell.admin-shell .pc-monthly-col { grid-area: monthly; min-width: 0; }
  .app-shell.admin-shell .pc-balance-col { grid-area: balance; max-width: none; }
  .app-shell.admin-shell .pc-chart-col { grid-area: chart; max-width: none; min-width: 0; }
  .app-shell.admin-shell .pc-chart-col > .period-row { margin-top: 0 !important; }
  .app-shell.admin-shell .pc-side-col { grid-area: side; max-width: none; display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
  .app-shell.admin-shell .pc-side-col > * { margin-top: 0 !important; }
  .app-shell.admin-shell .pc-history-col { grid-area: history; }
  /* Bug report #6 item 6.3 — the «تاریخچه رویدادها» heading keeps its own
     26px top margin (like «سود ماه‌به‌ماه»); it used to be zeroed here and
     sat on the chart card. */

  /* `#pc-history-container` carries the generic `.list-grid` class, which
     at this width normally means a 3-column card grid (line ~630) — wrong
     here: the reference (giti-pay-desktop-partner-accounts-reference.html)
     shows the whole event history as ONE card with flush, full-width rows
     separated by a divider, not a grid of boxed cards. The `#id` selector
     below outranks `.list-grid`'s class selector so this wins regardless
     of source order. Each event's internal layout (title+dot / amount /
     meta / edit+delete icons) is unpacked into that one row via `display:
     contents` on its `.pc-event-head` wrapper — the markup and mobile
     CSS are untouched; these are added classes with no base-level rules
     of their own. */
  .app-shell.admin-shell .pc-history-col #pc-history-container {
    display: block; background: var(--surface); border-radius: var(--radius-card);
    box-shadow: var(--shadow); padding: 6px 0; margin-top: 14px;
  }
  .app-shell.admin-shell .pc-history-col #pc-history-container > .card {
    display: grid; grid-template-columns: 1fr auto auto; align-items: center; column-gap: 14px;
    border-radius: 0; box-shadow: none; background: transparent; margin-top: 0;
    padding: 15px 20px; border-bottom: 1px solid var(--border);
  }
  .app-shell.admin-shell .pc-history-col #pc-history-container > .card:last-child { border-bottom: none; }
  .app-shell.admin-shell .pc-history-col .pc-event-head { display: contents; }
  .app-shell.admin-shell .pc-history-col .pc-event-title-wrap { grid-column: 1; grid-row: 1; }
  .app-shell.admin-shell .pc-history-col .pc-event-meta { grid-column: 1; grid-row: 2; margin-top: 2px !important; }
  .app-shell.admin-shell .pc-history-col .pc-event-amount { grid-column: 2; grid-row: 1 / span 2; }
  .app-shell.admin-shell .pc-history-col .pc-event-icons { grid-column: 3; grid-row: 1 / span 2; margin-top: 0 !important; }
}

/* ---- Bug batch #4 item 4.4 — «سود ماه‌به‌ماه» on the partners page:
   the shared .data-table rows; on mobile each month is a card (month +
   profit/%, then deposits / withdrawals / month-end figure, labelled), on
   desktop one table row with a column per figure. */
.dt-monthly .m-cell { display: block; }
.dt-monthly .m-cell::before { content: attr(data-label) ": "; font-family: var(--font-body); }
.dt-monthly .row-end { flex-shrink: 0; }
#pc-monthly-scope .period-btn { flex: none; white-space: nowrap; padding: 8px 14px; }
@media (min-width: 1200px) {
  .app-shell.admin-shell .t-head.dt-monthly,
  .app-shell.admin-shell .data-table.dt-monthly > .row { grid-template-columns: 1.3fr 1fr 80px 1fr 1fr 1.3fr; cursor: default; }
  .app-shell.admin-shell .data-table.dt-monthly .row-main,
  .app-shell.admin-shell .data-table.dt-monthly .row-main .sub { display: contents; }
  .app-shell.admin-shell .data-table.dt-monthly .name { grid-column: 1; }
  .app-shell.admin-shell .data-table.dt-monthly .amt { grid-column: 2; }
  .app-shell.admin-shell .data-table.dt-monthly .m-pct { grid-column: 3; margin-top: 0 !important; font-size: 13.5px !important; }
  .app-shell.admin-shell .data-table.dt-monthly .m-cell { font-size: 14px; color: var(--text); grid-row: 1; text-align: right; }
  .app-shell.admin-shell .data-table.dt-monthly .name,
  .app-shell.admin-shell .data-table.dt-monthly .amt,
  .app-shell.admin-shell .data-table.dt-monthly .m-pct { grid-row: 1; text-align: right; }
  .app-shell.admin-shell .data-table.dt-monthly .m-cell:nth-child(1) { grid-column: 4; }
  .app-shell.admin-shell .data-table.dt-monthly .m-cell:nth-child(2) { grid-column: 5; }
  .app-shell.admin-shell .data-table.dt-monthly .m-cell:nth-child(3) { grid-column: 6; }
  .app-shell.admin-shell .data-table.dt-monthly .m-cell::before { content: none; }
}

/* ---- Bug report #6 item 6.1 — «سود ماه‌به‌ماه» below 640px: one card per
   month (monthly-profit-mobile.html); 640px and up: the table, unchanged
   (its ≥1200px rules above; the same rules for 640–1199px below). Colours
   mapped to tokens: green -> --emerald-text / --emerald-bg, red -> --danger /
   --danger-bg. Signed amounts sit in <bdi dir="ltr">. --------------------- */
.mp-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mp-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 14px 16px; }
.mp-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); }
.mp-month { display: flex; align-items: center; gap: var(--space-1); font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; }
.mp-tag { font-size: 11px; font-weight: 600; color: var(--ink-2); background: var(--ink-tint); border-radius: 999px; padding: 2px 9px; }
.mp-result { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 0; }
.mp-profit { font-size: 18px; font-weight: 800; color: var(--emerald-text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mp-profit small { font-size: 11px; font-weight: 500; color: var(--muted-text); margin-inline-start: 3px; }
.mp-rate { font-size: 12px; font-weight: 700; color: var(--emerald-text); background: var(--emerald-bg); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.mp-rate.none { color: var(--muted-text); background: var(--neutral-tint); }
.mp-card.loss .mp-profit, .mp-card.loss .mp-rate { color: var(--danger-text); }
.mp-card.loss .mp-rate { background: var(--danger-bg); }
.mp-stats { margin: 12px 0 0; padding-top: 12px; border-top: 1px dashed var(--border); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-1); }
.mp-stats div { min-width: 0; }
.mp-stats dt { font-size: 11px; color: var(--muted-text); margin-bottom: 2px; }
.mp-stats dd { margin: 0; font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.mp-stats .zero { color: var(--muted-text); font-weight: 500; }
.mp-table { display: none; }
@media (min-width: 640px) {
  .mp-list { display: none; }
  .mp-table { display: block; }
}
@media (min-width: 640px) and (max-width: 1199px) {
  .app-shell.admin-shell .t-head.dt-monthly {
    display: grid; align-items: center; gap: 14px; padding: 14px 22px;
    font-size: 12px; font-weight: 700; color: var(--muted-text); border-bottom: 1px solid var(--border);
    grid-template-columns: 1.3fr 1fr 80px 1fr 1fr 1.3fr;
  }
  .app-shell.admin-shell .list-grid.data-table.dt-monthly {
    display: block; grid-template-columns: none;
    background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 6px 0;
  }
  .app-shell.admin-shell .data-table.dt-monthly > .row {
    display: grid; align-items: center; gap: 14px; border-radius: 0; box-shadow: none; background: transparent;
    margin-bottom: 0; padding: 15px 22px; border-bottom: 1px solid var(--border);
    grid-template-columns: 1.3fr 1fr 80px 1fr 1fr 1.3fr; cursor: default;
  }
  .app-shell.admin-shell .data-table.dt-monthly > .row:last-child { border-bottom: none; }
  .app-shell.admin-shell .data-table.dt-monthly .row-end,
  .app-shell.admin-shell .data-table.dt-monthly .row-main,
  .app-shell.admin-shell .data-table.dt-monthly .row-main .sub { display: contents; }
  .app-shell.admin-shell .data-table.dt-monthly .row-end .amt { font-size: 14px; }
  .app-shell.admin-shell .data-table.dt-monthly .name { grid-column: 1; }
  .app-shell.admin-shell .data-table.dt-monthly .amt { grid-column: 2; }
  .app-shell.admin-shell .data-table.dt-monthly .m-pct { grid-column: 3; margin-top: 0 !important; font-size: 13.5px !important; }
  .app-shell.admin-shell .data-table.dt-monthly .m-cell { font-size: 14px; color: var(--text); grid-row: 1; text-align: right; }
  .app-shell.admin-shell .data-table.dt-monthly .name,
  .app-shell.admin-shell .data-table.dt-monthly .amt,
  .app-shell.admin-shell .data-table.dt-monthly .m-pct { grid-row: 1; text-align: right; }
  .app-shell.admin-shell .data-table.dt-monthly .m-cell:nth-child(1) { grid-column: 4; }
  .app-shell.admin-shell .data-table.dt-monthly .m-cell:nth-child(2) { grid-column: 5; }
  .app-shell.admin-shell .data-table.dt-monthly .m-cell:nth-child(3) { grid-column: 6; }
  .app-shell.admin-shell .data-table.dt-monthly .m-cell::before { content: none; }
}

/* ---- Debtor/creditor (ledger.html): matches giti-pay-desktop-debtor-
   creditor-reference.html — the 2 summary cards + "ثبت مورد جدید" button
   in one row, then a real table of open items (label+status on the
   right, amount+settle button on the left of the same row) instead of
   stacked full-width settle buttons. -------------------------------- */
@media (min-width: 1200px) {
  .app-shell.admin-shell .dc-summary-row {
    display: grid; grid-template-columns: 1fr 1fr auto; column-gap: 20px; align-items: stretch;
  }
  .app-shell.admin-shell .dc-summary-row .dc-summary-cards { display: contents !important; }
  .app-shell.admin-shell .dc-summary-row .dc-new-btn { width: auto; margin-top: 0 !important; white-space: nowrap; padding: 0 22px; }

  .app-shell.admin-shell .data-table.dt-ledger > .card {
    display: grid; grid-template-columns: 1fr auto auto; align-items: center; column-gap: 18px;
    border-radius: 0; box-shadow: none; background: transparent; margin-bottom: 0;
    padding: 16px 22px; border-bottom: 1px solid var(--border);
  }
  .app-shell.admin-shell .data-table.dt-ledger > .card:last-child { border-bottom: none; }
  .app-shell.admin-shell .data-table.dt-ledger > .card:hover { background: var(--stage); }
  .app-shell.admin-shell .data-table.dt-ledger .dc-head { display: contents; }
  .app-shell.admin-shell .data-table.dt-ledger .dc-settle button {
    width: auto; margin-top: 0 !important; white-space: nowrap;
  }
}

/* ---- Settings: right-side vertical menu, selected section shown beside it
   (classic two-pane settings layout) — pure CSS, the existing JS still just
   toggles `.active` on the sub-view; the menu itself is kept visible by
   force here regardless of that class. ------------------------------------ */
@media (min-width: 1200px) {
  /* Selector targets `#page-content` (not `.screen`, which is the mobile
     shell — empty and hidden at this width after the Fix Prompt #30
     revisit-3 relocation, since `#page-content` is moved out of it into
     `.dsk-content-slot`) so this grid still applies wherever the real
     content ends up. */
  .app-shell.admin-shell #page-content:has(#view-menu) {
    display: grid; grid-template-columns: 300px 1fr; column-gap: 24px; align-items: start;
  }
  .app-shell.admin-shell #view-menu {
    display: block !important; grid-column: 1;
    background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 8px;
  }
  .app-shell.admin-shell #view-menu .menu-row {
    background: transparent; box-shadow: none; border-radius: 10px; margin-bottom: 0;
  }
  .app-shell.admin-shell .settings-view:not(#view-menu) { grid-column: 2; min-width: 0; }
  .app-shell.admin-shell .settings-view:not(#view-menu) > form,
  .app-shell.admin-shell .settings-view:not(#view-menu) > .sheet-note,
  .app-shell.admin-shell .settings-view:not(#view-menu) > .alert { max-width: 640px; }
  .app-shell.admin-shell .settings-view .es-sub,
  .app-shell.admin-shell .version-item > div { max-width: 72ch; }
  .app-shell.admin-shell .settings-view:not(#view-menu):not(.active) { display: none; }
  .app-shell.admin-shell .settings-view:not(#view-menu).active {
    display: block; background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 26px;
  }
}

/* ---- Small single-purpose forms not covered above (payment edit, cancel-
   invoice, pay-installment, quick-payment, notifications) intentionally keep the default `.screen` 720px cap from the
   tablet rule above — a centered form column, not a full-bleed stretch.
   `.form-card-narrow` is for the same kind of short form embedded on an
   otherwise-wide (screen-wide) list page, e.g. cancellations. ---------------------------------------------------------------- */
@media (min-width: 768px) {
  .app-shell.admin-shell .form-card-narrow { max-width: 480px; }
}
/* `.section-narrow` needs the 720px tablet cap gone by 1200px — every
   current user of it (fund's hero/compare/bottom rows, partner-capital's
   balance column) also carries its own desktop-specific max-width rule
   above, but that rule and this one have equal specificity, so without
   an upper bound here the later-in-file `.section-narrow` selector kept
   winning the cascade and silently re-capped all of them back to 720px
   at desktop widths — this is what was making fund/partner-accounts
   render in a squeezed ~720px column instead of the reference's full
   1120px content width. */
@media (min-width: 768px) and (max-width: 1199.98px) {
  .app-shell.admin-shell .section-narrow { max-width: 720px; }
}

::-webkit-scrollbar { display: none; }

/* ==========================================================================
   Fix Prompt #44 — installment/penalty card redesign (mobile only; the
   desktop اقساط/جریمه tables keep their existing `.row`/`.icon-btn`
   markup untouched per that Fix Prompt's item 2 — see admin/invoice_detail.html
   for the `.inst-mobile-only`/`.inst-desktop-only` split).
   Reference: gitipay-installment-penalty-redesign.html at the repo root.
   Class names below are copied from it directly; colors are remapped
   onto this app's own tokens (see tokens.css) instead of the reference's
   separate --navy/--green/--amber/etc. palette, which would otherwise be
   a second, disconnected color system. `.amt` is deliberately scoped to
   `.inst-card__amounts .amt` rather than a bare `.amt` rule — a bare rule
   would silently reskin every OTHER page's plain `.amt.mono` amount text
   (cancellations, customer detail, fund, payment history, the invoices
   list) into a boxed panel, none of which this Fix
   Prompt's scope note allows touching.
   ========================================================================== */
.inst-desktop-only { display: none; }
@media (min-width: 1200px) {
  .inst-mobile-only { display: none; }
  .inst-desktop-only { display: block; }
}

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 99px; }
.pill--green { background: var(--emerald-bg); color: var(--emerald-text); }
.pill--amber { background: var(--gold-tint); color: var(--gold-text); }
.pill--red { background: var(--danger-bg); color: var(--danger-text); }
.pill--grey { background: var(--neutral-tint); color: var(--muted-text); }
.pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

.btn { font-family: inherit; font-size: 12.5px; font-weight: 700; border-radius: 9px; padding: 9px 14px; border: none; cursor: pointer; }
.btn--primary { background: var(--ink-2); color: #fff; }
.btn--ghost { background: var(--surface-2); color: var(--text); }
.btn--ghost-red { background: var(--surface-2); color: var(--danger-text); }
.btn--icon {
  background: var(--surface-2); color: var(--text-soft); width: 34px; height: 34px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0; border: none; cursor: pointer; text-decoration: none;
}
.btn--icon svg { width: 16px; height: 16px; }

.inst-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; }
.inst-card--dim { opacity: .75; }
.inst-card__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.inst-card__num { font-size: 14.5px; font-weight: 800; color: var(--text); }
.inst-card__due { font-size: 11.5px; color: var(--muted-text); margin-bottom: 12px; }
.inst-card__due b { color: var(--text-soft); font-weight: 600; }
.inst-card__amounts { display: flex; gap: 10px; margin-bottom: 12px; }
.inst-card__amounts .amt { flex: 1; background: var(--surface-2); border-radius: 10px; padding: 9px 12px; }
.inst-card__amounts .amt__label { display: block; font-size: 10.5px; color: var(--muted-text); margin-bottom: 3px; }
.inst-card__amounts .amt__value { display: block; font-size: 15px; font-weight: 800; color: var(--text); }
.inst-card__amounts .amt__value--paid { color: var(--emerald-text); }
.inst-card__amounts .amt__value--remain { color: var(--danger-text); }
.inst-card__actions { display: flex; gap: 8px; align-items: center; }
.inst-card__actions .btn--primary { flex: 1; }
.inst-card__actions .spacer { flex: 1; }
.inst-card__actions form { margin: 0; }

.inst-card__penalty-note { font-size: 11.5px; color: var(--emerald-text); margin: -4px 0 12px; line-height: 1.8; }

/* Bug batch #1 item 3 — per-payment rows inside an installment
   (partials/payment_records.html), mobile card and desktop table. */
.btn--icon-danger { color: var(--danger); }
.pay-list { background: var(--surface-2); border-radius: 10px; padding: 4px 12px; margin-bottom: 12px; }
.pay-list__title { font-size: 11px; font-weight: 700; color: var(--muted-text); padding: 8px 0 4px; }
.pay-list__row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.pay-list__main { flex: 1; min-width: 0; }
.pay-list__amount { font-size: 13px; font-weight: 700; color: var(--text); }
.pay-list__note { font-size: 11px; font-weight: 500; color: var(--muted-text); }
.pay-list__meta { font-size: 11px; color: var(--muted-text); margin-top: 2px; }
.pay-list__row form { margin: 0; }
.pay-list__row .btn--icon { background: var(--surface); }
.pay-list--desktop { margin: -4px 0 10px; padding-inline-start: 48px; }
/* Bug batch #2 item 2.4 — the list is an accordion (collapsed by default).
   grid-template-rows 0fr↔1fr animates the real content height both ways;
   visibility keeps collapsed rows out of the tab order. */
.pay-list__toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 40px; padding: 4px 0; background: none; border: none; font: inherit; color: var(--muted-text); cursor: pointer; text-align: start; }
.pay-list__toggle .pay-list__title { padding: 0; }
.pay-list__toggle:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; border-radius: 6px; }
.pay-list__chevron { width: 16px; height: 16px; flex-shrink: 0; transition: transform .25s ease; }
.pay-list__toggle[aria-expanded="true"] .pay-list__chevron { transform: rotate(180deg); }
.pay-list__body { display: grid; grid-template-rows: 0fr; visibility: hidden; transition: grid-template-rows .28s ease, visibility .28s; }
.pay-list.is-open .pay-list__body { grid-template-rows: 1fr; visibility: visible; }
.pay-list__inner { overflow: hidden; min-height: 0; }
@media (prefers-reduced-motion: reduce) {
  .pay-list__chevron, .pay-list__body { transition: none; }
}

.pen-banner { display: flex; align-items: center; gap: 10px; background: var(--gold-tint); color: var(--gold-text); border-radius: 12px; padding: 11px 14px; font-size: 12.5px; font-weight: 600; margin-bottom: 14px; }
.pen-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
.pen-card__main { flex: 1; }
.pen-card__top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.pen-card__num { font-size: 13.5px; font-weight: 700; color: var(--text); }
.pen-card__amount { font-size: 17px; font-weight: 800; color: var(--danger-text); }
.pen-card__amount--settled { color: var(--emerald-text); }
.pen-card__amount span { font-size: 11px; font-weight: 500; color: var(--muted-text); margin-inline-start: 4px; }
.pen-card__actions { display: flex; flex-direction: column; gap: 6px; }
.pen-card__actions .btn { padding: 7px 14px; font-size: 11.5px; }
.pen-card__actions form { margin: 0; }

/* Customer behavior score — score + emoji pair, deliberately colorless
   (the emoji carries the meaning, per design-reference/customer-score-model.md). */
.score-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--text-soft); background: var(--neutral-tint); padding: 2px 9px; border-radius: 100px; white-space: nowrap; vertical-align: middle; flex-shrink: 0; }
.score-chip .score-emoji { font-size: 14px; line-height: 1; }
.score-chip--lg { font-size: 15px; padding: 6px 14px; gap: 6px; }
.score-chip--lg .score-emoji { font-size: 20px; }
.score-chip__label { font-weight: 600; color: var(--muted-text); }
.score-history { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.score-history__row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.score-history__row:first-child { border-top: 0; }
.score-history__main { flex: 1; min-width: 0; }
.score-history__text { font-size: 13px; color: var(--text); line-height: 1.7; }
.score-history__date { font-size: 11.5px; color: var(--muted-text); margin-top: 2px; }
.score-history__delta { font-size: 14px; font-weight: 800; color: var(--text); direction: ltr; unicode-bidi: isolate; flex-shrink: 0; }
.score-history__row--voided .score-history__text,
.score-history__row--voided .score-history__delta { text-decoration: line-through; color: var(--muted-text); }
.score-history__row--reversal .score-history__text { color: var(--text-soft); }

/* ==========================================================================
   REDESIGN #5 — the shared history module (.hist) and the notifications
   page (.ntf), ported from history-notifications-redesign.html. Its
   placeholder palette is mapped onto the existing tokens (tokens.css) —
   no new colors: primary -> --ink / --ink-2 / --ink-tint, positive text -> --emerald-text, navy ->
   --text, blue -> --ink-2 (its tint mixed from --ink-2), danger ->
   --danger / --danger-bg, warn and gold -> --gold / --gold-tint, neutral
   -> --neutral-tint, radius -> --radius-card, shadow -> --shadow. The
   reference's generic classes carry a hist- prefix (.hist-chip,
   .hist-menu, .hist-btn, .hist-amt, …) since the app already defines
   .chip/.menu/.btn/.amt. Layout switches with container queries, so the
   same markup is the phone list and the desktop columns.
   ========================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.hist, .ntf {
  --hist-blue-tint: color-mix(in srgb, var(--ink-2) 10%, transparent);
  --hist-hover-border: color-mix(in srgb, var(--text) 22%, transparent);
}
.hist { container-type: inline-size; container-name: hist; }

/* toolbar */
.hist-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.hist-search-row { display: flex; gap: var(--space-1); }
.hist-search { flex: 1; display: flex; align-items: center; gap: var(--space-1); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 0 var(--space-2); height: 44px; margin: 0; }
.hist-search svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.hist-search input { border: 0; outline: 0; background: transparent; font: inherit; font-size: 16px; color: var(--text); width: 100%; height: 100%; padding: 0; box-shadow: none; min-width: 0; }
.hist-search:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink-tint); }
.hist-icon-btn { width: 44px; height: 44px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-card); border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); cursor: pointer; position: relative; padding: 0; }
.hist-icon-btn svg { width: 18px; height: 18px; }
.hist-icon-btn:hover { color: var(--text); border-color: var(--hist-hover-border); }
.hist-icon-btn[aria-expanded="true"] { color: var(--text); border-color: var(--text); }
.hist-icon-btn .badge-dot { position: absolute; top: 9px; left: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); border: 2px solid var(--surface); }
.hist-icon-btn:focus-visible, .hist-chip:focus-visible, .hist-more:focus-visible, .hist-btn:focus-visible,
.hist-diff-toggle:focus-visible, .hist-pill a:focus-visible, .hist-menu [role="menuitem"]:focus-visible,
.hist-meta a:focus-visible, .ntf-link:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.hist-chips, .ntf-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: 0 -2px; }
.hist-chips::-webkit-scrollbar, .ntf-tabs::-webkit-scrollbar { display: none; }
.hist-chip { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.hist-chip .count { font-size: 11px; color: var(--muted-text); font-weight: 500; }
.hist-chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: #fff; }
.hist-chip[aria-pressed="true"] .count { color: rgba(255, 255, 255, .75); }

.hist-filters { display: none; grid-template-columns: 1fr 1fr; gap: var(--space-1); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--space-2); }
.hist-filters.open { display: grid; }
.hist-filters label { font-size: 11.5px; color: var(--muted-text); display: flex; flex-direction: column; gap: 4px; min-width: 0; margin: 0; }
.hist-filters input, .hist-filters select { height: 40px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2); width: 100%; min-width: 0; }
.hist-filters .full { grid-column: 1 / -1; }
.hist-filters-apply { display: flex; justify-content: flex-end; }
.hist-active-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.hist-pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 10px; border-radius: 999px; background: var(--hist-blue-tint); color: var(--ink-2); font-size: 12px; font-weight: 500; }
.hist-pill a { width: 20px; height: 20px; border-radius: 50%; color: inherit; display: inline-flex; align-items: center; justify-content: center; }
.hist-pill a svg { width: 12px; height: 12px; }

/* day groups */
.hist-day { margin-top: 14px; }
.hist-day-label { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-1); padding: var(--space-1) 2px; background: var(--bg); font-size: 12px; font-weight: 600; color: var(--text-soft); }
.hist-day-label .sum { font-weight: 500; color: var(--muted-text); font-size: 11.5px; white-space: nowrap; }
.hist-day-label .hist-amt { font-size: 11.5px; }
/* no overflow:hidden (as in the reference): it would clip the last row's «⋯» menu */
.hist-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); }

/* row — phone: icon | text | menu, amount + tag on a second line */
.hist-col-who { display: none; }
.hist-head { display: none; grid-template-columns: 40px minmax(0, 1fr) 140px 230px 40px; column-gap: 10px; padding: 10px 18px 0; font-size: 11.5px; color: var(--muted-text); font-weight: 500; }
.hist-head > div:nth-child(4) { text-align: left; }
.hist-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 34px; align-items: start; column-gap: 10px; row-gap: 6px; padding: 14px 12px 14px 6px; border-top: 1px solid var(--border); position: relative; }
.hist-list > .hist-row:first-child { border-top: 0; }

.hist-main { min-width: 0; }
.hist-title { font-size: 13.5px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; overflow-wrap: anywhere; }
.hist-title .subj { font-weight: 500; color: var(--text-soft); }
.hist-meta { font-size: 11.5px; color: var(--muted-text); display: flex; flex-wrap: wrap; gap: 2px 0; margin-top: 2px; }
.hist-meta > span:not(:last-child)::after { content: "·"; margin: 0 6px; color: var(--muted); }
.hist-meta a { color: var(--ink-2); text-decoration: none; }
.hist-meta a:hover { text-decoration: underline; }
.hist-lines { margin-top: 6px; font-size: 12px; color: var(--text-soft); line-height: 1.9; overflow-wrap: anywhere; }

.hist-side { grid-column: 2; grid-row: 2; display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: var(--space-1); flex-wrap: wrap; }
.hist-amt { font-size: 15px; font-weight: 700; direction: ltr; unicode-bidi: isolate; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hist-amt small { font-size: 11px; font-weight: 500; color: var(--muted-text); margin-inline-start: 3px; }
.hist-amt.in { color: var(--emerald-text); }
.hist-amt.out { color: var(--danger-text); }
.hist-amt.neutral { color: var(--text); }

.hist-tag { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.hist-tag.green { background: var(--emerald-bg); color: var(--emerald-text); }
.hist-tag.red { background: var(--danger-bg); color: var(--danger-text); }
.hist-tag.amber { background: var(--gold-tint); color: var(--gold-text); }
.hist-tag.gray { background: var(--neutral-tint); color: var(--text-soft); }
.hist-tag.blue { background: var(--hist-blue-tint); color: var(--ink-2); }

.hist-actions { grid-column: 3; grid-row: 1; display: flex; align-items: center; justify-content: center; min-width: 34px; }
.hist-more { width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.hist-more:hover, .hist-more[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.hist-more svg { width: 18px; height: 18px; }
.hist-lock { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.hist-lock svg { width: 15px; height: 15px; }

.hist-menu { position: absolute; inset-inline-end: 14px; top: 46px; z-index: 5; min-width: 190px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px color-mix(in srgb, var(--text) 14%, transparent); padding: 6px; display: none; }
.hist-menu.open { display: block; }
.hist-menu.up { top: auto; bottom: 46px; }
.hist-menu form { margin: 0; }
.hist-menu [role="menuitem"] { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border: 0; background: transparent; border-radius: 7px; font: inherit; font-size: 13px; color: var(--text); cursor: pointer; text-align: right; text-decoration: none; }
.hist-menu [role="menuitem"]:hover, .hist-menu [role="menuitem"]:focus-visible { background: var(--surface-2); }
.hist-menu [role="menuitem"] svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.hist-menu .danger, .hist-menu .danger svg { color: var(--danger); }
.hist-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* edit details (expandable) */
.hist-diff-toggle { grid-column: 2 / -1; justify-self: start; display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; padding: 0; color: var(--ink-2); font: inherit; font-size: 12px; cursor: pointer; }
.hist-diff-toggle svg { width: 14px; height: 14px; transition: transform .2s; }
.hist-diff-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.hist-diff { grid-column: 2 / -1; display: grid; grid-template-rows: 0fr; transition: grid-template-rows .22s ease; }
.hist-diff.open { grid-template-rows: 1fr; }
.hist-diff > div { overflow: hidden; min-height: 0; }
.hist-diff:not(.open) > div { visibility: hidden; }
.hist-diff-box { margin: 8px 0 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.hist-diff-box dt { color: var(--muted-text); }
.hist-diff-box dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.hist-diff-box dd.full { grid-column: 1 / -1; color: var(--text-soft); }
.hist-diff-box del { color: var(--danger-text); text-decoration-thickness: 1px; }
.hist-diff-box ins { color: var(--emerald-text); text-decoration: none; font-weight: 600; }

.hist-footer { display: flex; justify-content: center; margin-top: var(--space-3); }
.hist-footer--top { margin: var(--space-1) 0 0; }
.hist-btn { height: 42px; padding: 0 18px; border-radius: var(--radius-card); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-1); text-decoration: none; }
.hist-btn:hover { border-color: var(--hist-hover-border); }
.hist-btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }

.hist-empty { text-align: center; padding: 40px var(--space-3); color: var(--muted-text); font-size: 13px; }
.hist-empty .icon-tile { display: flex; margin: 0 auto var(--space-2); }
.hist-empty strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; }
.hist-empty-action { margin-top: 14px; }

/* compact (invoice page, partners): no search box, no customer/invoice
   subject (the page already says which); the filter button sits beside
   the chips; the recorder goes into the meta line */
.hist--compact .hist-subject { display: none; }
.hist--compact .hist-row { padding: 12px 14px 12px 6px; }
.hist--compact .hist-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: var(--space-1); row-gap: 10px; }
.hist--compact .hist-search-row { order: 2; }
.hist--compact .hist-chips { order: 1; }
.hist--compact .hist-filters, .hist--compact .hist-active-filters { order: 3; grid-column: 1 / -1; }

/* desktop: column layout via container query */
@container hist (min-width: 720px) {
  .hist-toolbar { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .hist-search-row { flex: 0 0 340px; }
  .hist-chips { flex: 1; flex-wrap: wrap; overflow: visible; }
  .hist-active-filters, .hist-filters { flex-basis: 100%; }
  .hist-filters { grid-template-columns: repeat(4, 1fr); }
  .hist-filters .full { grid-column: auto; align-self: end; }
  .hist-row, .hist--compact .hist-row { grid-template-columns: 40px minmax(0, 1fr) 140px 230px 40px; align-items: center; padding: 12px 18px; }
  .hist-main { grid-column: 2; }
  .hist-col-who { grid-column: 3; grid-row: 1; font-size: 12px; color: var(--text-soft); display: block; }
  .hist-who-meta { display: none; }
  .hist-side { grid-column: 4; grid-row: 1; justify-content: flex-end; }
  .hist-actions { grid-column: 5; grid-row: 1; }
  .hist-diff-toggle, .hist-diff { grid-column: 2 / -1; }
  .hist-head { display: grid; }
}

/* ---- Notifications page (.ntf) ------------------------------------------- */
.ntf { container-type: inline-size; container-name: ntf; }
.hist [hidden], .ntf [hidden] { display: none !important; }
.ntf-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-2); }
.ntf-head h2 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: var(--space-1); color: var(--text); }
.ntf-head .count { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--ink-2); color: #fff; font-size: 12px; font-weight: 700; }
.ntf-tabs { margin-bottom: 4px; }
.ntf-group { margin-top: 14px; }
.ntf-group-label { font-size: 12px; font-weight: 600; color: var(--text-soft); padding: 6px 2px; }
.ntf-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.ntf-card { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 4px var(--space-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 14px; cursor: pointer; position: relative; transition: box-shadow .15s, border-color .15s; }
.ntf-card:hover { border-color: var(--hist-hover-border); box-shadow: var(--shadow); }
.ntf-card.unread { background: color-mix(in srgb, var(--ink) 3%, var(--surface)); border-color: color-mix(in srgb, var(--ink) 35%, transparent); }
.ntf-ico { grid-row: 1 / span 3; position: relative; align-self: start; }
.ntf-card.unread .ntf-ico::after { content: ""; position: absolute; top: -3px; inset-inline-start: -3px; width: 11px; height: 11px; border-radius: 50%; background: var(--ink); border: 2px solid var(--surface); }
.ntf-title { font-size: 13.5px; font-weight: 600; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.ntf-card:not(.unread) .ntf-title { font-weight: 500; }
.ntf-time { grid-column: 3; grid-row: 1; font-size: 11px; color: var(--muted-text); white-space: nowrap; }
.ntf-body { grid-column: 2 / -1; font-size: 12.5px; color: var(--text-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ntf-foot { grid-column: 2 / -1; display: flex; align-items: center; justify-content: space-between; margin-top: 6px; gap: var(--space-1); position: relative; }
.ntf-link { font-size: 12px; font-weight: 600; color: var(--ink-2); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.ntf-link svg { width: 14px; height: 14px; }
.ntf-foot .hist-more { width: 30px; height: 30px; margin-inline-start: auto; }
.ntf-foot .hist-menu { top: 36px; inset-inline-end: 0; }
.ntf-foot .hist-menu.up { top: auto; bottom: 36px; }
@container ntf (min-width: 640px) {
  .ntf-card { padding: 16px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .hist *, .ntf * { transition: none !important; }
}

/* ==========================================================================
   Fix Prompt 9 — the icon system (partials/icons.html, docs/DESIGN_RULES.md
   §2). Sizes 16 / 20 / 24 only; colour = currentColor from the parent.
   The size classes win over the older per-container `svg { width… }` rules
   (they predate one scale), hence !important on width/height only.
   ========================================================================== */
svg.icon { display: inline-block; flex-shrink: 0; vertical-align: middle; }
svg.icon--16 { width: 16px !important; height: 16px !important; }
svg.icon--20 { width: 20px !important; height: 20px !important; }
svg.icon--24 { width: 24px !important; height: 24px !important; }
svg.icon--unknown { display: none; }

/* one container style: rounded square, the token at ~12% behind, the token
   at 100% on the icon; 40×40 with a 20px icon, 48×48 with 24 (empty states) */
.icon-tile {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: var(--radius-card);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-tile--lg { width: 48px; height: 48px; }
.icon-tile--ink { background: var(--ink-tint); color: var(--ink); }
.icon-tile--emerald { background: var(--emerald-bg); color: var(--emerald); }
.icon-tile--danger { background: var(--danger-bg); color: var(--danger); }
.icon-tile--gold { background: var(--gold-tint); color: var(--gold); }
.icon-tile--neutral { background: var(--neutral-tint); color: var(--muted); }
.empty-state .icon-tile { display: flex; margin: 0 auto var(--space-2); }
.icon--muted { color: var(--muted); }
.icon--danger { color: var(--danger); }
/* status colours for an icon that stands for a status (the score) */
.icon--emerald { color: var(--emerald); }
.icon--gold-text { color: var(--gold-text); }
.icon--danger-text { color: var(--danger-text); }
/* 5.18 (owner): back/forward are drawn LTR and mirrored in RTL, so back
   points right and forward points left — one rule, not per page */
[dir="rtl"] svg.icon--dir { transform: scaleX(-1); }

/* icon + label in one control (buttons, links) */
.icon-label { display: inline-flex; align-items: center; gap: 6px; }

/* ---- Touch targets (Fix Prompt 22) ------------------------------------------
   Every small control gets an invisible hit area of at least 44×44 px, centred
   on it. Nothing visible changes: the ::after has no paint (no background,
   border or shadow), only a box the browser hit-tests, so taps on it fire the
   control. Centred (top/left 50% + translate), so it is the same in RTL and LTR.
   The focus ring stays on the control itself. Where two controls sit closer
   than 44 px centre to centre, --hit-w / --hit-h shrink the area to the gap's
   midpoint, so neighbours share a boundary instead of overlapping. */
:where(.icon-circle-btn, .hero-eye-btn, .hero-dot, button.chip, a.chip, .period-btn, .type-tab, .toggle-switch,
       .cta-sm, .fc-btn, .fc-link, .fc-seg button, .hist-btn, .hist-chip, .hist-more, .hist-diff-toggle, .icon-btn,
       .btn--icon) { position: relative; }
:where(.icon-circle-btn, .hero-eye-btn, .hero-dot, button.chip, a.chip, .period-btn, .type-tab, .toggle-switch,
       .cta-sm, .fc-btn, .fc-link, .fc-seg button, .hist-btn, .hist-chip, .hist-more, .hist-diff-toggle, .icon-btn,
       .btn--icon)::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: var(--hit-w, max(100%, 44px)); height: var(--hit-h, max(100%, 44px));
  transform: translate(-50%, -50%);
}
/* carousel dots: 12 px wide, 9 px apart — each gets its half of the gap */
.hero-dot { --hit-w: calc(100% + 9px); }
/* chip rows scroll sideways, so they clip whatever sticks out above and below.
   Room for the hit area is made inside the row with padding and taken back so
   nothing moves. Only negative margins are used for that (they subtract cleanly
   even when they collapse with a neighbour's margin); where the row's own margin
   is positive (.chip-row's top, set inline per page), translateY takes it back. */
.chip-row { padding-top: 3px; padding-bottom: 3px; margin-bottom: -4px; transform: translateY(-3px); }
.hist-chips, .ntf-tabs { padding: 5px 2px; margin: -3px -2px; }
.ntf-tabs { margin-bottom: -3px; }   /* was 4px: what follows always has a top margin of 8px or more */

/* Fix Prompt 40 §5 — the approved eight-point star pattern (design-reference/brand/pattern/, served copies in
   /static/brand/pattern/). For margins, frames and bands only: the logo, the main text and QR codes always sit on a
   white card, never directly on the pattern (docs/DESIGN_RULES.md §1, brand-identity.html §۸). Not applied to any
   page yet: the landing page and printables will use it. */
.gp-pattern { background-color: var(--bg); background-image: url('/static/brand/pattern/gitipay-pattern-star-light.svg'); background-size: 40px 40px; background-repeat: repeat; }
.gp-pattern--dark { background-color: var(--ink-2); background-image: url('/static/brand/pattern/gitipay-pattern-star-dark.svg'); }

/* Fix Prompt 43 — the guide link at the foot of every customer page */
.cust-foot { margin: 22px 0 0; text-align: center; }
.cust-foot a { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }

/* Fix Prompt 42 §3 — «سهام» (partials/share_label.html). Partner identity colours: the first partner --ink, the second
   --gold; names in the text-safe variants. Identity, not status. */
.sh-label { display: inline-flex; flex-direction: column; gap: 4px; min-width: 120px; max-width: 220px; vertical-align: middle; }
.sh-names { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 11.5px; font-weight: 700; line-height: 1.5; }
.sh-name.sh-p0 { color: var(--ink-2); }
.sh-name.sh-p1 { color: var(--gold-text); }
.sh-dot { color: var(--muted-text); font-weight: 400; }
.sh-bar { display: flex; height: 4px; border-radius: 999px; overflow: hidden; background: var(--neutral-tint); }
.sh-bar i.sh-p0 { background: var(--ink); }
.sh-bar i.sh-p1 { background: var(--gold); }
.sh-tag { font-size: 10.5px; font-weight: 600; color: var(--muted-text); background: var(--neutral-tint); border-radius: 999px; padding: 1px 7px; }
.sh-legacy .sh-bar { opacity: .55; }

/* Fix Prompt 42 §4 — «پوشش وثیقه»: green at or above the collateral setting, yellow down to the red threshold, red below */
.cov-pill { display: inline-block; font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.cov-pill.cov-green { background: var(--emerald-bg); color: var(--emerald-text); }
.cov-pill.cov-yellow { background: var(--gold-tint); color: var(--gold-text); }
.cov-pill.cov-red { background: var(--danger-bg); color: var(--danger-text); }
.cov-none { color: var(--muted-text); font-size: 12px; }
.sh-row { margin-top: 6px; }

/* Fix Prompt 42 — the partner scheme section (admin/_partners_scheme.html); identity colours as .sh-p0 / .sh-p1 */
.ps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.ps-card .ps-head { font-size: 15px; margin-bottom: 8px; }
.ps-kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 4px 0; color: var(--text-soft); }
.ps-kv b { color: var(--text); }
.ps-sub { margin-top: 10px; font-size: 12.5px; font-weight: 800; color: var(--text); }
.ps-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
.ps-table th { text-align: right; font-weight: 700; color: var(--muted-text); padding: 4px; }
.ps-table td { padding: 4px; border-top: 1px solid var(--border); }
.ps-checks { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12px; }
.ps-checks li { display: flex; gap: 6px; align-items: flex-start; padding: 3px 0; }
.ps-checks li.ok { color: var(--emerald-text); }
.ps-checks li.bad { color: var(--danger-text); }
.ps-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 12px; }
.ps-exp { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.ps-exp:first-child { border-top: none; }
.ps-undone { opacity: .55; }
.sh-label { max-width: 100%; }
.sh-name { white-space: nowrap; }
@media (min-width: 900px) {
  .app-shell.admin-shell .data-table .row-end .cov-pill,
  .app-shell.admin-shell .data-table .row-end .cov-none { justify-self: start; }
}
.sh-label { width: max-content; }   /* its natural width (capped by max-width) — not the column's narrowest */
.sh-names { flex-wrap: nowrap; }
.sh-tags { display: flex; gap: 4px; }
.sh-names { flex-wrap: wrap; }      /* a fallback only: with the pill below, the names fit on one line */
@media (max-width: 899px) {
  .row-end .cov-pill, .row-end .cov-none { display: block; width: max-content; margin: 5px 0 0 auto; }
}
