:root {
    --mp-accent: #68717d;
    --mp-accent-strong: #343b44;
    --mp-soft: #f1f3f5;
    --mp-soft-strong: #e5e8ec;
    --mp-border: #d6dbe2;
    --mp-ring: rgba(104, 113, 125, .18);
    --mp-on-accent: #ffffff;
}

/* V381: one restrained colour language across the whole application. */
body[data-marketplace-theme="ozon"] {
    --mp-accent: #1769e8;
    --mp-accent-strong: #0d56c8;
    --mp-soft: #eef5ff;
    --mp-soft-strong: #dfeeff;
    --mp-border: #b9d3fb;
    --mp-ring: rgba(23, 105, 232, .17);
    --mp-on-accent: #ffffff;
}
body[data-marketplace-theme="wildberries"] {
    --mp-accent: #874497;
    --mp-accent-strong: #713680;
    --mp-soft: #f6eff8;
    --mp-soft-strong: #eedff2;
    --mp-border: #ddc9e4;
    --mp-ring: rgba(135, 68, 151, .17);
    --mp-on-accent: #ffffff;
}
body[data-marketplace-theme="yandex"] {
    --mp-accent: #c49b00;
    --mp-accent-strong: #816700;
    --mp-soft: #fff9dc;
    --mp-soft-strong: #fff1ad;
    --mp-border: #ead573;
    --mp-ring: rgba(196, 155, 0, .18);
    --mp-on-accent: #211b00;
}

/* A slim colour line identifies the marketplace without repainting the page. */
body[data-marketplace-theme] .page-container > :is(
    .products-modern-hero,
    .orders-modern-hero,
    .pricing-page-header,
    .pricing-heading,
    .promotion-hero,
    .product-card-header,
    .marketplace-warehouse-hero,
    .page-hero,
    .content-hero
) {
    border-top: 3px solid var(--mp-accent) !important;
}

body[data-marketplace-theme] :is(
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea,
    [contenteditable="true"]
):focus {
    border-color: var(--mp-accent) !important;
    box-shadow: 0 0 0 3px var(--mp-ring) !important;
    outline: none !important;
}

/* Marketplace-specific actions and selected controls receive the current page accent. */
body[data-marketplace-theme]:not([data-marketplace-theme="general"]) :is(
    .products-modern-market-action,
    .pricing-primary-action,
    .promotion-primary-action,
    .product-card-primary-action,
    .marketplace-primary-action,
    [data-marketplace-primary]
) {
    border-color: var(--mp-accent) !important;
    background: var(--mp-accent) !important;
    color: var(--mp-on-accent) !important;
    box-shadow: none !important;
}

body[data-marketplace-theme]:not([data-marketplace-theme="general"]) :is(
    .products-modern-market-tab.is-active,
    .product-platform-tab.active,
    .dashboard-marketplace-tab.active,
    .promotion-section-tab.active,
    .settings-tab.is-active,
    [data-marketplace-tab].active,
    [data-marketplace-tab][aria-selected="true"]
) {
    border-color: var(--mp-border) !important;
    background: var(--mp-soft) !important;
    color: var(--mp-accent-strong) !important;
    box-shadow: inset 0 -2px 0 var(--mp-accent) !important;
}

/* Table rows and compact cards keep only a quiet marketplace marker. */
:is(
    .orders-row--ozon,
    .product-row--ozon,
    .marketplace-row--ozon,
    [data-marketplace="ozon"]
) { --row-mp-accent: #1769e8; --row-mp-soft: #eef5ff; }
:is(
    .orders-row--wb,
    .orders-row--wildberries,
    .product-row--wb,
    .product-row--wildberries,
    .marketplace-row--wb,
    .marketplace-row--wildberries,
    [data-marketplace="wb"],
    [data-marketplace="wildberries"]
) { --row-mp-accent: #874497; --row-mp-soft: #f6eff8; }
:is(
    .orders-row--yandex,
    .product-row--yandex,
    .marketplace-row--yandex,
    [data-marketplace="yandex"],
    [data-marketplace="yandex_market"]
) { --row-mp-accent: #c49b00; --row-mp-soft: #fff9dc; }

:is(
    .orders-row--ozon,
    .orders-row--wb,
    .orders-row--wildberries,
    .orders-row--yandex,
    .product-row--ozon,
    .product-row--wb,
    .product-row--wildberries,
    .product-row--yandex,
    .marketplace-row--ozon,
    .marketplace-row--wb,
    .marketplace-row--wildberries,
    .marketplace-row--yandex
) > :first-child {
    box-shadow: inset 3px 0 0 var(--row-mp-accent) !important;
}

/* Windows inherit the marketplace of the page. */
body[data-marketplace-theme] .app-managed-window {
    border-color: var(--mp-border) !important;
}
body[data-marketplace-theme] .app-managed-window > .app-window-titlebar {
    background: linear-gradient(90deg, var(--mp-soft-strong) 0, var(--mp-soft) 36%, #f6f7f9 100%) !important;
    border-bottom-color: var(--mp-border) !important;
    box-shadow: inset 0 3px 0 var(--mp-accent) !important;
}
body[data-marketplace-theme] .app-window-control:hover {
    background: var(--mp-soft-strong) !important;
}
body[data-marketplace-theme] .app-window-control--close:hover {
    background: #e5484d !important;
    color: #fff !important;
}
body[data-marketplace-theme] .app-window-dock-button::before {
    border-color: var(--mp-accent) !important;
}
body[data-marketplace-theme] .app-window-dock-button:hover {
    border-color: var(--mp-border) !important;
    background: var(--mp-soft) !important;
}

/* Existing marketplace labels become a little easier to recognise. */
:is(.products-modern-marketplace-badge--ozon,.api-platform-label--ozon,.communications-marketplace-badge--ozon,.marketplace-chip--ozon,.store-chip--ozon) {
    border-color:#bdd5fb !important; background:#eaf3ff !important; color:#145fcf !important;
}
:is(.products-modern-marketplace-badge--wildberries,.api-platform-label--wildberries,.communications-marketplace-badge--wildberries,.marketplace-chip--wildberries,.store-chip--wb,.store-chip--wildberries) {
    border-color:#ddc9e4 !important; background:#f5edf8 !important; color:#7a3b89 !important;
}
:is(.products-modern-marketplace-badge--yandex,.api-platform-label--yandex,.communications-marketplace-badge--yandex,.communications-marketplace-badge--yandex_market,.marketplace-chip--yandex,.store-chip--yandex) {
    border-color:#ead573 !important; background:#fff8d4 !important; color:#796100 !important;
}

@media (prefers-reduced-motion: reduce) {
    body[data-marketplace-theme] * { scroll-behavior: auto !important; }
}

/* V382: keep the marketplace line on the window frame, not on a shorter
   padded titlebar. */
body[data-marketplace-theme] .app-managed-window {
    border-top-color: var(--mp-accent) !important;
}
body[data-marketplace-theme] .app-managed-window > .app-window-titlebar {
    box-shadow: none !important;
}
