/* Final contrast layer — always loaded after all legacy module styles. */
#app .sidebar .account{grid-template-columns:38px minmax(0,1fr) 34px 28px!important}
#app select option{background:#0b1b17;color:#eaf6f2}

/* Dark theme: eliminate every legacy white island. */
html:not([data-theme="light"]) #app .dashboard-widget,
html:not([data-theme="light"]) #app .law-summary article,
html:not([data-theme="light"]) #app .law-item,
html:not([data-theme="light"]) #app .law-changes article,
html:not([data-theme="light"]) #app .office-metrics article,
html:not([data-theme="light"]) #app .law-summary article,
html:not([data-theme="light"]) #app .widget-empty-state,
html:not([data-theme="light"]) #app .widget-library,
html:not([data-theme="light"]) #app .widget-library label{
 background:linear-gradient(145deg,#0d1c18,#091512)!important;
 border-color:rgba(139,255,222,.15)!important;
 color:#edf8f4!important;
 box-shadow:0 12px 34px rgba(0,0,0,.2)!important;
}
html:not([data-theme="light"]) #app .dashboard-widget>header{background:#0d1d19!important;border-color:rgba(139,255,222,.13)!important;color:#edf8f4!important}
html:not([data-theme="light"]) #app .dashboard-widget>header b,
html:not([data-theme="light"]) #app .widget-row b,
html:not([data-theme="light"]) #app .widget-metric b,
html:not([data-theme="light"]) #app .widget-kpis b,
html:not([data-theme="light"]) #app .rate-mini span,
html:not([data-theme="light"]) #app .law-summary b,
html:not([data-theme="light"]) #app .law-item h3,
html:not([data-theme="light"]) #app .law-changes p{color:#edf8f4!important}
html:not([data-theme="light"]) #app .law-summary span,
html:not([data-theme="light"]) #app .law-summary small,
html:not([data-theme="light"]) #app .law-item p,
html:not([data-theme="light"]) #app .law-item small,
html:not([data-theme="light"]) #app .law-changes time,
html:not([data-theme="light"]) #app .law-changes small,
html:not([data-theme="light"]) #app .widget-row small,
html:not([data-theme="light"]) #app .widget-row em,
html:not([data-theme="light"]) #app .widget-metric span,
html:not([data-theme="light"]) #app .widget-empty{color:#91aaa2!important}
html:not([data-theme="light"]) #app .law-category,
html:not([data-theme="light"]) #app .law-actions a,
html:not([data-theme="light"]) #app .law-actions button,
html:not([data-theme="light"]) #app .law-changes button,
html:not([data-theme="light"]) #app .widget-row time,
html:not([data-theme="light"]) #app .rate-mini b{color:#4be5bd!important}
html:not([data-theme="light"]) #app .law-item-icon{background:#173129!important;color:#4be5bd!important}
html:not([data-theme="light"]) #app .law-actions button,
html:not([data-theme="light"]) #app .law-changes button{background:#122720!important;border:1px solid rgba(139,255,222,.17)!important;border-radius:7px!important;padding:7px 10px!important}
html:not([data-theme="light"]) #app .law-changes article.unread{background:#13221f!important;border-left-color:#43e8ba!important}
html:not([data-theme="light"]) #app .widget-kpis div{background:#10221d!important;border:1px solid rgba(139,255,222,.13)!important}
html:not([data-theme="light"]) #app .widget-row{color:#dcebe6!important;border-color:rgba(139,255,222,.12)!important}
html:not([data-theme="light"]) #app .widget-row:hover{background:#11231f!important}
html:not([data-theme="light"]) #app .widget-controls button{background:#142923!important;color:#91aaa2!important}
html:not([data-theme="light"]) #app .dashboard-editbar{background:#10251f!important;border-color:rgba(139,255,222,.22)!important}
html:not([data-theme="light"]) #app .dashboard-editbar span{color:#c2d7d0!important}

/* Light high-tech theme: explicit readable contrast. */
html[data-theme="light"] #app select option{background:#fff;color:#172b24}
html[data-theme="light"] #app .law-summary article,
html[data-theme="light"] #app .law-item,
html[data-theme="light"] #app .law-changes article,
html[data-theme="light"] #app .dashboard-widget,
html[data-theme="light"] #app .widget-empty-state,
html[data-theme="light"] #app .widget-library,
html[data-theme="light"] #app .widget-library label{background:linear-gradient(145deg,#fff,#f6faf8)!important;border-color:#d3e2dc!important;color:#172b24!important;box-shadow:0 10px 28px rgba(25,69,56,.07)!important}
html[data-theme="light"] #app .law-summary b,
html[data-theme="light"] #app .law-item h3,
html[data-theme="light"] #app .law-changes p,
html[data-theme="light"] #app .dashboard-widget>header b,
html[data-theme="light"] #app .widget-row b,
html[data-theme="light"] #app .widget-metric b{color:#172b24!important}
html[data-theme="light"] #app .law-summary span,
html[data-theme="light"] #app .law-summary small,
html[data-theme="light"] #app .law-item p,
html[data-theme="light"] #app .law-item small,
html[data-theme="light"] #app .law-changes time,
html[data-theme="light"] #app .law-changes small{color:#657c73!important}
html[data-theme="light"] #app .law-item-icon{background:#e2f2ed!important;color:#117c62!important}
html[data-theme="light"] #app .law-changes article.unread{background:#f0f8f5!important;border-left-color:#169878!important}

/* Keep all text above WCAG-like readable levels. */
#app .workspace{font-size:14px!important}
#app .workspace p,#app .workspace small{opacity:1!important}
#app .live-indicator{color:#72dcbc!important}

/* Complete legacy surface normalization across every application module. */
html:not([data-theme="light"]) #app :is(
 .finance-kpis article,.finance-modules article,.nbu-rates article,.court-tools a,
 .client-kpis article,.client-list>button,.case-list>button,.office-metrics article,
 .configurator-card,.reaction-rule,.reaction-rule>header,.hosting-account,
 .saas-panel,.saas-plan,.saas-new-plan,.saas-included label,.admin-tabs button,
 .template-access-row select,.portal-site-meta,.person-card,.org-card,.office-card,
 .channel-card,.channel-account,.widget-library label,.service-domains>span,
 .work-grid article,.document-list article,.generator pre,.court-date
 ){
 background:#0d1c18!important;
 background-image:linear-gradient(145deg,#0e1e1a,#091512)!important;
 border-color:rgba(139,255,222,.15)!important;
 color:#eaf6f2!important;
 box-shadow:none!important;
}
html:not([data-theme="light"]) #app :is(
 .finance-kpis article,.nbu-rates article,.client-kpis article,.office-metrics article,
 .configurator-card,.reaction-rule,.hosting-account,.saas-panel,.saas-plan,.saas-new-plan,
 .court-tools a,.client-list>button,.case-list>button
 ):hover{background:#11251f!important;border-color:rgba(89,240,196,.28)!important}
html:not([data-theme="light"]) #app :is(
 .finance-kpis b,.finance-modules b,.nbu-rates b,.nbu-rates article>span,
 .client-kpis b,.client-list b,.case-list b,.office-metrics b,.configurator-card h2,
 .reaction-rule h3,.hosting-account h3,.saas-panel h2,.saas-plan h3,.saas-plan footer strong,
 .court-tools b,.court-tools strong,.work-grid b,.document-list h3,.nbu-table strong
 ){color:#edf8f4!important}
html:not([data-theme="light"]) #app :is(
 .finance-kpis span,.finance-modules span,.nbu-rates small,.client-kpis span,.client-list small,
 .client-list em,.case-list small,.case-list em,.office-metrics span,.configurator-card p,
 .cfg-saved span,.reaction-rule label,.hosting-account small,.saas-panel>header>span,
 .saas-module label,.saas-plan label,.saas-plan footer small,.saas-subscriptions article small,
 .court-tools span,.court-date span,.work-grid small,.document-list small
 ){color:#8da79f!important}
html:not([data-theme="light"]) #app :is(.nbu-rates article>span,.nbu-rates button,.court-links a,.configurator-form>small,.saas-module-icon){color:#49e2ba!important}
html:not([data-theme="light"]) #app :is(.nbu-rates button,.court-links button,.configurator-card button,.saas-save,.saas-subscriptions button){background:#122720!important;border:1px solid rgba(139,255,222,.18)!important;color:#62dfbe!important;border-radius:7px!important}
html:not([data-theme="light"]) #app :is(.client-source,.court-date,.saas-module-icon,.cfg-logo){background:#173129!important;color:#53dfba!important}
html:not([data-theme="light"]) #app :is(.reaction-condition,.reaction-action,.saas-panel>header,.saas-module,.saas-included,.saas-subscriptions article,.nbu-table>div,.invoice-list article,.case-head,.case-tabs details,.document-list article){border-color:rgba(139,255,222,.13)!important}
html:not([data-theme="light"]) #app :is(.reaction-rule input,.reaction-rule select,.reaction-rule textarea,.saas-module input,.saas-plan input,.saas-plan select,.saas-new-plan input,.saas-new-plan select,.saas-subscriptions select,.template-access-row select){background:#071310!important;color:#eaf6f2!important;border-color:#28483f!important}
html:not([data-theme="light"]) #app .generator pre{color:#dcece6!important}
html:not([data-theme="light"]) #app .finance-status{background:#372d18!important;color:#f0bd6c!important}
html:not([data-theme="light"]) #app .finance-status.paid{background:#15362c!important;color:#64e6c0!important}

html[data-theme="light"] #app :is(
 .finance-kpis article,.finance-modules article,.nbu-rates article,.court-tools a,
 .client-kpis article,.client-list>button,.case-list>button,.office-metrics article,
 .configurator-card,.reaction-rule,.reaction-rule>header,.hosting-account,
 .saas-panel,.saas-plan,.saas-new-plan,.saas-included label,.admin-tabs button,
 .template-access-row select,.portal-site-meta,.person-card,.org-card,.office-card,
 .channel-card,.channel-account,.widget-library label,.service-domains>span,
 .work-grid article,.document-list article,.generator pre,.court-date
 ){
 background:#fff!important;
 background-image:linear-gradient(145deg,#fff,#f5faf7)!important;
 border-color:#d3e2dc!important;
 color:#172b24!important;
 box-shadow:0 8px 24px rgba(24,66,53,.06)!important;
}
html[data-theme="light"] #app :is(
 .finance-kpis b,.finance-modules b,.nbu-rates b,.client-kpis b,.client-list b,.case-list b,
 .office-metrics b,.configurator-card h2,.hosting-account h3,.saas-panel h2,.saas-plan h3,
 .saas-plan footer strong,.court-tools b,.court-tools strong,.work-grid b,.document-list h3,.nbu-table strong
 ){color:#172b24!important}
html[data-theme="light"] #app :is(
 .finance-kpis span,.finance-modules span,.nbu-rates small,.client-kpis span,.client-list small,
 .client-list em,.case-list small,.case-list em,.office-metrics span,.configurator-card p,
 .cfg-saved span,.hosting-account small,.saas-panel>header>span,.saas-module label,.saas-plan label,
 .saas-plan footer small,.saas-subscriptions article small,.court-tools span,.court-date span,.work-grid small
 ){color:#657c73!important}

/* Safety net for modules added later: an article can never remain white in dark mode. */
html:not([data-theme="light"]) #app .workspace article{background-color:#0d1c18!important;color:#eaf6f2!important;border-color:rgba(139,255,222,.15)!important}
html:not([data-theme="light"]) #app .workspace article :is(h1,h2,h3,h4,h5,h6,b,strong){color:#edf8f4!important}
html:not([data-theme="light"]) #app .workspace article :is(p,small,span:not(.badge):not(.finance-status)){color:#8fa9a1!important}
html[data-theme="light"] #app .workspace article{background-color:#fff!important;color:#172b24!important;border-color:#d3e2dc!important}
html[data-theme="light"] #app .workspace article :is(h1,h2,h3,h4,h5,h6,b,strong){color:#172b24!important}
html[data-theme="light"] #app .workspace article :is(p,small,span:not(.badge):not(.finance-status)){color:#657c73!important}

/* Hosting and remaining application-specific surfaces found by the full audit. */
html:not([data-theme="light"]) #app :is(
 .hosting-stat,.hosting-card,.hosting-actions button,.hosting-actions a,.hosting-record.head,
 .hosting-credentials label,.hosting-secret-note,.hosting-result,.hosting-confirm,.hosting-danger-zone,
 .calendar-shell,.channel-overview article,.channel-setting-card,.complimentary-controls,
 .domain-dialog,.domain-switch-dialog,.dns-guide,.domain-order-page aside,.domain-input select,
 .menu-option,.org-person,.personnel-summary article,.person-dialog,.staff-modal form,
 .site-transfer-row,.site-transfer-row select,.widget-channel-list label,.webhook-info,
 .catalog-empty,.catalog-tabs a,.filters button,.filters span,.language-panel,.language-panel button
 ){
 background:#0d1c18!important;
 background-image:linear-gradient(145deg,#0e1e1a,#091512)!important;
 color:#eaf6f2!important;
 border-color:rgba(139,255,222,.16)!important;
 box-shadow:none!important;
}
html:not([data-theme="light"]) #app :is(
 .hosting-stat b,.hosting-card h2,.hosting-card h3,.hosting-record b,.hosting-record strong,
 .channel-overview h2,.channel-setting-card h2,.domain-dialog h2,.domain-switch-dialog h2,
 .menu-option b,.org-person b,.personnel-summary b,.person-dialog h2,.catalog-empty h2
 ){color:#edf8f4!important}
html:not([data-theme="light"]) #app :is(
 .hosting-stat small,.hosting-card p,.hosting-record small,.hosting-tool-page header p,
 .channel-overview p,.channel-setting-card p,.domain-order-page aside p,.org-person small,
 .personnel-summary span,.person-dialog p,.site-transfer-row small,.webhook-info small
 ){color:#8da79f!important}
html:not([data-theme="light"]) #app .hosting-records{border-color:rgba(139,255,222,.16)!important}
html:not([data-theme="light"]) #app .hosting-record{border-color:rgba(139,255,222,.12)!important}
html:not([data-theme="light"]) #app .hosting-record code,
html:not([data-theme="light"]) #app .hosting-credentials code{color:#57dfbd!important}
html:not([data-theme="light"]) #app .hosting-secret-note{color:#f0c477!important;border-color:#8a6a2b!important}
html:not([data-theme="light"]) #app .hosting-result{color:#65e8c1!important;border-color:#31876e!important}
html:not([data-theme="light"]) #app .hosting-result.error,
html:not([data-theme="light"]) #app .hosting-danger-zone{background:#241317!important;background-image:none!important;color:#ff9099!important;border-color:#71363d!important}
html:not([data-theme="light"]) #app :is(.hosting-actions button,.hosting-actions a,.catalog-tabs a,.filters button,.language-panel button){background:#122720!important;color:#b9d1c9!important;border-color:rgba(139,255,222,.18)!important}

html[data-theme="light"] #app :is(
 .hosting-stat,.hosting-card,.hosting-actions button,.hosting-actions a,.hosting-record.head,
 .hosting-credentials label,.hosting-secret-note,.hosting-result,.hosting-confirm,.hosting-danger-zone,
 .calendar-shell,.channel-overview article,.channel-setting-card,.complimentary-controls,
 .domain-dialog,.domain-switch-dialog,.dns-guide,.domain-order-page aside,.domain-input select,
 .menu-option,.org-person,.personnel-summary article,.person-dialog,.staff-modal form,
 .site-transfer-row,.site-transfer-row select,.widget-channel-list label,.webhook-info,
 .catalog-empty,.catalog-tabs a,.filters button,.filters span,.language-panel,.language-panel button
 ){
 background:#fff!important;
 background-image:linear-gradient(145deg,#fff,#f5faf7)!important;
 color:#172b24!important;
 border-color:#d3e2dc!important;
 box-shadow:0 8px 24px rgba(24,66,53,.06)!important;
}
html[data-theme="light"] #app :is(.hosting-stat b,.hosting-card h2,.hosting-card h3,.hosting-record b,.channel-setting-card h2,.domain-dialog h2,.menu-option b,.org-person b,.personnel-summary b){color:#172b24!important}
html[data-theme="light"] #app :is(.hosting-stat small,.hosting-card p,.hosting-record small,.channel-setting-card p,.org-person small,.personnel-summary span){color:#657c73!important}

/* Defensive rule for legacy card-like DIVs carrying inline or old white backgrounds. */
html:not([data-theme="light"]) #app .workspace :is([class*="-stat"],[class*="-kpi"],[class*="-tile"],[class*="-summary"]){background-color:#0d1c18!important;color:#eaf6f2!important;border-color:rgba(139,255,222,.15)!important}
html[data-theme="light"] #app .workspace :is([class*="-stat"],[class*="-kpi"],[class*="-tile"],[class*="-summary"]){background-color:#fff!important;color:#172b24!important;border-color:#d3e2dc!important}

html:not([data-theme="light"]) #app .workspace .auto-dark-surface{background:#0d1c18!important;background-image:none!important;color:#eaf6f2!important;border-color:rgba(139,255,222,.16)!important;box-shadow:none!important}
html:not([data-theme="light"]) #app .workspace .auto-dark-surface :is(h1,h2,h3,h4,h5,h6,b,strong){color:#edf8f4!important}
html:not([data-theme="light"]) #app .workspace .auto-dark-surface :is(p,small){color:#8fa9a1!important}
html:not([data-theme="light"]) #app .inbox-shell,html:not([data-theme="light"]) #app .inbox-shell iframe{background:#071310!important;border-color:rgba(139,255,222,.16)!important}
