/* ── Main menu (#appnav) ───────────────────────────────────────────
 * Desktop: strip under the navy header with a gold top border.
 * Mobile ≤640px: bottom tab bar with a gold top border + "More" sheet.
 * Loaded last, so it overrides the old .topbar-actions / burger rules. */
.topbar-ctx,.topbar-burger{display:none!important}

.appnav{position:sticky;top:var(--topbar-h,58px);z-index:99;background:var(--navy,#1B3240);border-top:2px solid var(--gold,#DAAA3A);box-shadow:0 4px 14px -4px rgba(0,0,0,.35);font-family:'DM Sans',sans-serif}
.appnav-row{display:flex;align-items:center;gap:4px;max-width:1400px;margin:0 auto;padding:6px 24px;min-height:50px}
.appnav-more{display:contents}
.nav-btn{display:inline-flex;align-items:center;gap:8px;height:38px;padding:0 14px;border:0;border-radius:8px;background:transparent;color:rgba(255,255,255,.88);font:inherit;font-size:14px;font-weight:600;text-decoration:none;cursor:pointer;white-space:nowrap;position:relative;transition:background .12s,color .12s}
.nav-btn:hover{background:rgba(255,255,255,.09);color:#fff}
.nav-btn:focus-visible{outline:2px solid var(--gold,#DAAA3A);outline-offset:2px}
.nav-btn[hidden]{display:none!important}
.nav-ico{flex:none;color:rgba(255,255,255,.7)}
.nav-btn.is-active{background:rgba(255,255,255,.1);color:#fff}
.nav-btn.is-active .nav-ico{color:var(--gold,#DAAA3A)}
.nav-btn.is-active::after{content:"";position:absolute;left:12px;right:12px;bottom:-7px;height:3px;border-radius:3px 3px 0 0;background:var(--gold,#DAAA3A)}
.nav-primary{background:var(--gold,#DAAA3A);color:#1B3240;font-weight:700;padding:0 16px}
.nav-primary .nav-ico{color:#1B3240}
.nav-primary:hover{background:var(--gold-light,#e8bf5a)}
.nav-ext .nav-ico{width:17px;height:17px}
.nav-more-toggle{display:none}
.nav-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* desktop order: destinations left · tools right · New File last */
@media (min-width:641px){
  .appnav-row>[data-view="dashboard"]{order:1}
  .appnav-row>[data-view="analytics"]{order:2}
  .appnav-row>[data-view="payments"]{order:3}
  #btn-leads{order:4}
  .appnav-more>.nav-btn:not(#btn-leads):not(.nav-ext):not([data-only]){order:5}
  .nav-spacer{order:6;flex:1 1 auto}
  .appnav-more [data-only]{order:7}
  .nav-ext{order:8;color:rgba(255,255,255,.75);font-weight:500}
  .nav-primary{order:9;margin-left:8px}
}

@media (max-width:1000px){
  .appnav-row{padding:6px 12px}
  .nav-btn{padding:0 10px}
  .nav-ext .nav-lbl{display:none}
  .nav-ext::after{content:"Lenders";font-size:14px}
}

/* ── mobile: bottom tab bar ─────────────────────────────────────── */
@media (max-width:640px){
  .appnav{position:fixed;top:auto;left:0;right:0;bottom:0;z-index:250;background:#fff;border-top:3px solid var(--gold,#DAAA3A);border-bottom:0;box-shadow:0 -4px 16px rgba(15,31,61,.10);padding-bottom:env(safe-area-inset-bottom,0)}
  .appnav-row{display:grid;grid-template-columns:repeat(5,1fr);gap:0;padding:4px 4px 2px;min-height:62px;max-width:none}
  .appnav-row>.nav-btn{order:0;flex-direction:column;justify-content:center;gap:3px;height:56px;padding:0 2px;font-size:11px;font-weight:600;border-radius:10px;color:#4a5d68}
  .appnav-row>.nav-btn .nav-lbl{line-height:1.1;text-align:center;white-space:normal}
  .appnav-row>.nav-btn.is-active{background:transparent;color:var(--navy,#1B3240)}
  .appnav-row>.nav-btn.is-active::after{left:30%;right:30%;top:-4px;bottom:auto;border-radius:0 0 3px 3px}
  .appnav .nav-ico{color:#4a5d68}
  .appnav-row>.nav-btn.is-active .nav-ico,.nav-more-toggle.has-active .nav-ico{color:var(--navy,#1B3240)}
  .appnav .nav-btn:hover{background:var(--g50,#f7f7f5);color:var(--navy,#1B3240)}
  .appnav .nav-btn:focus-visible{outline-color:var(--navy,#1B3240)}
  .nav-more-toggle{display:inline-flex}
  .nav-more-toggle.has-active{color:var(--navy,#1B3240)}
  .appnav-row>.nav-primary{margin:0;background:transparent;color:var(--navy,#1B3240)}
  .appnav-row>.nav-primary .nav-ico{width:44px;height:44px;padding:11px;margin-top:-20px;border-radius:50%;background:var(--gold,#DAAA3A);color:#1B3240;box-shadow:0 4px 12px rgba(15,31,61,.25);border:3px solid #fff}
  .appnav-row>.nav-primary:hover{background:transparent}

  .appnav-more{display:none;position:absolute;right:8px;bottom:calc(100% + 8px);min-width:230px;flex-direction:column;gap:2px;padding:6px;background:#fff;border:1px solid var(--g200,#dddbd4);border-top:3px solid var(--gold,#DAAA3A);border-radius:12px;box-shadow:0 10px 30px rgba(15,31,61,.22)}
  .appnav.more-open .appnav-more{display:flex}
  .appnav-more .nav-btn{order:0;width:100%;height:46px;justify-content:flex-start;font-size:15px;margin:0;color:var(--navy,#1B3240)}
  .appnav-more .nav-btn.is-active{background:#f2efe6}
  .appnav-more .nav-btn.is-active::after{display:none}
  .appnav-more .nav-spacer{display:none}
  .nav-ext .nav-lbl{display:inline}
  .nav-ext::after{content:none}

  body{padding-bottom:calc(76px + env(safe-area-inset-bottom,0))}
}

@media print{.appnav{display:none!important}}

/* Numbers (KPI) bar removed from the app — Sort now lives in the filter row. */
#kpi-bar{display:none!important}
.filter-sort-lbl{font-size:12px;font-weight:600;color:var(--g600,#5f5d55);margin-left:4px}
.filter-dir{min-width:32px;font-weight:700;color:var(--navy,#1B3240)}

/* ── Account · sync · help cluster, docked in the top bar ───────── */
.topbar #wlp-utility-tray{position:static!important;inset:auto!important;justify-self:end;align-self:center;display:inline-flex;align-items:center;gap:2px;margin:0;padding:2px;background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.18);box-shadow:none;backdrop-filter:none;z-index:auto}
.topbar #wlp-utility-tray .wlp-tray-collapse{display:none!important}
.topbar #wlp-utility-tray .lbl,.topbar #wlp-utility-tray .acct-pill .nm{display:none!important}
.topbar #wlp-utility-tray .acct-pill{height:22px;padding:0!important;border:0;background:transparent;max-width:none}
.topbar #wlp-utility-tray .acct-pill .av{width:22px;height:22px;font-size:10px}
.topbar #wlp-utility-tray #sb-sync-pill,.topbar #wlp-utility-tray .wlp-tray-btn{width:22px;height:22px;min-width:0;padding:0;margin:0;justify-content:center;border:0;background:transparent}
.topbar #wlp-utility-tray .wlp-tray-btn .ico{font-size:12px;font-weight:800}
.topbar #wlp-utility-tray #sb-sync-pill .dot{width:8px;height:8px}

/* ── Loans screen: colour toggle bar + sideways-scrolling tiles ─────────── */
.filter-bar{align-items:center;justify-content:space-between;gap:10px 14px}
.lb-seg{display:inline-flex;background:#fff;border:1px solid var(--g200,#dddbd4);border-radius:10px;padding:3px;gap:2px;max-width:100%}
.lb-tg{display:inline-flex;align-items:center;gap:7px;border:0;background:transparent;border-radius:7px;padding:7px 13px;font:600 13px 'DM Sans',sans-serif;color:#55606a;cursor:pointer;white-space:nowrap}
.lb-tg:hover{background:var(--g50,#f7f7f5);color:var(--navy,#1B3240)}
.lb-tg:focus-visible{outline:2px solid var(--gold,#DAAA3A);outline-offset:2px}
.lb-dot{width:9px;height:9px;border-radius:50%;background:var(--c)}
.lb-tg:first-child .lb-dot{display:none}
.lb-n{font-weight:700;opacity:.75}
.lb-s{display:none}
.lb-tg.is-on{background:var(--c);color:var(--ct,#fff)}
.lb-tg.is-on .lb-dot{background:var(--ct,#fff)}
.lb-tools{display:flex;align-items:center;gap:8px;flex-wrap:wrap}

@media (min-height:520px){
  html.dash-fit,html.dash-fit body{overflow:hidden;height:100%}
  html.dash-fit .wlp-footer{display:none!important}
  html.dash-fit .dash-wrap{--dash-bot:0px;--cols:3;--rows:1;--gap:14px;max-width:none;box-sizing:border-box;height:calc(100vh - var(--dash-top,120px) - var(--dash-bot));height:calc(100dvh - var(--dash-top,120px) - var(--dash-bot));padding:12px 20px 14px;display:flex;flex-direction:column;overflow:hidden}
  html.dash-fit .dash-heading{display:none}
  html.dash-fit .filter-bar{flex:0 0 auto;margin:0 0 12px}
  html.dash-fit .loan-grid{flex:1 1 auto;min-height:0;display:grid;grid-auto-flow:column;grid-template-columns:none;grid-auto-columns:calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));grid-template-rows:repeat(var(--rows),minmax(0,1fr));gap:var(--gap);overflow-x:auto;overflow-y:hidden;scroll-snap-type:x proximity;padding-bottom:8px;overscroll-behavior:contain}
  html.dash-fit .loan-card{display:flex;flex-direction:column;min-height:0;overflow:hidden;scroll-snap-align:start;padding-top:14px}
  html.dash-fit .loan-card:hover{transform:none}
  html.dash-fit .lc-prog-bar{margin-top:auto}
  html.dash-fit .new-card,html.dash-fit .empty-dash{min-height:0}
  html.dash-fit .empty-dash{grid-column:auto;grid-row:1/-1;align-self:center;width:calc(100vw - 60px);max-width:100%}
}
@media (min-height:520px) and (max-width:1099px){html.dash-fit .dash-wrap{--cols:2}}
@media (min-height:880px) and (min-width:700px){html.dash-fit .dash-wrap{--rows:2}}
@media (min-height:520px) and (max-width:700px){
  html.dash-fit .dash-wrap{--cols:1;--gap:10px;padding:8px 10px 8px}
  html.dash-fit .loan-grid{grid-auto-columns:calc(100% - 34px);scroll-snap-type:x mandatory}
  html.dash-fit .filter-bar{gap:8px}
  html.dash-fit .lb-seg{width:100%}
  html.dash-fit .lb-tg{flex:1 1 0;min-width:0;flex-direction:column;gap:0;padding:5px 2px;font-size:11px;justify-content:center}
  html.dash-fit .lb-dot{display:none!important}
  html.dash-fit .lb-l{display:none}
  html.dash-fit .lb-s{display:block}
  html.dash-fit .lb-n{font-size:13px}
  html.dash-fit .lb-tools{width:100%;flex-wrap:nowrap;gap:6px}
  html.dash-fit .lb-tools .filter-sort-lbl{display:none}
  html.dash-fit .lb-tools .filter-sel{min-width:0;flex:1 1 0;height:34px}
  html.dash-fit .lb-tools .filter-dir{flex:0 0 34px}
  html.dash-fit .lb-tools .filter-search{order:-1;flex:1.4 1 0;height:34px}
}
@media (min-height:520px) and (max-width:640px){
  html.dash-fit .dash-wrap{--dash-bot:calc(76px + env(safe-area-inset-bottom,0px))}
  html.dash-fit body{padding-bottom:0!important}
}
@media print{html.dash-fit,html.dash-fit body{overflow:visible!important;height:auto!important}html.dash-fit .dash-wrap{height:auto!important}html.dash-fit .loan-grid{display:block!important;overflow:visible!important}}
html.dash-fit .loan-card{justify-content:space-between}
html.dash-fit .loan-card>*{flex-shrink:0}
html.dash-fit .lc-prog-bar{margin-top:0}
@media (min-width:1100px){html.dash-fit .lb-tools{flex-wrap:nowrap}html.dash-fit .filter-search{flex:0 1 200px}}

/* ── Never let the menu push the page sideways ─────────────────── */
html{overflow-x:hidden}
@media (min-width:641px){
  .appnav-row{flex-wrap:nowrap;min-width:0}
  .appnav-row .nav-btn{flex:0 1 auto;min-width:0}
  .nav-data .nav-lbl{display:none}
  .nav-data{padding:0 10px}
}
@media (min-width:641px) and (max-width:1300px){
  .nav-tool .nav-lbl{display:none}
  .nav-tool{padding:0 10px}
}
@media (min-width:641px) and (max-width:900px){
  .appnav-row{padding:6px 8px;gap:2px}
  .nav-btn{padding:0 8px}
  .nav-ext::after{content:none}
  .nav-primary .nav-lbl{display:none}
}

/* ── Modals: scroll up/down only, never sideways ───────────────── */
.overlay{overflow-x:hidden}
.overlay .modal{overflow-x:hidden;overscroll-behavior:contain;touch-action:pan-y;box-sizing:border-box}
.overlay .modal *{max-width:100%;box-sizing:border-box}
.overlay .modal input,.overlay .modal select,.overlay .modal textarea{min-width:0}
