.sales_deal_modal_overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 24px;

    box-sizing: border-box;

    background:
        color-mix(
            in srgb,
            #0f172a 58%,
            transparent
        );

    backdrop-filter: blur(4px);
}

.sales_deal_modal_overlay[hidden] {
    display: none;
}

.sales_deal_modal {
    position: relative;

    display: flex;
    flex-direction: column;

    width: min(1180px, 100%);
    height: min(850px, calc(100dvh - 48px));

    border: 1px solid var(--color-border-subtle);
    border-radius: 18px;

    background: var(--color-surface);
    color: var(--color-text);

    box-shadow:
        0 28px 80px
        color-mix(
            in srgb,
            #000000 32%,
            transparent
        );

    overflow: hidden;
}

.sales_deal_modal_header {
    position: relative;

    display: flex;
    align-items: center;
    justify-content: space-between;

    flex: 0 0 auto;

    min-height: 92px;
    padding: 18px 22px;

    box-sizing: border-box;

    border-bottom: 1px solid var(--color-border-subtle);

    background: var(--color-surface);
}

.sales_deal_modal_identity {
    min-width: 0;
}

.sales_deal_modal_identity > span:first-child {
    color: var(--color-text-soft);

    font-size: 11px;
    font-weight: 700;
}

.sales_deal_modal_identity h2 {
    max-width: 540px;
    margin: 4px 0 7px;

    color: var(--color-text-strong);

    font-size: 22px;
    line-height: 1.2;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sales_deal_modal_labels {
    display: flex;
    flex-wrap: wrap;

    gap: 6px;
}

.sales_deal_stage_badge,
.sales_deal_source_badge {
    display: inline-flex;
    align-items: center;

    min-height: 24px;
    padding: 0 9px;

    border-radius: 999px;

    font-size: 11px;
    font-weight: 700;
}

.sales_deal_stage_badge {
    background:
        color-mix(
            in srgb,
            var(--sales-deal-stage-color) 14%,
            var(--color-surface)
        );

    color: var(--sales-deal-stage-color);

    box-shadow:
        inset 0 0 0 1px
        color-mix(
            in srgb,
            var(--sales-deal-stage-color) 32%,
            transparent
        );
}

.sales_deal_source_badge {
    background: #dbeafe;
    color: #1d4ed8;
}

.sales_deal_modal_header_actions {
    display: flex;
    align-items: center;

    gap: 9px;
}

.sales_deal_stage_control {
    display: flex;
    flex-direction: column;

    min-width: 180px;
    gap: 4px;
}

.sales_deal_stage_control > span {
    color: var(--color-text-soft);

    font-size: 10px;
    font-weight: 600;
}

.sales_deal_stage_control select {
    min-height: 38px;
    padding: 0 10px;

    border: 1px solid var(--color-border);
    border-radius: 9px;

    background: var(--color-surface);
    color: var(--color-text);

    font-size: 13px;
}

.sales_deal_action,
.sales_deal_more_button,
.sales_deal_modal_close {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 40px;

    border-radius: 9px;

    cursor: pointer;
}

.sales_deal_action {
    padding: 0 14px;

    border: 1px solid var(--color-border);

    background: var(--color-surface);
    color: var(--color-text);

    font-size: 13px;
    font-weight: 600;
}

.sales_deal_action[hidden] {
    display: none !important;
}

.sales_deal_action_primary {
    border-color: var(--color-primary);

    background: var(--color-primary);
    color: var(--color-text-white);
}

.sales_deal_more_button,
.sales_deal_modal_close {
    width: 40px;
    padding: 0;

    border: 1px solid var(--color-border);

    background: var(--color-surface-soft);
    color: var(--color-text-soft);
}

.sales_deal_more_button {
    font-size: 17px;
    letter-spacing: 1px;
}

.sales_deal_more_button[hidden] {
    display: none !important;
}

.sales_deal_modal_close {
    font-size: 24px;
    font-weight: 300;
}

.sales_deal_more_button:hover,
.sales_deal_modal_close:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-strong);
}

.sales_deal_more_menu {
    position: absolute;
    top: 70px;
    right: 68px;
    z-index: 5;

    min-width: 190px;
    padding: 6px;

    border: 1px solid var(--color-border);
    border-radius: 10px;

    background: var(--color-surface);

    box-shadow:
        0 14px 30px
        color-mix(
            in srgb,
            #000000 18%,
            transparent
        );
}

.sales_deal_more_menu[hidden] {
    display: none;
}

.sales_deal_more_menu button {
    width: 100%;
    min-height: 38px;
    padding: 0 11px;

    border: 0;
    border-radius: 7px;

    background: transparent;

    font-size: 13px;
    font-weight: 600;
    text-align: left;

    cursor: pointer;
}

.sales_deal_menu_danger {
    color: #dc2626;
}

.sales_deal_menu_danger:hover {
    background: #fee2e2;
}

.sales_deal_menu_restore {
    color: #15803d;
}

.sales_deal_menu_restore:hover {
    background: #dcfce7;
}

.sales_deal_tabs {
    display: flex;
    flex: 0 0 auto;

    min-height: 51px;
    padding: 0 22px;
    gap: 4px;

    border-bottom: 1px solid var(--color-border-subtle);

    background: var(--color-surface);
    overflow-x: auto;
}

.sales_deal_tab {
    position: relative;

    display: inline-flex;
    align-items: center;

    min-width: max-content;
    padding: 0 15px;

    border: 0;

    background: transparent;
    color: var(--color-text-soft);

    font-size: 13px;
    font-weight: 650;

    cursor: pointer;
}

.sales_deal_tab::after {
    position: absolute;
    right: 12px;
    bottom: 0;
    left: 12px;

    height: 2px;

    border-radius: 2px 2px 0 0;

    background: transparent;

    content: "";
}

.sales_deal_tab:hover {
    color: var(--color-text-strong);
}

.sales_deal_tab.active {
    color: var(--color-primary);
}

.sales_deal_tab.active::after {
    background: var(--color-primary);
}

.sales_deal_tab > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 21px;
    height: 21px;
    margin-left: 6px;
    padding: 0 6px;

    box-sizing: border-box;

    border-radius: 999px;

    background: var(--color-surface-secondary);
    color: var(--color-text-soft);

    font-size: 10px;
}

.sales_deal_modal_loading,
.sales_deal_modal_error {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;

    gap: 10px;

    color: var(--color-text-soft);
}

.sales_deal_modal_error {
    flex-direction: column;

    padding: 30px;

    text-align: center;
}

.sales_deal_modal_error[hidden],
.sales_deal_modal_loading[hidden] {
    display: none;
}

.sales_deal_modal_error strong {
    color: var(--color-text-strong);
}

.sales_deal_modal_error button {
    min-height: 38px;
    padding: 0 14px;

    border: 0;
    border-radius: 9px;

    background: var(--color-primary);
    color: var(--color-text-white);

    font-weight: 600;

    cursor: pointer;
}

.sales_deal_modal_body {
    flex: 1;

    min-height: 0;
    padding: 22px;

    box-sizing: border-box;

    background: var(--color-surface-muted);

    overflow-y: auto;
    overscroll-behavior: contain;
}

.sales_deal_modal_body[hidden] {
    display: none;
}

.sales_deal_panel {
    display: none;
}

.sales_deal_panel.active {
    display: block;
}

.sales_deal_overview_grid {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        290px;

    gap: 16px;
}

.sales_deal_overview_main,
.sales_deal_overview_side > div,
.sales_deal_description_card,
.sales_deal_customer_card,
.sales_deal_customer_actions,
.sales_deal_delivery_grid,
.sales_deal_delivery_address,
.sales_deal_payment_card {
    border: 1px solid var(--color-border-subtle);
    border-radius: 13px;

    background: var(--color-surface);
}

.sales_deal_overview_main,
.sales_deal_description_card {
    padding: 18px;
}

.sales_deal_section_heading,
.sales_deal_panel_header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 16px;
}

.sales_deal_section_heading span,
.sales_deal_panel_header span {
    color: var(--color-text-soft);

    font-size: 11px;
    font-weight: 600;
}

.sales_deal_section_heading h3,
.sales_deal_panel_header h3 {
    margin: 3px 0 0;

    color: var(--color-text-strong);

    font-size: 17px;
}

.sales_deal_section_heading button,
.sales_deal_panel_header button,
.sales_deal_overview_address button,
.sales_deal_delivery_address button,
.sales_deal_delivery_address a,
.sales_deal_customer_actions button,
.sales_deal_customer_actions a {
    min-height: 36px;
    padding: 0 12px;

    border: 1px solid var(--color-border);
    border-radius: 8px;

    background: var(--color-surface);
    color: var(--color-text);

    font-size: 12px;
    font-weight: 600;
    text-decoration: none;

    cursor: pointer;
}

.sales_deal_section_heading button:hover,
.sales_deal_panel_header button:hover,
.sales_deal_overview_address button:hover,
.sales_deal_delivery_address button:hover,
.sales_deal_delivery_address a:hover,
.sales_deal_customer_actions button:hover,
.sales_deal_customer_actions a:hover {
    border-color: var(--color-primary);

    color: var(--color-primary);
}

.sales_deal_summary_list {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 11px;
    margin: 18px 0 0;
}

.sales_deal_summary_list > div {
    min-width: 0;
    padding: 12px;

    border-radius: 9px;

    background: var(--color-surface-muted);
}

.sales_deal_summary_list dt {
    margin-bottom: 5px;

    color: var(--color-text-soft);

    font-size: 10px;
}

.sales_deal_summary_list dd {
    min-width: 0;
    margin: 0;

    color: var(--color-text-strong);

    font-size: 13px;
    font-weight: 650;

    overflow-wrap: anywhere;
}

.sales_deal_summary_list a {
    color: inherit;
}

.sales_deal_overview_address {
    display: grid;

    grid-template-columns: 1fr auto;
    align-items: center;

    gap: 6px 14px;
    margin-top: 12px;
    padding: 13px;

    border-radius: 9px;

    background: var(--color-surface-muted);
}

.sales_deal_overview_address > span,
.sales_deal_delivery_address > span {
    grid-column: 1 / -1;

    color: var(--color-text-soft);

    font-size: 10px;
}

.sales_deal_overview_address strong,
.sales_deal_delivery_address strong {
    min-width: 0;

    color: var(--color-text-strong);

    font-size: 13px;
    line-height: 1.45;

    white-space: normal;
    overflow-wrap: anywhere;
}

.sales_deal_overview_side {
    display: flex;
    flex-direction: column;

    gap: 12px;
}

.sales_deal_overview_side > div {
    padding: 16px;
}

.sales_deal_amount_card {
    display: flex;
    flex-direction: column;

    gap: 5px;
}

.sales_deal_amount_card > span,
.sales_deal_amount_card small {
    color: var(--color-text-soft);

    font-size: 11px;
}

.sales_deal_amount_card strong {
    color: var(--color-text-strong);

    font-size: 24px;
}

.sales_deal_warning_card {
    border-color: #fcd34d !important;

    background: #fffbeb !important;
}

.sales_deal_warning_card strong {
    display: block;

    margin-bottom: 5px;

    color: #92400e;
}

.sales_deal_warning_card span {
    color: #a16207;

    font-size: 12px;
    line-height: 1.4;
}

.sales_deal_warning_card[hidden] {
    display: none;
}

.sales_deal_quick_actions {
    display: flex;
    flex-direction: column;

    gap: 8px;
}

.sales_deal_quick_actions button {
    min-height: 39px;

    border: 1px solid var(--color-border);
    border-radius: 8px;

    background: var(--color-surface);
    color: var(--color-text);

    font-size: 12px;
    font-weight: 600;

    cursor: pointer;
}

.sales_deal_quick_actions button:hover {
    border-color: var(--color-primary);

    color: var(--color-primary);
}

.sales_deal_description_card {
    margin-top: 16px;
}

.sales_deal_description_card p {
    margin: 15px 0 0;

    color: var(--color-text-slate);
    line-height: 1.55;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.sales_deal_panel_header {
    margin-bottom: 16px;
}

.sales_deal_customer_card {
    display: flex;
    align-items: center;

    padding: 20px;
    gap: 16px;
}

.sales_deal_customer_avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;

    width: 58px;
    height: 58px;

    border-radius: 50%;

    background:
        color-mix(
            in srgb,
            var(--color-primary) 13%,
            var(--color-surface)
        );

    color: var(--color-primary);

    font-size: 18px;
    font-weight: 800;
}

.sales_deal_customer_details {
    display: flex;
    flex-direction: column;

    min-width: 0;
    gap: 5px;
}

.sales_deal_customer_details h4 {
    margin: 0;

    color: var(--color-text-strong);

    font-size: 18px;
}

.sales_deal_customer_details a {
    color: var(--color-primary);

    text-decoration: none;
}

.sales_deal_customer_details span {
    color: var(--color-text-soft);

    font-size: 12px;
}

.sales_deal_customer_actions {
    display: flex;
    align-items: center;

    gap: 9px;
    margin-top: 12px;
    padding: 13px;
}

.sales_deal_customer_actions a,
.sales_deal_customer_actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    height: 36px;
    margin: 0;
    box-sizing: border-box;

    font-family: inherit;
    line-height: 1;
    vertical-align: middle;
}

.sales_deal_products {
    border: 1px solid var(--color-border-subtle);
    border-radius: 13px;

    background: var(--color-surface);

    overflow: hidden;
}

.sales_deal_product {
    display: grid;

    grid-template-columns:
        minmax(220px, 1fr)
        120px
        110px
        110px;

    align-items: center;

    gap: 14px;
    padding: 15px 16px;

    border-bottom: 1px solid var(--color-border-subtle);
}

.sales_deal_product:last-child {
    border-bottom: 0;
}

.sales_deal_product_service {
    margin-left: 30px;

    border-left: 3px solid var(--color-primary);

    background:
        color-mix(
            in srgb,
            var(--color-primary) 5%,
            var(--color-surface)
        );
}

.sales_deal_product_name,
.sales_deal_product_quantity,
.sales_deal_product_price {
    display: flex;
    flex-direction: column;

    min-width: 0;
    gap: 4px;
}

.sales_deal_product_name strong {
    color: var(--color-text-strong);

    font-size: 13px;

    overflow-wrap: anywhere;
}

.sales_deal_product_name span,
.sales_deal_product_quantity span,
.sales_deal_product_price span {
    color: var(--color-text-soft);

    font-size: 10px;
}

.sales_deal_product_quantity strong,
.sales_deal_product_price strong {
    color: var(--color-text-slate);

    font-size: 12px;
}

.sales_deal_product_amount {
    color: var(--color-text-strong);

    font-size: 14px;
    font-weight: 750;
    text-align: right;
}

.sales_deal_products_empty,
.sales_deal_history_empty {
    padding: 35px;

    color: var(--color-text-soft);

    text-align: center;
}

.sales_deal_products_total {
    display: flex;
    align-items: center;
    justify-content: flex-end;

    gap: 25px;
    padding: 17px 3px 0;

    color: var(--color-text-soft);
}

.sales_deal_products_total strong {
    color: var(--color-text-strong);

    font-size: 21px;
}

.sales_deal_delivery_grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    overflow: hidden;
}

.sales_deal_delivery_grid > div {
    display: flex;
    flex-direction: column;

    min-width: 0;
    padding: 16px;
    gap: 5px;

    border-right: 1px solid var(--color-border-subtle);
}

.sales_deal_delivery_grid > div:last-child {
    border-right: 0;
}

.sales_deal_delivery_grid span {
    color: var(--color-text-soft);

    font-size: 10px;
}

.sales_deal_delivery_grid strong {
    color: var(--color-text-strong);

    font-size: 13px;

    overflow-wrap: anywhere;
}

.sales_deal_delivery_address {
    margin-top: 14px;
    padding: 17px;
}

.sales_deal_delivery_address > div {
    display: flex;
    align-items: center;

    gap: 8px;
    margin-top: 13px;
}

.sales_deal_delivery_address a,
.sales_deal_delivery_address button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    height: 36px;
    margin: 0;
    box-sizing: border-box;

    font-family: inherit;
    line-height: 1;
    vertical-align: middle;
}

.sales_deal_payment_card {
    display: flex;
    flex-direction: column;

    padding: 22px;
    gap: 7px;
}

.sales_deal_payment_card span,
.sales_deal_payment_card small {
    color: var(--color-text-soft);

    font-size: 11px;
}

.sales_deal_payment_card strong {
    color: var(--color-text-strong);

    font-size: 19px;
}

/* Подтверждение фактического получения оплаты. */
#salesDealPaymentConfirmation {
    margin: 8px 0 0;
    color: var(--color-text-soft);
    font-size: 13px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.sales_deal_history {
    position: relative;

    padding-left: 13px;
}

.sales_deal_history_item {
    position: relative;

    display: grid;

    grid-template-columns: 20px 1fr;

    gap: 11px;
    padding-bottom: 19px;
}

.sales_deal_history_item::before {
    position: absolute;
    top: 18px;
    bottom: 0;
    left: 7px;

    width: 1px;

    background: var(--color-border-subtle);

    content: "";
}

.sales_deal_history_item:last-child::before {
    display: none;
}

.sales_deal_history_marker {
    position: relative;
    z-index: 1;

    width: 15px;
    height: 15px;
    margin-top: 2px;

    border: 3px solid var(--color-surface-muted);
    border-radius: 50%;

    background: var(--color-primary);

    box-sizing: border-box;
}

.sales_deal_history_item strong {
    color: var(--color-text-strong);

    font-size: 13px;
}

.sales_deal_history_item p {
    margin: 5px 0;

    color: var(--color-text-slate);

    font-size: 12px;
}

.sales_deal_history_item small {
    display: block;

    margin-top: 5px;

    color: var(--color-text-soft);

    font-size: 10px;
}


:root[data-theme="dark"] .sales_deal_source_badge {
    background: #1e3a5f;
    color: #bfdbfe;
}

:root[data-theme="dark"] .sales_deal_warning_card {
    border-color: #854d0e !important;

    background: #422006 !important;
}

:root[data-theme="dark"] .sales_deal_warning_card strong {
    color: #fde68a;
}

:root[data-theme="dark"] .sales_deal_warning_card span {
    color: #fcd34d;
}

:root[data-theme="dark"] .sales_deal_menu_danger:hover {
    background: #4c1d1d;
}

:root[data-theme="dark"] .sales_deal_menu_restore:hover {
    background: #143d25;
}


@media (max-width: 850px) {
    .sales_deal_modal_overlay {
        padding: 12px;
    }

    .sales_deal_modal {
        height: calc(100dvh - 24px);

        border-radius: 15px;
    }

    .sales_deal_modal_header {
        align-items: flex-start;

        min-height: auto;
        padding: 16px;
    }

    .sales_deal_modal_identity h2 {
        max-width: calc(100vw - 170px);

        font-size: 19px;
    }

    .sales_deal_stage_control {
        display: none;
    }

    .sales_deal_modal_header_actions {
        gap: 6px;
    }

    .sales_deal_action {
        display: none;
    }

    .sales_deal_tabs {
        min-height: 48px;
        padding: 0 10px;
    }

    .sales_deal_tab {
        padding: 0 12px;
    }

    .sales_deal_modal_body {
        padding: 16px;
    }

    .sales_deal_overview_grid {
        grid-template-columns: 1fr;
    }

    .sales_deal_summary_list {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .sales_deal_product {
        grid-template-columns:
            minmax(0, 1fr)
            auto;

        gap: 10px 14px;
    }

    .sales_deal_product_name {
        grid-column: 1;
    }

    .sales_deal_product_quantity {
        grid-column: 1;
    }

    .sales_deal_product_price {
        grid-column: 2;
        grid-row: 1;

        text-align: right;
    }

    .sales_deal_product_amount {
        grid-column: 2;
        grid-row: 2;
    }

    .sales_deal_delivery_grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .sales_deal_delivery_grid > div:nth-child(2) {
        border-right: 0;
    }

    .sales_deal_delivery_grid > div:nth-child(-n + 2) {
        border-bottom: 1px solid var(--color-border-subtle);
    }
}


@media (max-width: 520px) {
    .sales_deal_modal_overlay {
        align-items: stretch;

        padding: 0;
    }

    .sales_deal_modal {
        width: 100%;
        height: 100dvh;

        border: 0;
        border-radius: 0;
    }

    .sales_deal_modal_header {
        padding: 13px 12px;
    }

    .sales_deal_modal_identity h2 {
        max-width: calc(100vw - 125px);

        font-size: 17px;
    }

    .sales_deal_modal_identity > span:first-child {
        font-size: 10px;
    }

    .sales_deal_more_button,
    .sales_deal_modal_close {
        width: 38px;
        height: 38px;
    }

    .sales_deal_more_menu {
        top: 58px;
        right: 52px;
    }

    .sales_deal_tabs {
        scrollbar-width: none;
    }

    .sales_deal_tabs::-webkit-scrollbar {
        display: none;
    }

    .sales_deal_modal_body {
        padding: 12px;
    }

    .sales_deal_overview_main,
    .sales_deal_description_card {
        padding: 14px;
    }

    .sales_deal_summary_list {
        grid-template-columns: 1fr;
    }

    .sales_deal_overview_address {
        grid-template-columns: 1fr;
    }

    .sales_deal_overview_address button {
        width: 100%;
    }

    .sales_deal_customer_card {
        align-items: flex-start;

        padding: 15px;
    }

    .sales_deal_customer_actions,
    .sales_deal_delivery_address > div {
        flex-direction: column;
    }

    .sales_deal_customer_actions a,
    .sales_deal_customer_actions button,
    .sales_deal_delivery_address a,
    .sales_deal_delivery_address button {
        display: inline-flex;
        align-items: center;
        justify-content: center;

        width: 100%;
    }

    .sales_deal_product {
        padding: 13px;
    }

    .sales_deal_product_service {
        margin-left: 15px;
    }

    .sales_deal_delivery_grid {
        grid-template-columns: 1fr;
    }

    .sales_deal_delivery_grid > div {
        border-right: 0;
        border-bottom: 1px solid var(--color-border-subtle);
    }

    .sales_deal_delivery_grid > div:last-child {
        border-bottom: 0;
    }

    .sales_deal_panel_header {
        align-items: flex-start;
    }

    .sales_deal_panel_header button {
        flex: 0 0 auto;
    }
}
/* ==========================================================
   РЕДАКТИРОВАНИЕ ТОВАРОВ СДЕЛКИ
========================================================== */

.sales_deal_product {
    grid-template-columns:
        minmax(190px, 1fr)
        164px
        105px
        minmax(190px, 220px)
        105px
        38px;
}

.sales_deal_quantity_control,
.sales_deal_actual_weight_control {
    display: flex;
    align-items: center;

    min-width: 0;
    gap: 6px;
}

.sales_deal_quantity_control {
    width: 100%;
}

.sales_deal_quantity_control button,
.sales_deal_actual_weight_control button,
.sales_deal_product_remove {
    flex: 0 0 auto;

    border: 1px solid var(--color-border-strong);
    border-radius: 9px;

    font-family: inherit;
    font-weight: 700;

    cursor: pointer;
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        opacity 0.18s ease;
}

.sales_deal_quantity_control button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 34px;
    height: 36px;
    padding: 0;

    background: var(--color-surface-secondary);
    color: var(--color-text-strong);

    font-size: 18px;
    line-height: 1;
}

.sales_deal_quantity_control button:hover {
    border-color: var(--color-primary);

    background:
        color-mix(
            in srgb,
            var(--color-primary) 10%,
            var(--color-surface)
        );

    color: var(--color-primary);
}

.sales_deal_quantity_input,
.sales_deal_actual_weight_input {
    min-width: 0;
    height: 36px;
    padding: 0 8px;

    box-sizing: border-box;

    border: 1px solid var(--color-border-strong);
    border-radius: 9px;

    background: var(--color-surface);
    color: var(--color-text-strong);

    font: inherit;
    font-size: 12px;
    font-weight: 650;
    text-align: center;

    outline: none;
}

.sales_deal_quantity_input {
    width: 72px;
}

.sales_deal_actual_weight_input {
    width: 82px;
}

.sales_deal_quantity_input:focus,
.sales_deal_actual_weight_input:focus {
    border-color: var(--color-primary);

    box-shadow:
        0 0 0 3px
        color-mix(
            in srgb,
            var(--color-primary) 16%,
            transparent
        );
}

.sales_deal_actual_weight {
    display: flex;
    flex-direction: column;

    min-width: 0;
    gap: 4px;
}

.sales_deal_actual_weight > span {
    color: var(--color-text-soft);

    font-size: 10px;
}

.sales_deal_actual_weight > strong {
    color: var(--color-text-slate);

    font-size: 12px;
}

.sales_deal_actual_weight_save {
    min-height: 36px;
    padding: 0 11px;

    border-color: var(--deals-positive-action) !important;

    background:
        color-mix(
            in srgb,
            var(--deals-positive-action) 12%,
            var(--color-surface)
        );

    color: var(--deals-positive-action);
    font-size: 11px;
}

.sales_deal_actual_weight_save:hover {
    border-color:
        var(--deals-positive-action-hover) !important;

    background:
        var(--deals-positive-action-hover);

    color: var(--color-text-white);
}

.sales_deal_actual_weight_saved {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sales_deal_actual_weight_saved[hidden],
.sales_deal_actual_weight_control[hidden] {
    display: none !important;
}

.sales_deal_actual_weight_edit,
#salesDealAssignDriver {
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid var(--color-border-strong);
    border-radius: 9px;
    background: var(--color-surface-secondary);
    color: var(--color-primary);
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

#salesDealAssignDriver[hidden] {
    display: none !important;
}

.sales_deal_driver_overlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgb(15 23 42 / 52%);
}

.sales_deal_driver_overlay[hidden] { display: none; }

.sales_deal_driver_dialog {
    width: min(420px, 100%);
    padding: 24px;
    border: 1px solid var(--color-border-subtle);
    border-radius: 16px;
    background: var(--color-surface);
    color: var(--color-text-strong);
    box-shadow: 0 24px 70px rgb(15 23 42 / 28%);
}

.sales_deal_driver_dialog h3 { margin: 0 0 6px; }
.sales_deal_driver_dialog p { margin: 0 0 18px; color: var(--color-text-soft); }
.sales_deal_driver_dialog select {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--color-border-strong);
    border-radius: 10px;
    background: var(--color-surface);
    color: var(--color-text-strong);
}
.sales_deal_driver_dialog > div {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}
.sales_deal_driver_dialog button {
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--color-border-strong);
    border-radius: 10px;
    background: var(--color-surface-secondary);
    color: var(--color-text-strong);
    font: inherit;
    cursor: pointer;
}
#salesDealDriverSave { border-color: var(--color-primary); background: var(--color-primary); color: white; }

.sales_deal_product_remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 36px;
    height: 36px;
    padding: 0;

    border-color:
        var(--deals-danger-surface-strong);

    background:
        var(--deals-danger-surface);

    color:
        var(--deals-danger-text);

    font-size: 21px;
    line-height: 1;
}

.sales_deal_product_remove:hover {
    border-color:
        var(--deals-danger-text);

    background:
        var(--deals-danger-text);

    color: var(--color-text-white);
}

.sales_deal_product_busy {
    opacity: 0.62;
    pointer-events: none;
}

.sales_deal_product button:disabled,
.sales_deal_product input:disabled {
    cursor: wait;
}

.sales_deal_products[data-readonly="true"]
.sales_deal_product {
    grid-template-columns:
        minmax(220px, 1fr)
        130px
        110px
        minmax(120px, 180px)
        110px;
}


/* ==========================================================
   ПЛАНШЕТ
========================================================== */

@media (max-width: 1050px) {
    .sales_deal_product,
    .sales_deal_products[data-readonly="true"]
    .sales_deal_product {
        grid-template-columns:
            minmax(0, 1fr)
            minmax(150px, 190px)
            38px;

        gap: 12px;
    }

    .sales_deal_product_name {
        grid-column: 1;
        grid-row: 1;
    }

    .sales_deal_product_price {
        grid-column: 2;
        grid-row: 1;

        text-align: right;
    }

    .sales_deal_product_remove {
        grid-column: 3;
        grid-row: 1;
    }

    .sales_deal_product_quantity {
        grid-column: 1;
        grid-row: 2;
    }

    .sales_deal_actual_weight {
        grid-column: 2;
        grid-row: 2;

        align-items: flex-end;
    }

    .sales_deal_product_amount {
        grid-column: 3;
        grid-row: 2;

        align-self: end;
    }

    .sales_deal_actual_weight_control {
        justify-content: flex-end;
    }
}


/* ==========================================================
   МОБИЛЬНОЕ ОТОБРАЖЕНИЕ
========================================================== */

@media (max-width: 600px) {
    .sales_deal_product,
    .sales_deal_products[data-readonly="true"]
    .sales_deal_product {
        grid-template-columns:
            minmax(0, 1fr)
            auto;

        gap: 12px;
        padding: 14px;
    }

    .sales_deal_product_service {
        margin-left: 6px;
        padding: 8px 10px;
        gap: 6px 8px;
        border-left-width: 3px;
        grid-template-columns: minmax(0, 1fr) auto auto;
    }

    .sales_deal_product_service .sales_deal_product_name span {
        display: none;
    }

    .sales_deal_product_service .sales_deal_product_quantity {
        grid-column: 2;
        grid-row: 1;
        align-self: center;
    }

    .sales_deal_product_service .sales_deal_product_price {
        display: none;
    }

    .sales_deal_product_service .sales_deal_product_amount {
        grid-column: 3;
        grid-row: 1;
        align-self: center;
        justify-self: end;
    }

    .sales_deal_product_service .sales_deal_product_remove {
        grid-column: 3;
        grid-row: 2;
        width: 30px;
        height: 30px;
    }

    .sales_deal_product_service .sales_deal_quantity_control button {
        width: 30px;
        height: 32px;
    }

    .sales_deal_product_service .sales_deal_quantity_input {
        width: 54px;
        height: 32px;
        flex: 0 0 54px;
    }

    .sales_deal_product_service .sales_deal_product_name strong {
        font-size: 13px;
    }

    .sales_deal_product_name {
        grid-column: 1;
        grid-row: 1;
    }

    .sales_deal_product_remove {
        grid-column: 2;
        grid-row: 1;

        align-self: start;
    }

    .sales_deal_product_quantity {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .sales_deal_quantity_control {
        width: 100%;
    }

    .sales_deal_quantity_input {
        flex: 1;

        width: auto;
    }

    .sales_deal_product_price {
        grid-column: 1;
        grid-row: 3;

        text-align: left;
    }

    .sales_deal_product_amount {
        grid-column: 2;
        grid-row: 3;

        align-self: end;
    }

    .sales_deal_actual_weight {
        grid-column: 1 / -1;
        grid-row: 4;

        align-items: stretch;
    }

    .sales_deal_actual_weight_control {
        display: grid;
        grid-template-columns:
            minmax(0, 1fr)
            auto;

        width: 100%;
    }

    .sales_deal_actual_weight_input {
        width: 100%;
    }

    .sales_deal_actual_weight_save {
        min-width: 104px;
    }
}
/* ==========================================================
   ОПЕРАЦИОННЫЕ ДЕЙСТВИЯ НА ТЕЛЕФОНЕ
========================================================== */

@media (max-width: 850px) {
    .sales_deal_modal_header {
        flex-wrap: wrap;

        gap: 12px;
    }

    .sales_deal_modal_identity {
        flex: 1 1 100%;

        padding-right: 4px;
    }

    .sales_deal_modal_identity h2 {
        max-width: 100%;
    }

    .sales_deal_modal_header_actions {
        display: flex;
        align-items: stretch;

        width: 100%;
        gap: 7px;
    }

    #salesDealClaimButton,
    #salesDealOperationButton {
        display: inline-flex;
        align-items: center;
        justify-content: center;

        flex: 1 1 auto;

        min-width: 0;
        min-height: 40px;
        padding: 6px 10px;

        border-radius: 10px;

        font-size: 12px;
        line-height: 1.2;
        text-align: center;
        white-space: normal;
    }

    #salesDealClaimButton[hidden],
    #salesDealOperationButton[hidden] {
        display: none;
    }

    .sales_deal_more_button,
    .sales_deal_modal_close {
        flex: 0 0 40px;

        width: 40px;
        height: 40px;
    }

    .sales_deal_more_menu {
        top: calc(100% - 8px);
        right: 58px;
    }
}


@media (max-width: 520px) {
    .sales_deal_modal_header {
        gap: 10px;
    }

    .sales_deal_modal_header_actions {
        gap: 6px;
    }

    #salesDealClaimButton,
    #salesDealOperationButton {
        min-height: 38px;
        padding: 5px 8px;

        font-size: 11px;
    }

    .sales_deal_more_button,
    .sales_deal_modal_close {
        flex-basis: 38px;

        width: 38px;
        height: 38px;
    }

    .sales_deal_more_menu {
        top: calc(100% - 5px);
        right: 50px;
    }
}


/* Per-deal sale price editor. */
.sales_deal_price_saved,
.sales_deal_price_control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.sales_deal_price_saved[hidden],
.sales_deal_price_control[hidden] { display: none !important; }
.sales_deal_price_input {
    width: 120px;
    max-width: 100%;
    min-height: 34px;
    padding: 6px 8px;
    border: 1px solid var(--color-border-strong);
    border-radius: 9px;
    background: var(--color-surface-secondary);
    color: inherit;
    font: inherit;
}
.sales_deal_price_edit,
.sales_deal_price_save,
.sales_deal_price_cancel {
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid var(--color-border-strong);
    border-radius: 9px;
    background: var(--color-surface-secondary);
    color: var(--color-primary);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}
.sales_deal_customer_analytics {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    margin: 3px 0 5px;
    color: var(--color-text-secondary);
    font-size: 12px;
}

.sales_deal_customer_analytics .customer_new_badge {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 1px 7px;
    border: 1px solid color-mix(in srgb, var(--color-primary) 45%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-primary) 12%, transparent);
    color: var(--color-primary-text);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
}
