/* bpLOANos — the few additions the live app needs on top of the design's own CSS.
   Everything uses the design's theme variables, so both themes (Executive Navy /
   Soft Neutral) style these automatically. */

/* ---------- sign-in / invite / loading screens */
body.booting > *:not(#boot-screen):not(script) { display: none !important; }
body:not(.booting) > #boot-screen { display: none; }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; background: var(--bg-page); }
.auth-card { width: 100%; max-width: 420px; padding: 34px 34px 30px !important; border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-pop) !important; }
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo img { height: 46px; width: auto; }
.auth-title { font-size: 21px; font-weight: 700; margin-bottom: 4px; text-align: center; }
.auth-sub { color: var(--text-secondary); font-size: 13px; text-align: center; margin-bottom: 20px; }
.auth-card .field { margin-bottom: 12px; }
.auth-card .field input { width: 100%; }
.auth-remember { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-secondary); margin: 4px 0 10px; cursor: pointer; }
.auth-error { color: var(--pill-danger-text); min-height: 18px; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.auth-btn { width: 100%; justify-content: center; padding: 11px 16px !important; margin-top: 4px; display: inline-flex; text-align: center; text-decoration: none; }
.auth-foot { margin-top: 18px; color: var(--text-muted); font-size: 11.5px; letter-spacing: .02em; }
.boot-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent-solid); animation: sc-spin .8s linear infinite; }
@keyframes sc-spin { to { transform: rotate(360deg); } }
body.sc-loading { cursor: progress; }
body.sc-loading .main { opacity: .72; transition: opacity .15s; }

/* ---------- toasts + "saved" indicator */
#sc-toasts { position: fixed; right: 18px; bottom: 18px; z-index: 6000; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.sc-toast { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); border-left: 4px solid var(--accent-solid); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); padding: 10px 14px; font-size: 12.5px; font-weight: 600; opacity: 0; transform: translateY(8px); transition: all .2s; white-space: pre-line; }
.sc-toast.show { opacity: 1; transform: none; }
.sc-toast.error { border-left-color: var(--pill-danger-text); }
#sc-saved { color: rgba(255,255,255,0.55); font-size: 11.5px; font-weight: 600; opacity: 0; transition: opacity .3s; white-space: nowrap; }
#sc-saved.show { opacity: 1; }
html[data-theme="airy"] #sc-saved { color: var(--text-muted); }

/* ---------- real document viewer inside the design's side-by-side review */
.sc-real-viewer { display: flex; flex-direction: column; height: 100%; min-height: 560px; }
.sc-real-viewer iframe, .sc-real-viewer img { flex: 1; }
.sc-real-viewer-bar { display: flex; gap: 14px; align-items: center; font-size: 11.5px; padding: 8px 2px 0; color: var(--text-secondary); }
.sc-real-viewer-bar span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.sc-real-viewer-bar a { color: var(--accent-solid); font-weight: 700; text-decoration: none; }
#sc-doc-preview-frame { margin-bottom: 14px; }
#sc-doc-preview-frame .sc-real-viewer { min-height: 420px; }

/* ---------- portal sessions (real borrower / broker / investor logins) use the design's
   external-party chrome: no staff sidebar or control bar, no "preview" banner. */
body.portal-session .control-bar, body.portal-session .sidebar { display: none; }
body.portal-session .app-shell { min-height: 100vh; }
body.portal-session .external-preview-banner { display: none !important; }
.sc-portal-signout { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.external-shell-header { display: flex; align-items: center; }

/* ---------- application wizard validation */
.wz-err { display: none; color: var(--pill-danger-text); font-size: 11.5px; font-weight: 600; margin-top: 4px; }
.wz-invalid .wz-err { display: block; }
.wz-invalid input, .wz-invalid select, .wz-invalid textarea { border-color: var(--pill-danger-text) !important; box-shadow: 0 0 0 3px var(--pill-danger-bg); }
.wz-invalid .toggle-pill { border-color: var(--pill-danger-text); }
.app-step.wz-done::after { content: "✓"; float: right; color: var(--pill-success-text); font-weight: 800; }
.wz-ack { font-size: 12px; line-height: 1.6; color: var(--text-secondary); background: var(--bg-card-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; max-height: 160px; overflow: auto; }
.pac-container { z-index: 7000 !important; border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); font-family: inherit; }

/* ---------- account menu (profile chip) */
#sc-account-menu button { display: block; width: 100%; text-align: left; }

/* ---------- address autocomplete suggestions (design's dropdown menu style) */
.wz-ac button { display: block; width: 100%; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Drag-and-drop onto a document folder */
.doc-row.doc-drop-target { outline: 2px dashed var(--accent-solid); outline-offset: -2px; background: color-mix(in srgb, var(--accent-solid) 8%, transparent); border-radius: 8px; }
#doc-list-body.doc-drop-target { outline: 2px dashed var(--border-strong, var(--accent-solid)); outline-offset: -4px; }
#doc-list-body.doc-drop-target::before { content: "Drop onto a document folder to upload it there and run the reader"; display: block; padding: 6px 12px; font-size: 12px; color: var(--text-secondary); }

/* Track record import preview */
.tri-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.tri-table th { text-align: left; font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--text-secondary); padding: 6px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tri-table td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tri-table td:first-child, .tri-table th:first-child { width: 26px; }
.tri-table .terms-input { width: 100%; min-width: 0; box-sizing: border-box; }
.tri-table td:nth-child(2) { min-width: 220px; }
.tri-table td:nth-child(3) { min-width: 150px; }
.tri-table td:nth-child(4), .tri-table td:nth-child(7) { min-width: 128px; }
.tri-table td:nth-child(5), .tri-table td:nth-child(6), .tri-table td:nth-child(8) { min-width: 92px; }

/* Clear modal: a real file fills the left pane, which gets the larger share of the modal */
.modal-body:has(.sc-real-viewer) { grid-template-columns: 1.35fr 1fr; }
.modal-viewer:has(.sc-real-viewer) { padding: 12px; align-items: stretch; justify-content: stretch; overflow: hidden; }
.modal-viewer .sc-real-viewer { width: 100%; height: 100%; min-height: 0; }
.modal-viewer .sc-real-viewer iframe { width: 100%; height: 100%; min-height: 0; }
.modal-viewer .sc-real-viewer img { width: 100%; height: 100%; object-fit: contain; }
.modal-card:has(#modal-viewer .sc-real-viewer) { height: 94vh; }
.modal-body:has(#modal-viewer .sc-real-viewer) { grid-template-rows: minmax(0, 1fr); min-height: 0; }

/* Form controls the design left unstyled (no class) get the same look as its .field inputs,
   and selects use one consistent chevron instead of the browser's default arrow. */
select:not([class]),
input:not([class]):not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]):not([type=color]):not([type=hidden]),
textarea:not([class]) {
  font-family: inherit; font-size: 13px; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background-color: var(--bg-card-alt); color: var(--text-primary);
  transition: border-color .15s, background-color .15s;
}
select:not([class]):focus, input:not([class]):focus, textarea:not([class]):focus { outline: 2px solid var(--accent-solid); outline-offset: 1px; background-color: var(--bg-card); }
select:not([class]), .field select, select.terms-input, .add-comment-row select {
  -webkit-appearance: none; appearance: none; cursor: pointer; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a94a6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 12px;
}
select:not([class]):hover, .field select:hover, select.terms-input:hover { border-color: var(--accent-solid); }

/* Reader notes sit tight under the checklist item they explain; the divider moves below the note. */
.check-row:has(+ .sc-reader-note) { border-bottom: none; padding-bottom: 2px; }
.sc-reader-note { margin: 0; padding: 0 0 10px 30px; border-bottom: 1px solid var(--border); font-size: 11.5px; line-height: 1.45; }

/* Borrower portal / upload link: drop a file onto a document row; External notes under each item. */
.sc-portal-doc { transition: box-shadow .12s, outline-color .12s; outline: 2px dashed transparent; outline-offset: 2px; }
.sc-portal-doc.sc-drop-over { outline-color: var(--accent-solid, #2e5395); box-shadow: 0 0 0 4px rgba(46,83,149,.12); }
.sc-portal-note { margin: -2px 0 8px 3px; padding: 7px 12px; border-radius: 0 0 6px 6px; background: var(--bg-subtle, #F6F8FB); font-size: 12px; line-height: 1.45; color: var(--text-secondary); border-left: 3px solid #9fb0c8; }
.sc-portal-note.is-action { background: #FDEAEA; color: #8B1E1E; border-left-color: #C0392B; }
.sc-portal-note.is-resolved { opacity: .7; text-decoration: none; border-left-color: #4C9A6A; }

/* Advance invoice dropzone */
#adv-invoice-drop { border: 2px dashed var(--border, #d5dbe5); border-radius: 8px; color: var(--text-secondary); font-size: 12.5px; background: var(--bg-card-alt, #f6f8fb); }
#adv-invoice-drop.sc-drop-over { border-color: var(--accent-solid, #2e5395); color: var(--accent-solid, #2e5395); }

/* Light segmented filters: always legible (bordered track, dark labels, gradient active pill). */
.seg.seg-light { background: var(--bg-card) !important; border: 1px solid var(--border); }
.seg.seg-light button { color: var(--text-primary) !important; opacity: .8; }
.seg.seg-light button.active { background: var(--grad-primary) !important; color: #fff !important; opacity: 1; }
.seg.seg-light button:hover:not(.active) { opacity: 1; background: var(--bg-card-alt); }

/* Collapsible left navigation (icon-only rail) */
body.sc-nav-collapsed .sidebar { width: 72px; padding: 20px 8px; align-items: center; }
body.sc-nav-collapsed .sidebar .brand { padding: 4px 0 22px; justify-content: center; }
body.sc-nav-collapsed .sidebar .brand .name { display: none; }
body.sc-nav-collapsed .sidebar a { justify-content: center; padding: 11px; font-size: 0; gap: 0; }
body.sc-nav-collapsed .sidebar a svg { width: 19px; height: 19px; }
body.sc-nav-collapsed .sidebar .sec-label { display: none; height: 14px; }
.sc-nav-toggle { margin: 0 0 10px; display: flex; align-items: center; gap: 8px; border: none; background: transparent; color: var(--sidebar-text); font: inherit; font-size: 12.5px; padding: 9px 12px; border-radius: 10px; cursor: pointer; }
.sc-nav-toggle:hover { color: var(--sidebar-text-active); background: rgba(127,127,127,.12); }
body.sc-nav-collapsed .sc-nav-toggle { justify-content: center; font-size: 0; padding: 11px; }
body.sc-nav-collapsed .sc-nav-toggle svg { transform: rotate(180deg); }

/* Left navigation: gradient rail + larger, brighter, easier-to-read items (both themes; lenders'
   own nav color gets the same treatment via --sidebar-grad from __applyBrandTheme). */
html[data-theme="navy"] {
  --sidebar-grad: linear-gradient(180deg, #0b1630 0%, #122a58 50%, #1d4590 100%);
  --sidebar-text: rgba(255,255,255,0.90);
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active-bg: rgba(255,255,255,0.14);
}
html[data-theme="airy"] {
  --sidebar-grad: linear-gradient(180deg, #ffffff 0%, #f4f8f6 55%, #e6f1ec 100%);
  --sidebar-text: #2f3833;
  --sidebar-hover: rgba(15,157,118,0.07);
}
.sidebar { background: var(--sidebar-grad, var(--sidebar-bg)); background-attachment: fixed; }
.sidebar a { font-size: 15px; font-weight: 600; padding: 11px 12px; gap: 12px; letter-spacing: .005em; transition: background .15s, color .15s; }
.sidebar a svg { width: 18px; height: 18px; opacity: 1; }
.sidebar a:hover:not(.active) { background: var(--sidebar-hover, rgba(127,127,127,.1)); color: var(--sidebar-text-active); }
html[data-theme="navy"] .sidebar a.active { background: var(--sidebar-active-bg); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06); }
.sidebar .brand .name { font-size: 16px; }
html[data-theme="navy"] .sidebar .sec-label { color: rgba(255,255,255,0.55); }
.sc-nav-toggle { color: var(--sidebar-text); font-size: 13px; }
body.sc-nav-collapsed .sidebar a { font-size: 0; }

/* Wizard fields filled from an uploaded application */
.wz-autofilled input, .wz-autofilled select, .wz-autofilled textarea { background: color-mix(in srgb, var(--accent-solid, #2e5395) 7%, var(--bg-card)) !important; box-shadow: inset 3px 0 0 var(--accent-solid, #2e5395); }
.wz-autofilled .toggle-pill.selected { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-solid, #2e5395) 35%, transparent); }
