/* Global CRM appearance switch. Loaded after page-specific styles. */

.main-navbar .crm-theme-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.crm-theme-toggle__label {
    flex: 1 1 auto;
}

.crm-theme-toggle__switch {
    position: relative;
    width: 38px;
    height: 22px;
    flex: 0 0 38px;
    margin-left: auto;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #e2e8f0;
    transition: border-color 0.18s ease, background-color 0.18s ease;
}

.crm-theme-toggle__switch span {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
    transition: transform 0.18s ease;
}

.crm-theme-toggle.is-active .crm-theme-toggle__switch {
    border-color: #3b82f6;
    background: #2563eb;
}

.crm-theme-toggle.is-active .crm-theme-toggle__switch span {
    transform: translateX(16px);
}

:root[data-crm-theme="dark"] {
    color-scheme: dark;
    --primary: #60a5fa;
    --primary-hover: #93c5fd;
    --primary-soft: #172554;
    --bg: #0b1220;
    --surface: #111827;
    --surface-muted: #172033;
    --border: #2a3a52;
    --text: #e5edf7;
    --text-muted: #94a3b8;
    --success: #34d399;
    --info: #60a5fa;
    --warning: #fbbf24;
    --danger: #f87171;
    --sidebar-bg: #0f172a;
    --sidebar-bg-hover: rgba(148, 163, 184, 0.1);
    --sidebar-text: #d9e3f0;
    --sidebar-active: #6366f1;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 16px 38px rgba(0, 0, 0, 0.36);
}

html[data-crm-theme="dark"],
html[data-crm-theme="dark"] body,
html[data-crm-theme="dark"] #app,
html[data-crm-theme="dark"] .main-wrapper,
html[data-crm-theme="dark"] .wrapper,
html[data-crm-theme="dark"] .page-wrapper,
html[data-crm-theme="dark"] .content-wrapper,
html[data-crm-theme="dark"] .content,
html[data-crm-theme="dark"] .main-content,
html[data-crm-theme="dark"] .section {
    background: var(--bg) !important;
    background-color: var(--bg) !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] body {
    scrollbar-color: #475569 #111827;
}

html[data-crm-theme="dark"] .main-navbar,
html[data-crm-theme="dark"] .navbar-bg,
html[data-crm-theme="dark"] .main-header,
html[data-crm-theme="dark"] .navbar {
    background: #0f172a !important;
    border-bottom-color: #26354a !important;
}

html[data-crm-theme="dark"] .main-sidebar,
html[data-crm-theme="dark"] .left-side,
html[data-crm-theme="dark"] aside.main-sidebar {
    background: #0f172a !important;
    border-right-color: #26354a !important;
}

html[data-crm-theme="dark"] .main-footer {
    border-top-color: var(--border) !important;
    background: var(--bg) !important;
    color: var(--text-muted) !important;
}

html[data-crm-theme="dark"] h1,
html[data-crm-theme="dark"] h2,
html[data-crm-theme="dark"] h3,
html[data-crm-theme="dark"] h4,
html[data-crm-theme="dark"] h5,
html[data-crm-theme="dark"] h6,
html[data-crm-theme="dark"] .page-title,
html[data-crm-theme="dark"] .card-title,
html[data-crm-theme="dark"] .modal-title,
html[data-crm-theme="dark"] label,
html[data-crm-theme="dark"] .control-label {
    color: var(--text) !important;
}

html[data-crm-theme="dark"] p,
html[data-crm-theme="dark"] small,
html[data-crm-theme="dark"] .text-muted,
html[data-crm-theme="dark"] .help-block,
html[data-crm-theme="dark"] .form-text {
    color: var(--text-muted) !important;
}

html[data-crm-theme="dark"] hr,
html[data-crm-theme="dark"] .dropdown-divider {
    border-color: var(--border) !important;
}

/* Shared surfaces */
html[data-crm-theme="dark"] .card,
html[data-crm-theme="dark"] .card-body,
html[data-crm-theme="dark"] .card-header,
html[data-crm-theme="dark"] .card-footer,
html[data-crm-theme="dark"] .main-page-card,
html[data-crm-theme="dark"] .main-page-card--flat > .card-body,
html[data-crm-theme="dark"] .modal-content,
html[data-crm-theme="dark"] .modal-header,
html[data-crm-theme="dark"] .modal-body,
html[data-crm-theme="dark"] .modal-footer,
html[data-crm-theme="dark"] .dropdown-menu,
html[data-crm-theme="dark"] .list-group-item,
html[data-crm-theme="dark"] .breadcrumb,
html[data-crm-theme="dark"] .table-responsive,
html[data-crm-theme="dark"] .profile-card,
html[data-crm-theme="dark"] .profile-section,
html[data-crm-theme="dark"] .dashboard-card,
html[data-crm-theme="dark"] .board-card,
html[data-crm-theme="dark"] .issue-card {
    border-color: var(--border) !important;
    background: var(--surface) !important;
    background-color: var(--surface) !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .breadcrumb-item,
html[data-crm-theme="dark"] .breadcrumb-item.active {
    color: var(--text-muted) !important;
}

html[data-crm-theme="dark"] .breadcrumb-item a,
html[data-crm-theme="dark"] a:not(.btn):not(.badge):not(.dropdown-item) {
    color: #7db5ff;
}

/* Form fields and Select2 */
html[data-crm-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]),
html[data-crm-theme="dark"] textarea,
html[data-crm-theme="dark"] select,
html[data-crm-theme="dark"] .form-control,
html[data-crm-theme="dark"] .custom-select,
html[data-crm-theme="dark"] .input-group-text,
html[data-crm-theme="dark"] .gj-textbox-md {
    border-color: #3a4b63 !important;
    background: #0f172a !important;
    background-color: #0f172a !important;
    color: var(--text) !important;
    box-shadow: none !important;
}

html[data-crm-theme="dark"] input::placeholder,
html[data-crm-theme="dark"] textarea::placeholder,
html[data-crm-theme="dark"] .form-control::placeholder {
    color: #64748b !important;
    opacity: 1;
}

html[data-crm-theme="dark"] input:focus,
html[data-crm-theme="dark"] textarea:focus,
html[data-crm-theme="dark"] select:focus,
html[data-crm-theme="dark"] .form-control:focus {
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.16) !important;
}

html[data-crm-theme="dark"] input:disabled,
html[data-crm-theme="dark"] input[readonly],
html[data-crm-theme="dark"] textarea:disabled,
html[data-crm-theme="dark"] textarea[readonly],
html[data-crm-theme="dark"] select:disabled,
html[data-crm-theme="dark"] .form-control:disabled,
html[data-crm-theme="dark"] .form-control[readonly] {
    border-color: #2a3a52 !important;
    background: #182235 !important;
    color: #94a3b8 !important;
    opacity: 1;
}

html[data-crm-theme="dark"] select option {
    background: #111827;
    color: var(--text);
}

html[data-crm-theme="dark"] .select2-container--default .select2-selection--single,
html[data-crm-theme="dark"] .select2-container--bootstrap .select2-selection,
html[data-crm-theme="dark"] .select2-dropdown,
html[data-crm-theme="dark"] .select2-search__field,
html[data-crm-theme="dark"] .select2-results,
html[data-crm-theme="dark"] .select2-results__option {
    border-color: #3a4b63 !important;
    background: #0f172a !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .select2-selection__rendered,
html[data-crm-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .select2-results__option--highlighted[aria-selected],
html[data-crm-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"] {
    background: #1e3a5f !important;
    color: #ffffff !important;
}

/* Tables */
html[data-crm-theme="dark"] .table,
html[data-crm-theme="dark"] table {
    color: var(--text) !important;
    background: transparent !important;
}

html[data-crm-theme="dark"] .table thead th,
html[data-crm-theme="dark"] table thead th {
    border-color: var(--border) !important;
    background: #172033 !important;
    color: #b8c5d6 !important;
}

html[data-crm-theme="dark"] .table td,
html[data-crm-theme="dark"] .table th,
html[data-crm-theme="dark"] table td,
html[data-crm-theme="dark"] table th {
    border-color: var(--border) !important;
}

html[data-crm-theme="dark"] .table tbody tr,
html[data-crm-theme="dark"] .table tbody td,
html[data-crm-theme="dark"] table tbody tr,
html[data-crm-theme="dark"] table tbody td {
    background: var(--surface) !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .table-hover tbody tr:hover,
html[data-crm-theme="dark"] .table-hover tbody tr:hover td,
html[data-crm-theme="dark"] table tbody tr:hover td {
    background: #18263a !important;
}

/* Buttons and menus */
html[data-crm-theme="dark"] .btn-light,
html[data-crm-theme="dark"] .btn-secondary {
    border-color: #3a4b63 !important;
    background: #1b283c !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .btn-light:hover,
html[data-crm-theme="dark"] .btn-secondary:hover {
    border-color: #52647d !important;
    background: #24344b !important;
    color: #ffffff !important;
}

html[data-crm-theme="dark"] .btn-outline-secondary,
html[data-crm-theme="dark"] .btn-outline-info {
    border-color: #4b6380 !important;
    color: #b8d5ff !important;
}

html[data-crm-theme="dark"] .btn-outline-secondary:hover,
html[data-crm-theme="dark"] .btn-outline-info:hover {
    background: #1e3a5f !important;
    color: #ffffff !important;
}

html[data-crm-theme="dark"] .dropdown-item {
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .dropdown-item:hover,
html[data-crm-theme="dark"] .dropdown-item:focus,
html[data-crm-theme="dark"] .dropdown-item.active {
    background: #1e293b !important;
    color: #ffffff !important;
}

html[data-crm-theme="dark"] .main-navbar .crm-user-menu .dropdown-divider {
    border-color: var(--border) !important;
}

html[data-crm-theme="dark"] .main-navbar .crm-user-menu__item:hover i,
html[data-crm-theme="dark"] .main-navbar .crm-user-menu__item:focus i {
    background: #20324a !important;
}

html[data-crm-theme="dark"] .main-navbar .crm-user-menu__item--danger,
html[data-crm-theme="dark"] .main-navbar .crm-user-menu__item--danger i {
    color: #f87171 !important;
}

html[data-crm-theme="dark"] .main-navbar .crm-user-menu__item--danger i,
html[data-crm-theme="dark"] .main-navbar .crm-user-menu__item--danger:hover {
    background: #3b1820 !important;
}

/* Lists and filters */
html[data-crm-theme="dark"] .list-filter-panel,
html[data-crm-theme="dark"] .orders-filter-panel,
html[data-crm-theme="dark"] .orders-work-queue,
html[data-crm-theme="dark"] .orders-status-directory,
html[data-crm-theme="dark"] .orders-status-directory__item,
html[data-crm-theme="dark"] .orders-filter-quick-toggle,
html[data-crm-theme="dark"] .orders-results-toolbar,
html[data-crm-theme="dark"] .orders-bulk-panel__inner,
html[data-crm-theme="dark"] .list-summary,
html[data-crm-theme="dark"] .list-toolbar {
    border-color: var(--border) !important;
    background: var(--surface) !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .orders-work-queue:hover,
html[data-crm-theme="dark"] .orders-status-directory__item:hover {
    border-color: #4c6685 !important;
    background: #18263a !important;
}

html[data-crm-theme="dark"] .orders-work-queue.is-active,
html[data-crm-theme="dark"] .orders-status-directory__item.is-active {
    border-color: #3b82f6 !important;
    background: #172554 !important;
}

html[data-crm-theme="dark"] .orders-work-queue span,
html[data-crm-theme="dark"] .orders-results-toolbar__count strong,
html[data-crm-theme="dark"] .order-list-row td {
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .orders-work-queue strong,
html[data-crm-theme="dark"] .orders-sort-control__icon {
    background: #1e293b !important;
    color: #cbd5e1 !important;
}

html[data-crm-theme="dark"] .orders-sort-control .form-control {
    border-color: #3a4b63 !important;
    background: #0f172a !important;
}

html[data-crm-theme="dark"] .order-list-row td {
    border-top-color: var(--border) !important;
    background: var(--surface) !important;
}

html[data-crm-theme="dark"] .order-list-row:hover td {
    background: #18263a !important;
}

html[data-crm-theme="dark"] .order-number-cell__link {
    color: #8bbcff !important;
}

html[data-crm-theme="dark"] .order-status-trigger {
    border-color: #3a4b63 !important;
    background: #1e293b !important;
    color: #cbd5e1 !important;
}

html[data-crm-theme="dark"] .order-status-trigger--consideration,
html[data-crm-theme="dark"] .order-status-trigger--inspection {
    border-color: #0e7490 !important;
    background: #123044 !important;
    color: #7dd3fc !important;
}

html[data-crm-theme="dark"] .order-status-trigger--on_coordination,
html[data-crm-theme="dark"] .order-status-trigger--coordinate {
    border-color: #a16207 !important;
    background: #35270f !important;
    color: #fde68a !important;
}

html[data-crm-theme="dark"] .order-status-trigger--need_detail,
html[data-crm-theme="dark"] .order-status-trigger--in_progress {
    border-color: #6d28d9 !important;
    background: #2b1d49 !important;
    color: #d8b4fe !important;
}

html[data-crm-theme="dark"] .order-status-trigger--done,
html[data-crm-theme="dark"] .order-status-trigger--wait_asc {
    border-color: #4338ca !important;
    background: #222452 !important;
    color: #c7d2fe !important;
}

html[data-crm-theme="dark"] .order-status-trigger--adopted_from_asc {
    border-color: #15803d !important;
    background: #123021 !important;
    color: #86efac !important;
}

html[data-crm-theme="dark"] .order-status-trigger--rejection {
    border-color: #b91c1c !important;
    background: #35171c !important;
    color: #fca5a5 !important;
}

html[data-crm-theme="dark"] .order-row-actions .btn {
    border-color: #40536c !important;
    background: #172033 !important;
    color: #bfdbfe !important;
}

html[data-crm-theme="dark"] .order-row-actions .btn:hover {
    border-color: #60a5fa !important;
    background: #1e3a5f !important;
    color: #ffffff !important;
}

html[data-crm-theme="dark"] .order-preview-fact--money {
    border-color: #166534 !important;
    background: #112a20 !important;
}

html[data-crm-theme="dark"] .order-preview-fact--money.has-balance {
    border-color: #92400e !important;
    background: #33240f !important;
}

html[data-crm-theme="dark"] .order-preview-fact--money.has-balance strong,
html[data-crm-theme="dark"] .order-preview-balance {
    color: #fdba74 !important;
}

html[data-crm-theme="dark"] .order-preview-customer-type--client {
    border-color: #1d4ed8 !important;
    background: #172554 !important;
    color: #bfdbfe !important;
}

html[data-crm-theme="dark"] .order-preview-customer-type--contractor {
    border-color: #6d28d9 !important;
    background: #2e1f53 !important;
    color: #ddd6fe !important;
}

/* Order workspace */
html[data-crm-theme="dark"] .order-edit-head,
html[data-crm-theme="dark"] .order-edit-work-card,
html[data-crm-theme="dark"] .order-edit-section,
html[data-crm-theme="dark"] .order-edit-sidebar__section,
html[data-crm-theme="dark"] .order-status-workflow,
html[data-crm-theme="dark"] .order-detail-item,
html[data-crm-theme="dark"] .order-edit-event,
html[data-crm-theme="dark"] .order-sidebar-disclosure__content,
html[data-crm-theme="dark"] .order-create-card,
html[data-crm-theme="dark"] .order-create-submitbar,
html[data-crm-theme="dark"] .order-create-device-summary,
html[data-crm-theme="dark"] .order-create-device-details,
html[data-crm-theme="dark"] .order-create-payment-card {
    border-color: var(--border) !important;
    background: var(--surface) !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .order-workspace-toolbar {
    border-color: var(--border) !important;
    background: #111827 !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .order-workspace-savebar {
    border-color: var(--border) !important;
    background: rgba(17, 24, 39, 0.97) !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .order-workspace-toolbar__context,
html[data-crm-theme="dark"] .order-status-workflow__primary {
    border-color: var(--border) !important;
}

html[data-crm-theme="dark"] .order-workspace-toolbar__context strong,
html[data-crm-theme="dark"] .order-edit-section__title,
html[data-crm-theme="dark"] .order-edit-sidebar__title {
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .order-workspace-tab {
    color: var(--text-muted) !important;
}

html[data-crm-theme="dark"] .order-workspace-tab:hover {
    border-color: var(--border) !important;
    background: #1e293b !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .order-workspace-tab.is-active {
    border-color: #3b82f6 !important;
    background: #172554 !important;
    color: #93c5fd !important;
}

html[data-crm-theme="dark"] .order-workspace-tab__value,
html[data-crm-theme="dark"] .order-edit-head__finance-item,
html[data-crm-theme="dark"] .order-status-workflow__current,
html[data-crm-theme="dark"] .crm-js .order-edit-workspace:not(.is-initialized) .order-workspace-loading {
    border-color: var(--border) !important;
    background: var(--surface-muted) !important;
}

html[data-crm-theme="dark"] .order-edit-head__status,
html[data-crm-theme="dark"] .order-edit-head__status-chip {
    border-color: #40536c !important;
    background: #1e293b !important;
    color: #cbd5e1 !important;
}

html[data-crm-theme="dark"] .order-edit-head__status--inspection,
html[data-crm-theme="dark"] .order-edit-head__status--new,
html[data-crm-theme="dark"] .order-edit-head__status-chip--current {
    border-color: #3b82f6 !important;
    background: #172554 !important;
    color: #bfdbfe !important;
}

html[data-crm-theme="dark"] .order-edit-head__status--coordinate,
html[data-crm-theme="dark"] .order-edit-head__status--in_progress,
html[data-crm-theme="dark"] .order-edit-head__status--done,
html[data-crm-theme="dark"] .order-edit-head__status--adopted_from_asc,
html[data-crm-theme="dark"] .order-edit-head__status--issued_to_client,
html[data-crm-theme="dark"] .order-edit-head__status-chip--done {
    border-color: #15803d !important;
    background: #123021 !important;
    color: #86efac !important;
}

html[data-crm-theme="dark"] .order-edit-head__status--on_coordination,
html[data-crm-theme="dark"] .order-edit-head__status--need_detail,
html[data-crm-theme="dark"] .order-edit-head__status--wait_asc {
    border-color: #b45309 !important;
    background: #35270f !important;
    color: #fde68a !important;
}

html[data-crm-theme="dark"] .order-edit-head__status--rejection,
html[data-crm-theme="dark"] .order-edit-head__status-chip--danger {
    border-color: #b91c1c !important;
    background: #35171c !important;
    color: #fca5a5 !important;
}

html[data-crm-theme="dark"] .gj-datepicker [role="right-icon"] button,
html[data-crm-theme="dark"] .input-group-append .btn,
html[data-crm-theme="dark"] .input-group-addon {
    border-color: #3a4b63 !important;
    background: #1e293b !important;
    color: #bfdbfe !important;
}

html[data-crm-theme="dark"] .order-status-workflow__primary-action > form.change-status-form > p {
    border-color: #a16207 !important;
    background: #33240f !important;
    color: #fde68a !important;
}

html[data-crm-theme="dark"] .order-status-workflow__other,
html[data-crm-theme="dark"] .order-status-workflow__danger {
    border-color: var(--border) !important;
}

html[data-crm-theme="dark"] .order-status-workflow__other > summary {
    color: #cbd5e1 !important;
}

html[data-crm-theme="dark"] .order-status-workflow__alternative-list > .btn,
html[data-crm-theme="dark"] .order-status-workflow__alternative-list > form.change-status-form > .btn {
    border-color: #3a4b63 !important;
    background: #172033 !important;
    color: #cbd5e1 !important;
}

html[data-crm-theme="dark"] .order-edit-section .form-control,
html[data-crm-theme="dark"] .order-edit-section input,
html[data-crm-theme="dark"] .order-edit-section select,
html[data-crm-theme="dark"] .order-edit-section textarea {
    border-color: #3a4b63 !important;
    background: #0f172a !important;
    color: var(--text) !important;
}

/* Bulk intake and warehouse/catalog workspaces */
html[data-crm-theme="dark"] .bulk-create-context,
html[data-crm-theme="dark"] .bulk-create-panel,
html[data-crm-theme="dark"] .bulk-create-workspace-sticky,
html[data-crm-theme="dark"] .bulk-order-row,
html[data-crm-theme="dark"] .bulk-create-footer,
html[data-crm-theme="dark"] .bulk-paste-panel__content,
html[data-crm-theme="dark"] .warehouse-workspace-nav,
html[data-crm-theme="dark"] .warehouse-workspace-subnav,
html[data-crm-theme="dark"] .warehouse-item-edit-form,
html[data-crm-theme="dark"] .invoice-item-row,
html[data-crm-theme="dark"] .invoice-workspace,
html[data-crm-theme="dark"] .order-detail-catalog-modal .modal-content,
html[data-crm-theme="dark"] .order-detail-catalog__header,
html[data-crm-theme="dark"] .order-detail-catalog__body,
html[data-crm-theme="dark"] .order-detail-catalog__footer,
html[data-crm-theme="dark"] .order-detail-catalog__filter,
html[data-crm-theme="dark"] .order-detail-catalog__searchbar,
html[data-crm-theme="dark"] .order-detail-catalog-item,
html[data-crm-theme="dark"] .order-detail-catalog__empty {
    border-color: var(--border) !important;
    background: var(--surface) !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .bulk-order-row.checked,
html[data-crm-theme="dark"] .bulk-order-row.not_checked,
html[data-crm-theme="dark"] .bulk-order-row.has-error,
html[data-crm-theme="dark"] .order-detail-catalog__body,
html[data-crm-theme="dark"] .order-detail-catalog-item.is-unavailable {
    background: var(--surface-muted) !important;
}

html[data-crm-theme="dark"] .bulk-order-row__device-name,
html[data-crm-theme="dark"] .bulk-create-progress,
html[data-crm-theme="dark"] .order-detail-catalog__kind,
html[data-crm-theme="dark"] .order-detail-catalog-item__badge.is-cost {
    border-color: var(--border) !important;
    background: #1e293b !important;
    color: #cbd5e1 !important;
}

/* Profile, chat and secondary panels */
html[data-crm-theme="dark"] .profile-info-item,
html[data-crm-theme="dark"] .profile-file-control,
html[data-crm-theme="dark"] .chat-thread,
html[data-crm-theme="dark"] .chat-composer,
html[data-crm-theme="dark"] .chat-composer__input-wrap,
html[data-crm-theme="dark"] .chat-message,
html[data-crm-theme="dark"] .order-edit-events__empty,
html[data-crm-theme="dark"] .related-order-candidates,
html[data-crm-theme="dark"] .related-order-history,
html[data-crm-theme="dark"] .related-order-candidate {
    border-color: var(--border) !important;
    background: var(--surface-muted) !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .chat-scroll,
html[data-crm-theme="dark"] .order-sidebar-disclosure .chat-composer,
html[data-crm-theme="dark"] .order-sidebar-disclosure .chat-composer__previews {
    border-color: var(--border) !important;
    background: #0f172a !important;
    color: var(--text) !important;
    box-shadow: none !important;
}

html[data-crm-theme="dark"] .order-chat-tabs .nav-link {
    color: var(--text-muted) !important;
}

html[data-crm-theme="dark"] .order-chat-tabs .nav-link.active,
html[data-crm-theme="dark"] .order-chat-tabs .nav-item.show .nav-link {
    background: #17324d !important;
    color: #7dd3fc !important;
    box-shadow: inset 0 0 0 1px #27577c !important;
}

html[data-crm-theme="dark"] .chat-bubble--other,
html[data-crm-theme="dark"] .chat-bubble--other::after {
    border-color: #3a4b63 !important;
    background: #1e293b !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .chat-bubble--mine,
html[data-crm-theme="dark"] .chat-bubble--mine::after {
    background: #17472d !important;
    color: #dcfce7 !important;
}

/* Current order stage */
html[data-crm-theme="dark"] .order-status-workflow__badge {
    border-color: #3b5ccc !important;
    background: #172554 !important;
    color: #bfdbfe !important;
}

html[data-crm-theme="dark"] .order-status-workflow--on_coordination .order-status-workflow__badge,
html[data-crm-theme="dark"] .order-status-workflow--need_detail .order-status-workflow__badge,
html[data-crm-theme="dark"] .order-status-workflow--wait_asc .order-status-workflow__badge {
    border-color: #b45309 !important;
    background: #33240f !important;
    color: #fde68a !important;
}

html[data-crm-theme="dark"] .order-status-workflow--coordinate .order-status-workflow__badge,
html[data-crm-theme="dark"] .order-status-workflow--in_progress .order-status-workflow__badge,
html[data-crm-theme="dark"] .order-status-workflow--done .order-status-workflow__badge,
html[data-crm-theme="dark"] .order-status-workflow--adopted_from_asc .order-status-workflow__badge {
    border-color: #15803d !important;
    background: #112a20 !important;
    color: #bbf7d0 !important;
}

html[data-crm-theme="dark"] .order-status-workflow--rejection .order-status-workflow__badge {
    border-color: #b91c1c !important;
    background: #35171c !important;
    color: #fecaca !important;
}

/* External shipment form */
html[data-crm-theme="dark"] .shipment-step-body,
html[data-crm-theme="dark"] .shipment-selected-panel__head {
    border-color: var(--border) !important;
}

html[data-crm-theme="dark"] .shipment-step-head p,
html[data-crm-theme="dark"] .shipment-bulk-panel__head small,
html[data-crm-theme="dark"] .shipment-selected-panel__head small,
html[data-crm-theme="dark"] .shipment-form-summary small {
    color: var(--text-muted) !important;
}

html[data-crm-theme="dark"] .shipment-step-number,
html[data-crm-theme="dark"] .shipment-form-summary__icon {
    background: #172554 !important;
    color: #93c5fd !important;
}

html[data-crm-theme="dark"] .shipment-required-badge {
    border-color: #1d4ed8 !important;
    background: #172554 !important;
    color: #bfdbfe !important;
}

html[data-crm-theme="dark"] .shipment-optional-badge {
    border-color: var(--border) !important;
    background: #1e293b !important;
    color: #cbd5e1 !important;
}

html[data-crm-theme="dark"] .shipment-mode-switch {
    border-color: var(--border) !important;
    background: #0f172a !important;
}

html[data-crm-theme="dark"] .shipment-mode-switch__button {
    color: var(--text-muted) !important;
}

html[data-crm-theme="dark"] .shipment-mode-switch__button:hover {
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .shipment-mode-switch__button.is-active {
    background: #1e293b !important;
    color: #93c5fd !important;
    box-shadow: inset 0 0 0 1px #40536c !important;
}

html[data-crm-theme="dark"] .shipment-selected-panel,
html[data-crm-theme="dark"] .shipment-selected-panel__head,
html[data-crm-theme="dark"] .shipment-form-actions {
    border-color: var(--border) !important;
    background: rgba(17, 24, 39, 0.97) !important;
    color: var(--text) !important;
}

html[data-crm-theme="dark"] .shipment-device-results,
html[data-crm-theme="dark"] .shipment-selected-list {
    border-color: var(--border) !important;
    background: #0f172a !important;
}

html[data-crm-theme="dark"] .shipment-device-result,
html[data-crm-theme="dark"] .shipment-selected-row {
    border-color: var(--border) !important;
    background: #111827 !important;
}

html[data-crm-theme="dark"] .shipment-device-result:hover,
html[data-crm-theme="dark"] .shipment-device-results__empty {
    background: #1e293b !important;
}

html[data-crm-theme="dark"] .shipment-selected-empty,
html[data-crm-theme="dark"] .shipment-form-summary p {
    color: var(--text-muted) !important;
}

html[data-crm-theme="dark"] .shipment-pdf-file,
html[data-crm-theme="dark"] .shipment-selected-panel__head span {
    border-color: var(--border) !important;
    background: #1e293b !important;
    color: #cbd5e1 !important;
}

html[data-crm-theme="dark"] .shipment-device-meta {
    color: #94a3b8 !important;
}

html[data-crm-theme="dark"] .shipment-device-meta strong {
    color: #cbd5e1 !important;
}

html[data-crm-theme="dark"] .shipment-selected-panel__error {
    border-color: #b91c1c !important;
    background: #35171c !important;
}

html[data-crm-theme="dark"] .shipment-document-disclosure__summary:hover {
    background: #172033 !important;
}

/* Dashboard */
html[data-crm-theme="dark"] .task-deadline-panel,
html[data-crm-theme="dark"] .task-deadline-card,
html[data-crm-theme="dark"] .dashboard-board,
html[data-crm-theme="dark"] .dashboard-column,
html[data-crm-theme="dark"] .kanban-column,
html[data-crm-theme="dark"] .kanban-card {
    border-color: var(--border) !important;
    background: var(--surface) !important;
    color: var(--text) !important;
}

/* Alerts keep semantic color but avoid bright backgrounds. */
html[data-crm-theme="dark"] .alert-info {
    border-color: #1d4ed8 !important;
    background: #172554 !important;
    color: #bfdbfe !important;
}

html[data-crm-theme="dark"] .alert-success {
    border-color: #15803d !important;
    background: #112a20 !important;
    color: #bbf7d0 !important;
}

html[data-crm-theme="dark"] .alert-warning {
    border-color: #b45309 !important;
    background: #33240f !important;
    color: #fde68a !important;
}

html[data-crm-theme="dark"] .alert-danger {
    border-color: #b91c1c !important;
    background: #35171c !important;
    color: #fecaca !important;
}

html[data-crm-theme="dark"] .close {
    color: #cbd5e1 !important;
    text-shadow: none !important;
}

html[data-crm-theme="dark"] .crm-task-menu__item.is-overdue {
    background: #33240f !important;
}

html[data-crm-theme="dark"] .task-bucket-tab.is-active {
    background: var(--primary-soft) !important;
}

html[data-crm-theme="dark"] .task-assignee-filter {
    border-color: var(--border) !important;
    background: var(--surface) !important;
}

html[data-crm-theme="dark"] .task-linked-order,
html[data-crm-theme="dark"] .order-task-panel__item,
html[data-crm-theme="dark"] .order-task-panel__empty {
    border-color: var(--border) !important;
    background: var(--surface-muted) !important;
}

html[data-crm-theme="dark"] .task-linked-order__icon,
html[data-crm-theme="dark"] .order-task-panel__count {
    background: var(--primary-soft) !important;
}

html[data-crm-theme="dark"] .task-board-preview-panel,
html[data-crm-theme="dark"] .task-board-preview-column__head,
html[data-crm-theme="dark"] .task-board-form-note {
    border-color: var(--border) !important;
    background: var(--surface) !important;
}

html[data-crm-theme="dark"] .task-board-preview-column {
    border-color: var(--border) !important;
    background: var(--surface-muted) !important;
}

html[data-crm-theme="dark"] .task-board-form-note > span {
    background: #112a20 !important;
}

@media print {
    html[data-crm-theme="dark"] {
        color-scheme: light;
        --bg: #ffffff;
        --surface: #ffffff;
        --surface-muted: #ffffff;
        --border: #d1d5db;
        --text: #000000;
        --text-muted: #374151;
    }

    html[data-crm-theme="dark"] body,
    html[data-crm-theme="dark"] .main-content,
    html[data-crm-theme="dark"] .card,
    html[data-crm-theme="dark"] .card-body,
    html[data-crm-theme="dark"] .table,
    html[data-crm-theme="dark"] table,
    html[data-crm-theme="dark"] tr,
    html[data-crm-theme="dark"] td,
    html[data-crm-theme="dark"] th {
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
    }
}
