/* Appearance controls and shared screen palette. Print keeps the existing light design. */
:root{color-scheme:light;--theme-control:#fff;--theme-control-text:#344d68;--theme-control-border:#dfe6ef;--theme-control-hover:#edf3f7;--chart-grid:#e6edf4;--chart-grid-vertical:#edf1f6;--chart-income:#00998b;--chart-expense:#d64d42;--chart-net:#173653;--chart-point:#fff}
.theme-toggle{display:inline-flex;align-items:center;justify-content:center;flex:0 0 44px;width:44px;height:44px;padding:10px;border:1px solid var(--theme-control-border);border-radius:10px;background:var(--theme-control);color:var(--theme-control-text);cursor:pointer;touch-action:manipulation}
.theme-toggle[hidden]{display:none!important}.theme-toggle:hover{background:var(--theme-control-hover)}.theme-toggle:focus-visible{outline:3px solid #3e9dde;outline-offset:3px}.theme-toggle .icon{display:block;width:22px;height:22px}.theme-toggle span{display:inline-flex}.theme-toggle .theme-sun{display:none}html[data-theme=dark] .theme-toggle .theme-sun{display:inline-flex}html[data-theme=dark] .theme-toggle .theme-moon{display:none}
.auth-controls,.verification-controls{display:flex;align-items:center;gap:10px}.language-control .theme-toggle .icon{width:22px;height:22px}.verification-header{flex-wrap:wrap}.verification-controls{margin-left:auto}
.top-actions{flex-shrink:0}.breadcrumb{min-width:0;overflow:hidden;white-space:nowrap}.breadcrumb strong{overflow:hidden;text-overflow:ellipsis}.auth-top{flex-wrap:wrap}.auth-controls{margin-left:auto}
.dot.green{background:var(--chart-income)}.dot.red{background:var(--chart-expense)}.dot.navy{background:var(--chart-net)}
@media screen{
  html[data-theme=dark]{color-scheme:dark;--bg:#0b1322;--white:#142136;--surface:#142136;--text:#e5edf8;--ink:#e5edf8;--muted:#a9b9cf;--border:#33465f;--line:#33465f;--green:#68d4bc;--green-light:#123d35;--red:#ff9c94;--red-light:#482b32;--primary:#83b5ff;--soft:#1c2c43;--hover:#20334d;--link-hover:#a0ead9;--button-primary:#117765;--success-bg:#123d35;--success-text:#94e7c5;--warning-bg:#43361e;--warning-text:#f3d18c;--error-bg:#482b32;--error-text:#ffb1aa;--theme-control:#1c2c43;--theme-control-text:#e5edf8;--theme-control-border:#445a76;--theme-control-hover:#283e5a;--chart-grid:#34465f;--chart-grid-vertical:#293c54;--chart-income:#68d4bc;--chart-expense:#ff9c94;--chart-net:#9dbdff;--chart-point:#142136;background:var(--bg);color:var(--text)}
  html[data-theme=dark] body{background:var(--bg);color:var(--text)}
  html[data-theme=dark] :is(.panel,.summary-card,.branch-bar,.auth-top,.login-card,.workflow-stage){background:var(--white)}
  html[data-theme=dark] :is(input,select,textarea){background-color:var(--white);color:var(--text);border-color:var(--border)}
  html[data-theme=dark] :is(input,textarea)::placeholder{color:var(--muted);opacity:1}
  html[data-theme=dark] :is(input,select,textarea):disabled{opacity:.65}
  html[data-theme=dark] :is(input,select,textarea):focus{border-color:#68d4bc;box-shadow:0 0 0 3px #68d4bc25}
  html[data-theme=dark] :focus-visible{outline-color:#83b5ff}
  html[data-theme=dark] a:hover{color:var(--link-hover)}
  html[data-theme=dark] :is(.brand,.nav-item,.workflow-stage strong){color:var(--text)}
  html[data-theme=dark] :is(.brand .icon,.branch-card .eyebrow,.nav-group.current-group>summary,.nav-group.current-group>summary>.icon){color:var(--green)}
  html[data-theme=dark] :is(.nav-group summary,.nav-item .icon,.nav-group summary>.icon,.locale-form .icon,.branch-bar label,.branch-bar>span,.readiness-row p,.borrower-details dt,.borrower-balances dt,.borrower-details small,.borrower-balances .panel-heading span,.workflow-totals dt,.review-facts span,.review-list dt,.review-list small,.help-section p,#executive-table small,#backup-sets small){color:var(--muted)}
  html[data-theme=dark] :is(.button:hover,.icon-button:hover,.nav-item:hover,.nav-group summary:hover,.bank-row:hover,tbody tr:hover){background:var(--hover);color:var(--text);border-color:var(--border)}
  html[data-theme=dark] .button.primary{background:var(--button-primary);border-color:var(--button-primary);color:#fff}
  html[data-theme=dark] .button.primary:hover{background:#0c6657}
  html[data-theme=dark] .button.danger{background:var(--error-bg);border-color:#8d5a64;color:var(--error-text)}
  html[data-theme=dark] :is(.avatar,.metric-icon,.bank-icon,.nav-count,.sidebar-search input,.borrower-tabs span){background:var(--soft);color:var(--text)}
  html[data-theme=dark] :is(.sidebar .nav-item.active,.workflow-stage.selected,.help-step,.approval-vote){background:var(--green-light);color:var(--green);border-color:var(--green)}
  html[data-theme=dark] .nav-item.active .nav-dot{background:var(--green)}
  html[data-theme=dark] .metric-icon.green{background:var(--green-light);color:var(--green)}
  html[data-theme=dark] .metric-icon.red{background:var(--red-light);color:var(--red)}
  html[data-theme=dark] :is(th,tfoot th){background:var(--soft);color:var(--text)}
  html[data-theme=dark] :is(td,.readiness-row,.borrower-notes,.workflow-stage,.review-file-counts span){border-color:var(--border)}
  html[data-theme=dark] .status{background:var(--soft);color:var(--text)}
  html[data-theme=dark] :is(.status-posted,.status-paid,.alert.success){background:var(--success-bg);color:var(--success-text);border-color:var(--green)}
  html[data-theme=dark] .status-partial{background:var(--warning-bg);color:var(--warning-text)}
  html[data-theme=dark] :is(.status-reversed,.status-void,.status-cancelled,.alert.error){background:var(--error-bg);color:var(--error-text);border-color:#8d5a64}
  html[data-theme=dark] .notice{background:var(--soft);color:var(--text);border-color:var(--border)}
  html[data-theme=dark] .chart text{fill:var(--muted)}
  html[data-theme=dark] :is(#backup-sets summary,.security-logout button){color:#9dbdff}
  html[data-theme=dark] progress::-webkit-progress-bar{background:var(--soft)}
  html[data-theme=dark] .security-qr{background:#fff}
  /* Document controls follow the interface; sheets retain their own light palette. */
  html[data-theme=dark] .loan-documents{--ink:var(--text);--muted:#a9b9cf;--line:#33465f;--primary:#83b5ff;--primary-dark:#a4c8ff;--button-primary:#255faa}
  html[data-theme=dark] .loan-documents .document-tab.active{background:var(--soft);color:var(--primary-dark)}
  html[data-theme=dark] :is(.loan-documents .sheet,.invoice-paper){color-scheme:light;--white:#fff;--paper:#fff;--surface:#fff;--text:#14243b;--ink:#1d324c;--muted:#6c7e93;--border:#dfe6ef;--line:#dbe5ef;--soft:#f1f5f8;--hover:#fafcfd;--green:#098572;--green-light:#e4f4ef;--red:#c9453d;--red-light:#fde9e8;--primary:#1468c8;--primary-dark:#073b82;--navy:#102f55;--tint:#edf5fc;--link-hover:#075f52;--button-primary:#1468c8;--success-bg:#e4f5ed;--success-text:#08705c;--warning-bg:#fff1d5;--warning-text:#976a11;--error-bg:#faeae8;--error-text:#ad443d;background:#fff;color:var(--ink)}
  html[data-theme=dark] .loan-documents .sheet .contract-table tfoot td{background:#edf5fc;color:#073b82}
  html[data-theme=dark] .loan-documents .sheet .contract-table .contract-grand-total td{background:#073b82;color:#fff}
  html[data-theme=dark] .verification-result{background:var(--success-bg);color:var(--success-text);border-color:var(--green)}
  html[data-theme=dark] .verification-result:not(.state-valid){background:var(--warning-bg);color:var(--warning-text);border-color:#957a40}
  html[data-theme=dark] :is(.verification-result.state-invalid,.verification-result.state-revoked,.verification-result.state-reversed,.verification-result.state-cancelled){background:var(--error-bg);color:var(--error-text);border-color:#8d5a64}
  html[data-theme=dark] .verification-details .verification-total{color:#a4c8ff}
  /* Login and MFA share the owner's existing blue/purple artwork. */
  html[data-theme=dark] body.finance-login{--primary:#2463eb;--accent:#6545d4;background:radial-gradient(ellipse at 5% 80%,#16294a,transparent 55%),linear-gradient(125deg,#091221,#151a35)}
  html[data-theme=dark] .auth-shell{border-color:var(--border);box-shadow:0 26px 72px -25px #0009}
  html[data-theme=dark] .login-panel{background:linear-gradient(150deg,#142136,#172039)}
  html[data-theme=dark] :is(.language-control,.input-icon,.password-toggle,.account-support){color:var(--muted)}
  html[data-theme=dark] .login-brand .brand-logo{color:#83b5ff}
  html[data-theme=dark] .language-control select{background:transparent}
  html[data-theme=dark] .language-control option{background:var(--white);color:var(--text)}
  html[data-theme=dark] .input-wrap input{background:#101c30;color:var(--ink)}
  html[data-theme=dark] .input-wrap input:focus{background:#101c30;border-color:#83b5ff;box-shadow:0 0 0 4px #83b5ff20}
  html[data-theme=dark] :is(.password-toggle:hover,.help-content){background:var(--soft);color:var(--text)}
  html[data-theme=dark] .finance-login .notice[data-kind=error]{background:var(--error-bg);color:var(--error-text);border-color:#8d5a64}
  html[data-theme=dark] .finance-login .notice[data-kind=success]{background:var(--success-bg);color:var(--success-text);border-color:var(--green)}
  html[data-theme=dark] :is(.field-error,.caps-lock){color:var(--warning-text)}
}
@media(max-width:400px){.topbar{padding-left:10px;padding-right:10px;gap:4px}.top-actions{gap:4px}.top-actions .locale-form select{max-width:90px;padding-left:6px;padding-right:16px}.top-actions>form:not(.locale-form) select{max-width:60px;padding-left:4px;padding-right:14px}.top-actions .avatar{width:28px;height:28px}.top-actions .icon-button,.topbar>.mobile-menu{width:28px;padding:4px}.verification-header .brand{height:60px}.verification-controls{margin-bottom:12px}}
@media print{html[data-theme]{color-scheme:light}.theme-toggle{display:none!important}}
