/* Persistent app-wide theme tokens and the professionally tuned light palette. */
:root {
    color-scheme: dark;
    --theme-bg: #060e1e;
    --theme-sidebar: #07162c;
    --theme-topbar: rgba(7,22,44,.92);
    --theme-surface: #0b1a2f;
    --theme-surface-raised: #0f1f38;
    --theme-input: #071326;
    --theme-border: rgba(148,163,184,.17);
    --theme-text: #e2e8f0;
    --theme-muted: #94a3b8;
    --theme-subtle: #71839c;
    --theme-shadow: 0 12px 30px rgba(0,0,0,.18);
}

html[data-theme="light"] {
    color-scheme: light;
    --theme-bg: #f3f6fb;
    --theme-sidebar: #ffffff;
    --theme-topbar: rgba(255,255,255,.94);
    --theme-surface: #ffffff;
    --theme-surface-raised: #f8faff;
    --theme-input: #ffffff;
    --theme-border: #dce4ef;
    --theme-text: #17243a;
    --theme-muted: #52637a;
    --theme-subtle: #718198;
    --theme-shadow: 0 10px 28px rgba(29,48,79,.08);
}

html[data-theme="light"] body,
html[data-theme="light"] .app-layout,
html[data-theme="light"] .main-wrapper,
html[data-theme="light"] .page-body,
html[data-theme="light"] .admin-container {
    background-color: var(--theme-bg) !important;
    color: var(--theme-text) !important;
}
html[data-theme="light"] body { background: #f3f6fb !important; }
html[data-theme="light"] body.theme-light,
html[data-theme="light"] body.theme-light :is(.auth-card,.header-card,.info-card) { color: #26364c !important; }
html[data-theme="light"] body.theme-light :is(.header-subtitle,.form-label,.auth-card label,.auth-card h1,.auth-card h2,.auth-card h3,.auth-card p,.auth-card strong) { color: #34445a !important; }
html[data-theme="light"] body.theme-light :is(.form-label,.auth-card label,.auth-card h1,.auth-card h2,.auth-card h3,.auth-card p,.auth-card strong) { color: #34445a !important; }
html[data-theme="light"] body.theme-light .auth-card :is(input:not([type="checkbox"]),select,textarea) { background: #fff !important; border-color: #cbd6e4 !important; color: #17243a !important; }
html[data-theme="light"] body.theme-light .auth-card :is(input,textarea)::placeholder { color: #8795a8 !important; }
html[data-theme="light"] body.theme-light .auth-card .input-icon { color: #718198 !important; }
html[data-theme="light"] body.theme-light .auth-card .btn-primary { color: #03251f !important; }

html[data-theme="light"] .app-sidebar {
    background: linear-gradient(180deg,#fff 0%,#f8faff 100%) !important;
    border-right: 1px solid var(--theme-border) !important;
    box-shadow: 4px 0 22px rgba(29,48,79,.06) !important;
}
html[data-theme="light"] .sidebar-brand,
html[data-theme="light"] .sidebar-footer { border-color: var(--theme-border) !important; }
html[data-theme="light"] .sidebar-brand { border-bottom-color: var(--theme-border) !important; }
html[data-theme="light"] #sidebarBrandLogo { filter: none !important; }
html[data-theme="light"] .sidebar-footer { background: #f8faff !important; }
html[data-theme="light"] .sidebar-section-title { color: #718198 !important; }
html[data-theme="light"] .sidebar-link { color: #52637a !important; }
html[data-theme="light"] .sidebar-link i { color: #718198 !important; }
html[data-theme="light"] .sidebar-link:hover { background: #edf8f6 !important; color: #087f6b !important; }
html[data-theme="light"] .sidebar-link.active { background: #e5f7f3 !important; color: #087f6b !important; border-color: #b8e8dc !important; box-shadow: none !important; }
html[data-theme="light"] .sidebar-link.active i,
html[data-theme="light"] .sidebar-link:hover i { color: #087f6b !important; }
html[data-theme="light"] .sidebar-user-card:hover { background: #edf2f8 !important; }

html[data-theme="light"] .topbar {
    background: var(--theme-topbar) !important;
    border-bottom: 1px solid var(--theme-border) !important;
    box-shadow: 0 3px 14px rgba(29,48,79,.04);
}
html[data-theme="light"] .topbar-page-title,
html[data-theme="light"] .topbar .topbar-page-title,
html[data-theme="light"] .admin-title h1 { color: #17243a !important; }

html[data-theme="light"] :is(.card,.auth-card,.header-card,.info-card,.admin-header,.admin-card,.section-card,.compact-card,.rep-card,.chart-card,.kpi-card,.ag-card,.ag-header-card,.tl-hd-card,.tl-card,.policy-card,.role-panel,.user-modal-dialog,.profile-modal,.stamp-modal-box,.modal-content,.sc-modal-box,.document-card,.detail-card,.settings-card-body,.modal-v4-card,.kpi-mini-card) {
    background: var(--theme-surface) !important;
    border-color: var(--theme-border) !important;
    box-shadow: var(--theme-shadow) !important;
    color: var(--theme-text) !important;
}
html[data-theme="light"] :is(.card-header,.compact-header,.user-modal-header,.modal-header,.sc-modal-header,.stamp-modal-header,.card-footer,.profile-modal-header,.profile-modal-footer,.sc-modal-footer,.stamp-modal-footer,.admin-header) {
    background: #f7f9fd !important;
    border-color: var(--theme-border) !important;
}
html[data-theme="light"] .admin-container .stat-card {
    background: linear-gradient(145deg, #ffffff 0%, #f8faff 100%) !important;
    border-top-color: var(--theme-border) !important;
    border-right-color: var(--theme-border) !important;
    border-bottom-color: var(--theme-border) !important;
    box-shadow: 0 5px 16px rgba(29,48,79,.07) !important;
}
html[data-theme="light"] .admin-container .stat-card:hover {
    background: linear-gradient(145deg, #ffffff 0%, #f0faf7 100%) !important;
    box-shadow: 0 9px 22px rgba(29,48,79,.11) !important;
}
html[data-theme="light"] .admin-container .stat-card .stat-label { color: #718198 !important; }
html[data-theme="light"] .admin-container .stat-card .stat-value { color: #17243a !important; }
html[data-theme="light"] :is(.ag-layout,.tl-layout,.rep-container,.detail-container,.prepare-container,.dash-wrapper,.editor-main,.canvas-viewport,.viewer-container) { background-color: var(--theme-bg) !important; color: var(--theme-text) !important; }
html[data-theme="light"] :is(.editor-wrapper,.editor-toolbar,.tool-ribbon,.sidebar-left,.sidebar-right,.tabs-nav,.tab-panel,.canvas-toolbar,.editor-panel,.field-list-container) { background: #fff !important; border-color: var(--theme-border) !important; color: #26364c !important; }
html[data-theme="light"] :is(.editor-toolbar,.tool-ribbon,.sidebar-left,.sidebar-right,.tabs-nav,.tab-panel,.field-list-container) { box-shadow: 0 4px 15px rgba(29,48,79,.05) !important; }
html[data-theme="light"] :is(.ribbon-tool,.editor-action-btn,.tool-btn,.prop-section,.field-card) { color: #34445a !important; }
html[data-theme="light"] :is(.ribbon-tool:hover,.editor-action-btn:hover,.tool-btn:hover) { background: #edf8f5 !important; color: #087f6b !important; }
html[data-theme="light"] :is(.card-title,.section-title,.admin-title h1,.user-modal-heading h2,.stamp-modal-title,.modal-header h3,.sc-modal-title,.step-title,.chart-title,.kpi-value,.header-mini h1,.header-text h1) { color: #17243a !important; }
html[data-theme="light"] :is(.auth-card,.header-card,.info-card) :is(h1,h2,h3,h4,p,label,strong) { color: #34445a !important; }
html[data-theme="light"] :is(.page-header-card,.section-header-card,.admin-header,.ag-header-card,.tl-hd-card) :is(h1,h2,h3,h4,p,span,strong,label) { color: #34445a !important; }
html[data-theme="light"] :is(.page-header-card,.section-header-card,.admin-header,.ag-header-card,.tl-hd-card) :is(h1,h2,h3) { color: #17243a !important; }
html[data-theme="light"] .page-body { background: var(--theme-bg) !important; }
/* App editors use the current product theme; only actual uploaded-document
   pages below stay white for signing and preview. */
html[data-theme="dark"] :is(.editor-body,.editor-container) { background: var(--theme-bg) !important; color: var(--theme-text) !important; }
html[data-theme="dark"] :is(.editor-ribbon,.word-page,.toc-preview-mini,.floating-save) { background: var(--theme-surface) !important; border-color: var(--theme-border) !important; color: var(--theme-text) !important; }
html[data-theme="dark"] .policy-content-editor { background: #071326 !important; color: #e2e8f0 !important; border-color: var(--theme-border) !important; }
html[data-theme="light"] :is(.editor-body,.editor-container) { background: var(--theme-bg) !important; color: var(--theme-text) !important; }
html[data-theme="light"] .editor-ribbon,
html[data-theme="light"] .toc-preview-mini,
html[data-theme="light"] .floating-save { background: #fff !important; border-color: var(--theme-border) !important; box-shadow: var(--theme-shadow) !important; }
html[data-theme="light"] .word-page { background: #f8fafd !important; border-color: var(--theme-border) !important; box-shadow: var(--theme-shadow) !important; color: #243247 !important; }
html[data-theme="light"] .policy-content-editor { background: #fff !important; color: #243247 !important; border-color: #d8e1ec !important; }
html[data-theme="light"] .policy-content-editor :is(h1,h2,h3,h4) { color: #17243a !important; }
/* Policy create/edit rich text field is an app editor, not a PDF page. */
html[data-theme="dark"] .content-editor-shell { background: #071326 !important; border-color: var(--theme-border) !important; }
html[data-theme="dark"] .content-editor-toolbar { background: #0b1a2f !important; border-color: var(--theme-border) !important; }
html[data-theme="dark"] .policy-rich-editor { background: #071326 !important; color: #e2e8f0 !important; caret-color: #34e8c0; }
html[data-theme="dark"] .policy-rich-editor :is(h1,h2,h3,h4) { color: #f1f5f9 !important; }
html[data-theme="dark"] .policy-rich-editor:empty::before { color: #8795a8 !important; }
html[data-theme="dark"] .policy-rich-editor a { color: #67c8ff !important; }
html[data-theme="light"] .content-editor-shell { background: #fff !important; border-color: #d5deea !important; }
html[data-theme="light"] .content-editor-toolbar { background: #f4f7fb !important; border-color: #dce4ef !important; }
html[data-theme="light"] .content-editor-toolbar .tool-btn { background: #fff !important; border-color: #dce4ef !important; color: #46576e !important; }
html[data-theme="light"] .content-editor-toolbar .tool-btn:hover { background: #eaf7f3 !important; border-color: #b8e8dc !important; color: #087f6b !important; }
html[data-theme="light"] .policy-rich-editor { background: #fff !important; color: #243247 !important; caret-color: #087f6b; }
html[data-theme="light"] .policy-rich-editor :is(h1,h2,h3,h4) { color: #17243a !important; }
html[data-theme="light"] .policy-rich-editor:empty::before { color: #8795a8 !important; }
html[data-theme="light"] .policy-rich-editor a { color: #087fba !important; }
/* Dynamic approval rows contain inline dark colors, so the light theme needs
   stronger selectors for both the row surface and its generated inputs. */
html[data-theme="light"] #workflow-stages-container .workflow-stage-row { background: #f5f8fc !important; border-color: #d7e0eb !important; box-shadow: 0 2px 8px rgba(29,48,79,.04); }
html[data-theme="light"] #workflow-stages-container .workflow-stage-row:hover { border-color: #9ed9cb !important; }
html[data-theme="light"] #workflow-stages-container .workflow-stage-row .stage-name-input,
html[data-theme="light"] #workflow-stages-container .workflow-stage-row .stage-desc-input,
html[data-theme="light"] #workflow-stages-container .workflow-stage-row input[type="text"] { background: #fff !important; border-color: #cbd6e4 !important; color: #243247 !important; }
html[data-theme="light"] #workflow-stages-container .workflow-stage-row input::placeholder { color: #8795a8 !important; }
html[data-theme="light"] #workflow-stages-container .workflow-stage-row .stage-badge { color: #087f6b !important; background: #e5f7f3 !important; }
html[data-theme="light"] #policyForm div[style*="background: rgba(245,158,11"] { background: #fff8e8 !important; border-color: #f2d08a !important; }
html[data-theme="light"] #policyForm div[style*="background: rgba(245,158,11"] div:first-child { color: #9a5b00 !important; }
html[data-theme="light"] #policyForm div[style*="background: rgba(245,158,11"] div:last-child { color: #72521a !important; }
html[data-theme="light"] #policyForm p { color: #64748b !important; }
html[data-theme="light"] #policyForm .toc-preview { background: #f8fafd !important; border-color: #dce4ef !important; color: #52637a !important; box-shadow: inset 0 1px 2px rgba(29,48,79,.03) !important; }
html[data-theme="light"] #policyForm .toc-preview .toc-item { color: #34445a !important; border-color: #e4eaf1 !important; }
html[data-theme="light"] #policyForm .toc-preview .toc-item.indent { color: #64748b !important; }
html[data-theme="light"] #policyForm .toc-preview .dots { border-color: #aab7c7 !important; }
/* Bulk policy upload: replace translucent navy fills with clear light surfaces. */
html[data-theme="light"] .bulk-intro { background: #f0fbf8 !important; border-color: #c6ebe1 !important; color: #52637a !important; }
html[data-theme="light"] .bulk-intro strong { color: #087f6b !important; }
html[data-theme="light"] .bulk-drop { background: #f8fbff !important; border-color: #9ccfc4 !important; }
html[data-theme="light"] .bulk-drop:hover,
html[data-theme="light"] .bulk-drop.is-dragover { background: #effaf7 !important; border-color: #0b9a7f !important; }
html[data-theme="light"] .bulk-drop-title { color: #17243a !important; }
html[data-theme="light"] .bulk-drop-hint { color: #64748b !important; }
html[data-theme="light"] .bulk-drop-cta { background: #e7f7f2 !important; color: #087f6b !important; border-color: #b8e8dc !important; }
html[data-theme="light"] .bulk-signer-card { background: #f8fafd !important; border-color: #dce4ef !important; box-shadow: 0 3px 12px rgba(29,48,79,.05); }
html[data-theme="light"] .bulk-signer-card h4 { color: #17243a !important; }
html[data-theme="light"] .bulk-order { background: #e5f7f3 !important; color: #087f6b !important; border-color: #b8e8dc !important; }
html[data-theme="light"] .bulk-file-chip { background: #fff !important; border-color: #dce4ef !important; color: #34445a !important; }
html[data-theme="light"] .bulk-actions { border-color: #e2e8f0 !important; }
/* Shared policy navigation header and segmented tabs. */
html[data-theme="light"] .policy-header { background: linear-gradient(135deg,#fff 0%,#f3f8fc 100%) !important; border-color: #dce4ef !important; box-shadow: var(--theme-shadow) !important; }
html[data-theme="light"] .policy-title h1 { color: #17243a !important; }
html[data-theme="light"] .policy-title p { color: #64748b !important; }
html[data-theme="light"] .policy-nav { background: #edf2f8 !important; border-color: #dce4ef !important; }
html[data-theme="light"] .policy-nav-item { color: #52637a !important; }
html[data-theme="light"] .policy-nav-item i { color: inherit !important; }
html[data-theme="light"] .policy-nav-item:hover { background: #e3eaf3 !important; color: #17243a !important; }
html[data-theme="light"] .policy-nav-item.active { background: #e1f5f0 !important; border-color: #bee8dd !important; color: #087f6b !important; box-shadow: none !important; }
html[data-theme="light"] .policy-header .card-toolbar .btn-tool { background: #fff !important; border-color: #d6dfeb !important; color: #52637a !important; }
html[data-theme="light"] .policy-header .card-toolbar .btn-tool:hover { background: #edf8f5 !important; border-color: #b8e8dc !important; color: #087f6b !important; }
/* Reports dashboard: override its page-local dark palette and improve chart contrast. */
html[data-theme="light"] .rep-container { --primary-navy: #17243a; --titan-green: #087f6b; --border-color: #dce4ef; --text-muted: #64748b; --bg-light: #f3f6fb; --accent-blue: #087fba; --accent-yellow: #a86600; }
html[data-theme="light"] .rep-dashboard-header { background: linear-gradient(135deg,#fff 0%,#f4f8fc 100%) !important; border-color: #dce4ef !important; box-shadow: var(--theme-shadow) !important; }
html[data-theme="light"] .rep-dashboard-header .header-left h1 { color: #17243a !important; }
html[data-theme="light"] .rep-dashboard-header .header-left p { color: #64748b !important; }
html[data-theme="light"] .view-switcher { background: #edf2f8 !important; border: 1px solid #dce4ef !important; }
html[data-theme="light"] .view-switcher .switch-btn { color: #52637a !important; }
html[data-theme="light"] .view-switcher .switch-btn:hover { background: #e4eaf2 !important; color: #17243a !important; }
html[data-theme="light"] .view-switcher .switch-btn.active { background: #e1f5f0 !important; color: #087f6b !important; box-shadow: inset 0 0 0 1px #bee8dd !important; }
html[data-theme="light"] .rep-container .kpi-card,
html[data-theme="light"] .rep-container .chart-card,
html[data-theme="light"] .rep-container .rep-card { background: #fff !important; border-color: #dce4ef !important; box-shadow: var(--theme-shadow) !important; }
html[data-theme="light"] .rep-container .chart-title,
html[data-theme="light"] .rep-container .kpi-value { color: #17243a !important; }
html[data-theme="light"] .rep-container .kpi-label { color: #64748b !important; }
html[data-theme="light"] .rep-container .rep-card .card-header { background: #f7f9fd !important; border-color: #dce4ef !important; }
html[data-theme="light"] .rep-container .rep-card .card-title { color: #17243a !important; }
html[data-theme="light"] .rep-container .rep-table td { color: #34445a !important; border-color: #e6ebf2 !important; }
html[data-theme="light"] .rep-container .rep-table td.col-doc-title { color: #17243a !important; }
html[data-theme="light"] .rep-container .rep-table tr:hover td { background: #f1faf8 !important; color: #17243a !important; }
html[data-theme="light"] .rep-container .rep-table .btn-tool { color: #34445a !important; }
html[data-theme="light"] :is(.admin-title p,.user-modal-heading p,.section-description,.header-text p,.header-mini .header-meta,.audit-sub,.doc-meta,.date-sub,.section-sub,.kpi-label,.form-hint,.sc-hint,.sc-modal-sub) { color: #64748b !important; }

html[data-theme="light"] .admin-nav { background: #edf2f8 !important; border-color: var(--theme-border) !important; }
html[data-theme="light"] .admin-nav-item { color: #52637a !important; }
html[data-theme="light"] .admin-nav-item:hover { background: #e3eaf3 !important; color: #17243a !important; }
html[data-theme="light"] .admin-nav-item.active { background: #e1f5f0 !important; color: #087f6b !important; border-color: #bee8dd !important; }
html[data-theme="light"] .admin-nav-item i { color: inherit !important; }

html[data-theme="light"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]),select,textarea,.form-control,.form-select) {
    background-color: var(--theme-input) !important;
    border-color: #cbd6e4 !important;
    color: #17243a !important;
    box-shadow: none;
}
html[data-theme="light"] :is(input,textarea,select)::placeholder { color: #8795a8 !important; }
html[data-theme="light"] :is(input,select,textarea):focus { border-color: #11a88a !important; box-shadow: 0 0 0 3px rgba(17,168,138,.13) !important; }
html[data-theme="light"] input[type="checkbox"],
html[data-theme="light"] input[type="radio"] { accent-color: #0b9a7f; }
html[data-theme="light"] input[type="file"]::file-selector-button { border: 0; border-radius: 6px; padding: 7px 10px; background: #e8f6f2; color: #087f6b; font-weight: 700; cursor: pointer; }

html[data-theme="light"] :is(table,.admin-table,.mini-table,.ag-table) { color: #26364c !important; }
html[data-theme="light"] :is(.admin-table th,.mini-table th,.ag-table th,table thead th) { background: #f1f5fa !important; color: #52637a !important; border-color: var(--theme-border) !important; }
html[data-theme="light"] :is(.admin-table td,.mini-table td,.ag-table td,table tbody td) { color: #34445a !important; border-color: #e6ebf2 !important; }
html[data-theme="light"] :is(.admin-table tr:hover td,.mini-table tr:hover td,.ag-table tr:hover td) { background: #f3f8fb !important; }
html[data-theme="light"] .rep-table-wrapper { border-color: var(--theme-border) !important; }

/* Consistent scroll regions keep long data tables usable while their headers stay visible. */
.global-table-scroll {
    width: 100%;
    max-height: min(68vh, 720px) !important;
    overflow: auto !important;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}
.global-table-scroll > table { width: 100%; }
.global-table-scroll table thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 20 !important;
}
.global-table-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.global-table-scroll::-webkit-scrollbar-track { background: var(--theme-bg); border-radius: 8px; }
.global-table-scroll::-webkit-scrollbar-thumb { background: #718198; border: 2px solid var(--theme-bg); border-radius: 8px; }
.global-table-scroll::-webkit-scrollbar-thumb:hover { background: #52637a; }
html[data-theme="light"] .global-table-scroll table thead th { background: #edf2f8 !important; color: #34445a !important; }
html[data-theme="dark"] .global-table-scroll table thead th { background: #0b1a2f !important; color: #c2cede !important; }

html[data-theme="light"] :is(.role-option,.two-factor-option,.file-preview-item,.recipient-card,.field-card,.prop-row,.prop-section,.stamp-list-item,.upload-zone,.adopt-drop-zone,.font-card,.template-card,.status-box,.rejection-quote,.audit-entry) {
    background-color: #f7f9fc !important;
    border-color: var(--theme-border) !important;
    color: #34445a !important;
}
html[data-theme="light"] :is(.role-option-copy strong,.role-option > div,.two-factor-option .role-option-copy strong,.file-name,.doc-title,.info-value,.audit-main,.rejection-title,.status-value) { color: #26364c !important; }
html[data-theme="light"] :is(.role-option-copy small,.two-factor-option .role-option-copy small,.file-size,.info-label,.audit-sub,.date-main) { color: #64748b !important; }
html[data-theme="light"] :is(.role-option:hover,.two-factor-option:hover,.stamp-list-item:hover,.stamp-list-item.selected,.upload-zone:hover,.adopt-drop-zone:hover,.font-card:hover,.font-card.active) { background: #edf8f5 !important; border-color: #a8ded2 !important; }

html[data-theme="light"] :is(.ag-table thead th,.admin-table thead th) { position: sticky; }
html[data-theme="light"] :is(.empty-state,.ag-empty) { color: #64748b !important; }
html[data-theme="light"] :is(.kpi-mini-card,.dash-card,.dash-panel,.dash-widget,.dashboard-card,.rep-dashboard-header) { background: #fff !important; border-color: var(--theme-border) !important; color: #26364c !important; box-shadow: var(--theme-shadow) !important; }
html[data-theme="light"] :is(.chart-box,.kpi-mini-card,.dash-card,.dash-panel,.dash-widget,.dashboard-card) { background: #fff !important; border-color: var(--theme-border) !important; color: #26364c !important; box-shadow: var(--theme-shadow) !important; }
html[data-theme="light"] .dash-hero-compact { background: linear-gradient(135deg,#fff 0%,#f1faf8 100%) !important; border-color: #cfe8e1 !important; box-shadow: var(--theme-shadow) !important; }
html[data-theme="light"] .dash-hero-compact h2,
html[data-theme="light"] .kpi-mini-val,
html[data-theme="light"] .chart-box-title { color: #17243a !important; }
html[data-theme="light"] .dash-hero-compact p,
html[data-theme="light"] .kpi-mini-lbl { color: #64748b !important; }
html[data-theme="light"] .chart-box-header { background: #f7f9fd !important; border-color: var(--theme-border) !important; }
html[data-theme="light"] .table-item-clean { border-color: #e8edf4 !important; color: #34445a !important; }
html[data-theme="light"] .table-item-clean:hover { background: #f1faf8 !important; }
html[data-theme="light"] .btn-action-secondary { background: #fff !important; border-color: #d6dfeb !important; color: #34445a !important; }
html[data-theme="light"] .btn-action-secondary:hover { background: #edf8f5 !important; color: #087f6b !important; }
html[data-theme="light"] .del-box { background: #fff !important; border-color: #cfdbe8 !important; box-shadow: 0 26px 70px rgba(22,39,63,.24) !important; }
html[data-theme="light"] .del-box .del-body { background: #fff !important; color: #34445a !important; }
html[data-theme="light"] .del-box .del-hd { background: #f7f9fd !important; border-color: #dce4ef !important; }
html[data-theme="light"] .del-box .del-footer { background: #f7f9fd !important; border-color: #dce4ef !important; }
html[data-theme="light"] .del-box .del-footer button[type="button"] { background: #eef2f7 !important; color: #52637a !important; border: 1px solid #dce4ef !important; }
html[data-theme="light"] .del-box .del-footer button[type="button"]:hover { background: #e5ebf3 !important; color: #17243a !important; }
html[data-theme="light"] #templateActionModal .ms-body button:not(.ms-btn-primary) { background: #eef2f7 !important; border: 1px solid #dce4ef !important; color: #52637a !important; }
html[data-theme="light"] #templateActionModal .ms-body button:not(.ms-btn-primary):hover { background: #e5ebf3 !important; color: #17243a !important; }
html[data-theme="light"] .ms-header,.theme-light .ms-header,
html[data-theme="light"] .del-hd { background: #f7f9fd !important; border-color: var(--theme-border) !important; }
html[data-theme="light"] .ms-title,.theme-light .ms-title { color: #17243a !important; }
html[data-theme="light"] .ms-option { background: #f7f9fc !important; border-color: var(--theme-border) !important; color: #34445a !important; }
html[data-theme="light"] .ms-select { background: #fff !important; border-color: #cbd6e4 !important; color: #17243a !important; }
html[data-theme="light"] .file-drop-area { background: #f6fbfa !important; border-color: #9ed9cb !important; color: #34445a !important; }
html[data-theme="light"] .upload-file-label { color: #64748b !important; }
html[data-theme="light"] .del-footer { background: #f7f9fd !important; border-color: var(--theme-border) !important; }
html[data-theme="light"] :is(.modal-v4-card,.modal-content,.stamp-modal-box,.sc-modal-box,#logModal > div) { background: #fff !important; border-color: var(--theme-border) !important; color: #26364c !important; }
html[data-theme="light"] :is(.modal-v4-card,.modal-content,.stamp-modal-box,.sc-modal-box,#logModal > div) :is(h1,h2,h3,h4,p,label,span,strong) { color: #34445a !important; }
html[data-theme="light"] #logModal > div > div:first-child,
html[data-theme="light"] #logModal > div > div:last-child { background: #f7f9fd !important; border-color: var(--theme-border) !important; }
html[data-theme="light"] #logModal > div > div:nth-child(2) { background: #f6f8fb !important; color: #34445a !important; }
html[data-theme="light"] .canvas-area { background: #e9eef5 !important; }
html[data-theme="light"] .toolbar, html[data-theme="light"] .editor-toolbar { color: #34445a !important; }
html[data-theme="light"] .user-modal-overlay,
html[data-theme="light"] .modal-overlay,
html[data-theme="light"] .profile-modal-overlay { background: rgba(21,35,55,.38) !important; }
html[data-theme="light"] .user-modal-body .user-form-actions { background: rgba(255,255,255,.97) !important; border-color: var(--theme-border) !important; }
html[data-theme="light"] .user-modal-body .user-form-actions .btn-tool { background: #f2f5f9 !important; border-color: var(--theme-border) !important; color: #34445a !important; }
html[data-theme="light"] :is(.upload-dropdown-menu,.tl-filter-dropdown,.dropdown-menu) { background: #fff !important; border-color: var(--theme-border) !important; box-shadow: 0 16px 38px rgba(29,48,79,.14) !important; }
html[data-theme="light"] :is(.dropdown-item,.upload-dropdown-menu .dropdown-item strong) { color: #26364c !important; }
html[data-theme="light"] .dropdown-item:hover { background: #edf8f5 !important; }
html[data-theme="light"] :is(.btn-tool,.btn-secondary,.btn-cancel,.btn-ag-outline) { background: #f1f5fa !important; border-color: #d6dfeb !important; color: #34445a !important; }
html[data-theme="light"] :is(.btn-tool:hover,.btn-secondary:hover,.btn-cancel:hover,.btn-ag-outline:hover) { background: #e7edf5 !important; color: #17243a !important; }
html[data-theme="light"] :is(.btn-save,.btn-primary,.btn-ag-primary,.btn-upload-main,.btn-upload-split,.sc-btn-save) { color: #03251f !important; }
html[data-theme="light"] .btn-danger { color: #fff !important; }
html[data-theme="light"] *[style*="color:#fff"],
html[data-theme="light"] *[style*="color: #fff"],
html[data-theme="light"] *[style*="color:#ffffff"],
html[data-theme="light"] *[style*="color: #ffffff"],
html[data-theme="light"] *[style*="color:#e2e8f0"],
html[data-theme="light"] *[style*="color: #e2e8f0"],
html[data-theme="light"] *[style*="color:#f1f5f9"],
html[data-theme="light"] *[style*="color: #f1f5f9"],
html[data-theme="light"] *[style*="color:#cbd5e1"],
html[data-theme="light"] *[style*="color: #cbd5e1"] { color: #26364c !important; }
html[data-theme="light"] *[style*="color:#94a3b8"],
html[data-theme="light"] *[style*="color: #94a3b8"],
html[data-theme="light"] *[style*="color:#7e92ad"],
html[data-theme="light"] *[style*="color: #7e92ad"],
html[data-theme="light"] *[style*="color:#4e6280"],
html[data-theme="light"] *[style*="color: #4e6280"] { color: #64748b !important; }

/* Keep real document and signature canvases white for accurate reading/signing. */
html[data-theme="light"] :is(.page-wrap,.paper-sheet,.document-page,.document-canvas,.signing-page,.pdf-page,.pdf-canvas,.preview-paper) { background: #fff !important; color: #1e293b !important; }
html[data-theme="light"] :is(.page-wrap,.paper-sheet,.document-page,.pdf-page,.preview-paper) { box-shadow: 0 8px 26px rgba(29,48,79,.16) !important; }

html[data-theme="light"] ::-webkit-scrollbar-track { background: #e9eef5; }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #b7c5d5; }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #8fa3ba; }

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 11px;
    border: 1px solid rgba(0,212,170,.28);
    border-radius: 8px;
    background: rgba(0,212,170,.08);
    color: #34e8c0;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.theme-toggle:hover { background: rgba(0,212,170,.15); border-color: rgba(0,212,170,.48); transform: translateY(-1px); }
html[data-theme="light"] .theme-toggle { background: #f2f7fb; border-color: #d5e1eb; color: #34445a; }
html[data-theme="light"] .theme-toggle:hover { background: #e7f5f1; border-color: #a8ded2; color: #087f6b; }

/* Shared readable sizing: compact UI stays dense without relying on tiny labels. */
html body :is(.ag-tab,.filter-tab,.admin-nav-item,.btn-tool,.btn-ag,.btn-action-primary,.btn-action-secondary,.theme-toggle) {
    font-family: inherit !important;
    font-size: max(12.5px, .82em) !important;
    line-height: 1.35 !important;
}
html body :is(.admin-table td,.rep-table td,.mini-table td,.ag-table td,.tl-table td,.table td) {
    font-size: max(13px, .86em) !important;
    line-height: 1.45 !important;
}
html body :is(.admin-table,.rep-table,.mini-table,.ag-table,.tl-table,.table) td :is(small,span,div) {
    font-size: max(13px, 1em) !important;
    line-height: 1.4 !important;
}
html body :is(.admin-table th,.rep-table th,.mini-table th,.ag-table th,.tl-table th,.table th) {
    font-size: max(11.5px, .78em) !important;
    line-height: 1.35 !important;
}
html body :is(.doc-meta,.date-sub,.ag-tab .count,.filter-tab .count,.kpi-mini-lbl,.api-stat .label,.form-label,.settings-card-body .form-label) {
    font-size: max(12px, .8em) !important;
    line-height: 1.4 !important;
}
html body :is(.card-title,.chart-box-title,.section-title,.chart-title) {
    font-size: max(14px, .9em) !important;
}
html body :is(.ag-search-input,.create-grid input,.create-grid select,.create-grid textarea,.settings-card-body .form-control) {
    font-size: max(13px, .86em) !important;
    min-height: 38px;
}
html body :is(.btn-ag,.btn-tool,.btn-action-primary,.btn-action-secondary) { min-height: 34px; }
html body .ag-tab { padding-top: 12px; padding-bottom: 12px; }
html body .ag-table td { padding-top: 13px; padding-bottom: 13px; }
/* Use one comfortable scale for KPI cards across dashboards and reports. */
html body :is(.kpi-card,.kpi-mini-card,.api-stat) {
    min-height: 96px;
    padding: 16px 18px !important;
    border-radius: 10px !important;
}
html body :is(.kpi-label,.kpi-mini-lbl,.api-stat .label) {
    font-size: 13px !important;
    line-height: 1.4 !important;
}
html body :is(.kpi-value,.kpi-mini-val,.api-stat .value) {
    font-size: 24px !important;
    line-height: 1.15 !important;
}
html body .kpi-trend { font-size: 12.5px !important; line-height: 1.4 !important; }
html body .kpi-grid { gap: 14px; }
html body .kpi-compact-strip { gap: 14px; }
html body .switch-btn {
    min-height: 38px;
    padding: 9px 15px !important;
    font-size: 13px !important;
    line-height: 1.35 !important;
}
.standalone-theme-toggle { position: fixed; top: 18px; right: 20px; z-index: 5000; }
@media (max-width: 700px) {
    .theme-toggle { width: 34px; min-width: 34px; padding: 0; }
    .theme-toggle span { display: none; }
}
