:root {
    color-scheme: light;
    --theme-bg-page: #f0f4f8;
    --theme-bg-panel: #ffffff;
    --theme-bg-elevated: #ffffff;
    --theme-bg-inset: #f7f9fc;
    --theme-bg-interactive: #eef3f8;
    --theme-bg-selected: #e6f3f1;
    --theme-bg-hover: #edf5f7;
    --theme-bg-pressed: #dceae9;
    --theme-text-primary: #172033;
    --theme-text-secondary: #334155;
    --theme-text-muted: #5b6b7f;
    --theme-text-inverse: #ffffff;
    --theme-border: #d9e2ec;
    --theme-border-strong: #aebed0;
    --theme-divider: #e7edf3;
    --theme-brand: #0f766e;
    --theme-brand-strong: #115e59;
    --theme-brand-soft: #e6f3f1;
    --theme-accent: #0f766e;
    --theme-accent-hover: #115e59;
    --theme-link: #0759a6;
    --theme-link-hover: #064581;
    --theme-control-primary-bg: #0f766e;
    --theme-control-primary-hover: #115e59;
    --theme-control-primary-pressed: #0b4f4a;
    --theme-control-primary-text: #ffffff;
    --theme-control-secondary-bg: #ffffff;
    --theme-control-secondary-hover: #edf5f7;
    --theme-control-secondary-text: #172033;
    --theme-control-quiet-bg: transparent;
    --theme-control-quiet-hover: #eef3f8;
    --theme-control-destructive-bg: #b4232b;
    --theme-control-destructive-hover: #8e1921;
    --theme-control-destructive-text: #ffffff;
    --theme-focus: #155eef;
    --theme-focus-ring: rgba(21, 94, 239, 0.28);
    --theme-shadow-sm: 0 1px 3px rgba(15, 39, 71, 0.08);
    --theme-shadow: 0 16px 38px rgba(15, 39, 71, 0.14);
    --theme-shadow-lg: 0 22px 54px rgba(15, 39, 71, 0.18);
    --theme-overlay: rgba(15, 23, 42, 0.56);
    --theme-success: #166534;
    --theme-success-bg: #ecfdf3;
    --theme-success-border: #9adbb9;
    --theme-warning: #8a3d0a;
    --theme-warning-bg: #fff8e8;
    --theme-warning-border: #e6c66f;
    --theme-danger: #a71923;
    --theme-danger-bg: #fff1f2;
    --theme-danger-border: #f0a8ae;
    --theme-info: #075985;
    --theme-info-bg: #eaf6ff;
    --theme-info-border: #9bc9e8;
    --theme-sla: #8a3d0a;
    --theme-sla-bg: #fff8e8;
    --theme-sla-border: #e6c66f;
    --theme-risk: #a71923;
    --theme-risk-bg: #fff1f2;
    --theme-risk-border: #f0a8ae;
    --theme-unread: #075985;
    --theme-unread-bg: #edf7ff;
    --theme-unread-border: #8ec5eb;
    --theme-input-bg: #ffffff;
    --theme-input-border: #718399;
    --theme-input-hover-border: #52677e;
    --theme-input-placeholder: #68788c;
    --theme-disabled-bg: #e9eef4;
    --theme-disabled-text: #718096;
    --theme-row-bg: #ffffff;
    --theme-row-alt-bg: #f8fafc;
    --theme-row-hover-bg: #eef6f7;
    --theme-row-selected-bg: #e6f3f1;
    --theme-row-selected-border: #75aaa5;
    --theme-badge-bg: #eaf6ff;
    --theme-badge-border: #9bc9e8;
    --theme-badge-text: #075985;
    --theme-code-bg: #eef3f8;
    --theme-code-text: #243247;
    --theme-chart-1: #0f766e;
    --theme-chart-2: #2563eb;
    --theme-chart-3: #b45309;
    --theme-chart-4: #7c3aed;
    --theme-chart-grid: #cbd5e1;
    --theme-chrome-bg: rgba(255, 255, 255, 0.94);
    --theme-glass-bg: rgba(255, 255, 255, 0.82);
    --theme-page-gradient: linear-gradient(180deg, #fbfcfe 0%, var(--theme-bg-page) 46%, #f7f9fc 100%);
    --theme-panel-gradient: linear-gradient(180deg, var(--theme-bg-elevated) 0%, var(--theme-bg-inset) 100%);
    --theme-status-success-gradient: linear-gradient(135deg, var(--theme-bg-elevated), var(--theme-success-bg));
    --theme-status-warning-gradient: linear-gradient(135deg, var(--theme-bg-elevated), var(--theme-warning-bg));
    --theme-status-danger-gradient: linear-gradient(135deg, var(--theme-bg-elevated), var(--theme-danger-bg));

    /* Compatibility aliases keep existing portal components on the shared foundation. */
    --page: var(--theme-bg-page);
    --bg: var(--theme-bg-page);
    --panel: var(--theme-bg-panel);
    --surface-raised: var(--theme-bg-elevated);
    --soft: var(--theme-bg-inset);
    --soft-2: var(--theme-bg-inset);
    --soft-blue: var(--theme-info-bg);
    --line: var(--theme-border);
    --line-strong: var(--theme-border-strong);
    --text: var(--theme-text-primary);
    --heading: var(--theme-text-primary);
    --muted: var(--theme-text-muted);
    --primary: var(--theme-brand);
    --primary-dark: var(--theme-brand-strong);
    --primary-soft: var(--theme-link);
    --accent: var(--theme-accent);
    --accent-dark: var(--theme-accent-hover);
    --ok: var(--theme-success);
    --ok-bg: var(--theme-success-bg);
    --warn: var(--theme-warning);
    --warn-bg: var(--theme-warning-bg);
    --danger: var(--theme-danger);
    --danger-bg: var(--theme-danger-bg);
    --info: var(--theme-info);
    --focus: var(--theme-focus);
    --danger-soft: var(--theme-danger-bg);
    --danger-line: var(--theme-danger-border);
    --warning-soft: var(--theme-warning-bg);
    --warning-line: var(--theme-warning-border);
    --success-soft: var(--theme-success-bg);
    --success-line: var(--theme-success-border);
    --info-soft: var(--theme-info-bg);
    --selected-line: var(--theme-row-selected-border);
    --shadow-sm: var(--theme-shadow-sm);
    --shadow: var(--theme-shadow);
    --shadow-lg: var(--theme-shadow-lg);
    --shadow-soft: var(--theme-shadow-sm);
    --staff-chrome-bg: var(--theme-bg-elevated);
    --staff-chrome-line: var(--theme-border);
    --staff-chrome-text: var(--theme-text-primary);
    --staff-chrome-heading: var(--theme-text-primary);
    --staff-chrome-muted: var(--theme-text-muted);
    --staff-chrome-accent: var(--theme-brand);
    --staff-chrome-soft: var(--theme-brand-soft);
    --staff-chrome-focus: var(--theme-focus);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --theme-bg-page: #0f1724;
    --theme-bg-panel: #162131;
    --theme-bg-elevated: #1b293b;
    --theme-bg-inset: #111b29;
    --theme-bg-interactive: #223247;
    --theme-bg-selected: #153936;
    --theme-bg-hover: #203348;
    --theme-bg-pressed: #283d52;
    --theme-text-primary: #f1f5f9;
    --theme-text-secondary: #d4dde8;
    --theme-text-muted: #aab7c6;
    --theme-text-inverse: #07111f;
    --theme-border: #35465a;
    --theme-border-strong: #5a6f86;
    --theme-divider: #2a3a4d;
    --theme-brand: #65d5c9;
    --theme-brand-strong: #93e7de;
    --theme-brand-soft: #153936;
    --theme-accent: #59c9bd;
    --theme-accent-hover: #7cdacf;
    --theme-link: #8ec5ff;
    --theme-link-hover: #b7d9ff;
    --theme-control-primary-bg: #65d5c9;
    --theme-control-primary-hover: #8ae3d9;
    --theme-control-primary-pressed: #4bb9ae;
    --theme-control-primary-text: #071b1b;
    --theme-control-secondary-bg: #1b293b;
    --theme-control-secondary-hover: #263a50;
    --theme-control-secondary-text: #f1f5f9;
    --theme-control-quiet-hover: #223247;
    --theme-control-destructive-bg: #d95762;
    --theme-control-destructive-hover: #ef7881;
    --theme-control-destructive-text: #1f0709;
    --theme-focus: #86b2ff;
    --theme-focus-ring: rgba(134, 178, 255, 0.42);
    --theme-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --theme-shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
    --theme-shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.46);
    --theme-overlay: rgba(2, 6, 15, 0.78);
    --theme-success: #91e7ae;
    --theme-success-bg: #142d24;
    --theme-success-border: #397a58;
    --theme-warning: #f5cf83;
    --theme-warning-bg: #332819;
    --theme-warning-border: #8b672a;
    --theme-danger: #f8a3aa;
    --theme-danger-bg: #351d24;
    --theme-danger-border: #93404d;
    --theme-info: #9dcbff;
    --theme-info-bg: #172c43;
    --theme-info-border: #3f6f9e;
    --theme-sla: #f5cf83;
    --theme-sla-bg: #332819;
    --theme-sla-border: #8b672a;
    --theme-risk: #f8a3aa;
    --theme-risk-bg: #351d24;
    --theme-risk-border: #93404d;
    --theme-unread: #a8d2ff;
    --theme-unread-bg: #162b43;
    --theme-unread-border: #4f84b5;
    --theme-input-bg: #111c2b;
    --theme-input-border: #586c83;
    --theme-input-hover-border: #8094aa;
    --theme-input-placeholder: #95a3b3;
    --theme-disabled-bg: #202b39;
    --theme-disabled-text: #8995a4;
    --theme-row-bg: #162131;
    --theme-row-alt-bg: #111b29;
    --theme-row-hover-bg: #1e3343;
    --theme-row-selected-bg: #153936;
    --theme-row-selected-border: #4baea5;
    --theme-badge-bg: #172c43;
    --theme-badge-border: #3f6f9e;
    --theme-badge-text: #a8d2ff;
    --theme-code-bg: #111b29;
    --theme-code-text: #dce7f3;
    --theme-chart-1: #65d5c9;
    --theme-chart-2: #8ebcff;
    --theme-chart-3: #f5c76f;
    --theme-chart-4: #c5a4ff;
    --theme-chart-grid: #46596e;
    --theme-chrome-bg: rgba(22, 33, 49, 0.95);
    --theme-glass-bg: rgba(27, 41, 59, 0.86);
    --theme-page-gradient: linear-gradient(180deg, #111c2b 0%, var(--theme-bg-page) 52%, #0c1420 100%);
    --theme-panel-gradient: linear-gradient(180deg, var(--theme-bg-elevated) 0%, var(--theme-bg-panel) 100%);
}

:root[data-theme="light"] {
    color-scheme: light;
}

.portal-theme--borrower {
    --theme-brand: #0d47a1;
    --theme-brand-strong: #0b326f;
    --theme-brand-soft: #eaf4ff;
    --theme-accent: #c94f12;
    --theme-accent-hover: #a83f16;
    --theme-control-primary-bg: #c94f12;
    --theme-control-primary-hover: #a83f16;
    --theme-control-primary-pressed: #87300d;
    --theme-control-primary-text: #ffffff;
    --theme-row-selected-bg: #eaf4ff;
    --theme-row-selected-border: #75a8dc;
    --primary: var(--theme-brand);
    --primary-dark: var(--theme-brand-strong);
    --primary-soft: var(--theme-link);
    --accent: var(--theme-accent);
    --accent-dark: var(--theme-accent-hover);
}

:root[data-theme="dark"] .portal-theme--borrower {
    --theme-brand: #75baff;
    --theme-brand-strong: #a9d4ff;
    --theme-brand-soft: #172d49;
    --theme-accent: #ff9a65;
    --theme-accent-hover: #ffb18a;
    --theme-control-primary-bg: #ff9a65;
    --theme-control-primary-hover: #ffb18a;
    --theme-control-primary-pressed: #e77c45;
    --theme-control-primary-text: #281006;
    --theme-row-selected-bg: #172d49;
    --theme-row-selected-border: #4d82b5;
}

.portal-theme {
    background: var(--theme-page-gradient);
    color: var(--theme-text-primary);
}

.portal-theme :where(h1, h2, h3, h4, h5, h6) {
    color: var(--theme-text-primary);
}

.portal-theme :where(.stack) {
    align-content: start;
}

.portal-theme :where(.workspace) > .stack {
    align-self: start;
}

.portal-theme :where(input, select, textarea) {
    border-color: var(--theme-input-border);
    background: var(--theme-input-bg);
    color: var(--theme-text-primary);
}

.portal-theme :where(input, select, textarea):hover {
    border-color: var(--theme-input-hover-border);
}

/* Keep the existing native calendar controls within narrow form columns. */
.portal-theme input:is([type="date"], [type="datetime-local"], [type="time"]) {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    appearance: auto;
}

.portal-theme input:is([type="date"], [type="datetime-local"], [type="time"])::-webkit-calendar-picker-indicator {
    opacity: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.portal-theme :where(input, select, textarea)::placeholder {
    color: var(--theme-input-placeholder);
    opacity: 1;
}

.portal-theme :where(input, select, textarea):disabled,
.portal-theme :where(input, textarea)[readonly] {
    border-color: var(--theme-border);
    background: var(--theme-disabled-bg);
    color: var(--theme-disabled-text);
}

.portal-theme input::file-selector-button {
    min-height: 40px;
    border: 1px solid var(--theme-border-strong);
    border-radius: 6px;
    background: var(--theme-control-secondary-bg);
    color: var(--theme-control-secondary-text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.portal-theme input::file-selector-button:hover {
    background: var(--theme-control-secondary-hover);
}

.portal-theme :where(button, a, input, select, textarea, summary):focus-visible {
    outline: 3px solid var(--theme-focus);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px var(--theme-focus-ring);
}

.portal-theme :where(h1, h2, h3, h4, h5, h6)[tabindex="-1"]:focus {
    outline: none;
}

.portal-theme button {
    background-color: var(--theme-control-primary-bg);
    color: var(--theme-control-primary-text);
}

.portal-theme button.link-button {
    background: transparent;
    color: var(--theme-link);
    box-shadow: none;
}

.portal-theme button.link-button:hover {
    background: var(--theme-control-quiet-hover);
    color: var(--theme-link-hover);
    box-shadow: none;
}

.portal-theme--borrower .auth-alternate-action button.link-button:hover {
    background: transparent;
}

.portal-theme button.secondary {
    border-color: var(--theme-border);
    background: var(--theme-control-secondary-bg);
    color: var(--theme-control-secondary-text);
    box-shadow: var(--theme-shadow-sm);
}

.portal-theme button.secondary:hover {
    border-color: var(--theme-border-strong);
    background: var(--theme-control-secondary-hover);
    color: var(--theme-link);
}

.portal-theme button:disabled {
    border-color: var(--theme-border);
    background: var(--theme-disabled-bg);
    color: var(--theme-disabled-text);
    box-shadow: none;
    opacity: 1;
}

.portal-theme :where(code, pre, kbd, samp) {
    background: var(--theme-code-bg);
    color: var(--theme-code-text);
}

.portal-theme :where(dialog, [role="dialog"], [role="menu"]) {
    color: var(--theme-text-primary);
}

/* Shared staff dashboard surfaces and operational states. */
.portal-theme--staff .staff-portal-chrome {
    border-color: var(--theme-border);
    background: var(--theme-chrome-bg);
    box-shadow: var(--theme-shadow-sm);
}

.portal-theme--staff :is(.staff-account-menu__trigger, .staff-account-menu__popover, .staff-account-menu__signout) {
    border-color: var(--theme-border);
    background: var(--theme-bg-elevated);
    color: var(--theme-text-primary);
}

.portal-theme--staff .staff-account-menu__popover {
    box-shadow: var(--theme-shadow);
}

.portal-theme--staff :where(.staff-account-menu__trigger, .staff-account-menu__signout):hover {
    background: var(--theme-bg-hover);
}

.portal-theme--staff :where(.topbar, .sidebar, .panel, .card, .state, .advanced-config, .metric, .upload-slot, .tab, table, .document-check) {
    border-color: var(--theme-border);
    background: var(--theme-bg-panel);
    color: var(--theme-text-primary);
}

.portal-theme--staff :where(.queue-row, .item, .metric) {
    border-color: var(--theme-border);
    background: var(--theme-panel-gradient);
    box-shadow: var(--theme-shadow-sm);
}

.portal-theme--staff :where(.queue-overview, .application-context, .field-builder-row) {
    border-color: var(--theme-border);
    background: var(--theme-bg-inset);
}

.portal-theme--staff :is(.step, .queue-metric, button.filter-chip, .tab) {
    border-color: var(--theme-border);
    background: var(--theme-bg-elevated);
    color: var(--theme-text-primary);
}

.portal-theme--staff :is(.step.active, .queue-row.active, .tab.active, button.queue-metric.active, button.filter-chip.active) {
    border-color: var(--theme-row-selected-border);
    background: var(--theme-row-selected-bg);
    color: var(--theme-brand-strong);
}

.portal-theme--staff .queue-row:hover,
.portal-theme--staff :where(button.queue-metric, button.filter-chip):hover {
    border-color: var(--theme-border-strong);
    background: var(--theme-row-hover-bg);
    color: var(--theme-text-primary);
}

.portal-theme--staff .queue-row:active {
    background: var(--theme-bg-pressed);
}

.portal-theme--staff button.banking-result:not(:disabled) {
    border-color: var(--theme-border);
    background: var(--theme-bg-panel);
    color: var(--theme-text-secondary);
}

.portal-theme--staff button.banking-result:not(:disabled):hover {
    border-color: var(--theme-border-strong);
    background: var(--theme-control-quiet-hover);
    color: var(--theme-text-secondary);
}

.portal-theme--staff button.banking-result:disabled {
    cursor: not-allowed;
}

.portal-theme--staff :where(.panel-header, th, td) {
    border-color: var(--theme-divider);
}

.portal-theme--staff .app-shell .tab,
.portal-theme--staff .app-shell .tab:hover,
.portal-theme--staff .app-shell .tab.active {
    background: transparent;
}

.portal-theme--staff th {
    background: var(--theme-bg-inset);
    color: var(--theme-text-muted);
}

.portal-theme--staff :is(.state.error, .badge.danger) {
    border-color: var(--theme-danger-border);
    background: var(--theme-danger-bg);
    color: var(--theme-danger);
}

.portal-theme--staff :is(.state.ok, .badge.ok, .upload-slot.complete) {
    border-color: var(--theme-success-border);
    background: var(--theme-success-bg);
    color: var(--theme-success);
}

.portal-theme--staff :is(.state.warn, .badge.warn, .upload-slot.needed) {
    border-color: var(--theme-warning-border);
    background: var(--theme-warning-bg);
    color: var(--theme-warning);
}

.portal-theme--staff .badge:not(.ok, .warn, .danger) {
    border-color: var(--theme-badge-border);
    background: var(--theme-badge-bg);
    color: var(--theme-badge-text);
}

.portal-theme--staff .queue-row--overdue {
    border-left-color: var(--theme-danger);
    background: linear-gradient(90deg, var(--theme-danger-bg), var(--theme-row-bg) 22%);
}

.portal-theme--staff :where(.queue-row--due-today, .queue-row--exception, .queue-row--needs-documents) {
    border-left-color: var(--theme-warning);
    background: linear-gradient(90deg, var(--theme-warning-bg), var(--theme-row-bg) 22%);
}

.portal-theme--staff .queue-row--ready {
    border-left-color: var(--theme-success);
    background: linear-gradient(90deg, var(--theme-success-bg), var(--theme-row-bg) 22%);
}

.portal-theme--staff :is(dialog.field-help-dialog .field-help-dialog-panel, button.field-help-dialog-close) {
    border-color: var(--theme-border);
    background: var(--theme-bg-elevated);
    color: var(--theme-text-primary);
}

.portal-theme--staff dialog.field-help-dialog::backdrop {
    background: var(--theme-overlay);
}

.portal-theme--staff button.field-help-button {
    border-color: var(--theme-info-border);
    background: var(--theme-info-bg);
    color: var(--theme-info);
}

.portal-theme--staff :is(button.field-help-button, button.field-help-dialog-close):hover {
    border-color: var(--theme-info-border);
    background: var(--theme-bg-hover);
    color: var(--theme-info);
}

.portal-theme--staff button.danger-button {
    border-color: var(--theme-control-destructive-bg);
    background: var(--theme-control-destructive-bg);
    color: var(--theme-control-destructive-text);
}

.portal-theme--staff button.danger-button:hover {
    border-color: var(--theme-control-destructive-hover);
    background: var(--theme-control-destructive-hover);
}

.portal-theme--staff .logo-preview-well:not(.logo-preview-well--dark) {
    border-color: var(--theme-border-strong);
    background: var(--theme-bg-inset);
}

.portal-theme--staff pre {
    border: 1px solid var(--theme-border);
    background: var(--theme-code-bg);
    color: var(--theme-code-text);
}

.portal-theme--staff a:not(.staff-portal-chrome__brand, .staff-portal-chrome__link) {
    color: var(--theme-link);
}

.portal-theme--staff .login-page a.item {
    color: inherit;
    text-decoration: none;
}

.portal-theme--staff .login-page a.item:hover {
    border-color: var(--theme-border-strong);
    background: var(--theme-row-hover-bg);
    color: var(--theme-text-primary);
}

/* Borrower dashboard, guided-flow, document, and message surfaces. */
.portal-theme--borrower .app-header,
.portal-theme--borrower .app-header.is-compact {
    border-color: var(--theme-border);
    background: var(--theme-chrome-bg);
    box-shadow: var(--theme-shadow-sm);
}

.portal-theme--borrower :is(.brand-copy strong, .account-copy span, .account-popover-copy strong) {
    color: var(--theme-text-primary);
}

.portal-theme--borrower :where(.account-menu, .account-popover, .account-staff-verification) {
    border-color: var(--theme-border);
    background: var(--theme-bg-elevated);
    color: var(--theme-text-primary);
}

.portal-theme--borrower .account-popover {
    box-shadow: var(--theme-shadow);
}

.portal-theme--borrower :where(
    .loan-type-tile,
    .step-tile,
    .apply-entry-shell,
    .choice-btn,
    .step,
    .auth-panel,
    .auth-card-shell,
    .field-help-dialog-panel,
    .identity-document-panel,
    .document-camera-panel,
    .page-action-bar,
    .terms-box,
    .final-identity-panel,
    .dashboard-empty-state,
    .dashboard-submission-confirmation,
    .dashboard-message-expanded,
    .dev-tools,
    .item,
    .metric-card,
    .data-card,
    .application-card,
    .product-card,
    .choice-card,
    .document-card,
    .attachment-review-panel,
    .attachment-card,
    .review-card,
    .offer-summary,
    .dashboard-action-card,
    .dashboard-message-card,
    .dashboard-applications,
    .dashboard-messages,
    .borrower-application-card,
    .application-facts div,
    .upload-slot,
    .identity-capture-card,
    .condition-item
) {
    border-color: var(--theme-border);
    background: var(--theme-panel-gradient);
    color: var(--theme-text-primary);
}

.portal-theme--borrower :is(.featured-offer-band, .auth-panel .panel-header, .application-facts div, .offer-summary .offer-facts, .metric-card.primary) {
    border-color: var(--theme-border);
    background: var(--theme-bg-elevated);
    color: var(--theme-text-primary);
}

.portal-theme--borrower :is(.auth-card input, .auth-card select, .verification-card input, .verification-card select) {
    border-color: var(--theme-input-border);
    background: var(--theme-input-bg);
    color: var(--theme-text-primary);
}

.portal-theme--borrower .verification-card .verification-actions button.secondary {
    border-color: var(--theme-border);
    background: var(--theme-control-secondary-bg);
    color: var(--theme-control-secondary-text);
}

.portal-theme--borrower :where(.auth-layout, .identity-frame, .attachment-review-panel, #signature-form) {
    border-color: var(--theme-border);
    background: var(--theme-bg-inset);
}

.portal-theme--borrower :is(.auth-mode-option.active, .choice-btn.recommended, .dashboard-metric[aria-pressed="true"], .product-card.selected, .choice-card.selected, .document-card.selected, #branch-form, #preferred-loan-officer-form, .inline-loan-selection) {
    border-color: var(--theme-row-selected-border);
    background: var(--theme-row-selected-bg);
    color: var(--theme-text-primary);
}

.portal-theme--borrower button.auth-mode-option {
    border-color: transparent;
    background: transparent;
    color: var(--theme-text-secondary);
    box-shadow: none;
    transform: none;
}

.portal-theme--borrower button.auth-mode-option:hover {
    background: var(--theme-bg-hover);
    color: var(--theme-text-primary);
    box-shadow: none;
    transform: none;
}

.portal-theme--borrower button.auth-mode-option.active,
.portal-theme--borrower button.auth-mode-option.active:hover {
    border-color: var(--theme-row-selected-border);
    background: var(--theme-row-selected-bg);
    color: var(--theme-text-primary);
    box-shadow: var(--theme-shadow-sm);
    transform: none;
}

.portal-theme--borrower :where(.loan-type-tile, .step-tile, .choice-btn, .product-card, .borrower-application-card, .dashboard-message-card):hover {
    border-color: var(--theme-border-strong);
    background: var(--theme-bg-hover);
}

.portal-theme--borrower :is(.choice-btn, .step) {
    border-color: var(--theme-border);
    background: var(--theme-bg-elevated);
    color: var(--theme-text-primary);
}

.portal-theme--borrower :is(.dashboard-filter-button, .application-card-primary, .dashboard-message-toggle, .account-trigger) {
    background: var(--theme-control-quiet-bg);
    color: var(--theme-text-primary);
}

.portal-theme--borrower .dashboard-metric:not(:disabled) {
    border-color: var(--theme-border);
    background: var(--theme-bg-panel);
    color: var(--theme-text-primary);
}

.portal-theme--borrower .dashboard-metric:not(:disabled):hover {
    border-color: var(--theme-border-strong);
    background: var(--theme-control-quiet-hover);
    color: var(--theme-text-primary);
}

.portal-theme--borrower :where(.dashboard-filter-button, .application-card-primary, .dashboard-message-toggle):hover {
    border-color: var(--theme-border-strong);
    background: var(--theme-control-quiet-hover);
}

.portal-theme--borrower :is(.dashboard-filter-button[aria-pressed="true"], .application-card-primary:active, .dashboard-message-toggle:active) {
    border-color: var(--theme-row-selected-border);
    background: var(--theme-bg-pressed);
}

.portal-theme--borrower .application-facts {
    border-color: var(--theme-divider);
    background: var(--theme-divider);
}

.portal-theme--borrower :is(.product-card p, .choice-card p, .review-head p, .offer-summary p, .product-facts span, .offer-facts span, .slot-meta span) {
    color: var(--theme-text-secondary);
}

.portal-theme--borrower :is(.state.error, .badge.error, .dashboard-live.error) {
    border-color: var(--theme-danger-border);
    background: var(--theme-danger-bg);
    color: var(--theme-danger);
}

.portal-theme--borrower :is(.state.ok, .badge.ok, .dashboard-live) {
    border-color: var(--theme-success-border);
    background: var(--theme-success-bg);
    color: var(--theme-success);
}

.portal-theme--borrower :is(.state.warn, .badge.warn) {
    border-color: var(--theme-warning-border);
    background: var(--theme-warning-bg);
    color: var(--theme-warning);
}

.portal-theme--borrower .badge:not(.info, .ok, .warn, .error),
.portal-theme--borrower .badge.info {
    border-color: var(--theme-badge-border);
    background: var(--theme-badge-bg);
    color: var(--theme-badge-text);
}

.portal-theme--borrower .dashboard-attention-banner {
    border-color: var(--theme-warning-border);
    border-left-color: var(--theme-warning);
    background: var(--theme-status-warning-gradient);
}

.portal-theme--borrower .dashboard-attention-banner.urgency-overdue {
    border-color: var(--theme-danger-border);
    border-left-color: var(--theme-danger);
    background: var(--theme-status-danger-gradient);
}

.portal-theme--borrower .dashboard-attention-icon {
    background: var(--theme-warning);
    color: var(--theme-text-inverse);
}

.portal-theme--borrower .urgency-overdue .dashboard-attention-icon {
    background: var(--theme-danger);
}

.portal-theme--borrower .dashboard-message-card.unread {
    border-color: var(--theme-unread-border);
    background: linear-gradient(90deg, var(--theme-unread-bg), var(--theme-row-bg) 42%);
}

.portal-theme--borrower .dashboard-message-card.urgency-overdue {
    border-left-color: var(--theme-danger);
}

.portal-theme--borrower :where(.dashboard-message-card.urgency-due_soon, .dashboard-message-card.urgency-action_required) {
    border-left-color: var(--theme-warning);
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-section-heading h3 {
    font-weight: 600;
}

.portal-theme--borrower .dashboard-messages--customer :is(.dashboard-filter-button, .dashboard-sort-control, .dashboard-sort-control select) {
    font-weight: 500;
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-filter-button[aria-pressed="true"] {
    font-weight: 600;
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-message-card {
    border-left-width: 1px;
    background: var(--theme-bg-panel);
    box-shadow: none;
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-message-card.unread {
    border-color: var(--theme-border);
    border-left: 2px solid var(--theme-unread-border);
    background: var(--theme-bg-elevated);
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-message-card:is(.urgency-overdue, .urgency-due_soon, .urgency-action_required) {
    border-left-width: 2px;
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-message-card.urgency-overdue {
    border-left-color: var(--theme-danger);
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-message-card:is(.urgency-due_soon, .urgency-action_required) {
    border-left-color: var(--theme-warning);
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-message-toggle {
    gap: 6px;
    font-weight: 400;
}

.portal-theme--borrower .dashboard-messages--customer .message-badges {
    gap: 12px;
}

.portal-theme--borrower .dashboard-messages--customer .message-badges .badge {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--theme-text-muted);
    font-weight: 500;
}

.portal-theme--borrower .dashboard-messages--customer .message-badges .badge.warn {
    color: var(--theme-warning);
}

.portal-theme--borrower .dashboard-messages--customer .message-badges .badge.error {
    color: var(--theme-danger);
}

.portal-theme--borrower .dashboard-messages--customer .message-badges .badge.info {
    color: var(--theme-unread);
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-message-heading time {
    color: var(--theme-text-muted);
    font-weight: 400;
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-message-subject {
    font-size: 15px;
    font-weight: 600;
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-message-preview {
    font-weight: 400;
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-message-meta {
    font-weight: 400;
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-message-meta strong {
    font-weight: 500;
}

.portal-theme--borrower .dashboard-messages--customer .dashboard-message-toggle-label {
    font-weight: 500;
}

.portal-theme--borrower :is(.identity-frame.done, .offer-summary.signed) {
    border-color: var(--theme-success-border);
    background: var(--theme-status-success-gradient);
}

.portal-theme--borrower .review-card.error {
    border-color: var(--theme-danger-border);
    background: var(--theme-status-danger-gradient);
}

.portal-theme--borrower :is(
    .document-overview,
    .document-overview.complete,
    .identity-capture-card,
    .identity-capture-card.needed,
    .identity-capture-card.complete,
    .review-card.warn,
    .review-card.ok,
    .upload-slot.needed,
    .upload-slot.complete,
    .attachment-card.needed,
    .attachment-card.complete
) {
    border-color: var(--theme-border);
    background: var(--theme-panel-gradient);
}

.portal-theme--borrower :is(.field-help-dialog, .identity-document-dialog, .document-camera-dialog)::backdrop {
    background: var(--theme-overlay);
}

.portal-theme--borrower :is(.field-help-dialog-close, .document-camera-close, .account-verify-link, .button-link) {
    border-color: var(--theme-border);
    background: var(--theme-control-secondary-bg);
    color: var(--theme-control-secondary-text);
}

.portal-theme--borrower .public-apply-action {
    border-color: var(--theme-control-primary-bg);
    background: var(--theme-control-primary-bg);
    color: var(--theme-control-primary-text);
}

.portal-theme--borrower .public-apply-action:hover {
    border-color: var(--theme-control-primary-hover);
    background: var(--theme-control-primary-hover);
    color: var(--theme-control-primary-text);
}

.portal-theme--borrower .public-apply-action:active,
.portal-theme--borrower :is(.landing-hero, .featured-offer, .landing-cta-band) button:not(.secondary):active {
    border-color: var(--theme-control-primary-pressed);
    background: var(--theme-control-primary-pressed);
    color: var(--theme-control-primary-text);
    box-shadow: var(--theme-shadow-sm);
    transform: translateY(0);
}

.portal-theme--borrower .loan-type-tile:active {
    border-color: var(--theme-border-strong);
    background: var(--theme-bg-pressed);
    color: var(--theme-text-primary);
    box-shadow: var(--theme-shadow-sm);
    transform: translateY(-1px);
}

.portal-theme--borrower .product-icon--auto {
    background: var(--theme-info-bg);
    color: var(--theme-info);
}

.portal-theme--borrower .product-icon--personal {
    background: var(--theme-warning-bg);
    color: var(--theme-warning);
}

.portal-theme--borrower .product-icon--loan {
    background: var(--theme-bg-interactive);
    color: var(--theme-text-secondary);
}

.theme-control {
    display: grid;
    grid-template-columns: auto minmax(96px, 1fr);
    gap: 8px;
    align-items: center;
    min-width: 0;
    color: var(--theme-text-muted);
    font-family: "Inter", "IBM Plex Sans", "Source Sans Pro", "Segoe UI", sans-serif;
}

.theme-control label {
    color: var(--theme-text-muted);
    font-size: 12px;
    line-height: 16px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: none;
    white-space: nowrap;
}

.theme-control select {
    width: auto;
    min-width: 104px;
    min-height: 44px;
    border: 1px solid var(--theme-input-border);
    border-radius: 8px;
    padding: 9px 30px 9px 10px;
    background-color: var(--theme-input-bg);
    color: var(--theme-text-primary);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    box-shadow: var(--theme-shadow-sm);
    cursor: pointer;
}

.theme-control select:hover {
    border-color: var(--theme-input-hover-border);
    background-color: var(--theme-bg-hover);
}

.appearance-menu {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
}

.appearance-menu__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 999px;
    white-space: nowrap;
}

.appearance-menu__icon {
    position: relative;
    width: 18px;
    height: 18px;
    overflow: hidden;
    flex: 0 0 auto;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.appearance-menu__icon::before {
    content: "";
    position: absolute;
    inset: 0 50% 0 0;
    background: currentColor;
}

.appearance-menu__chevron {
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.16s ease;
}

.appearance-menu.is-open .appearance-menu__chevron {
    transform: rotate(225deg) translate(-1px, -1px);
}

.appearance-menu__popover {
    box-sizing: border-box;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 60;
    display: grid;
    gap: 8px;
    width: min(300px, calc(100vw - 24px));
    padding: 12px;
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    background: var(--theme-bg-elevated);
    color: var(--theme-text-primary);
    box-shadow: var(--theme-shadow);
}

.appearance-menu__popover[hidden] {
    display: none;
}

.appearance-menu__popover .theme-control {
    width: 100%;
    grid-template-columns: 1fr;
    gap: 4px;
}

.appearance-menu__popover .theme-control select {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
}

.appearance-menu__popover p {
    margin: 0;
    color: var(--theme-text-muted);
    font-size: 12px;
    line-height: 17px;
}

.appearance-page-toolbar {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 60;
}

.staff-account-menu__appearance .theme-control {
    width: 100%;
    grid-template-columns: 1fr;
    gap: 4px;
}

.staff-account-menu__appearance .theme-control select {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
}

.portal-notification-center {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    z-index: 100;
    display: grid;
    gap: 10px;
    width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}

.portal-theme--staff .portal-notification-center {
    top: calc(var(--staff-portal-chrome-sticky-offset, 0px) + 12px);
}

.portal-theme--borrower .portal-notification-center {
    top: 92px;
}

.portal-notification {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px 12px;
    padding: 14px;
    border: 1px solid var(--theme-warning-border);
    border-left-width: 4px;
    border-radius: 12px;
    background: var(--theme-bg-elevated);
    color: var(--theme-text-primary);
    box-shadow: var(--theme-shadow-lg);
    pointer-events: auto;
    overflow-wrap: anywhere;
    animation: portal-notification-enter 160ms ease-out;
}

.portal-notification--error {
    border-color: var(--theme-danger-border);
}

.portal-notification--success {
    border-color: var(--theme-success-border);
}

.portal-notification__icon {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--theme-warning-bg);
    color: var(--theme-warning);
    font-size: 15px;
    line-height: 1;
    font-weight: 700;
}

.portal-notification--error .portal-notification__icon {
    background: var(--theme-danger-bg);
    color: var(--theme-danger);
}

.portal-notification--success .portal-notification__icon {
    background: var(--theme-success-bg);
    color: var(--theme-success);
}

.portal-notification__content {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.portal-notification__content strong {
    color: var(--theme-text-primary);
    font-size: 15px;
    line-height: 21px;
    font-weight: 600;
}

.portal-notification__content p {
    margin: 0;
    color: var(--theme-text-secondary);
    font-size: 14px;
    line-height: 20px;
}

.portal-notification__actions {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.portal-theme button.portal-notification__action {
    width: auto;
    min-height: 36px;
    border: 1px solid var(--theme-border-strong);
    border-radius: 8px;
    padding: 6px 10px;
    background: var(--theme-control-secondary-bg);
    color: var(--theme-control-secondary-text);
    box-shadow: none;
    font-size: 13px;
    line-height: 18px;
    font-weight: 600;
}

.portal-theme button.portal-notification__action:hover {
    background: var(--theme-control-secondary-hover);
    color: var(--theme-control-secondary-text);
    transform: none;
}

.portal-theme button.portal-notification__action--primary {
    border-color: var(--theme-link);
    color: var(--theme-link);
}

.upload-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    max-width: 100%;
    margin-top: 8px;
    padding: 7px 10px;
    border: 1px solid var(--theme-info-border);
    border-radius: 999px;
    background: var(--theme-info-bg);
    color: var(--theme-info);
    font-size: 13px;
    line-height: 18px;
    font-weight: 600;
}

.upload-progress[hidden] {
    display: none;
}

.upload-progress__spinner {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: upload-progress-spin 720ms linear infinite;
}

.upload-progress__text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.upload-slot.is-uploading,
.attachment-card.is-uploading {
    border-color: var(--theme-info-border);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-info) 14%, transparent);
}

@keyframes upload-progress-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes portal-notification-enter {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.portal-attention-refresh {
    --portal-attention-color: var(--theme-warning-border);
    animation: portal-attention-refresh 480ms ease-out;
}

.portal-notification--error.portal-attention-refresh,
.state.error.portal-attention-refresh,
.state.danger.portal-attention-refresh,
.is-error.portal-attention-refresh,
.is-danger.portal-attention-refresh {
    --portal-attention-color: var(--theme-danger-border);
}

.portal-notification--success.portal-attention-refresh,
.state.ok.portal-attention-refresh,
.state.success.portal-attention-refresh,
.is-ok.portal-attention-refresh,
.is-success.portal-attention-refresh {
    --portal-attention-color: var(--theme-success-border);
}

@keyframes portal-attention-refresh {
    0%, 100% {
        outline: 3px solid transparent;
        outline-offset: 0;
    }

    40% {
        outline-color: var(--portal-attention-color);
        outline-offset: 4px;
    }
}

@media (max-width: 680px) {
    .portal-theme--borrower .app-header {
        align-items: flex-start;
    }

    .portal-theme--borrower .header-actions {
        min-width: 136px;
    }

    .portal-theme--borrower .account-menu {
        order: 1;
    }

    .public-site .appearance-menu__label,
    .appearance-page-toolbar .appearance-menu__label {
        display: none;
    }

    .public-site .brand-copy,
    .public-site .header-link,
    .public-site .header-actions > [data-root-action="apply"] {
        display: none;
    }

    .appearance-page-toolbar {
        top: 10px;
        right: 10px;
    }

    .appearance-page-toolbar .appearance-menu__trigger {
        width: 52px;
        padding-right: 8px;
        padding-left: 8px;
    }

    .staff-portal-chrome .theme-control,
    .staff-portal-chrome .theme-control select {
        width: 100%;
    }

    .portal-notification-center {
        left: max(10px, env(safe-area-inset-left));
        right: max(10px, env(safe-area-inset-right));
        width: auto;
    }

    .portal-theme--borrower .portal-notification-center {
        top: 78px;
    }

    .portal-notification {
        padding: 12px;
    }
}

@media (prefers-contrast: more) {
    .portal-theme {
        --theme-border: var(--theme-border-strong);
        --theme-input-border: var(--theme-border-strong);
    }
}

@media (prefers-reduced-motion: reduce) {
    .portal-theme *,
    .portal-theme *::before,
    .portal-theme *::after {
        scroll-behavior: auto !important;
    }

    .portal-notification {
        animation: none;
    }

    .portal-attention-refresh {
        outline: 3px solid var(--portal-attention-color);
        outline-offset: 2px;
        animation: none;
    }

    .upload-progress__spinner {
        animation: none;
        border-right-color: currentColor;
    }
}
.technical-details {
    margin-top: 0.75rem;
    max-width: 100%;
}

.technical-details > summary {
    cursor: pointer;
    font-weight: 700;
    min-height: 2.75rem;
    padding-block: 0.7rem;
}

.technical-details__list {
    display: grid;
    gap: 0.5rem 1rem;
    grid-template-columns: minmax(8rem, auto) minmax(0, 1fr);
    margin: 0;
}

.technical-details__list dt,
.technical-details__list dd {
    margin: 0;
}

.technical-details code,
.product-technical-details code {
    display: inline-block;
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
    word-break: break-word;
}

@media (max-width: 32rem) {
    .technical-details__list {
        grid-template-columns: minmax(0, 1fr);
    }
}
