/* ================================================================
   Modern popup cards — one shared look for every modal family
   (sales/vault/expenses .modal, main-app .pdm-* / .sal-edit-* / .qac-* /
   .st-* / PIN box, confirm dialogs .cdlg, reports .rpt-modal, Excel
   import .wimp-*). Loaded LAST on each page, so it wins by cascade.
   Only the shell changes: overlay, card, header, close button, footer,
   motion, focus ring, phone bottom-sheet. Widths/content stay per-app.
   The zero-pay warning (.zw-*) is deliberately left loud and untouched.
   ================================================================ */
:root{
  --mm-brand:#ff6b35; --mm-brand-dark:#b8431a; --mm-brand-soft:#fff1ec;
  --mm-ink:#1f2430; --mm-muted:#6b7280; --mm-line:#ebe7df; --mm-soft:#faf9f6;
  --mm-radius:20px;
  --mm-shadow:0 0 0 1px rgba(16,24,40,.05), 0 12px 24px -8px rgba(16,24,40,.14), 0 32px 72px -16px rgba(16,24,40,.30);
}

/* ── Backdrop: dim + blur, fades in ───────────────────────────── */
.modal-overlay, .pdm-overlay, .sal-edit-overlay, .qac-overlay, .st-overlay,
.sal-pin-overlay, .rpt-modal-bg, html .wimp-overlay{
  background:rgba(22,26,36,.46);
  -webkit-backdrop-filter:blur(6px) saturate(115%); backdrop-filter:blur(6px) saturate(115%);
  animation:mmFade .18s ease-out;
}
.cdlg-overlay{ background:rgba(22,26,36,.46); -webkit-backdrop-filter:blur(6px); backdrop-filter:blur(6px); }

/* ── Card ─────────────────────────────────────────────────────── */
.modal, .pdm-dialog, .sal-edit-card, .qac-modal, .st-dialog, .sal-pin-box,
.cdlg, .rpt-modal, html .wimp-modal{
  border-radius:var(--mm-radius);
  box-shadow:var(--mm-shadow);
  border:0;
}
.modal, .pdm-dialog, .sal-edit-card, .qac-modal, .st-dialog, .sal-pin-box,
.rpt-modal, html .wimp-modal{ animation:mmPop .22s cubic-bezier(.2,.9,.3,1.05); }
.modal, .sal-edit-card, .rpt-modal{ scrollbar-width:thin; scrollbar-color:#d9d4ca transparent; }

/* ── Header: white, brand hairline on top, stays put while body scrolls ── */
.modal-head, .pdm-header, .sal-edit-hd, .qac-head, html .wimp-head{
  position:sticky; top:0; z-index:2;
  background:#fff;
  padding:18px 22px 16px;
  border:0; border-bottom:1px solid var(--mm-line);
  box-shadow:inset 0 3px 0 var(--mm-brand);
  color:var(--mm-ink);
  gap:12px;
}
.qac-modal{ border-top:0; }
.modal-head h3, .modal-head > span, .pdm-header h3, .qac-head h3, html .wimp-head h3, .sal-edit-hd > span{
  margin:0; font-size:16.5px; font-weight:800; color:var(--mm-ink); letter-spacing:-.1px; line-height:1.4;
}
.sal-edit-hd > span{ display:flex; align-items:center; gap:10px; }
.sal-edit-hd > span i, .pdm-header h3 i{
  width:32px; height:32px; border-radius:10px; flex:0 0 auto;
  background:var(--mm-brand-soft); color:var(--mm-brand) !important;
  display:inline-flex; align-items:center; justify-content:center; font-size:14px;
}

/* ── Close button: soft round chip ────────────────────────────── */
.modal-head .icon-btn, .modal-head .x, .pdm-close, .sal-edit-hd button, .qac-close,
html .wimp-close, .rpt-modal-h button, .sal-pin-close{
  width:36px; height:36px; flex:0 0 auto; padding:0;
  border-radius:50%; border:0;
  background:#f3f1ec; color:var(--mm-muted);
  display:inline-flex; align-items:center; justify-content:center;
  font-size:16px; line-height:1; cursor:pointer;
  transition:background .15s, color .15s, transform .15s;
}
.modal-head .icon-btn:hover, .modal-head .x:hover, .pdm-close:hover, .sal-edit-hd button:hover,
.qac-close:hover, html .wimp-close:hover, .rpt-modal-h button:hover, .sal-pin-close:hover{
  background:var(--mm-brand-soft); color:var(--mm-brand-dark); transform:rotate(90deg);
}
.modal-head .icon-btn:focus-visible, .modal-head .x:focus-visible, .pdm-close:focus-visible,
.sal-edit-hd button:focus-visible, .qac-close:focus-visible{ outline:2px solid var(--mm-brand); outline-offset:2px; }

/* ── Body ─────────────────────────────────────────────────────── */
.modal-body, .sal-edit-body, .qac-body, html .wimp-body{ padding:20px 22px; }

/* ── Footer: soft strip, pinned to the bottom while body scrolls ── */
.modal-foot, .pdm-footer, .sal-edit-foot, .qac-foot, html .wimp-foot{
  position:sticky; bottom:0; z-index:2;
  background:var(--mm-soft);
  border-top:1px solid var(--mm-line);
  padding:14px 22px;
  gap:10px;
}
.modal-foot .btn, .pdm-footer .btn, .sal-edit-foot .sal-btn, .qac-foot .btn, html .wimp-foot .wimp-btn{
  min-height:42px; border-radius:11px; padding-inline:18px; font-weight:700;
}

/* ── Fields inside popups: rounder + brand focus ring ─────────── */
.modal-body :is(input,select,textarea):not([type=checkbox]):not([type=radio]),
.sal-edit-body :is(input,select,textarea):not([type=checkbox]):not([type=radio]),
.qac-body :is(input,select,textarea):not([type=checkbox]):not([type=radio]){
  border-radius:10px;
  transition:border-color .15s, box-shadow .15s;
}
.modal-body :is(input,select,textarea):not([type=checkbox]):not([type=radio]):focus,
.sal-edit-body :is(input,select,textarea):not([type=checkbox]):not([type=radio]):focus,
.qac-body :is(input,select,textarea):not([type=checkbox]):not([type=radio]):focus{
  outline:none; border-color:var(--mm-brand);
  box-shadow:0 0 0 3px rgba(255,107,53,.14);
}
/* inputs that live inside a bordered wrapper (currency prefix etc.) keep the ring on the wrapper */
.modal-body .amount-input input:focus, .sal-edit-body .sal-inp-wrap input:focus{ box-shadow:none; }
.modal-body .amount-input:focus-within, .sal-edit-body .sal-inp-wrap:focus-within{
  border-color:var(--mm-brand); box-shadow:0 0 0 3px rgba(255,107,53,.14);
}

/* ── Confirm dialog ───────────────────────────────────────────── */
.cdlg{ padding:28px 26px 22px; }
.cdlg-icon{ width:64px; height:64px; border-radius:20px; box-shadow:0 0 0 6px rgba(0,0,0,.025); }
.cdlg-title{ font-size:18px; font-weight:800; }
.cdlg-actions .btn{ min-height:42px; border-radius:11px; }

/* ── Salary PIN box ───────────────────────────────────────────── */
.sal-pin-box{ padding:40px 34px 32px; }

/* ── Reports drill-down popup ─────────────────────────────────── */
.rpt-modal{ padding:0; }
.rpt-modal-h{
  position:sticky; top:0; z-index:2; margin:0; background:#fff;
  padding:16px 20px; border-bottom:1px solid var(--mm-line); box-shadow:inset 0 3px 0 var(--mm-brand);
}
.rpt-modal > :not(.rpt-modal-h){ margin-inline:20px; }
.rpt-modal > :last-child{ margin-bottom:18px; }

/* ── Motion ───────────────────────────────────────────────────── */
@keyframes mmFade{ from{ opacity:0; } to{ opacity:1; } }
@keyframes mmPop{ from{ opacity:0; transform:translateY(12px) scale(.975); } to{ opacity:1; transform:none; } }
@keyframes mmSheet{ from{ transform:translateY(100%); } to{ transform:none; } }
@media (prefers-reduced-motion:reduce){
  .modal-overlay, .pdm-overlay, .sal-edit-overlay, .qac-overlay, .st-overlay, .sal-pin-overlay, .rpt-modal-bg,
  .modal, .pdm-dialog, .sal-edit-card, .qac-modal, .st-dialog, .sal-pin-box, .rpt-modal{ animation:none; }
}

/* ── Phones: popups become bottom sheets ──────────────────────── */
@media screen and (max-width:560px){
  .modal-overlay, .pdm-overlay, .sal-edit-overlay, .qac-overlay, .rpt-modal-bg{
    align-items:flex-end; padding:0;
  }
  .modal, .pdm-dialog, .sal-edit-card, .qac-modal, .rpt-modal{
    width:100%; max-width:none;
    border-radius:22px 22px 0 0;
    max-height:92vh; max-height:92dvh;
    animation:mmSheet .26s cubic-bezier(.2,.9,.3,1);
  }
  .modal-head, .pdm-header, .sal-edit-hd, .qac-head, .rpt-modal-h{ padding-top:22px; }
  /* grab handle */
  .modal-head::before, .pdm-header::before, .sal-edit-hd::before, .qac-head::before, .rpt-modal-h::before{
    content:""; position:absolute; top:8px; left:50%; transform:translateX(-50%);
    width:40px; height:4px; border-radius:4px; background:#ddd8ce;
  }
  .modal-head, .pdm-header, .sal-edit-hd, .qac-head, .rpt-modal-h{ position:sticky; }
  .modal-foot, .pdm-footer, .sal-edit-foot, .qac-foot{
    padding-bottom:calc(14px + env(safe-area-inset-bottom));
  }
  .modal-body, .sal-edit-body, .qac-body{ padding:16px 16px; }
  .modal-head, .pdm-header, .sal-edit-hd, .qac-head{ padding-inline:16px; }
  .modal-foot, .pdm-footer, .sal-edit-foot, .qac-foot{ padding-inline:16px; }
}

