/*
 * Dark scheme overrides — active only when <body> has the .theme-dark class
 * (set server-side from User->is_dark_mode and toggled from the header).
 *
 * IFRAME RULE: every selector is scoped with `html.standalone`. An inline
 * script in <head> adds the `standalone` class to <html> — before the first
 * paint — only when window.self === window.top (i.e. NOT inside an iframe). So
 * when embedded in an iframe the class is never added and NONE of these dark
 * rules apply: embedded modules always keep the standard light, portal-coloured
 * look. Gating in <head> (instead of on the body's late-removed .in-iframe
 * class) also means dark mode is in place at first paint — no light-to-dark
 * flash when navigating between pages.
 *
 * Scope: inverts the neutral "surface" chrome (page, navbar, sidebar, panels,
 * tables, forms, dropdowns, pagination) to a dark palette. Portal BRAND colours
 * keep applying: .btn-primary / .btn-secondary and .color-primary /
 * .color-secondary are intentionally NOT overridden, so each portal's accent
 * colours still show in dark mode.
 *
 * Every rule is prefixed with html.standalone body.theme-dark so it out-specifies
 * both custom.css (which uses !important on white backgrounds) and the inline
 * portal colour <style> block in head.blade.php.
 */

html.standalone body.theme-dark {
    --dm-bg: #1b2230;          /* page background            */
    --dm-surface: #232c3d;     /* navbar, sidebar, panels    */
    --dm-elevated: #2a3447;    /* inputs, hover, dropdowns   */
    --dm-border: #3a4456;      /* borders / dividers         */
    --dm-text: #e4e7ec;        /* primary text               */
    --dm-text-muted: #9aa4b2;  /* secondary / muted text     */

    background-color: var(--dm-bg) !important;
    color: var(--dm-text);
}

/* ---- Base surfaces (override custom.css white !important) ---- */
html.standalone body.theme-dark,
html.standalone body.theme-dark .page-inner,
html.standalone body.theme-dark .page-title,
html.standalone body.theme-dark #main-wrapper,
html.standalone body.theme-dark .page-content {
    background-color: var(--dm-bg) !important;
    color: var(--dm-text);
}
/* Default-coloured content links (and their currentColor SVG icons, e.g. the
   wizard's address download/delete/export actions) are too dim on dark — lift
   to a lighter, clearer blue. Real buttons (.btn*) and nav/pagination links keep
   their own treatment; .text-darkblue stays light via its !important rule above. */
html.standalone body.theme-dark .page-content a:not(.btn):not([class*="btn-"]):not(.nav-link):not(.page-link):not(.list-group-item),
html.standalone body.theme-dark .modal a:not(.btn):not([class*="btn-"]):not(.nav-link):not(.page-link):not(.list-group-item) {
    color: #5cb3ff;
}
html.standalone body.theme-dark .page-content a:not(.btn):not([class*="btn-"]):not(.nav-link):not(.page-link):not(.list-group-item):hover,
html.standalone body.theme-dark .modal a:not(.btn):not([class*="btn-"]):not(.nav-link):not(.page-link):not(.list-group-item):hover {
    color: #87caff;
}

/* ---- Top navbar (the visible bar is the inner .container-fluid) ---- */
html.standalone body.theme-dark .navbar,
html.standalone body.theme-dark .navbar.bg-light,
html.standalone body.theme-dark .navbar > .container-fluid,
html.standalone body.theme-dark .navbar > .container,
html.standalone body.theme-dark .navbar .logo-box {
    background: var(--dm-surface) !important;
    border-bottom-color: var(--dm-border) !important;
}
html.standalone body.theme-dark .navbar .logo-box a,
html.standalone body.theme-dark .user-name,
html.standalone body.theme-dark .text-darkblue,
html.standalone body.theme-dark .navbar .dropdown-toggle {
    color: var(--dm-text) !important;
}

/* ---- Sidebar / menu (user opted to darken these too) ---- */
html.standalone body.theme-dark .sidebar,
html.standalone body.theme-dark .sidebar-header,
html.standalone body.theme-dark .menu,
html.standalone body.theme-dark #menu-overlay,
html.standalone body.theme-dark #menu-overlay.sidebar {
    background: var(--dm-bg) !important;
}
html.standalone body.theme-dark .menu-title,
html.standalone body.theme-dark .sidebar-collapse-toggle,
html.standalone body.theme-dark .menu.accordion-menu a,
html.standalone body.theme-dark .menu.accordion-menu .fa-greater-than,
html.standalone body.theme-dark .menu-icon a,
html.standalone body.theme-dark .submenu-link .text-black,
html.standalone body.theme-dark .menu-item-title {
    color: var(--dm-text) !important;
}
/* Submenu containers and their items share the body background … */
html.standalone body.theme-dark .menu.accordion-menu li.open > a,
html.standalone body.theme-dark .menu.accordion-menu ul,
html.standalone body.theme-dark .menu.accordion-menu ul li a {
    background: var(--dm-bg) !important;
    color: var(--dm-text) !important;
}
/* … with a subtle elevated highlight on hover / active for feedback. */
html.standalone body.theme-dark .sidebar-collapse-toggle:hover,
html.standalone body.theme-dark .menu.accordion-menu > li > a:hover,
html.standalone body.theme-dark .menu.accordion-menu > li.active > a,
html.standalone body.theme-dark .menu.accordion-menu > li.active.open > a,
html.standalone body.theme-dark .menu.accordion-menu ul li a:hover,
html.standalone body.theme-dark .menu.accordion-menu ul li.active a,
html.standalone body.theme-dark .menu.accordion-menu ul.sub-menu li a:hover,
html.standalone body.theme-dark .menu.accordion-menu ul.sub-menu li.active a {
    background: var(--dm-elevated) !important;
    color: var(--dm-text) !important;
}
/* The "Menu" divider is invisible on the dark sidebar — lighten it so it still
   reads as a separator (notably in the collapsed icon-only bar). */
html.standalone body.theme-dark hr.menu-divider {
    background-color: var(--dm-text-muted);
    border-color: var(--dm-text-muted);
    opacity: 1;
}

/* ---- A menu list rendered inside a panel (e.g. dashboard "Klantenservice")
 * must follow the panel surface, not the sidebar background ---- */
html.standalone body.theme-dark .panel-body .menu,
html.standalone body.theme-dark .panel-body .menu.accordion-menu,
html.standalone body.theme-dark .panel-body .menu.accordion-menu li a {
    background: var(--dm-surface) !important;
}

/* ---- Panels / cards / modals ---- */
html.standalone body.theme-dark .panel,
html.standalone body.theme-dark .panel-white,
html.standalone body.theme-dark .panel-body,
html.standalone body.theme-dark .modal-content,
html.standalone body.theme-dark .card,
html.standalone body.theme-dark .dropzone,
html.standalone body.theme-dark .bg-white {
    background-color: var(--dm-surface) !important;
    color: var(--dm-text);
}
html.standalone body.theme-dark .panel .panel-heading,
html.standalone body.theme-dark .panel-default .panel-heading,
html.standalone body.theme-dark .accordion-button:not(.collapsed) {
    background-color: var(--dm-elevated) !important;
    color: var(--dm-text);
    border-bottom: 1px solid var(--dm-border) !important;
}
/* modern.css keeps a light 1px border (#EEE) on panels; with the 10px radius
   that light outline breaks the rounded corners in dark mode. Recolour it and
   let the heading fill the rounded top corners so they stay clean. */
html.standalone body.theme-dark .panel {
    border-color: var(--dm-border) !important;
}
html.standalone body.theme-dark .panel .panel-heading {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}
html.standalone body.theme-dark .panel-title,
html.standalone body.theme-dark .panel-info,
html.standalone body.theme-dark .card-title {
    color: var(--dm-text);
}

/* ---- Module tabs (nav-tabs / nav-pills + tab-content panel) ---- */
html.standalone body.theme-dark .tab-content {
    background: var(--dm-surface);
    color: var(--dm-text);
}
html.standalone body.theme-dark .nav-tabs,
html.standalone body.theme-dark .nav-tabs > li > a,
html.standalone body.theme-dark .nav-tabs .nav-link {
    color: var(--dm-text);
    border-color: var(--dm-border);
}
html.standalone body.theme-dark .nav-tabs > li.active > a,
html.standalone body.theme-dark .nav-tabs > li.active > a:hover,
html.standalone body.theme-dark .nav-tabs > li.active > a:focus,
html.standalone body.theme-dark .nav-tabs .nav-link.active {
    background-color: var(--dm-surface);
    border-bottom-color: var(--dm-surface);
    color: var(--dm-text);
}
html.standalone body.theme-dark .nav-tabs > li > a:hover,
html.standalone body.theme-dark .nav-tabs .nav-link:hover {
    background: var(--dm-elevated);
}

/* ---- Accordions (collapsible items in module steps, e.g. online ad) ----
 * Bootstrap accordions default to white; the buttons here also carry the
 * .color-default utility (#F0F0F0). Override the accordion's Bootstrap CSS
 * variables and the explicit rules, and lighten the chevron icon. */
html.standalone body.theme-dark .accordion {
    --bs-accordion-bg: var(--dm-surface);
    --bs-accordion-color: var(--dm-text);
    --bs-accordion-btn-bg: var(--dm-elevated);
    --bs-accordion-btn-color: var(--dm-text);
    --bs-accordion-active-bg: var(--dm-elevated);
    --bs-accordion-active-color: var(--dm-text);
    --bs-accordion-border-color: var(--dm-border);
}
html.standalone body.theme-dark .accordion-item {
    background-color: var(--dm-surface);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html.standalone body.theme-dark .accordion-button,
html.standalone body.theme-dark .accordion-button.color-default,
html.standalone body.theme-dark .accordion-button:not(.collapsed) {
    background-color: var(--dm-elevated) !important;
    color: var(--dm-text) !important;
}
html.standalone body.theme-dark .accordion-body {
    background-color: var(--dm-surface);
    color: var(--dm-text);
}
html.standalone body.theme-dark .accordion-button::after {
    filter: invert(1) brightness(1.7);
}
html.standalone body.theme-dark .accordion-button:focus {
    box-shadow: none;
    border-color: var(--dm-border);
}

/* ---- Selectable tiles / rows used throughout the module wizards ---- *
 * These have explicit light backgrounds (base #fff, hover #f3f3f3, selected
 * #f1f1f1). Quantity-option tiles and tier-row hover/selected use the portal/
 * brand accent (blue) on purpose, so those states are left untouched. */
html.standalone body.theme-dark .clickable-tile,
html.standalone body.theme-dark .clickable-subtile,
html.standalone body.theme-dark .tier-row,
html.standalone body.theme-dark .tile-button {
    background-color: var(--dm-elevated);
    color: var(--dm-text);
}
html.standalone body.theme-dark .clickable-tile:not(.quantity-option):hover,
html.standalone body.theme-dark .clickable-subtile:hover,
html.standalone body.theme-dark .clickable-tile:not(.quantity-option).selected,
html.standalone body.theme-dark .clickable-subtile.selected,
html.standalone body.theme-dark .tile-button:hover,
html.standalone body.theme-dark .icon-button {
    background-color: var(--dm-border) !important;
    color: var(--dm-text);
}
html.standalone body.theme-dark label.clickable-tile.quantity-option {
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html.standalone body.theme-dark #postcode_list .postcode {
    background-color: var(--dm-elevated);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html.standalone body.theme-dark .bg-header {
    background-color: var(--dm-elevated) !important;
    color: var(--dm-text);
}

/* ---- Bootstrap alert boxes (used as info/warning panels in wizards) ---- */
html.standalone body.theme-dark .alert-info {
    background-color: rgba(26, 154, 250, .12);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html.standalone body.theme-dark .alert-warning {
    background-color: rgba(255, 193, 7, .12);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html.standalone body.theme-dark .alert-danger {
    background-color: rgba(218, 46, 76, .14);
    border-color: var(--dm-border);
    color: var(--dm-text);
}

/* ---- Generic text utilities that hard-code dark colours ---- */
html.standalone body.theme-dark .page-breadcrumb ol.breadcrumb li a,
html.standalone body.theme-dark .page-breadcrumb ol.breadcrumb li.active,
html.standalone body.theme-dark .page-breadcrumb ul li a,
html.standalone body.theme-dark .footer-link,
html.standalone body.theme-dark .copyright,
html.standalone body.theme-dark .tile-info-header,
html.standalone body.theme-dark .article-item,
html.standalone body.theme-dark .accordion-button,
html.standalone body.theme-dark .accordion-button:not(.collapsed),
html.standalone body.theme-dark .nav-pills .nav-link,
html.standalone body.theme-dark .nav-pills .nav-link.active,
html.standalone body.theme-dark .text-black {
    color: var(--dm-text) !important;
}
html.standalone body.theme-dark .text-dark {
    color: var(--dm-text) !important;
}
html.standalone body.theme-dark .tile-info-price,
html.standalone body.theme-dark .product-info,
html.standalone body.theme-dark .text-gray,
html.standalone body.theme-dark .text-muted,
html.standalone body.theme-dark .text-black-50 {
    color: var(--dm-text-muted) !important;
}

/* ---- Footer ---- */
html.standalone body.theme-dark .page-footer {
    background: var(--dm-bg);
}

/* ---- Forms / inputs / select2 ---- */
html.standalone body.theme-dark .form-control,
html.standalone body.theme-dark .form-select,
html.standalone body.theme-dark textarea,
html.standalone body.theme-dark .select2-selection,
html.standalone body.theme-dark .select2-container--default .select2-selection--single,
html.standalone body.theme-dark .select2-container--default .select2-selection--multiple,
html.standalone body.theme-dark .input-group-text {
    background-color: var(--dm-elevated) !important;
    color: var(--dm-text) !important;
    border-color: var(--dm-border) !important;
}
html.standalone body.theme-dark .form-control:disabled,
html.standalone body.theme-dark .form-control.disabled,
html.standalone body.theme-dark .select2-container--disabled .select2-selection {
    background-color: var(--dm-surface) !important;
}
html.standalone body.theme-dark .select2-dropdown,
html.standalone body.theme-dark .select2-results__option {
    background-color: var(--dm-elevated) !important;
    color: var(--dm-text) !important;
}
/* Keep the keyboard/hover-highlighted option visually distinct — the generic
   !important rule above otherwise paints every option the same colour, so arrow
   navigation looks like it does nothing. */
html.standalone body.theme-dark .select2-results__option--highlighted,
html.standalone body.theme-dark .select2-results__option--highlighted[aria-selected] {
    background-color: #3a7bd5 !important;
    color: #fff !important;
}
/* The selected-value text and the dropdown search input both default to dark
   grey — unreadable on dark surfaces. */
html.standalone body.theme-dark .select2-container--default .select2-selection--single .select2-selection__rendered,
html.standalone body.theme-dark .select2-search__field {
    color: var(--dm-text) !important;
}
html.standalone body.theme-dark .select2-search--dropdown .select2-search__field {
    background-color: var(--dm-elevated) !important;
    border-color: var(--dm-border) !important;
}
html.standalone body.theme-dark ::placeholder {
    color: var(--dm-text-muted) !important;
}
/* Custom radio labels (e.g. shopcart payment methods) default to #666 — too dim on dark. */
html.standalone body.theme-dark .radio-item label {
    color: var(--dm-text);
}
html.standalone body.theme-dark .btn-default {
    background-color: var(--dm-elevated);
    color: var(--dm-text);
    border-color: var(--dm-border);
}
/* Header search bar: keep the template's borderless, transparent look in dark mode
   (the generic .form-control/.btn-default rules otherwise paint boxed edges). */
html.standalone body.theme-dark .search-form {
    background: var(--dm-surface) !important;
}
html.standalone body.theme-dark .search-form .input-group input,
html.standalone body.theme-dark .search-form .input-group button {
    background: none !important;
    border: none !important;
    color: var(--dm-text) !important;
}

/* Inline desktop header search: match the dark surface (the generic .form-control rule
   otherwise paints it white). */
html.standalone body.theme-dark .header-search-inline .form-control,
html.standalone body.theme-dark .header-search-inline .input-group-text {
    background: var(--dm-elevated) !important;
    border-color: var(--dm-border, rgba(255, 255, 255, 0.15)) !important;
    color: var(--dm-text) !important;
}
html.standalone body.theme-dark .header-search-inline .input-group-text i {
    color: var(--dm-text) !important;
}

/* Header counters (shopcart + notifications): red in light mode (bg-danger), yellow on dark. */
html.standalone body.theme-dark .header-count-badge {
    background-color: #ffe000 !important;
    color: #212529 !important;
}

/* "Read by" info button (btn-link) in the sent-notifications overview: lighter blue on dark. */
html.standalone body.theme-dark .js-readers-info {
    color: #5cb3ff !important;
}
html.standalone body.theme-dark .js-readers-info:hover,
html.standalone body.theme-dark .js-readers-info:focus {
    color: #87caff !important;
}

/* Modal close button (×) uses a dark SVG by default — invert it so it's visible
   on dark modal surfaces (same effect as Bootstrap's .btn-close-white). */
html.standalone body.theme-dark .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ---- List groups (e.g. search result groups) ---- */
html.standalone body.theme-dark .list-group-item {
    background-color: var(--dm-elevated);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html.standalone body.theme-dark .list-group-item-action:hover,
html.standalone body.theme-dark .list-group-item-action:focus {
    background-color: var(--dm-surface);
    color: var(--dm-text);
}
/* Notifications overview: clickable row hover (the light rgba hover reads wrong on dark). */
html.standalone body.theme-dark .notifications-list .notification-main:hover,
html.standalone body.theme-dark .notifications-list .notification-main:focus {
    background-color: var(--dm-surface) !important;
    color: var(--dm-text);
}

/* ---- Tables ---- */
html.standalone body.theme-dark table,
html.standalone body.theme-dark .table {
    color: var(--dm-text);
    border-color: var(--dm-border);
}
html.standalone body.theme-dark .table > :not(caption) > * > * {
    background-color: var(--dm-surface);
    color: var(--dm-text);
    border-color: var(--dm-border);
}
html.standalone body.theme-dark .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--dm-elevated);
}
html.standalone body.theme-dark .table-hover > tbody > tr:hover > * {
    background-color: var(--dm-elevated);
}
html.standalone body.theme-dark .dataTables_wrapper,
html.standalone body.theme-dark .dataTables_wrapper .dataTables_info,
html.standalone body.theme-dark .dataTables_wrapper .dataTables_length,
html.standalone body.theme-dark .dataTables_wrapper .dataTables_filter {
    color: var(--dm-text);
}
/* DataTables tints the sorted column (.sorting_1/2/3 — the first column by
   default) a lighter shade; match it to the normal cell background. */
html.standalone body.theme-dark table.dataTable.display tbody tr > .sorting_1,
html.standalone body.theme-dark table.dataTable.display tbody tr > .sorting_2,
html.standalone body.theme-dark table.dataTable.display tbody tr > .sorting_3,
html.standalone body.theme-dark table.dataTable.order-column tbody tr > .sorting_1,
html.standalone body.theme-dark table.dataTable.order-column tbody tr > .sorting_2,
html.standalone body.theme-dark table.dataTable.order-column tbody tr > .sorting_3,
html.standalone body.theme-dark table.dataTable.display tbody tr.odd > .sorting_1,
html.standalone body.theme-dark table.dataTable.display tbody tr.odd > .sorting_2,
html.standalone body.theme-dark table.dataTable.display tbody tr.odd > .sorting_3,
html.standalone body.theme-dark table.dataTable.display tbody tr.even > .sorting_1,
html.standalone body.theme-dark table.dataTable.display tbody tr.even > .sorting_2,
html.standalone body.theme-dark table.dataTable.display tbody tr.even > .sorting_3 {
    background-color: var(--dm-surface) !important;
}

/* ---- Pagination (Bootstrap, dataTables and the custom .panel-pagination) ---- */
html.standalone body.theme-dark .page-link,
html.standalone body.theme-dark .pagination > li > a,
html.standalone body.theme-dark .panel-pagination a,
html.standalone body.theme-dark .panel-pagination span {
    background-color: var(--dm-elevated) !important;
    color: var(--dm-text) !important;
    border-color: var(--dm-border) !important;
}
html.standalone body.theme-dark .page-item.disabled .page-link,
html.standalone body.theme-dark .panel-pagination .disabled {
    background-color: var(--dm-surface) !important;
    color: var(--dm-text-muted) !important;
}
html.standalone body.theme-dark .dataTables_wrapper .dataTables_paginate .paginate_button {
    background: var(--dm-elevated) !important;
    color: var(--dm-text) !important;
    border-color: var(--dm-border) !important;
}
/* The active page must stand out from the others (no contrast by default in dark mode).
   Covers Bootstrap pagination, the custom .panel-pagination and plain dataTables. */
html.standalone body.theme-dark .page-item.active .page-link,
html.standalone body.theme-dark .pagination > .active > a,
html.standalone body.theme-dark .pagination > li.active > span,
html.standalone body.theme-dark .panel-pagination .active,
html.standalone body.theme-dark .dataTables_wrapper .dataTables_paginate .paginate_button.current,
html.standalone body.theme-dark .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #5cb3ff !important;
    background-color: #5cb3ff !important;
    color: #0b1b2b !important;
    border-color: #5cb3ff !important;
}

/* ---- Dropdown menus ---- */
html.standalone body.theme-dark .dropdown-menu {
    background-color: var(--dm-surface);
    border-color: var(--dm-border);
}
html.standalone body.theme-dark .dropdown-item {
    color: var(--dm-text);
}
html.standalone body.theme-dark .dropdown-item:hover,
html.standalone body.theme-dark .dropdown-item:focus {
    background-color: var(--dm-elevated);
    color: var(--dm-text);
}
html.standalone body.theme-dark .dropdown-divider {
    border-color: var(--dm-border);
}

/* ---- AI-assistent lure/tab: the #1b7a4b green is too dark on dark; lighten it ---- */
html.standalone body.theme-dark .ai-hint,
html.standalone body.theme-dark #pills-ai-tab,
html.standalone body.theme-dark #pills-ai-tab:hover,
html.standalone body.theme-dark #pills-ai-tab:focus,
html.standalone body.theme-dark #pills-ai-tab.active,
html.standalone body.theme-dark #pills-ai-tab i {
    color: #4ed18d;
}

/* ---- Loading popup / overlay (white .message box from head's inline CSS) ---- */
html.standalone body.theme-dark #loading-popup .message {
    background: var(--dm-surface);
    color: var(--dm-text);
}
html.standalone body.theme-dark .loading-overlay-message {
    color: var(--dm-text);
}

/* ---- Order overview "Totaal incl. BTW" row (inline background-color:#ddd) ----
 * Inline styles without !important are beaten by an !important stylesheet rule. */
html.standalone body.theme-dark [style*="background-color:#ddd"] {
    background-color: var(--dm-elevated) !important;
    color: var(--dm-text);
}

/* ---- Summernote editor (news / article edit): dark surface, light text ---- */
html.standalone body.theme-dark .note-editable {
    background-color: var(--dm-elevated);
    color: var(--dm-text);
}
html.standalone body.theme-dark .note-editor.note-frame,
html.standalone body.theme-dark .note-editor .note-toolbar,
html.standalone body.theme-dark .note-editor .note-statusbar,
html.standalone body.theme-dark .note-editor .note-editing-area {
    background-color: var(--dm-surface);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html.standalone body.theme-dark .note-btn,
html.standalone body.theme-dark .note-editor .note-toolbar .note-btn {
    background-color: var(--dm-elevated) !important;
    color: var(--dm-text) !important;
    border-color: var(--dm-border) !important;
}
html.standalone body.theme-dark .note-btn:hover,
html.standalone body.theme-dark .note-btn.active {
    background-color: var(--dm-border) !important;
    color: var(--dm-text) !important;
}
html.standalone body.theme-dark .note-dropdown-menu {
    background-color: var(--dm-surface) !important;
    border-color: var(--dm-border) !important;
    color: var(--dm-text);
}
html.standalone body.theme-dark .note-dropdown-item:hover {
    background-color: var(--dm-elevated) !important;
}

/* ---- Invoice "paper" panel stays white (it represents a printed letter) ----
 * Only this panel is reset to white; the surrounding page keeps the dark theme.
 * The invoice's own <style> sets the brand colours (sender, climax, footer), so
 * we only restore the white surfaces, the dark default text, the dark-blue
 * heading and the black table borders that dark-mode.css would otherwise flip. */
html.standalone body.theme-dark .invoice-paper,
html.standalone body.theme-dark .invoice-paper .panel-heading,
html.standalone body.theme-dark .invoice-paper .panel-body {
    background-color: #fff !important;
    color: #000 !important;
}
html.standalone body.theme-dark .invoice-paper .text-darkblue {
    color: #0c2c84 !important;
}
html.standalone body.theme-dark .invoice-paper .panel-heading {
    border-bottom-color: #e7e7e7 !important;
}
html.standalone body.theme-dark .invoice-paper table,
html.standalone body.theme-dark .invoice-paper table th,
html.standalone body.theme-dark .invoice-paper table td {
    background-color: #fff !important;
    color: #000 !important;
    border-color: #000 !important;
}

/* ---- Log reporting "Totaal" (inline color:blue / .datacell-total #4169e1) ----
 * Pure/royal blue is hard to read on dark; lighten to a readable light blue. */
html.standalone body.theme-dark [style*="color:blue"],
html.standalone body.theme-dark [style*="color: blue"],
html.standalone body.theme-dark .datacell-total {
    color: #5cb3ff !important;
}

/* ---- Slimmer, darker scrollbars across the whole app (dark mode only) ---- */
html.standalone body.theme-dark * {
    scrollbar-width: thin;                               /* Firefox: narrower */
    scrollbar-color: var(--dm-border) var(--dm-bg);      /* Firefox: thumb / track */
}
html.standalone body.theme-dark ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
html.standalone body.theme-dark ::-webkit-scrollbar-track {
    background: var(--dm-bg);
}
html.standalone body.theme-dark ::-webkit-scrollbar-thumb {
    background-color: var(--dm-border);
    border-radius: 8px;
    border: 2px solid var(--dm-bg);                      /* inset padding → looks slimmer */
}
html.standalone body.theme-dark ::-webkit-scrollbar-thumb:hover {
    background-color: #4a566b;
}
html.standalone body.theme-dark ::-webkit-scrollbar-corner {
    background: var(--dm-bg);
}

/* ---- Misc dividers / borders ---- */
html.standalone body.theme-dark hr,
html.standalone body.theme-dark .modal-header,
html.standalone body.theme-dark .modal-footer {
    border-color: var(--dm-border);
}
/* Modal body separator lines: the .border-light utility (#f8f9fa !important)
   is too bright on dark — soften to the dark border colour. */
html.standalone body.theme-dark .modal-body.border-light {
    border-color: var(--dm-border) !important;
}

/* AI-assistent result summaries: in dark mode give the bold field labels (the "key:"
   part — Plaatsen, Rayon, POI-set, Product, …) a mint accent so they stand out from
   their values. Covers the PAA result card + in-module modals (.ai-result-list) and
   the distribution/advertisement tab preview (#ai-preview-fields). */
html.standalone body.theme-dark .ai-result-list li strong,
html.standalone body.theme-dark #ai-preview-fields li strong {
    color: #5cb3ff;
}
/* The result card title ("Suggestie van je AI-assistent") gets the mint/green accent. */
html.standalone body.theme-dark #paa-primary-result .card-title,
html.standalone body.theme-dark #ai-generator-preview .card-title {
    color: #8fdcb6;
}

/* Google Maps InfoWindow balloon (e.g. the selected postcode shown on the map). In dark
   mode Google's white box + drop-shadow looked off, so give the balloon a proper dark
   surface with light text and recolour the pointer/tail + soften the shadow. */
html.standalone body.theme-dark .gm-style .gm-style-iw,
html.standalone body.theme-dark .gm-style .gm-style-iw-c,
html.standalone body.theme-dark .gm-style .gm-style-iw-d {
    background: var(--dm-surface) !important;
}
html.standalone body.theme-dark .gm-style .gm-style-iw-c {
    box-shadow: 0 2px 10px rgba(0, 0, 0, .55) !important;
}
html.standalone body.theme-dark .gm-style .gm-style-iw,
html.standalone body.theme-dark .gm-style .gm-style-iw * {
    color: var(--dm-text) !important;
}
/* The little pointer/tail under the balloon (a rotated square Google renders via ::after). */
html.standalone body.theme-dark .gm-style .gm-style-iw-tc::after {
    background: var(--dm-surface) !important;
}
/* The close (×) button glyph stays visible on the dark surface. */
html.standalone body.theme-dark .gm-style .gm-style-iw button span {
    background-color: var(--dm-text-muted) !important;
}

/* ---- ACB (AiChatBot) chat panel ---- */
/* The offcanvas defaults to a white surface (Bootstrap --bs-offcanvas-bg); give it the
   dark panel surface + readable text. The embed is never dark (html.standalone gate). */
html.standalone body.theme-dark #acbPanel {
    background-color: var(--dm-surface) !important;
    color: var(--dm-text);
}
html.standalone body.theme-dark #acbPanel .offcanvas-title {
    color: var(--dm-text) !important;
}
html.standalone body.theme-dark #acbPanel .acb-reset {
    color: var(--dm-text-muted) !important;
}
/* The header/controls dividers use the .border-light utility (near-white) — soften. */
html.standalone body.theme-dark #acbPanel .border-light {
    border-color: var(--dm-border) !important;
}
/* Hand-off confirmation modal (#acbFinalizeModal, appended to <body> by acb.js): give it the
   dark panel surface + softened dividers so it doesn't flash a light background over the dark
   chat. The iframe embed stays light (html.standalone gate). */
html.standalone body.theme-dark #acbFinalizeModal .modal-content {
    background-color: var(--dm-surface) !important;
    color: var(--dm-text);
}
html.standalone body.theme-dark #acbFinalizeModal .modal-header,
html.standalone body.theme-dark #acbFinalizeModal .modal-footer {
    border-color: var(--dm-border) !important;
}
html.standalone body.theme-dark #acbFinalizeModal .modal-title {
    color: var(--dm-text);
}
html.standalone body.theme-dark #acbFinalizeModal .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}
/* Assistant (and typing) bubbles use .bg-light → an elevated dark surface + light text.
   User bubbles keep the brand colour (.bg-primary text-white). Applies both in the live
   panel (#acbPanel) and in the admin chat-history modal (#acb-chat-modal). */
html.standalone body.theme-dark #acbPanel .acb-bubble.bg-light,
html.standalone body.theme-dark #acb-chat-modal .acb-bubble.bg-light {
    background-color: var(--dm-elevated) !important;
    color: var(--dm-text);
}
/* The meta field labels (Gebruiker, Klant, …) in the chat-history modal header read as
   light blue in dark mode. */
html.standalone body.theme-dark #acb-chat-modal dt {
    color: #5cb3ff;
}
/* Choice buttons: a clearly-actionable blue on the dark surface (default → hover →
   selected get progressively brighter so the active multi-select state stands out). */
html.standalone body.theme-dark #acbPanel .acb-choice {
    background-color: #1d4a66;
    border-color: #3f8cc0;
    color: #d6ecfb;
}
html.standalone body.theme-dark #acbPanel .acb-choice:hover,
html.standalone body.theme-dark #acbPanel .acb-choice:focus {
    background-color: #246088;
    border-color: #5fa8db;
    color: #ffffff;
}
html.standalone body.theme-dark #acbPanel .acb-choice.active {
    background-color: #2f7aa6;
    border-color: #7cc0ec;
    color: #ffffff;
}
/* Group choice (Whize segmenten → sub-filters): green so it reads as "more underneath". */
html.standalone body.theme-dark #acbPanel .acb-choice.acb-choice-group {
    background-color: #1f4a23;
    border-color: #4f9d54;
    color: #d7f0d7;
}
html.standalone body.theme-dark #acbPanel .acb-choice.acb-choice-group:hover,
html.standalone body.theme-dark #acbPanel .acb-choice.acb-choice-group:focus {
    background-color: #2a5e2f;
    border-color: #6cba6c;
    color: #ffffff;
}
html.standalone body.theme-dark #acbPanel .acb-choice.acb-choice-group.active {
    background-color: #3a8a3f;
    border-color: #8fce8f;
    color: #ffffff;
}
