/* =====================================================================
   Finance UI: public invoice receipt, share panel, guest clients, wallets, QR page
   ===================================================================== */

/* ---------- Receipt (invoice.php / pay.php) ---------- */
.rcpt { position: relative; overflow: hidden; padding: clamp(20px, 3.2vw, 34px); border-radius: 24px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 22px; }
.rcpt::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 10px; background: radial-gradient(circle at 7px -2px, var(--bg) 6px, transparent 6.5px) 0 0 / 14px 10px repeat-x; opacity: .9; } /* torn-receipt edge */
.rcpt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.rcpt-head h2 { margin: 6px 0 0; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.rcpt-subject { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.rcpt-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.rcpt-parties > div { display: grid; gap: 3px; padding: 14px 16px; border-radius: 16px; background: #ffffff05; border: 1px solid var(--line); min-width: 0; }
.rcpt-parties span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
html[dir=rtl] .rcpt-parties span { letter-spacing: 0; }
.rcpt-parties strong { font-size: 15px; overflow-wrap: anywhere; }
.rcpt-parties small { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.rcpt-dates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.rcpt-dates div { padding: 10px 12px; border-radius: 12px; background: #ffffff04; border: 1px dashed var(--line); }
.rcpt-dates dt { font-size: 11px; color: var(--muted); }
.rcpt-dates dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.rcpt-items { display: grid; border-top: 1px solid var(--line); }
.rcpt-line { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.rcpt-n { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: #c8ff5514; color: var(--lime); }
.rcpt-desc { display: grid; gap: 3px; min-width: 0; }
.rcpt-desc strong { font-size: 15px; overflow-wrap: anywhere; }
.rcpt-desc small { color: var(--muted); font-size: 12.5px; }
.rcpt-amt { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rcpt-totals { display: grid; gap: 8px; width: min(380px, 100%); margin-inline-start: auto; }
.rcpt-totals > div { display: flex; justify-content: space-between; gap: 14px; font-size: 14px; color: var(--muted); }
.rcpt-totals > div > :last-child { color: var(--text); font-variant-numeric: tabular-nums; }
.rcpt-discount > :last-child, .rcpt-paid > :last-child { color: var(--lime) !important; }
.rcpt-grand { padding-top: 10px; border-top: 1px solid var(--line); font-size: 17px !important; font-weight: 800; color: var(--text) !important; }
.rcpt-due { padding: 12px 14px; border-radius: 14px; background: var(--lime); color: #10110f !important; font-weight: 800; font-size: 16px !important; }
.rcpt-due > :last-child, .rcpt-due small { color: #10110f !important; }
.rcpt-fx { font-size: 12px !important; }
.rcpt-notes { display: grid; gap: 12px; padding-top: 6px; }
.rcpt-notes span { display: block; font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.rcpt-notes p { margin: 0; font-size: 13.5px; color: #d9d6cc; }
.rcpt-stamp { position: absolute; top: 26px; inset-inline-end: -48px; transform: rotate(35deg); background: var(--lime); color: #10110f; font-weight: 900; letter-spacing: .2em; text-transform: uppercase; padding: 6px 60px; font-size: 13px; box-shadow: 0 6px 18px #0006; }
html[dir=rtl] .rcpt-stamp { transform: rotate(-35deg); letter-spacing: 0; }
.rcpt-compact { gap: 16px; }
.rcpt-payments { display: grid; gap: 10px; }
.rcpt-pay { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.rcpt-pay div { display: grid; gap: 2px; } .rcpt-pay small { color: var(--muted); font-size: 12px; }
.rcpt-pay-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #c8ff5514; color: var(--lime); }

/* ---------- Invoice page hero & actions ---------- */
.inv-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 22px; flex-wrap: wrap; padding: clamp(28px, 5vw, 64px) 0 22px; }
.inv-hero h1 { margin: 10px 0 0; font-size: clamp(34px, 5.4vw, 72px); letter-spacing: -.045em; line-height: 1; font-variant-numeric: tabular-nums; }
.inv-due { display: grid; gap: 6px; justify-items: end; padding: 18px 22px; border-radius: 22px; background: radial-gradient(ellipse at 100% 0, #2d3d1e, transparent 70%), #171a14; border: 1px solid #c8ff5540; min-width: min(320px, 100%); }
html[dir=rtl] .inv-due { justify-items: start; }
.inv-due > span { color: var(--muted); font-size: 13px; }
.inv-due strong { font-size: clamp(30px, 4vw, 44px); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.inv-due strong small { font-size: .42em; color: var(--lime); }
.inv-due > small { color: var(--muted); }
.inv-due.is-paid { background: var(--lime); border-color: var(--lime); }
.inv-due.is-paid > span, .inv-due.is-paid strong, .inv-due.is-paid strong small { color: #10110f; }
.inv-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.pay-doc-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Admin: share panel, guest tags, client mode ---------- */
.share-panel { display: grid; gap: 12px; border-color: #c8ff5540 !important; background: radial-gradient(ellipse at 0 0, #22301a, transparent 65%), var(--surface); }
.share-url { padding: 10px 12px; border-radius: 12px; background: #0c0d0b; border: 1px solid var(--line); overflow-x: auto; }
.share-url code { font-size: 12px; color: var(--lime); white-space: nowrap; }
.share-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.share-actions .button { flex: 1 1 auto; justify-content: center; }
.tag-guest { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; color: #ffcf6b; background: #ffcf6b14; border: 1px solid #ffcf6b40; vertical-align: middle; }
.client-mode { display: flex; gap: 8px; flex-wrap: wrap; }
.mode-pill { position: relative; display: inline-flex !important; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; font-weight: 700; font-size: 14px; min-height: 44px; transition: border-color .2s, background .2s; }
.mode-pill input { position: absolute; opacity: 0; pointer-events: none; }
.mode-pill:has(input:checked) { border-color: var(--lime); background: #c8ff5514; color: var(--lime); }
.mode-pill:has(input:focus-visible) { outline: 2px solid var(--lime); outline-offset: 2px; }

/* ---------- Wallets ---------- */
.wallet-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; padding: clamp(22px, 3vw, 32px); border-radius: 26px; background: radial-gradient(ellipse at 0 0, #2d3d1e, transparent 60%), radial-gradient(ellipse at 100% 100%, #1d2616, transparent 55%), var(--surface); border: 1px solid #c8ff5533; }
.wallet-total { display: block; margin-top: 10px; font-size: clamp(34px, 5vw, 60px); letter-spacing: -.045em; line-height: 1; font-variant-numeric: tabular-nums; }
.wallet-total small { font-size: .36em; color: var(--lime); letter-spacing: .04em; }
.wallet-per { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; color: var(--muted); }
.wallet-in { margin: 0; }
.wallet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 18px; }
.wallet-card { position: relative; display: grid; gap: 16px; padding: 20px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); transition: border-color .2s, transform .2s; }
.wallet-card:hover { border-color: #c8ff5566; transform: translateY(-2px); }
.wallet-card.is-main { border-color: var(--lime); background: radial-gradient(ellipse at 100% 0, #2a3a1c, transparent 60%), var(--surface); }
.wallet-card.is-archived { opacity: .55; }
.wallet-link { position: absolute; inset: 0; border-radius: inherit; z-index: 1; }
.wallet-card header { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.wallet-card h2 { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.wallet-card header small { color: var(--muted); font-size: 12px; }
.wallet-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: #c8ff5514; color: var(--lime); }
.wallet-main { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 800; color: #10110f; background: var(--lime); padding: 4px 9px; border-radius: 99px; white-space: nowrap; }
.wallet-main .icon { width: 12px; height: 12px; }
.wallet-balance { font-size: 28px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.wallet-balance small { font-size: .45em; color: var(--muted); }
.wallet-card footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.wallet-card footer form { position: relative; z-index: 2; }
.wtx-in { color: var(--lime) !important; } .wtx-out { color: #ff8a7a !important; }
.wtx-type { display: inline-flex; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: #ffffff08; border: 1px solid var(--line); white-space: nowrap; }
.wtx-type-payment, .wtx-type-deposit, .wtx-type-transfer_in { color: var(--lime); border-color: #c8ff5540; }
.wtx-type-withdrawal, .wtx-type-reversal, .wtx-type-transfer_out { color: #ff8a7a; border-color: #ff8a7a40; }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.seg label { position: relative; display: block; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px; border-radius: 12px; border: 1px solid var(--line); font-weight: 700; font-size: 13px; cursor: pointer; }
.seg input:checked + span { border-color: var(--lime); background: #c8ff5514; color: var(--lime); }
.seg input:focus-visible + span { outline: 2px solid var(--lime); outline-offset: 2px; }
.metric-wallet { border-color: #c8ff5540 !important; }
.metric-wallet small { display: flex; align-items: center; gap: 5px; }
.metric-wallet small .icon { width: 12px; height: 12px; color: var(--lime); }

/* ---------- QR page ---------- */
.qr-page { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.qr-stage { display: grid; place-items: center; }
.qr-card { position: relative; overflow: hidden; width: min(440px, 100%); padding: 30px 28px 26px; border-radius: 32px; text-align: center; background: radial-gradient(ellipse at 50% -10%, #34481f, transparent 60%), #141613; border: 1px solid #c8ff5540; box-shadow: 0 30px 80px #0007; }
.qr-glow { position: absolute; inset: auto -30% -50% -30%; height: 70%; background: radial-gradient(ellipse at 50% 50%, #c8ff5530, transparent 60%); filter: blur(20px); pointer-events: none; }
.qr-brand { position: relative; display: flex; justify-content: center; margin-bottom: 18px; }
.qr-lockup { height: 30px; width: auto; color: var(--text); }
.qr-code { position: relative; width: 100%; aspect-ratio: 1; border-radius: 22px; overflow: hidden; box-shadow: 0 0 0 1px #c8ff5533, 0 18px 50px #0008; }
.qr-code svg { display: block; width: 100%; height: 100%; }
.qr-caption { position: relative; margin: 18px 0 2px; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.qr-url { position: relative; margin: 0; color: var(--lime); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.qr-scan { position: relative; display: inline-flex; align-items: center; gap: 7px; margin: 14px 0 0; padding: 7px 12px; border-radius: 99px; font-size: 12px; color: var(--muted); border: 1px solid var(--line); }
.qr-controls { display: grid; gap: 14px; }
.qr-targets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.qr-target { position: relative; display: block; }
.qr-target input { position: absolute; opacity: 0; pointer-events: none; }
.qr-target span { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); font-weight: 700; font-size: 14px; cursor: pointer; transition: border-color .2s, background .2s; }
.qr-target input:checked + span { border-color: var(--lime); background: #c8ff5514; color: var(--lime); }
.qr-target input:focus-visible + span { outline: 2px solid var(--lime); outline-offset: 2px; }
.qr-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.qr-actions .button-wide { grid-column: 1 / -1; }
.qr-actions .button { justify-content: center; }
/* Present mode: the card fills the screen */
.qr-stage.is-present { position: fixed; inset: 0; z-index: 2000; background: radial-gradient(ellipse at 50% 30%, #23301a, #0b0c0a 70%); padding: 20px; }
.qr-stage.is-present .qr-card { width: min(92vmin, 560px); }
.qr-exit { position: fixed; top: 16px; inset-inline-end: 16px; z-index: 2001; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: #10110fcc; color: var(--text); font-size: 26px; cursor: pointer; }

@media (max-width: 900px) { .qr-page { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .rcpt-parties, .rcpt-dates { grid-template-columns: 1fr; }
  .rcpt-dates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inv-due { width: 100%; justify-items: start; }
  .inv-actions .button { flex: 1 1 auto; justify-content: center; }
  .rcpt-line { grid-template-columns: 24px minmax(0, 1fr); }
  .rcpt-amt { grid-column: 2; }
  .wallet-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .wallet-card { transition: none; } .wallet-card:hover { transform: none; } }
@media print { .inv-actions, .pay-steps, .pay-methods, .site-header, .site-footer { display: none !important; } }
