/**
 * Cosys dark mode – applies when html has data-theme="dark"
 * Body background is left to section-specific inline styles ($display['bg']).
 */
html[data-theme="dark"] body {
    color: #e2e2e8;
}

html[data-theme="dark"] #container {
    background: #252538 !important;
    border-color: #3d3d5c !important;
}

html[data-theme="dark"] a {
    color: #7eb8da;
}
html[data-theme="dark"] a:hover {
    color: #9dd4f5;
}

html[data-theme="dark"] hr {
    border-color: #3d3d5c;
}

/* Toolbar & header */
html[data-theme="dark"] #toolbar {
    background: #2d3d4a !important;
    border-color: #4a4a6a !important;
}

html[data-theme="dark"] #header_title h1 {
    color: #a0a0b0 !important;
}
html[data-theme="dark"] #header_title h2 {
    color: #8888a0 !important;
}

html[data-theme="dark"] #qmenu {
    background: #2d3d4a !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] #qmenu a {
    color: #e2e2e8 !important;
}
html[data-theme="dark"] #qmenu a:hover {
    color: #7eb8da !important;
}
/* qmenu icons: keep black then invert to white (link colour must not affect icon) */
html[data-theme="dark"] #qmenu .qmenu-icon, html[data-theme="dark"] #qmenu a .qmenu-icon {
    color: #000 !important;
}
html[data-theme="dark"] #qmenu .qmenu-icon svg {
    filter: invert(1);
}

/* Forms */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: #1e1e2e !important;
    color: #e2e2e8 !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
    border-color: #5a8ad8 !important;
    outline: none;
}

html[data-theme="dark"] .highlight {
    color: #7eb8da;
}

/* Messages */
html[data-theme="dark"] .success {
    background: #1e3d1e !important;
    border-color: #2d5a2d !important;
    color: #a8e0a8 !important;
}
html[data-theme="dark"] .error {
    background: #5a1a1a !important;
    border-color: #8a2a2a !important;
    color: #ffb0b0 !important;
}
html[data-theme="dark"] .warning {
    background: #4a3d1a !important;
    border-color: #6a5a2a !important;
    color: #e8d888 !important;
}
html[data-theme="dark"] .notice {
    background: #2d2d44 !important;
    border-color: #4a4a6a !important;
    color: #c0c0d0 !important;
}
html[data-theme="dark"] .required {
    border-color: #6a4a4a !important;
    background: #3d2d2d !important;
}

/* Sort / pagination */
html[data-theme="dark"] .sort {
    background: #2d3d4a !important;
    border-color: #3d4a5a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .pages {
    background: #2d3d3d !important;
    border-color: #4a4a5a !important;
    color: #e2e2e8 !important;
}

/* Tables */
html[data-theme="dark"] .ts {
    background: #2d2d3a !important;
    border-color: #3d3d5c !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ts th {
    color: #e2e2e8 !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] .ts td {
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ts_odd {
    background: #252538 !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] .ts_even {
    background: #2d3538 !important;
    border-color: #4a4a6a !important;
}
/* International (non-UK) L3PL summary: after .ts td so it wins in dark mode; inset box-shadow ensures visibility */
html[data-theme="dark"] .ts td.international {
    border-color: #c08cd4 !important;
    color: #c08cd4 !important;
    box-shadow: inset 0 0 0 2px #c08cd4;
}
/* L3PL summary: empty message and row states in dark mode */
html[data-theme="dark"] .l3pl-msg-empty {
    color: #7eb8da !important;
}
html[data-theme="dark"] .l3pl-summary-menu {
    background: #2d3d4a !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] .l3pl-summary-menu-label {
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .l3pl-summary-menu-select {
    background: #1e1e2e !important;
    color: #e2e2e8 !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] .l3pl-summary-menu-select:hover,
html[data-theme="dark"] .l3pl-summary-menu-select:focus {
    border-color: #5a8ad8 !important;
}
html[data-theme="dark"] .l3pl-conflict-badge {
    clear: both;
    background: #4a3a18 !important;
    border-color: #8a6a2a !important;
    color: #f0d690 !important;
}
html[data-theme="dark"] .l3pl-conflict-badge a {
    color: #9dd4f5 !important;
}
html[data-theme="dark"] .l3pl-conflict-badge a:hover {
    color: #bce4ff !important;
}
html[data-theme="dark"] .l3pl-conflict-panel {
    background: #4a3a18 !important;
    border-color: #8a6a2a !important;
    color: #f0d690 !important;
}
html[data-theme="dark"] .l3pl-conflict-title,
html[data-theme="dark"] .l3pl-conflict-row {
    color: #f0d690 !important;
}
html[data-theme="dark"] .l3pl-conflict-blocked {
    color: #ffb0b0 !important;
}
html[data-theme="dark"] .l3pl-alloc-table th {
    background: #2f5e3b !important;
    border-color: #4a6a5a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .l3pl-alloc-table td {
    background: #252538 !important;
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .l3pl-alloc-table td input[type='button'] {
    background: #2d3d4a !important;
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .l3pl-alloc-table tr.l3pl-alloc-summary-row td {
    background: #4a3d1a !important;
    border-color: #6a5a2a !important;
    color: #e8d888 !important;
}
html[data-theme="dark"] .ts tr.ts_row_incomplete {
    background: #5a3030 !important;
}
html[data-theme="dark"] .ts tr.ts_row_highlight {
    background: #2d3d4a !important;
}
html[data-theme="dark"] .ts_input {
    background: #1e1e2e !important;
    color: #e2e2e8 !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] .ts_input_changed {
    border-color: #5a8ad8 !important;
}
html[data-theme="dark"] .ts_detail {
    background: #2d2d44 !important;
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ts_detail_allocations {
    background: #2d3d44 !important;
    border-color: #4a5a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ts_detail_despatches {
    background: #2d3d38 !important;
    border-color: #4a5a5a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ts_detail_instructions {
    background: #3d2d38 !important;
    border-color: #5a4a5a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ts_detail_instructions img {
    filter: invert(1) !important;
}

html[data-theme="dark"] .ts_detail img {
    filter: invert(1) !important;
}

html[data-theme="dark"] #documents_upload img {
    filter: invert(1) !important;
}

html[data-theme="dark"] #delivery_details img {
    filter: invert(1) !important;
}

html[data-theme="dark"] #comment_container img {
    filter: invert(1) !important;
}


html[data-theme="dark"] .ts_separator {
    background: #252538 !important;
}

/* Notes & comments */
html[data-theme="dark"] .notes {
    background: #2d2d44 !important;
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .comment {
    background: #2d2d44 !important;
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}

/* Status badges */
html[data-theme="dark"] .status_pending {
    background: #3d3d4a !important;
    color: #c0c0d0 !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] .status_verify {
    background: #2d4a6a !important;
    color: #a0c8e8 !important;
    border-color: #4a6a8a !important;
}
html[data-theme="dark"] .status_working {
    background: #5a4a2d !important;
    color: #e8d090 !important;
    border-color: #8a6a3a !important;
}
html[data-theme="dark"] .status_question {
    background: #4a3d4a !important;
    color: #e0c0e0 !important;
    border-color: #6a5a6a !important;
}
html[data-theme="dark"] .status_part_despatched {
    background: #3d4a3d !important;
    color: #b0e0b0 !important;
    border-color: #5a6a5a !important;
}
html[data-theme="dark"] .status_despatched {
    background: #2d4a2d !important;
    color: #a8e0a8 !important;
    border-color: #4a6a4a !important;
}
html[data-theme="dark"] .status_cancelled {
    background: #353540 !important;
    color: #a0a0b0 !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] .status_hold {
    background: #5a2d2d !important;
    color: #e8a0a0 !important;
    border-color: #8a4a4a !important;
}

/* Menu buttons */
html[data-theme="dark"] .menu_button {
    background: #202b2b !important;
    border-color: #4a6a4a !important;
    color: #c0e0c0 !important;
}

html[data-theme="dark"] .menu_icon {
    filter: invert(1) hue-rotate(180) !important;
}

/* Stock table */
html[data-theme="dark"] .stock td {
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .stock tr:hover {
    background: #2d3538 !important;
}
html[data-theme="dark"] .stock th {
    background: #2d4a3d !important;
    border-color: #4a6a5a !important;
    color: #c0e8d0 !important;
}

/* Shared semantic accents in dark mode */
html[data-theme="dark"] .ui-accent-success { color: #7ed6a2 !important; }
html[data-theme="dark"] .ui-accent-info { color: #8bc8ff !important; }
html[data-theme="dark"] .ui-accent-warning { color: #f2cc7a !important; }
html[data-theme="dark"] .ui-accent-danger { color: #ffb0b0 !important; }
html[data-theme="dark"] .ui-muted-title { color: #b8b8c8 !important; }

html[data-theme="dark"] .ui-btn-success { background: #2f5e3b !important; border-color: #4a6a5a !important; color: #e2e2e8 !important; }
html[data-theme="dark"] .ui-btn-info { background: #2d4a6a !important; border-color: #4a6a8a !important; color: #e2e2e8 !important; }
html[data-theme="dark"] .ui-btn-warning { background: #6a4f1f !important; border-color: #8a6a2a !important; color: #e2e2e8 !important; }
html[data-theme="dark"] .ui-btn-danger { background: #6a2d2d !important; border-color: #8a4a4a !important; color: #e2e2e8 !important; }
html[data-theme="dark"] .ui-btn-modern {
    border-color: #5a6472 !important;
    background: linear-gradient(180deg, #4b5566 0%, #3a4352 100%) !important;
    color: #e2e2e8 !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 1px 2px rgba(0, 0, 0, 0.35) !important;
}
html[data-theme="dark"] .ui-btn-modern:hover {
    filter: brightness(1.08) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45) !important;
}
html[data-theme="dark"] .ui-btn-modern:active {
    filter: brightness(0.95) !important;
}

html[data-theme="dark"] .ui-table-header-green { background: #2f5e3b !important; border-color: #4a6a5a !important; color: #e2e2e8 !important; }
html[data-theme="dark"] .ui-table-header-blue { background: #2d4a6a !important; border-color: #4a6a8a !important; color: #e2e2e8 !important; }
html[data-theme="dark"] .ui-table-header-red { background: #6a2d2d !important; border-color: #8a4a4a !important; color: #e2e2e8 !important; }
html[data-theme="dark"] .ui-table-body-default { background: #252538 !important; border-color: #4a4a6a !important; color: #e2e2e8 !important; }
html[data-theme="dark"] .ui-table-body-warn { background: #4a3d1a !important; border-color: #6a5a2a !important; color: #e8d888 !important; }

html[data-theme="dark"] .ui-edit-highlight-green { background: #274433 !important; border-color: #4a6a5a !important; }
html[data-theme="dark"] .ui-edit-highlight-blue { background: #2a3f56 !important; border-color: #4a6a8a !important; }

html[data-theme="dark"] .ui-panel-danger { background: #5a3030 !important; }
html[data-theme="dark"] .ui-panel-danger-row { background: #6a3a3a !important; }

html[data-theme="dark"] .ui-chip-warning { background: #4a3d1a !important; color: #e8d888 !important; border-color: #6a5a2a !important; }
html[data-theme="dark"] .ui-sort-search { background: #2d3d4a !important; border-color: #4a4a6a !important; color: #e2e2e8 !important; }

html[data-theme="dark"] .ui-stock-negative { background-color: #5a2d2d !important; color: #f0b5b5 !important; }
html[data-theme="dark"] .ui-stock-low { background-color: #5c4425 !important; color: #f2d0a0 !important; }
html[data-theme="dark"] .ui-stock-warning { background-color: #2f4a26 !important; color: #d7efb6 !important; }
html[data-theme="dark"] .ui-stock-wip { background: #2a3f56 !important; color: #d5e7ff !important; opacity: 1 !important; }

html[data-theme="dark"] .csadmin-user-line {
    background: #24293a !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] .csadmin-user-never {
    background: #3a3a46 !important;
}
html[data-theme="dark"] .csadmin-user-inactive,
html[data-theme="dark"] .auditTable .audit-row-inactive {
    background: #5a2d2d !important;
}
html[data-theme="dark"] .csadmin-link-admin-active { color: #ff9a9a !important; }
html[data-theme="dark"] .csadmin-link-admin-inactive { color: #d0a6a6 !important; }
html[data-theme="dark"] .csadmin-link-agent-active { color: #8bc8ff !important; }
html[data-theme="dark"] .csadmin-link-agent-inactive { color: #a9b6e4 !important; }

html[data-theme="dark"] .permissions_table td.changed {
    background-color: #5a2d2d !important;
}
html[data-theme="dark"] .permissions_table td.changed input {
    outline-color: #ffb0b0 !important;
}
html[data-theme="dark"] .permissions_table th.changed {
    color: #ffb0b0 !important;
}
html[data-theme="dark"] .permissions_table td.muted {
    color: #b8b8c8 !important;
}

html[data-theme="dark"] .auditTable th,
html[data-theme="dark"] .auditTable td {
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .auditTable th {
    background: #2d4a3d !important;
    color: #c0e8d0 !important;
}

html[data-theme="dark"] .admin-user-line {
    background: #24293a !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] .admin-user-never {
    background: #3a3a46 !important;
}
html[data-theme="dark"] .admin-user-inactive {
    background: #5a2d2d !important;
}
html[data-theme="dark"] .admin-link-prfm-active { color: #ff9a9a !important; }
html[data-theme="dark"] .admin-link-prfm-inactive { color: #d0a6a6 !important; }
html[data-theme="dark"] .admin-link-client-active { color: #8bc8ff !important; }
html[data-theme="dark"] .admin-link-client-inactive { color: #a9b6e4 !important; }
html[data-theme="dark"] .admin-link-distributor-active { color: #8fd58f !important; }
html[data-theme="dark"] .admin-link-distributor-inactive { color: #d2d29a !important; }
html[data-theme="dark"] .admin-link-inactive-general { color: #ff9a9a !important; }

/* Fallback for legacy inline colors that still exist in section templates */
html[data-theme="dark"] [style*="#4caf50"],
html[data-theme="dark"] [style*="#4CAF50"] {
    background-color: #2f5e3b !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] [style*="#1979ca"],
html[data-theme="dark"] [style*="#006fc4"],
html[data-theme="dark"] [style*="#0072c6"],
html[data-theme="dark"] [style*="#a1c7f7"] {
    background-color: #2d4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] [style*="#dd3131"],
html[data-theme="dark"] [style*="#FF0000"],
html[data-theme="dark"] [style*="#ff0000"] {
    background-color: #6a2d2d !important;
    color: #ffb0b0 !important;
}
html[data-theme="dark"] [style*="#ffd199"],
html[data-theme="dark"] [style*="#ffae66"],
html[data-theme="dark"] [style*="#ffce9d"] {
    background-color: #4a3d1a !important;
    color: #e8d888 !important;
}
html[data-theme="dark"] [style*="#fffdcc"],
html[data-theme="dark"] [style*="#caf0db"] {
    background-color: #2f4a26 !important;
    color: #d7efb6 !important;
}
html[data-theme="dark"] [style*="#fdc4c4"],
html[data-theme="dark"] [style*="#fc9c9c"],
html[data-theme="dark"] [style*="#ffa8a8"],
html[data-theme="dark"] [style*="#f77373"] {
    background-color: #5a2d2d !important;
    color: #f0b5b5 !important;
}
html[data-theme="dark"] [style*="background-color: #FFF"],
html[data-theme="dark"] [style*="background-color:#FFF"],
html[data-theme="dark"] [style*="background: #FFF"],
html[data-theme="dark"] [style*="background:#FFF"] {
    background-color: #252538 !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] [style*="#e8f1fd"] {
    background-color: #2a3f56 !important;
    color: #d5e7ff !important;
    opacity: 1 !important;
}
html[data-theme="dark"] [style*="#9fd5b7"],
html[data-theme="dark"] [style*="#d1e9de"],
html[data-theme="dark"] [style*="#d6f5d7"] {
    background-color: #274433 !important;
    color: #d4f0de !important;
}
html[data-theme="dark"] [style*="#ddebf7"],
html[data-theme="dark"] [style*="#bcd1ed"] {
    background-color: #2a3f56 !important;
    color: #d5e7ff !important;
}
html[data-theme="dark"] [style*="#fcfacd"],
html[data-theme="dark"] [style*="#fdcd9c"],
html[data-theme="dark"] [style*="#e3f0db"],
html[data-theme="dark"] [style*="#d2e8dc"] {
    background-color: #4a3d1a !important;
    color: #e8d888 !important;
}
html[data-theme="dark"] [style*="#ddd"],
html[data-theme="dark"] [style*="#DDD"],
html[data-theme="dark"] [style*="#ccc"],
html[data-theme="dark"] [style*="#fdd2ce"] {
    background-color: #353540 !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] [style*="#C0C0C0"],
html[data-theme="dark"] [style*="#c0c0c0"] {
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] [style*="#003477"],
html[data-theme="dark"] [style*="#1a299d"],
html[data-theme="dark"] [style*="#2773a2"],
html[data-theme="dark"] [style*="#207144"] {
    color: #8bc8ff !important;
}
html[data-theme="dark"] [style*="#d92e2e"],
html[data-theme="dark"] [style*="#cc0000"] {
    color: #ffb0b0 !important;
}
html[data-theme="dark"] [style*="color: #999"],
html[data-theme="dark"] [style*="color:#999"] {
    color: #b8b8c8 !important;
}

html[data-theme="dark"] .img-border {
    border-color: #4a4a6a !important;
}

html[data-theme="dark"] .div-Blur {
    background: #0a0a12 !important;
}

/* Red / utility */
html[data-theme="dark"] .red {
    color: #e88;
}

/* jQuery UI */
html[data-theme="dark"] .ui-widget-content {
    background: #252538 !important;
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ui-widget-content a {
    color: #7eb8da !important;
}
html[data-theme="dark"] .ui-widget-header {
    background: #3d3d5c !important;
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ui-state-default,
html[data-theme="dark"] .ui-widget-content .ui-state-default,
html[data-theme="dark"] .ui-widget-header .ui-state-default {
    background: #2d2d44 !important;
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ui-state-default a {
    color: #7eb8da !important;
}
html[data-theme="dark"] .ui-state-hover,
html[data-theme="dark"] .ui-widget-content .ui-state-hover,
html[data-theme="dark"] .ui-state-focus {
    background: #3d3d5c !important;
    border-color: #5a5a7a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ui-state-active {
    background: #2d3d5a !important;
    border-color: #4a6a8a !important;
}
html[data-theme="dark"] .ui-widget-overlay {
    background: #0a0a12 !important;
    opacity: 0.7 !important;
}
html[data-theme="dark"] .ui-dialog {
    background: #252538 !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] .ui-dialog .ui-dialog-titlebar {
    background: #3d3d5c !important;
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ui-dialog .ui-dialog-content {
    background: #252538 !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ui-datepicker {
    background: #252538 !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] .ui-datepicker th,
html[data-theme="dark"] .ui-datepicker td a,
html[data-theme="dark"] .ui-datepicker .ui-datepicker-title {
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ui-tabs .ui-tabs-nav li {
    background: #2d2d44 !important;
    border-color: #4a4a6a !important;
}
html[data-theme="dark"] .ui-tabs .ui-tabs-nav li a {
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ui-tabs .ui-tabs-nav li.ui-tabs-active {
    background: #252538 !important;
    border-bottom-color: #252538 !important;
}
html[data-theme="dark"] .ui-tabs .ui-tabs-panel {
    background: #252538 !important;
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ui-accordion .ui-accordion-header {
    background: #3d3d5c !important;
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ui-accordion .ui-accordion-content {
    background: #252538 !important;
    border-color: #4a4a6a !important;
    color: #e2e2e8 !important;
}
html[data-theme="dark"] .ui-menu .ui-menu-item a {
    background: #252538 !important;
    color: #e2e2e8 !important;
    border-color: #3d3d5c !important;
}

/* qmenu icons unchanged in dark mode – same .qmenu-icon in style.css */
