/* Final theme layer: keep foreground and surface paired after page styles. */
@media screen {
html:root[data-ui-theme=dark] body{
 --dark-page:#101a2b;--dark-surface:#1b2a40;--dark-soft:#253953;--dark-border:#455b76;--dark-ink:#eef4fc;--dark-muted:#becde0;--dark-link:#9dcdff;
 --overview-line:var(--dark-border);--overview-paper:var(--dark-surface);--overview-ink:var(--dark-ink);--overview-muted:var(--dark-muted);--overview-head:var(--dark-soft);
 --bs-body-bg:var(--dark-page);--bs-body-color:var(--dark-ink);--bs-secondary-color:var(--dark-muted);--bs-border-color:var(--dark-border);
 background:var(--dark-page)!important;color:var(--dark-ink)!important;color-scheme:dark;
}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(.card,.table-responsive,.mes-data-panel,.mes-list-card,.mes-query-tabs-tools,.overview-filter-panel,.status-page-query,.status-query-panel,.test-batch-scroll,.test-batch-actions,.work-suggestions,.worker-suggestions,.list-group-item,.allocation-day,.process-card,.report-metadata dt,.report-subtitle,.mes-production-shortcuts,.mes-panel-heading){background:var(--dark-surface)!important;color:var(--dark-ink)!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(h1,h2,h3,h4,h5,h6,label,legend,summary,.form-label,.model-name,.overview-model-name,.report-heading,.kpi-value,.allocation-balance){color:var(--dark-ink)!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(.text-muted,.overview-subtitle,.overview-section-label,.lot-board-note,.calendar-empty,.kpi-note,.staff-empty,.staff-planned,.test-table-search label){color:var(--dark-muted)!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(.text-dark,.text-body,.text-black){color:var(--dark-ink)!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(.bg-light,.bg-white,.badge.bg-light){background:var(--dark-soft)!important;color:var(--dark-ink)!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden]):not([type=button]):not([type=submit]),select,textarea){background-color:#152135!important;color:var(--dark-ink)!important;border-color:#60738d!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(input,textarea)::placeholder{color:#a8bad0!important;opacity:1}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(input,select,textarea):disabled{background-color:#263247!important;color:#b3c2d6!important;opacity:1}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(.table,table){--bs-table-bg:var(--dark-surface);--bs-table-color:var(--dark-ink);--bs-table-border-color:var(--dark-border);--bs-table-striped-bg:#203249;--bs-table-hover-bg:#29405b;--bs-table-hover-color:var(--dark-ink);color:var(--dark-ink)!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(table,.table)>:is(thead,tfoot)>tr>:is(th,td){background:var(--dark-soft)!important;color:var(--dark-ink)!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(table,.table)>tbody>tr>:is(th,td){background-color:var(--dark-surface)!important;color:var(--dark-ink)!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) table>tbody>tr:nth-child(even)>:is(th,td){background-color:#203249!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(table caption,.production-quantity,.production-quantity small,.production-quantity strong,.shipment-model-total,.shipment-quantity-value){color:var(--dark-ink)!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) .takt-transferred>td{background:#27394a!important;color:#c2d0de!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) [data-standard-takt]{color:#bdcce0!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) [data-measured-takt]{color:#b0d5ff!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) a:not(.btn):not(.state-complete):not(.mes-section-tabs a):not([data-stock-colored=true]){color:var(--dark-link)!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(.btn-outline-primary,.btn-outline-secondary){background:transparent!important;color:#b8d9ff!important;border-color:#7293bd!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(.btn-outline-primary,.btn-outline-secondary):hover{background:#29476a!important;color:#fff!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) .mes-section-tabs :is(button,a){background:#253953!important;color:#d3e6ff!important;border-color:#607998!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) .mes-section-tabs :is(button,a):is(.active,[aria-selected=true]){background:#2563b8!important;color:#fff!important;border-color:#7cafff!important}
/* Paired dark status cards replace pale backgrounds with white text. */
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(.production-kpi,.shipment-state-card,.shipment-model-total,.shipment-donut-card,.shipment-quantity-summary){background:#223d5b!important;color:var(--dark-ink)!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body #main-content .production-kpi:nth-child(1){background:#203f66!important}
html:root[data-ui-theme=dark] body #main-content .production-kpi:nth-child(2){background:#3d315f!important}
html:root[data-ui-theme=dark] body #main-content .production-kpi:nth-child(3){background:#603b17!important}
html:root[data-ui-theme=dark] body #main-content .production-kpi:nth-child(4){background:#194a41!important}
html:root[data-ui-theme=dark] body #main-content .production-kpi :is(.kpi-label,.kpi-icon,strong,small,span,a){color:#f2f6ff!important}
html:root[data-ui-theme=dark] body #main-content .production-kpi .kpi-icon{background:transparent!important}
html:root[data-ui-theme=dark] body #main-content :is(.mes-making-ring,.lot-total-progress,.kpi-track,.allocation-load-track){background:#32465f!important}
html:root[data-ui-theme=dark] body #main-content .mes-making-ring::before{background:#603b17!important}
html:root[data-ui-theme=dark] body #main-content :is(.mes-making-ring b,.mes-making-caption,.kpi-percent){color:#f2f6ff!important;text-shadow:none!important}
html:root[data-ui-theme=dark] body #main-content :is(.lot-total-progress b,.calendar-progress b,.calendar-progress small){color:#142d41!important;text-shadow:none!important}
html:root[data-ui-theme=dark] body #main-content :is(.overview-count-pill,.kpi-badge,.worker-chip,.allocation-balance,.report-paste-zone,.test-table-search){background:var(--dark-soft)!important;color:var(--dark-ink)!important;border-color:#60738d!important}
html:root[data-ui-theme=dark] body #main-content :is(.worker-chip button,.report-paste-zone span,.staff-count,.staff-names,.staff-leave .staff-names){color:#d3e5ff!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(.work-option:hover,.work-option[aria-selected=true],.list-group-item:hover){background:#2c4664!important;color:#f2f6ff!important}
html:root[data-ui-theme=dark] body #main-content :is(.test-batch-table tr.is-selected td,.test-batch-table tr.is-saved td){background:#234a50!important;color:#e5fff6!important}
html:root[data-ui-theme=dark] body #main-content :is(.staff-calendar,.overview-calendar,.worker-month-calendar) td{background:#1b2a40!important;color:#e9f2ff!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body #main-content :is(.staff-calendar .staff-weekend,.overview-calendar td.is-saturday,.worker-month-calendar .calendar-weekend){background:#342e48!important;color:#ede5ff!important}
html:root[data-ui-theme=dark] body #main-content :is(.staff-calendar .staff-holiday,.overview-calendar td.is-holiday,.worker-month-calendar .calendar-holiday,.staff-leave){background:#4b2c3b!important;color:#ffd3da!important}
html:root[data-ui-theme=dark] body #main-content :is(.staff-calendar .staff-outside,.worker-month-calendar .calendar-outside){background:#152033!important;color:#a6b9d1!important}
html:root[data-ui-theme=dark] body #main-content :is(.overview-calendar td.is-today,.kpi-calendar-day.selected){background:#254c73!important;color:#f2f6ff!important}
html:root[data-ui-theme=dark] body #main-content .allocation-day-remove:is(:hover,:focus){background:#60303e!important;color:#ffe1e6!important}
/* Charts: keep data-series colours; correct axes and neutral surfaces. */
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(.shipment-year-bars button,.shipment-year-track,.shipment-donut-center){background:var(--dark-soft)!important;color:var(--dark-ink)!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) .shipment-year-bars :is(strong,b){color:#d7eaff!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) svg text:not([fill='#fff']):not([fill='#ffffff']):not([fill='white']){fill:#c7d9ef!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) .shipment-month-scroll svg line{stroke:#455b76!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(.shipment-month-scroll,.shipment-month-legend,.shipment-month-heading){background:var(--dark-surface)!important;color:var(--dark-ink)!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) .shipment-month-scroll :is(th,td,caption){color:var(--dark-ink)!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) .report-photo-grid img{background:#152135!important}
/* Dialogs may be moved out of main-content by their existing scripts. */
html:root[data-ui-theme=dark] body :is(dialog,.overview-dialog,.context-help-dialog,.kpi-dialog-header,.overview-dialog-header,.context-help-dialog>header,.shipment-month-heading,.support-page,.support-message){background:var(--dark-surface)!important;color:var(--dark-ink)!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body :is(.context-help-dialog h2,.context-help-body p,.context-help-body small,.support-message small,.support-help){color:var(--dark-ink)!important}
html:root[data-ui-theme=dark] body :is(.support-messages,.support-message.mine){background:var(--dark-soft)!important;color:var(--dark-ink)!important}
html:root[data-ui-theme=dark] body .btn-close{filter:invert(1) grayscale(100%) brightness(200%)}
/* Sticky audit/permission cells use inline light backgrounds. */
html:root[data-ui-theme=dark] body #main-content :is(.sticky-bottom,[style*='position:sticky'][style*='background:white'],[style*='position: sticky'][style*='background: white']){background:var(--dark-surface)!important;color:var(--dark-ink)!important}
}
/* Print stays white irrespective of the on-screen theme. */
@media print{
html:root[data-ui-theme=dark] body,html:root[data-ui-theme=dark] body :is(#main-content,dialog) :is(h1,h2,h3,h4,h5,h6,.card,.table,th,td,dt,dd,p,summary,small,span,strong,a,label,.report-heading,.report-subtitle,.report-section-heading){background-color:#fff!important;color:#000!important;border-color:#777!important;box-shadow:none!important;text-shadow:none!important}
}
@media screen{
html:root[data-ui-theme=dark] body .mobile-shell{background:var(--dark-page)!important;color:var(--dark-ink)!important}
html:root[data-ui-theme=dark] body #main-content :is(.m-bottom,.work-card,.record-card,.filter-card,.notice-card,.own-schedule .own-calendar-day,.m-dialog,.m-menu,.m-panel,.m-tabs,.work-entry,.m-summary){background:var(--dark-surface)!important;color:var(--dark-ink)!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body #main-content :is(.welcome p,.work-balance-note,.m-bottom>a,.m-bottom>button){color:var(--dark-muted)!important}
html:root[data-ui-theme=dark] body #main-content .m-bottom .active{color:#9dcdff!important}
html:root[data-ui-theme=dark] body #main-content :is(.own-schedule .own-calendar-day[aria-pressed=true],.own-schedule .own-calendar-day.is-today){background:#254c73!important;color:#eef4fc!important}
html:root[data-ui-theme=dark] body #main-content :is(.own-schedule .own-calendar-day.is-off-day,.own-schedule .own-calendar-day.is-calendar-holiday){background:#4b2c3b!important;color:#ffd3da!important}
html:root[data-ui-theme=dark] body #main-content .work-remaining{background:#543b1d!important;color:#ffe0a6!important}
html:root[data-ui-theme=dark] body #main-content .work-remaining.is-complete{background:#194a3a!important;color:#b3f4d6!important}
}
@media screen{
html:root[data-ui-theme=dark] body #main-content .mes-production-shortcuts button{color:#b5d8ff!important}
html:root[data-ui-theme=dark] body :is(#main-content,dialog) [data-stock-colored=true]{background-color:var(--stock-color)!important;color:var(--stock-ink)!important}
}
@media screen{
html:root[data-ui-theme=dark] body #main-content :is(.own-work-link,.m-bottom>a,.m-bottom>button){background:var(--dark-surface)!important;color:#c4dfff!important;border-color:var(--dark-border)!important}
}

@media screen{
html:root[data-ui-theme=dark] body #main-content :is(.m-card,.m-stats>div,.entry-estimate>div,.menu-links a,.secondary,.result-picker label>span){background:var(--dark-surface)!important;color:var(--dark-ink)!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body #main-content :is(.m-stats span,.m-stats strong,.m-stats small,.entry-estimate span,.entry-estimate strong,.section-title small,.chart-day>span){color:#d6e6fb!important}
html:root[data-ui-theme=dark] body #main-content .chart-legend span{color:#a9cfff!important}
html:root[data-ui-theme=dark] body #main-content .chart-legend span:last-child{color:#ffabb7!important}
html:root[data-ui-theme=dark] body #main-content .own-calendar-weekday{color:#cbdcf2!important}
html:root[data-ui-theme=dark] body #main-content .own-calendar-weekday:is(:first-child,:nth-child(7)){color:#ffabb7!important}
html:root[data-ui-theme=dark] body #main-content .result-picker input:checked+span{background:#1b6349!important;color:#effff6!important}
html:root[data-ui-theme=dark] body #main-content .percent-badge.red{background:#572b39!important;color:#ffd1d9!important}
}

@media screen{
html:root[data-ui-theme=dark] body #main-content .mobile-shipping fieldset{background:var(--dark-surface)!important;color:var(--dark-ink)!important;border-color:var(--dark-border)!important}
html:root[data-ui-theme=dark] body #main-content .mobile-shipping .text-danger{color:#ffabb7!important}
html:root[data-ui-theme=dark] body #main-content .mobile-shipping .alert-success{background:#194a3a!important;color:#b3f4d6!important}
}
