.deals_page {
    width: 100%;
}

.deals_toolbar {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

.deals_search {
    width: 220px;
    padding: 10px 14px;

    border: 1px solid #666;
    border-radius: 8px;

    outline: none;
    font-size: 14px;
    font-family: inherit;

    transition: all .3s ease;
}

.deals_search:hover,
.deals_search:focus {
    border-color: #007bff;
    width: 300px;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.25);
}

.deals_filter {
    min-width: 170px;
    padding: 10px 14px;

    border: 1px solid #007bff;
    border-radius: 8px;

    background: #fff;
    color: #333;

    font-size: 14px;
    font-family: inherit;

    outline: none;
    cursor: pointer;

    transition: all .3s ease;
}

.deals_filter:hover,
.deals_filter:focus {
    border-color: #0056b3;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.25);
}

.deals_add_button {
    display: none;
    margin-left: auto;

    padding: 10px 16px;

    border: 1px solid #007bff;
    border-radius: 8px;

    background: #fff;
    color: #555;

    font-size: 14px;
    font-family: inherit;

    cursor: pointer;

    transition: all .3s ease;
}
.deals_add_button.active {
    display: flex;
}


.deals_add_button:hover {
    background: #007bff;
    color: #fff;
}

.deals_table {
    width: 100%;
    overflow-x: auto;
}

.deals_table_header,
.deals_table_row {
    display: grid;

    grid-template-columns:
        60px
        1.5fr
        1.3fr
        1.3fr
        1.3fr
        1fr
        1.2fr;

    align-items: center;
    gap: 15px;
    min-width: 950px;
}

.deals_table_header {
    padding: 12px 15px;

    color: #666;

    font-size: 13px;
    font-weight: 600;

    border-bottom: 1px solid #ddd;
}

.deals_table_row {
    padding: 15px;

    background: #fff;

    border: 1px solid #007bff;
    border-radius: 8px;

    cursor: pointer;

    transition: all .2s ease;
}

.deals_table_row:hover {
    box-shadow: 0 3px 10px rgba(0, 123, 255, 0.12);
    transform: translateY(-1px);
}

.deals_list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.deal_status {
    display: inline-flex;
    align-items: center;

    width: fit-content;

    padding: 5px 10px;

    border-radius: 6px;

    font-size: 12px;
    font-weight: 500;
}

.deals_empty {
    display: none;

    padding: 40px 20px;

    text-align: center;

    color: #666;
    font-size: 15px;
}

.deals_pagination {
    display: flex;
    justify-content: center;
    gap: 8px;

    margin-top: 25px;
}

.deals_pagination_button {
    min-width: 35px;
    height: 35px;

    padding: 0 8px;

    border: 1px solid #007bff;
    border-radius: 7px;

    background: #fff;
    color: #333;

    cursor: pointer;

    transition: all .2s ease;
}

.deals_pagination_button:hover,
.deals_pagination_button.active {
    background: #007bff;
    color: #fff;
}

.deal_create_form {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;

    align-items: center;
    justify-content: center;

    padding: 20px;
    box-sizing: border-box;

    background: rgba(0, 0, 0, 0.5);
}

.deal_create_form.active {
    display: flex;
}


.deal_modal_content {
    width: min(700px, calc(100% - 30px));
    max-height: 90vh;
    overflow-y: auto;

    padding: 28px;

    background: #fff;
    border-radius: 14px;

    box-sizing: border-box;

    box-shadow: 0 15px 50px rgba(0, 0, 0, .2);
}


/* HEADER */

.deal_modal_header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    margin-bottom: 28px;
}

.deal_modal_header h2 {
    margin: 0 0 5px;

    font-size: 23px;
}

.deal_modal_header p {
    margin: 0;

    color: #777;
    font-size: 14px;
}


.deal_modal_close {
    width: 35px;
    height: 35px;

    border: none;
    background: transparent;

    font-size: 27px;
    color: #777;

    cursor: pointer;
}

.deal_modal_close:hover {
    color: #e00000;
}


/* FORM */

.deal_form_group {
    display: flex;
    flex-direction: column;

    gap: 7px;

    margin-bottom: 18px;
}

.deal_form_group label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
}


.deal_form_group input,
.deal_form_group select,
.deal_form_group textarea {
    width: 100%;
    
    padding: 10px 12px;

    box-sizing: border-box;

    border: 1px solid #ddd;
    border-radius: 8px;

    background: #fff;

    font-family: inherit;
    font-size: 14px;

    outline: none;

    transition: border-color .2s ease,
                box-shadow .2s ease;
}


.deal_form_group input:focus,
.deal_form_group select:focus,
.deal_form_group textarea:focus {
    border-color: #007bff;

    box-shadow:
        0 0 0 3px rgba(0, 123, 255, .08);
}


.deal_form_group textarea {
    resize: vertical;
    min-height: 80px;
}


/* TWO COLUMNS */

.deal_form_grid {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 0 15px;
}


/* STATUS */

.deal_status_new {
    min-height: 40px;

    display: flex;
    align-items: center;

    padding: 0 12px;

    box-sizing: border-box;

    border: 1px solid #ddd;
    border-radius: 8px;

    background: #f7f7f7;

    color: #555;

    font-size: 14px;
}


/* PRODUCTS */

.deal_products {
    margin-top: 25px;
}

.deal_section_header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    margin-bottom: 12px;
}

.deal_section_header h3 {
    margin: 0 0 3px;

    font-size: 17px;
}

.deal_section_header span {
    color: #888;
    font-size: 12px;
}


#dealAddProduct {
    padding: 8px 12px;

    border: 1px solid #007bff;
    border-radius: 7px;

    background: #fff;
    color: #007bff;

    font-size: 13px;

    cursor: pointer;
}

#dealAddProduct:hover {
    background: #007bff;
    color: #fff;
}


/* PRODUCT CONTAINER */

.deal_products_list {
    display: flex;
    flex-direction: column;
    gap: 8px;

    padding: 12px;

    border: 1px solid #eee;
    border-radius: 10px;

    background: #fafafa;
}


/* TOTAL */

.deal_total {
    display: flex;

    justify-content: flex-end;
    align-items: center;

    gap: 15px;

    margin-top: 15px;

    font-size: 14px;
}

.deal_total strong {
    font-size: 19px;
}


/* BUTTONS */

.deal_form_actions {
    display: flex;

    justify-content: flex-end;

    gap: 10px;

    margin-top: 28px;

    padding-top: 18px;

    border-top: 1px solid #eee;
}


.deal_btn_cancel,
.deal_btn_submit {
    padding: 10px 18px;

    border-radius: 8px;

    font-size: 14px;

    cursor: pointer;

    transition: all .5s;
}

.deal_status_action {
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .5s;
    
}

.deal_actions_bar {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 16px;
}
#dealDetailsTitle {
    margin: 0;
    line-height: 1.2;
    white-space: nowrap;
}
.deal_details_status {
    margin: 0;
}

.deal_actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.update_status {
    background-color: #eef2ff;
    color: #4f46e5;
}
.update_status:hover {
    background-color: #e0e7ff;
    color: #4f46e5;
}

.delete_deal {
    background-color: #fee2e2;
    color: #dc2626;
}
.delete_deal:hover {
    background-color: #fecaca;
}

.deal_btn_cancel {
    border: 1px solid #ddd;

    background: #f5f5f5;

    color: #222;
}

.deal_btn_cancel:hover {
    background: #e5e5e5;
}

.deal_btn_submit {
    border: 1px solid #007bff;

    background: #007bff;
    color: #fff;
}


.deal_btn_submit:hover {
    background: #0069d9;
}


.deal_product_modal {
    position: fixed;
    inset: 0;
    z-index: 2100;

    display: none;

    align-items: center;
    justify-content: center;

    padding: 20px;

    box-sizing: border-box;
}

.deal_product_modal.active {
    display: flex;
}

.deal_product_modal_overlay {
    position: absolute;
    inset: 0;

    background: rgba(0, 0, 0, 0.5);
}

.deal_product_modal_content {
    position: relative;
    z-index: 1;

    width: min(450px, 100%);

    padding: 25px;

    box-sizing: border-box;

    background: #fff;

    border-radius: 12px;

    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.2);
}

.deal_product_modal_header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 25px;
}

.deal_product_modal_header h2 {
    margin: 0;

    font-size: 21px;
    font-weight: 600;
}

.deal_product_modal_header button {
    width: 35px;
    height: 35px;

    padding: 0;

    border: none;

    background: transparent;

    font-size: 28px;
    line-height: 1;

    color: #555;

    cursor: pointer;

    transition: color .3s ease;
}

.deal_product_modal_header button:hover {
    color: red;
}

.deal_product_field {
    display: flex;

    flex-direction: column;

    gap: 7px;

    margin-bottom: 18px;
}

.deal_product_field label {
    font-size: 14px;
    font-weight: 500;
    color: #555;
}

.deal_product_field select,
.deal_product_field input {
    width: 100%;

    min-height: 42px;

    padding: 9px 11px;

    box-sizing: border-box;

    border: 1px solid #aaa;
    border-radius: 7px;

    outline: none;

    font-family: inherit;
    font-size: 14px;

    background: #fff;

    transition: border-color .3s ease;
}

.deal_product_field select:focus,
.deal_product_field input:focus {
    border-color: #007bff;
}

.deal_product_price {
    display: flex;

    align-items: center;
    justify-content: space-between;

    padding: 15px 0;

    margin-top: 5px;

    border-top: 1px solid #eee;
}

.deal_product_price span {
    color: #777;
}

.deal_product_price strong {
    font-size: 18px;
}

.deal_product_actions {
    display: flex;

    justify-content: flex-end;

    gap: 10px;

    margin-top: 20px;
}

.deal_product_actions button {
    padding: 9px 16px;

    border-radius: 7px;

    font-size: 14px;

    cursor: pointer;

    transition: all .3s ease;
}

#dealProductCancel {
    border: 1px solid #ddd;

    background: #f5f5f5;

    color: #222;
}

#dealProductCancel:hover {
    background: #e5e5e5;
}

#dealProductAdd {
    border: 1px solid #007bff;

    background: #007bff;

    color: #fff;
    
    transition: all .5s;
}

#dealProductAdd:hover {
    background: #fff;

    color: #007bff;
}


.deal_product_remove {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 34px;
    height: 34px;
    margin-left: auto;
    padding: 0;

    border: 1px solid #e5e5e5;
    border-radius: 8px;

    background: #fff;
    color: #777;

    font-size: 16px;

    cursor: pointer;

    transition: all .2s ease;
}

.deal_product_remove:hover {
    background: #fff1f1;
    border-color: #ff5c5c;
    color: #e53935;
}

.deal_product_remove:active {
    transform: scale(.95);
}

.deal_product_row {
    padding: 14px 0;
    border-bottom: 1px solid #222;
}

.deal_product_row:last-child {
    border-bottom: none;
}

/* =========================================================
   POPUP ПРОСМОТРА СДЕЛКИ
========================================================= */

#dealDetailsModal {
    position: fixed;
    inset: 0;

    z-index: 10000;

    display: none;

    width: 100vw;
    height: 100vh;

    padding: 24px;

    box-sizing: border-box;

    align-items: center;
    justify-content: center;

    background: rgba(15, 23, 42, 0.55);

    overflow-y: auto;
}


/* Открытое состояние */

#dealDetailsModal.active {
    display: flex;
}


/* =========================================================
   САМО ОКНО
========================================================= */

#dealDetailsModal .deal_details_modal {
    position: relative;

    width: 100%;
    max-width: 900px;

    max-height: calc(100vh - 48px);

    margin: auto;

    box-sizing: border-box;

    background: #ffffff;

    border-radius: 18px;

    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.18);

    overflow: hidden;

    display: flex;
    flex-direction: column;
}


/* =========================================================
   HEADER
========================================================= */

#dealDetailsModal .deal_modal_header {
    position: relative;

    display: flex;

    align-items: flex-start;
    justify-content: space-between;

    gap: 20px;

    padding: 24px 28px;

    border-bottom: 1px solid #e5e7eb;

    background: #ffffff;
}


#dealDetailsModal .deal_modal_header h2 {
    margin: 0;

    font-size: 22px;
    line-height: 1.3;

    font-weight: 700;

    color: #111827;
}


#dealDetailsModal .deal_modal_header p {
    margin: 6px 0 0;

    font-size: 14px;

    color: #6b7280;
}


/* Кнопка закрытия */

#dealDetailsModal .deal_modal_close {
    flex-shrink: 0;

    width: 38px;
    height: 38px;

    padding: 0;

    border: none;

    border-radius: 10px;

    background: #f3f4f6;

    color: #6b7280;

    font-size: 24px;

    line-height: 1;

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}


#dealDetailsModal .deal_modal_close:hover {
    background: #e5e7eb;

    color: #111827;

    transform: scale(1.04);
}


/* =========================================================
   CONTENT
========================================================= */

#dealDetailsModal .deal_details_content {
    padding: 28px;

    overflow-y: auto;

    display: flex;
    flex-direction: column;

    gap: 24px;
}


/* =========================================================
   ОСНОВНАЯ ИНФОРМАЦИЯ
========================================================= */

#dealDetailsModal .deal_details_info {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 12px;
}


#dealDetailsModal .deal_details_info > div {
    min-width: 0;

    padding: 15px 16px;

    border: 1px solid #e5e7eb;

    border-radius: 12px;

    background: #f9fafb;

    display: flex;
    flex-direction: column;

    gap: 7px;
}


#dealDetailsModal .deal_details_info span {
    font-size: 12px;

    font-weight: 500;

    color: #6b7280;
}


#dealDetailsModal .deal_details_info strong {
    min-width: 0;

    font-size: 14px;

    font-weight: 600;

    color: #111827;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;
}


/* =========================================================
   ОПИСАНИЕ
========================================================= */

#dealDetailsModal .deal_details_description {
    display: flex;
    flex-direction: column;

    gap: 8px;
}


#dealDetailsModal .deal_details_description > span {
    font-size: 13px;

    font-weight: 600;

    color: #374151;
}


#dealDetailsModal .deal_details_description p {
    margin: 0;

    padding: 15px 16px;

    min-height: 50px;

    box-sizing: border-box;

    border: 1px solid #e5e7eb;

    border-radius: 12px;

    background: #f9fafb;

    font-size: 14px;

    line-height: 1.5;

    color: #374151;
}


/* =========================================================
   ТОВАРЫ
========================================================= */

#dealDetailsModal .deal_details_products {
    display: flex;
    flex-direction: column;

    gap: 10px;
}


#dealDetailsModal .deal_details_products
.deal_section_header {
    margin-bottom: 0;
}


#dealDetailsModal .deal_details_products
.deal_section_header h3 {
    margin: 0;

    font-size: 17px;

    font-weight: 700;

    color: #111827;
}


/* Список товаров */

#dealDetailsModal #dealDetailsProducts {
    width: 100%;
}


/* Строка товара */

#dealDetailsModal #dealDetailsProducts
.deal_product_row {

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        100px
        140px;

    align-items: center;

    gap: 20px;

    padding: 16px 0;

    border-bottom: 1px solid #e5e7eb;
}


#dealDetailsModal #dealDetailsProducts
.deal_product_row:last-child {
    border-bottom: none;
}


/* Название */

#dealDetailsModal #dealDetailsProducts
.deal_product_name {
    min-width: 0;

    display: flex;
    flex-direction: column;

    gap: 5px;
}


#dealDetailsModal #dealDetailsProducts
.deal_product_name strong {

    font-size: 14px;

    font-weight: 600;

    color: #111827;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;
}


#dealDetailsModal #dealDetailsProducts
.deal_product_name span {

    font-size: 13px;

    color: #6b7280;
}


/* Количество */

#dealDetailsModal #dealDetailsProducts
.deal_product_quantity {

    text-align: center;

    font-size: 14px;

    color: #374151;
}


/* Сумма */

#dealDetailsModal #dealDetailsProducts
.deal_product_sum {

    text-align: right;
}


#dealDetailsModal #dealDetailsProducts
.deal_product_sum strong {

    font-size: 14px;

    font-weight: 600;

    color: #111827;
}


/* Нет товаров */

#dealDetailsModal .deal_details_empty {

    padding: 30px 20px;

    text-align: center;

    border: 1px dashed #d1d5db;

    border-radius: 12px;

    color: #6b7280;

    font-size: 14px;
}


/* =========================================================
   ИТОГО
========================================================= */

#dealDetailsModal .deal_total {

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 20px;

    padding-top: 20px;

    border-top: 2px solid #e5e7eb;
}


#dealDetailsModal .deal_total span {

    font-size: 14px;

    font-weight: 500;

    color: #6b7280;
}


#dealDetailsModal .deal_total strong {

    font-size: 22px;

    font-weight: 700;

    color: #111827;
}


/* =========================================================
   СКРОЛЛ
========================================================= */

#dealDetailsModal .deal_details_content::-webkit-scrollbar {
    width: 7px;
}


#dealDetailsModal .deal_details_content::-webkit-scrollbar-track {
    background: transparent;
}


#dealDetailsModal .deal_details_content::-webkit-scrollbar-thumb {
    background: #d1d5db;

    border-radius: 10px;
}
.deal_edit_form {
    display: none;
}


.deal_edit_action {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    height: 38px;
    padding: 0 16px;

    border: 1px solid #d9dee7;
    border-radius: 8px;

    background: #ffffff;
    color: #374151;

    font-size: 14px;
    font-weight: 500;

    cursor: pointer;

    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease;
}

.deal_edit_action:hover {
    background: #f5f7fa;
    border-color: #c7ced9;
    color: #111827;
}

.deal_edit_action:active {
    background: #eef1f5;
    transform: translateY(1px);
}

.deal_edit_action:focus-visible {
    outline: none;
    border-color: #7c8cff;
    box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.15);
}

/* =========================================================
   РЕЖИМ РЕДАКТИРОВАНИЯ СДЕЛКИ
========================================================= */

#dealDetailsModal.editing .deal_timeline {
    display: none;
}

.deal_details_info_item.delivery_address {
    grid-column: 1 / -1;
}

#dealDetailsDeliveryAddress {
    min-width: 0;
    max-width: 100%;

    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

#dealDetailsCustomerPhone {
    color: inherit;
    text-decoration: none;
}