/*
 * Overlays: Bootstrap modals, tooltips/popovers and Notyf toasts on the shared tokens.
 * SweetAlert2 dialogs are styled by css/swal-theme.css (tagged .cd-swal by js/swal-theme.js).
 *
 * Modal anatomy (every modal): header = title (+ optional .ui-modal-subtitle) + close;
 * body on the surface colour with 20px padding; footer = secondary left of primary, right aligned.
 */

/* ---------- Modals ---------- */
.modal-content {
    border: 0;
    border-radius: var(--ui-radius);
    background-color: var(--ui-surface);
    box-shadow: var(--ui-shadow-pop);
}

/* Dropdowns (select pickers, autocomplete) may open past the dialog edge, so the content does not clip;
   its first and last sections carry the rounded corners instead. Scrollable dialogs keep Bootstrap's
   overflow: hidden, which their scrolling body needs. */
.modal-content > :first-child {
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
}

.modal-content > :last-child {
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}

.modal-dialog-scrollable .modal-content {
    overflow: hidden;
}

/* Split dialogs (order / product dialog with a history panel beside it): the wrapper is see-through,
   so it casts no shadow of its own; each panel is a raised surface instead */
.modal-content.ui-modal-split {
    background: transparent;
    box-shadow: none;
}

.ui-modal-split .open-order-modal-panel,
.ui-modal-split .ui-timeline-card {
    box-shadow: var(--ui-shadow-pop);
}

.ui-modal-split .open-order-modal-panel {
    border-radius: var(--ui-radius);
}

.modal-header {
    align-items: flex-start;
    gap: var(--ui-space-3);
    padding: 16px 20px;
    background: var(--ui-surface);
    border-bottom: 1px solid var(--ui-border);
}

.modal-title {
    display: flex;
    align-items: center;
    gap: var(--ui-space-2);
    font-size: var(--ui-fs-lg);
    font-weight: 700;
    line-height: 1.35;
    color: var(--ui-text);
}

.modal-title > :is(i, svg):first-child {
    color: var(--ui-faint);
    font-size: .9em;
}

.ui-modal-subtitle {
    display: block;
    margin: 2px 0 0;
    font-size: var(--ui-fs-sm);
    font-weight: 400;
    color: var(--ui-muted);
}

.modal-header .btn-close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    margin: -4px -6px -4px auto;
    padding: 0;
    border-radius: var(--ui-radius-sm);
    background-size: 12px;
    opacity: .55;
    transition: opacity var(--ui-ease), background-color var(--ui-ease);
}

.modal-header .btn-close:hover {
    opacity: .9;
    background-color: var(--ui-subtle);
}

.modal-body {
    padding: 20px;
    background-color: var(--ui-surface);
    color: var(--ui-body);
}

.modal-footer {
    gap: var(--ui-space-2);
    padding: 12px 20px;
    background: var(--ui-surface);
    border-top: 1px solid var(--ui-border);
}

.modal-footer > * {
    margin: 0;
}

/* Sections inside a modal body: a quiet subtle panel instead of a floating card */
.modal-body .ui-modal-section {
    padding: var(--ui-space-4);
    border-radius: var(--ui-radius);
    background: var(--ui-subtle);
}

.modal-body .ui-modal-section + .ui-modal-section {
    margin-top: var(--ui-space-3);
}

.modal-body .form-label,
.modal-body label.form-label {
    font-size: var(--ui-fs-sm);
    font-weight: 600;
    color: var(--ui-text);
    margin-bottom: 6px;
}

/* ---------- Tooltips ---------- */
.tooltip {
    --bs-tooltip-bg: var(--ui-tooltip-bg);
    --bs-tooltip-color: var(--ui-tooltip-text);
    --bs-tooltip-max-width: 280px;
    --bs-tooltip-padding-x: 10px;
    --bs-tooltip-padding-y: 7px;
    --bs-tooltip-border-radius: var(--ui-radius-sm);
    --bs-tooltip-font-size: .75rem;
    --bs-tooltip-opacity: 1;
}

.tooltip-inner {
    text-align: left;
    line-height: 1.45;
    box-shadow: var(--ui-shadow-pop);
}

/* ---------- Popovers ---------- */
.popover {
    --bs-popover-border-color: var(--ui-border);
    --bs-popover-border-radius: var(--ui-radius);
    --bs-popover-bg: var(--ui-surface);
    --bs-popover-header-bg: var(--ui-surface);
    --bs-popover-body-color: var(--ui-body);
    --bs-popover-font-size: var(--ui-fs-sm);
    box-shadow: var(--ui-shadow-pop);
}

/* ---------- Toasts (Notyf) ---------- */
.notyf__toast {
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow-pop);
    max-width: 380px;
}

.notyf__wrapper {
    padding: 12px 4px;
}

.notyf__message {
    font-size: var(--ui-fs-base);
    font-weight: 500;
    line-height: 1.45;
}

.notyf__dismiss-btn {
    border-radius: 0 var(--ui-radius) var(--ui-radius) 0;
}

/* ---------- Scan confirm dialog (pack screen): big product image, title, what will be added, two big buttons ---------- */
.ui-scan-confirm {
    max-width: 480px;
}

.ui-scan-confirm__image {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: min(52vh, 340px);
    padding: 12px 12px 16px;
    border-bottom: 1px solid var(--ui-border);
    background: var(--ui-surface);
}

.ui-scan-confirm__image img {
    display: block;
    width: 100%;
    max-width: 100%;
    max-height: min(52vh, 360px);
    height: auto;
    object-fit: contain;
}

.ui-scan-confirm__details {
    padding: 16px 20px 4px;
    text-align: center;
}

.ui-scan-confirm__title {
    margin: 0 0 6px;
    color: var(--ui-text);
    font-size: var(--ui-fs-md);
    font-weight: 600;
    line-height: 1.45;
}

.ui-scan-confirm__meta {
    margin: 0 0 12px;
    color: var(--ui-muted);
    font-size: var(--ui-fs-sm);
}

.ui-scan-confirm__stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 12px;
}

.ui-scan-confirm__progress {
    color: var(--ui-muted);
    font-size: var(--ui-fs-sm);
}

.ui-scan-confirm__progress strong {
    color: var(--ui-text);
}

.ui-scan-confirm .modal-footer .btn {
    flex: 1 1 0;
    min-height: 48px;
}

@media (max-width: 575.98px) {
    .ui-scan-confirm .modal-footer {
        flex-direction: column-reverse;
    }
}

@media (max-width: 575.98px) {
    .modal-header .modal-title {
        font-size: var(--ui-fs-md);
    }
}

/* ---------- jQuery UI autocomplete (product search in new order, order dialogs, transfers) ---------- */
.ui-autocomplete.ui-menu {
    padding: 6px;
    border: 1px solid var(--ui-border) !important;
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow-pop);
    max-height: 420px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1060;
}

.ui-autocomplete.ui-menu .ui-menu-item-wrapper {
    border: 0 !important;
    border-radius: var(--ui-radius-sm);
    margin: 0 !important;
}

.ui-autocomplete.ui-menu .ui-menu-item-wrapper.ui-state-active {
    background: var(--ui-subtle) !important;
    color: var(--ui-text) !important;
}

/* Footer actions share one height (a small Cancel next to a large primary looked uneven) */
.modal-footer > .btn,
.modal-footer > * > .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--ui-control-h);
    padding-top: 0;
    padding-bottom: 0;
}

/* Phones: footer buttons share the row; a button that wraps takes the full width, so two actions
   never sit stacked at different widths */
@media (max-width: 575.98px) {
    .modal-footer {
        flex-wrap: wrap;
    }

    .modal-footer > .btn {
        flex: 1 1 auto;
        margin-left: 0;
        margin-right: 0;
    }
}

/* Menus lifted to <body> by cd-ui.js (they were cut off by a card or tab pane): above modals */
.dt-button-collection.ui-menu-lifted {
    z-index: 1090;
}

/* Top-bar menus on phones: Bootstrap places navbar menus without Popper (right-aligned to their toggle),
   so a wide menu under a toggle near the middle ran off the left edge. Pin them inside the screen. */
@media (max-width: 575.98px) {
    .navbar .navbar-nav .dropdown-menu.show {
        position: fixed;
        left: 8px;
        right: 8px;
        width: auto;
        max-width: none;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }
}

/* Product dialog: white cards on a white body with hairlines read as one flat sheet. The body takes the page
   grey and the cards lift off it exactly like on a page; labels one step darker so they read at a glance. */
#productModal .modal-body {
    background-color: var(--ui-page);
}
#productModal .modal-body .card {
    background-color: var(--ui-surface);
    border-color: transparent !important;
    box-shadow: var(--ui-shadow);
}
#productModal :is(.product-spec-label, .product-kpi-label) {
    color: var(--ui-body);
}
#productModal .product-spec-row :is(.product-spec-value, strong) {
    color: var(--ui-text);
}
#productModal .modal-body thead th {
    color: var(--ui-body);
}

/* Seller detail dialog (FC → Sellers): same calm look as the product dialog. Cards lift off a page-grey body,
   KPI tiles are a label, a number and a short caption, user info stays label | value on phones too. */
#sellerDetailModal .modal-body {
    background-color: var(--ui-page);
}
#sellerDetailModal .modal-body :is(.card, .accordion-item) {
    background-color: var(--ui-surface);
    border: 0 !important;
    border-radius: var(--ui-radius) !important;
    box-shadow: var(--ui-shadow) !important;
    overflow: hidden;
}
#sellerDetailModal .modal-body .accordion {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#sellerDetailModal .seller-detail-modal-kpis .card-header {
    padding: 14px 16px 0 !important;
    border-bottom: 0;
    background: transparent;
}
#sellerDetailModal .seller-detail-modal-kpis .card-header h6 {
    font-size: .8rem;
    font-weight: 600 !important;
    color: var(--ui-muted);
}
#sellerDetailModal .seller-detail-modal-kpis .card-body {
    padding: 6px 16px 14px !important;
}
#sellerDetailModal .seller-detail-modal-kpis :is(.seller-kpi-value, .seller-kpi-sla-percent) {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ui-text);
}
#sellerDetailModal .seller-detail-modal-kpis .seller-kpi-value-secondary,
#sellerDetailModal .seller-detail-modal-kpis .seller-kpi-compare-slash {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ui-muted);
}
#sellerDetailModal .seller-detail-modal-kpis .seller-kpi-hint {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: .75rem;
    line-height: 1.4;
}
#sellerDetailModal .seller-detail-modal-kpis .seller-kpi-api-errors-row {
    margin-top: 8px;
}
#sellerDetailModal .seller-detail-modal-kpis .seller-kpi-api-errors-btn {
    padding: 6px 10px;
    border: 0;
    background: var(--ui-subtle);
}
#sellerDetailModal .seller-detail-modal-overview .card-header,
#sellerDetailModal .seller-detail-modal-overview .accordion-button {
    background: transparent;
}
#sellerDetailModal .seller-detail-modal-overview .card-header h6,
#sellerDetailModal .seller-detail-modal-overview .accordion-button {
    font-size: .95rem;
    font-weight: 600;
    color: var(--ui-text);
}
#sellerDetailModal .seller-detail-modal-overview .card + .card {
    margin-top: 12px;
}
#sellerDetailModal .seller-info-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}
#sellerDetailModal .seller-info-label {
    flex: 0 0 auto;
    color: var(--ui-muted);
}
#sellerDetailModal .seller-info-value {
    min-width: 0;
    text-align: right;
    overflow-wrap: anywhere;
    color: var(--ui-text);
    font-weight: 500;
}
@media (max-width: 575.98px) {
    #sellerDetailModal .seller-detail-modal-kpis {
        --bs-gutter-x: 10px;
        --bs-gutter-y: 10px;
    }
    #sellerDetailModal .seller-detail-modal-kpis .card-header {
        padding: 12px 12px 0 !important;
    }
    #sellerDetailModal .seller-detail-modal-kpis .card-body {
        padding: 4px 12px 12px !important;
    }
    #sellerDetailModal .seller-detail-modal-kpis .card-header h6 {
        font-size: .75rem;
    }
    #sellerDetailModal .seller-kpi-sla-window-badge {
        font-size: .65rem;
    }
}

/* Seller detail dialog, calmer: rows separated by space instead of a line each, quiet labels, one-line KPI
   captions, plain section heads, the API log as a link */
#sellerDetailModal :is(.seller-info-item, .seller-setting-item) {
    border-bottom: 0 !important;
    padding: 7px 0;
}
#sellerDetailModal .seller-info-label {
    min-width: 0;
    font-weight: 400;
    color: var(--ui-muted);
}
#sellerDetailModal .seller-detail-modal-overview .card-header,
#sellerDetailModal .seller-detail-modal-overview .accordion-button {
    border-bottom: 0 !important;
    padding-bottom: 4px;
    box-shadow: none !important;
}
#sellerDetailModal .seller-detail-modal-overview .card-body,
#sellerDetailModal .seller-detail-modal-overview .accordion-body {
    padding-top: 4px;
}
#sellerDetailModal .seller-setting-label {
    color: var(--ui-text);
}
#sellerDetailModal .seller-detail-modal-kpis .seller-kpi-api-errors-row {
    margin-top: 6px;
    padding-top: 0;
    border-top: 0;
}
#sellerDetailModal .seller-detail-modal-kpis .seller-kpi-api-errors-btn {
    width: auto !important;
    padding: 0;
    background: transparent !important;
    color: var(--ui-link, var(--ui-primary));
    gap: 4px !important;
    justify-content: flex-start !important;
}
#sellerDetailModal .seller-detail-modal-kpis .seller-kpi-api-errors-btn .seller-kpi-api-errors-label {
    color: inherit !important;
    font-weight: 600;
}
#sellerDetailModal .seller-detail-modal-kpis .seller-kpi-api-errors-btn:disabled {
    display: none !important;
}
#sellerDetailModal .seller-profiles-head {
    display: block;
    margin: 4px 0 8px;
}
#sellerDetailModal .seller-profiles-head h3 {
    margin-bottom: 4px;
    font-size: 1.05rem;
}
#sellerDetailModal .seller-profiles-head p {
    max-width: 70ch;
    font-size: .82rem;
}
#sellerDetailModal .card-header:has(.seller-profiles-head) {
    border-bottom: 0;
}
#sellerDetailModal .card-header:has(.seller-profiles-head) .form-label {
    margin-bottom: 4px !important;
    font-size: .78rem;
    color: var(--ui-muted);
}
#sellerDetailModal .seller-detail-modal-overview .accordion-body {
    padding-top: 10px;
}
#sellerDetailModal .seller-detail-modal-overview .card-body {
    padding-top: 8px;
}
#sellerDetailModal .seller-profiles-head p {
    max-width: 100ch;
}
#sellerDetailModal #custom_seller_settings:empty {
    display: none;
}
#sellerDetailModal .seller-detail-modal-overview .accordion-button {
    padding-bottom: 12px;
}
body[data-theme=dark] #sellerDetailModal .accordion-button::after {
    filter: invert(1) brightness(1.4);
}

/* Seller dialog → user information as a contact card: who on top, then e-mail and phone as tappable rows */
#sellerDetailModal .seller-contact {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
#sellerDetailModal .seller-contact__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
#sellerDetailModal .seller-contact__avatar {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--ui-primary-tint);
    color: var(--ui-primary);
    font-weight: 700;
    font-size: .95rem;
}
#sellerDetailModal .seller-contact__who {
    min-width: 0;
}
#sellerDetailModal .seller-contact__name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ui-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#sellerDetailModal .seller-contact__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 6px;
    font-size: .82rem;
    color: var(--ui-muted);
}
#sellerDetailModal .seller-contact__row {
    display: grid;
    grid-template-columns: 20px auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    margin: 0 -10px;
    border-radius: var(--ui-radius-md);
    color: var(--ui-text);
    text-decoration: none;
}
#sellerDetailModal .seller-contact__row:hover,
#sellerDetailModal .seller-contact__row:focus-visible {
    background: var(--ui-subtle);
}
#sellerDetailModal .seller-contact__row > i {
    color: var(--ui-muted);
    text-align: center;
}
#sellerDetailModal .seller-contact__label {
    color: var(--ui-muted);
    font-size: .85rem;
}
#sellerDetailModal .seller-contact__value {
    min-width: 0;
    text-align: right;
    overflow-wrap: anywhere;
    font-weight: 500;
}
#sellerDetailModal .seller-contact__row:not(.is-empty) .seller-contact__value {
    color: var(--ui-link, var(--ui-primary));
}
#sellerDetailModal .seller-contact__row.is-empty {
    pointer-events: none;
}

/* Seller dialog → shipment method profiles: with no profiles yet the card is the explanation and one empty state
   with its actions (no filters, toolbar or column heads for nothing); with profiles the filters are one tidy row */
#sellerDetailModal .seller-profiles-card.is-pristine .card-header .mt-2,
#sellerDetailModal .seller-profiles-card.is-pristine .card-header .btn-primary,
#sellerDetailModal .seller-profiles-card.is-pristine :is(.dataTables_length, .dt-buttons, .dataTables_info, .dataTables_paginate),
#sellerDetailModal .seller-profiles-card.is-pristine table thead {
    display: none !important;
}
#sellerDetailModal .seller-profiles-card .card-body {
    padding-top: 4px;
}
#sellerDetailModal .seller-profiles-card .empty-state-container {
    min-height: 0;
    padding: 20px 16px 28px;
}
#sellerDetailModal .seller-profiles-empty-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}
#sellerDetailModal .seller-profiles-card:not(.is-pristine) .seller-profiles-empty-actions {
    display: none;
}
#sellerDetailModal .seller-profiles-card .card-header .row.g-2 {
    --bs-gutter-y: 8px;
}
#sellerDetailModal .seller-profiles-card .dataTables_length label {
    font-size: .82rem;
    color: var(--ui-muted);
}
#sellerDetailModal .seller-profiles-card.is-pristine :is(.cd-list-tools, .cd-sort-btn, .cd-list-more) {
    display: none !important;
}
#sellerDetailModal .seller-profiles-card.is-pristine .card-body,
#sellerDetailModal .seller-profiles-card.is-pristine :is(.cd-cards-wrap, .dataTables_wrapper, table, tbody, tr, td) {
    background: var(--ui-surface) !important;
    box-shadow: none !important;
    border: 0 !important;
}
/* settings accordions: the title sits centred in the bar (16/12 padding put it high when collapsed), with an
   icon badge like the other section heads */
#sellerDetailModal .seller-detail-modal-overview .accordion-button {
    min-height: 56px;
    padding: 12px 18px !important;
    align-items: center;
    gap: 12px;
    font-size: .95rem;
}
#sellerDetailModal .seller-detail-modal-overview .accordion-button::before {
    content: "";
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background-color: var(--ui-primary-tint);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 16px;
}
#sellerDetailModal #sellerSettingsAccordionHeading .accordion-button::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23019add' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='4' y1='21' x2='4' y2='14'/%3E%3Cline x1='4' y1='10' x2='4' y2='3'/%3E%3Cline x1='12' y1='21' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12' y2='3'/%3E%3Cline x1='20' y1='21' x2='20' y2='16'/%3E%3Cline x1='20' y1='12' x2='20' y2='3'/%3E%3Cline x1='1' y1='14' x2='7' y2='14'/%3E%3Cline x1='9' y1='8' x2='15' y2='8'/%3E%3Cline x1='17' y1='16' x2='23' y2='16'/%3E%3C/svg%3E");
}
#sellerDetailModal #sellerPricingAccordionHeading .accordion-button::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23019add' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z'/%3E%3Cline x1='7' y1='7' x2='7.01' y2='7'/%3E%3C/svg%3E");
}
#sellerDetailModal .seller-detail-modal-overview .accordion-button::after {
    margin-left: auto;
}

/* Internal seller note in the shared rich editor: the editor reads as a field (one radius, one border) */
#sellerPrivateNoteCard .ck.ck-editor {
    border-radius: var(--ui-radius-md);
}
#sellerPrivateNoteCard .ck.ck-toolbar {
    border-color: var(--ui-border-strong) !important;
    border-radius: var(--ui-radius-md) var(--ui-radius-md) 0 0 !important;
    background: var(--ui-subtle) !important;
}
#sellerPrivateNoteCard .ck.ck-editor__editable {
    min-height: 120px;
    border-color: var(--ui-border-strong) !important;
    border-radius: 0 0 var(--ui-radius-md) var(--ui-radius-md) !important;
    background: var(--ui-surface) !important;
    color: var(--ui-text);
}
#sellerPrivateNoteCard .ck.ck-editor__editable.ck-focused {
    border-color: var(--ui-primary) !important;
    box-shadow: var(--ui-focus-ring) !important;
}
/* Internal seller note: a card like "User information"; the left column stretches to the settings column and
   the note card takes the rest of the height, the editor filling it (toolbar on top, a hairline, the text) */
@media (min-width: 992px) {
    #sellerDetailModal .seller-detail-modal-overview > .col-lg-6:first-child {
        display: flex;
        flex-direction: column;
    }
    #sellerDetailModal #sellerPrivateNoteCard {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        margin-bottom: 0;
    }
    #sellerDetailModal #sellerPrivateNoteCard > .card-body,
    #sellerPrivateNoteCard .ck.ck-editor,
    #sellerPrivateNoteCard .ck.ck-editor__main {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
    }
    #sellerPrivateNoteCard .ck.ck-editor__main > .ck-editor__editable {
        flex: 1 1 auto;
    }
}
#sellerDetailModal #sellerPrivateNoteCard > .card-body {
    padding: 4px 16px 16px !important;
}
#sellerPrivateNoteCard .ck.ck-editor {
    border: 1px solid var(--ui-border-strong);
    border-radius: var(--ui-radius-md);
    overflow: hidden;
}
#sellerPrivateNoteCard .ck.ck-editor__top .ck-sticky-panel__content,
#sellerPrivateNoteCard .ck.ck-toolbar {
    border: 0 !important;
    border-bottom: 1px solid var(--ui-border) !important;
    border-radius: 0 !important;
    background: var(--ui-subtle) !important;
}
#sellerPrivateNoteCard .ck.ck-editor__editable,
#sellerPrivateNoteCard .ck.ck-editor__editable:not(.ck-focused),
#sellerPrivateNoteCard .ck.ck-editor__editable.ck-focused {
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    min-height: 120px;
    padding: 4px 14px !important;
    background: var(--ui-surface) !important;
}
#sellerPrivateNoteCard .ck.ck-editor:focus-within {
    border-color: var(--ui-primary);
    box-shadow: var(--ui-focus-ring);
}
#sellerPrivateNoteCard .ck.ck-button {
    border-radius: 8px !important;
    color: var(--ui-body);
}
#sellerDetailModal .seller-detail-modal-overview > .col-lg-6:first-child {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#sellerDetailModal .seller-detail-modal-overview > .col-lg-6:first-child > .card {
    margin: 0 !important;
}

/* Channel settings dialog: a calm list. No icon circle per row, compact titles, muted one-line-ish help text,
   rows separated by hairlines, the switch centred on its row */
#channelSettingsBody > .mb-3:has(> .d-flex > label.switch) {
    margin: 0 !important;
    padding: 12px 0;
    border-top: 1px solid var(--ui-border);
}
#channelSettingsBody > .mb-3:has(> .d-flex > label.switch):first-of-type,
#channelSettingsBody > :not(.mb-3) + .mb-3:has(> .d-flex > label.switch) {
    border-top: 0;
}
#channelSettingsBody > .mb-3 > .d-flex:has(> label.switch) {
    align-items: center !important;
    gap: 16px;
}
#channelSettingsBody > .mb-3 > .d-flex:has(> label.switch) > .d-flex > i {
    display: none !important;
}
#channelSettingsBody > .mb-3 > .d-flex:has(> label.switch) .form-label {
    font-size: .9rem;
    font-weight: 600 !important;
    color: var(--ui-text);
}
#channelSettingsBody > .mb-3 > .d-flex:has(> label.switch) small.text-muted {
    margin-top: 2px;
    font-size: .8rem;
    line-height: 1.4;
    max-width: 52ch;
}
#channelSettingsBody > .mb-3 > .d-flex > label.switch {
    flex: none;
    margin-left: 0 !important;
}

/* ---------- Dark mode (Graphite) for dialogs and shared widgets ---------- */
/* dialogs that hold cards: the body is the page tone so cards stand off it like on a page */
body[data-theme=dark] .modal-body:has(> .card, > .row .card, .accordion-item, > div > .card) {
    background-color: var(--ui-page) !important;
}
body[data-theme=dark] .modal .accordion-item,
body[data-theme=dark] .modal .accordion-button,
body[data-theme=dark] .modal .accordion-button:not(.collapsed) {
    background-color: var(--ui-surface) !important;
    color: var(--ui-text) !important;
}
body[data-theme=dark] .modal .accordion-item {
    border: 1px solid var(--ui-border) !important;
}
body[data-theme=dark] .accordion-button::after {
    filter: invert(1) brightness(1.4);
}
/* CKEditor everywhere in dark mode: a raised toolbar and a field-coloured writing area with a visible edge */
body[data-theme=dark] .ck.ck-editor__top .ck-sticky-panel__content,
body[data-theme=dark] .ck.ck-toolbar {
    background: var(--ui-track) !important;
    border-color: var(--ui-border-strong) !important;
}
body[data-theme=dark] .ck.ck-toolbar .ck-button,
body[data-theme=dark] .ck.ck-toolbar .ck-button .ck-icon {
    color: var(--ui-body) !important;
}
body[data-theme=dark] .ck.ck-toolbar .ck-button:hover:not(.ck-disabled),
body[data-theme=dark] .ck.ck-toolbar .ck-button.ck-on {
    background: var(--ui-border-strong) !important;
}
body[data-theme=dark] .ck.ck-editor__main > .ck-editor__editable,
body[data-theme=dark] .ck.ck-editor__editable:not(.ck-editor__nested-editable) {
    background: var(--ui-input-bg, #14171b) !important;
    color: var(--ui-text) !important;
    border-color: var(--ui-border-strong) !important;
}
body[data-theme=dark] .ck.ck-editor__editable.ck-focused {
    border-color: var(--ui-primary) !important;
}
body[data-theme=dark] .ck.ck-placeholder::before,
body[data-theme=dark] .ck .ck-placeholder::before {
    color: var(--ui-placeholder) !important;
}
/* channel logos are dark artwork: a small white tile keeps them readable in dark mode */
body[data-theme=dark] img:is([src*="/images/channels/"], [src*="channel_logo"], [src*="/cd_logo/"]):not(.no-logo-tile):not(:is(#sidebar, .sidebar, .navbar, .sidebar-brand, .sidebar-logo) img) {
    background-color: #ffffff;
    border-radius: 6px;
    padding: 3px 5px;
}
html body[data-theme=dark] img:is([src*="/images/channels/"], [src*="channel_logo"], [src*="/cd_logo/"], .pim-channel-logo):not(.no-logo-tile):not(:is(#sidebar, .sidebar, .navbar, .sidebar-brand, .sidebar-logo) img) {
    background-color: #ffffff !important;
    border-radius: 6px;
    padding: 3px 5px;
    opacity: 1 !important;
    filter: none !important;
}
/* Graphite leftovers found by dark_palette_scan.py */
body[data-theme=dark] .page-link {
    background-color: var(--ui-surface) !important;
    border-color: var(--ui-border-strong) !important;
    color: var(--ui-body) !important;
}
body[data-theme=dark] .page-item.disabled .page-link {
    color: var(--ui-faint) !important;
}
body[data-theme=dark] .progress {
    background-color: var(--ui-track) !important;
}
body[data-theme=dark] :is(td, th)[style*="background"],
body[data-theme=dark] table :is(td, th):is([class*="table-"], [bgcolor]) {
    background-color: transparent !important;
}
body[data-theme=dark] .changelog-filter.is-active {
    background-color: var(--ui-primary-tint) !important;
    color: var(--ui-text) !important;
}
body[data-theme=dark] .ui-error-state {
    background-color: var(--ui-surface) !important;
}
body[data-theme=dark] .modal-content.bg-dark {
    background-color: #0e1013 !important;
}
/* Unstyled inputs fall back to the browser's own dark grey (#3b3b3b); zero specificity, so any styled field wins */
:where(body[data-theme=dark]) :where(input:not([type=checkbox], [type=radio], [type=range], [type=color], [type=button], [type=submit], [type=reset], [type=file]), textarea) {
    background-color: var(--cd-surface-input, #14171b);
    border: 1px solid var(--ui-border-strong);
    color: var(--ui-text);
}
/* Bootstrap's .table-light (dist dark.css: #343a4b) becomes the raised Graphite tone */
body[data-theme=dark] .table-light,
body[data-theme=dark] .table-light > :is(th, td),
body[data-theme=dark] :is(thead, tr).table-light > :is(th, td) {
    --bs-table-bg: var(--cd-surface-raised, #262b32);
    --bs-table-color: var(--ui-text);
    --bs-table-border-color: var(--ui-border);
    background-color: var(--cd-surface-raised, #262b32) !important;
    color: var(--ui-text);
}
/* Dark: floating labels are quiet grey above a bright value (brand blue only while the field has focus),
   table text in dialogs is body colour, not muted */
body[data-theme=dark] .form-floating > label,
body[data-theme=dark] .form-floating > label > i {
    color: var(--ui-muted) !important;
    font-weight: 500;
}
body[data-theme=dark] .form-floating > :is(.form-control, .form-select):focus ~ label,
body[data-theme=dark] .form-floating > :is(.form-control, .form-select):focus ~ label > i {
    color: var(--ui-link) !important;
}
body[data-theme=dark] .form-floating > :is(.form-control, .form-select) {
    color: var(--ui-text) !important;
}
body[data-theme=dark] .modal table tbody td {
    color: var(--ui-body);
}
/* Dark: locked (disabled) fields read as locked, like the grey fill in light mode */
body[data-theme=dark] :is(.form-control, .form-select):is(:disabled, [readonly]:not(.hasDatepicker):not([data-datepicker]):not(.cd-daterange__input)) {
    background-color: var(--ui-subtle) !important;
    border-color: var(--ui-border) !important;
}
/* Dark dialogs, from modal_scan.py (every dialog on every route, contrast scoped to the dialog) */
/* floating labels: quiet but readable on cards and on the page tone (muted was 3.8-4.1:1 at 11px) */
body[data-theme=dark] .form-floating > label,
body[data-theme=dark] .form-floating > label > i {
    color: color-mix(in srgb, var(--ui-muted) 45%, var(--ui-body)) !important;
}
/* red buttons: the deeper red from light mode carries white text (3.96 -> 6.4:1) */
html body[data-theme=dark] .btn-danger:not(:disabled) {
    background-color: #b02a37 !important;
    border-color: #b02a37 !important;
    color: #fff !important;
}
html body[data-theme=dark] .btn-danger:not(:disabled):hover {
    background-color: #9a2430 !important;
    border-color: #9a2430 !important;
}
/* brand fills with white text use the strong brand (the dark --ui-primary is lightened for text) */
html body[data-theme=dark] .ui-deliveries .delivery-actions-modal .delivery-action-modal-btn--primary,
html body[data-theme=dark] .pim-wizard-stepper-item.is-active .pim-wizard-stepper-dot,
html body[data-theme=dark] #editedImagePreviewModal .cd-compare-badge-new,
html body[data-theme=dark] .modal .nav-link.active,
html body[data-theme=dark] .modal .badge.badge-primary,
html body[data-theme=dark] .modal .badge.bg-primary {
    background-color: var(--ui-primary-strong) !important;
    border-color: var(--ui-primary-strong) !important;
    color: #fff !important;
}
html body[data-theme=dark] .ui-deliveries .delivery-actions-modal .delivery-action-modal-btn--primary:is(:hover, :focus, :active) {
    background-color: color-mix(in srgb, var(--ui-primary-strong) 88%, #000) !important;
}
/* legacy BS4 pill badges in dialogs (scan dialogs): dark text on the light fills */
html body[data-theme=dark] .modal .badge:is(.badge-info, .bg-info) {
    background-color: #0f6e9e !important;
    color: #fff !important;
}
html body[data-theme=dark] .modal .badge:is(.badge-warning, .bg-warning) {
    background-color: #fbbf24 !important;
    color: #1b1f24 !important;
}
/* links inside dialogs (help links, "fix" buttons) */
html body[data-theme=dark] .modal-body a:not(.btn):not(.badge):not(.nav-link):not(.dropdown-item):not(.list-group-item):not(.page-link),
html body[data-theme=dark] .msm-fix-bar .msm-fix-btn,
html body[data-theme=dark] .cd-import-guide-link {
    color: var(--ui-link) !important;
}
html body[data-theme=dark] .msm-fix-bar .msm-fix-label,
html body[data-theme=dark] .return-attachments-empty-hint {
    color: var(--ui-muted) !important;
}
/* soft brand badges and step numbers: lighter brand text on the brand tint (4.25 -> AA) */
html body[data-theme=dark] :is(.badge.badge-soft-primary, .badge.badge-soft-info, .fbc-howto-step, .pim-price-import-step-index) {
    color: color-mix(in srgb, var(--primary-brand, #0077ff) 55%, #fff) !important;
}
/* second modal_scan pass */
html body[data-theme=dark] .alert.alert-dark {
    background-color: var(--cd-surface-raised, #262b32) !important;
    border: 1px solid var(--ui-border) !important;
    color: var(--ui-body) !important;
}
html body[data-theme=dark] .alert.alert-dark a {
    color: var(--ui-link) !important;
}
html body[data-theme=dark] .page-item.active .page-link {
    background-color: var(--ui-primary-strong) !important;
    border-color: var(--ui-primary-strong) !important;
    color: #fff !important;
}
html body[data-theme=dark] .cd-required,
html body[data-theme=dark] .text-danger:not(.btn) {
    color: var(--ui-danger) !important;
}
html body[data-theme=dark] .msm-fix-bar .msm-fix-label,
html body[data-theme=dark] .method-checkbox-wrapper label.btn {
    color: var(--ui-body) !important;
}
html body[data-theme=dark] .ui-deliveries .delivery-actions-modal .delivery-action-modal-btn--primary .delivery-action-item__hint {
    color: #fff !important;
}
html body[data-theme=dark] .cd-import-chip {
    color: color-mix(in srgb, var(--primary-brand, #0077ff) 55%, #fff) !important;
}
