/* Mobile cards and mobile modal sheets */
@media (max-width: 1023.98px) {
    #card-view-container { display: block !important; }
    .mob-wh-card-list { display: block !important; }

    #orderModal.modal {
        overscroll-behavior-y: contain;
    }

    #orderModal .modal-dialog {
        margin: 0;
        max-width: 100%;
        width: 100%;
        height: 100dvh;
        min-height: 100dvh;
        align-items: flex-end;
    }

    #orderModal .modal-content {
        display: flex;
        flex-direction: column;
        border-radius: 22px 22px 0 0;
        height: min(100dvh, 100%);
        max-height: 100dvh;
        box-shadow: 0 -18px 42px rgba(15, 23, 42, 0.22);
        overflow: hidden;
    }

    #orderModal .order-modal-form {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    #orderModal .order-modal-header {
        padding-top: 1rem;
    }

    #orderModal .order-modal-header::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 42px;
        height: 5px;
        border-radius: 999px;
        background: #d6dbe5;
    }

    #orderModal .order-modal-body {
        flex: 1 1 auto;
        min-height: 0;
        padding: 1rem .9rem 1.1rem;
        max-height: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    #orderModal .order-modal-layout {
        grid-template-columns: 1fr;
        gap: .85rem;
    }

    #orderModal .order-modal-main {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    #orderModal .order-history-sidebar {
        display: none;
    }

    .order-fields-row {
        flex-direction: column;
        gap: .65rem;
    }

    .order-field {
        width: 100%;
        flex: 1 1 100%;
        min-width: unset;
    }

    .order-field .settings-input {
        width: 100%;
    }

    .order-product-inputs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .6rem;
        align-items: start;
    }

    .order-product-name-wrap {
        grid-column: 1 / -1;
        min-width: unset;
        width: 100%;
    }

    .order-field[style*="max-width:120px"],
    .order-field[style*="max-width:90px"] {
        min-width: 0;
        max-width: none !important;
        width: 100%;
        flex: 1 1 auto;
    }

    .order-product-submit-wrap {
        grid-column: 1 / -1;
        width: 100%;
    }

    .order-product-submit-btn {
        width: 100%;
        min-width: 0;
    }

    .order-status-pills {
        gap: .4rem;
    }

    .osp-pill {
        font-size: .78rem;
        padding: .55rem .7rem;
        min-height: 44px;
    }

    #orderModal .order-manager-section {
        padding: .85rem .9rem;
        gap: .5rem;
    }

    #orderModal .order-manager-help {
        font-size: .78rem;
    }

    #orderModal .order-manager-selection {
        max-height: min(32dvh, 260px);
        padding: .35rem;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    #orderModal .order-manager-selection .manager-item {
        min-height: 44px;
        padding: .45rem .55rem;
        margin: .2rem 0;
        font-size: .82rem;
        line-height: 1.3;
        transform: none;
    }

    #orderModal .order-manager-selection .manager-item-avatar {
        width: 26px;
        height: 26px;
        font-size: .64rem;
    }

    #orderModal .order-manager-selection .manager-item-title {
        font-size: .78rem;
    }

    #orderModal .order-manager-selection .manager-item-hint {
        font-size: .67rem;
    }

    #orderModal .order-manager-selection .manager-item:hover,
    #orderModal .order-manager-selection .manager-item.selected:hover {
        transform: none;
    }

    .order-modal-footer {
        flex-shrink: 0;
        padding: .8rem .9rem calc(.95rem + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid #edf1f7;
        background: rgba(255,255,255,0.98);
    }

    .order-delete-icon-btn {
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 10px;
        background: #ef4444 !important;
        border-color: #ef4444 !important;
        color: #fff !important;
        justify-content: center;
        flex-shrink: 0;
    }

    .order-delete-icon-btn:hover {
        background: #dc2626 !important;
        border-color: #dc2626 !important;
    }

    .order-footer-btn {
        height: 44px;
        padding: 0 1rem;
        font-size: .875rem;
    }

    #warehouseModal .modal-dialog {
        margin: .75rem auto;
        width: calc(100% - 1rem);
        max-width: calc(100% - 1rem);
        min-height: calc(100dvh - 1.5rem);
    }

    #warehouseModal.modal {
        overscroll-behavior-y: contain;
    }

    #warehouseModal .wh-modal-content {
        display: flex;
        flex-direction: column;
        max-height: calc(100dvh - 1.5rem);
        overflow: hidden;
    }

    #warehouseModal .warehouse-modal-form {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    #warehouseModal .wh-modal-content {
        border-radius: 22px 22px 0 0;
    }

    #warehouseModal .wh-modal-header {
        position: relative;
        padding-top: 1.2rem;
    }

    #warehouseModal .wh-modal-header::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 42px;
        height: 5px;
        border-radius: 999px;
        background: #d6dbe5;
    }

    #warehouseModal .wh-modal-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 1rem;
    }

    #warehouseModal .wh-modal-metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    #warehouseModal .wh-modal-metrics-grid > :first-child {
        grid-column: 1 / -1;
    }

    #warehouseModal #warehouse-product-title,
    #warehouseModal #warehouse-sku,
    #warehouseModal #warehouse-quantity,
    #warehouseModal #warehouse-price,
    #warehouseModal #warehouse-description,
    #warehouseModal #warehouse-category {
        width: 100%;
        min-width: 0;
    }

    #warehouseModal .wh-modal-footer {
        flex-shrink: 0;
    }
}

@media (min-width: 1024px) {
    #card-view-container { display: none !important; }
    .mob-wh-card-list { display: none !important; }
}

.mob-order-card {
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    border-radius: 18px;
    border: 1px solid #e8ecf3;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.07);
    padding: 1rem;
    margin-bottom: .85rem;
    position: relative;
}

.mob-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
}

.mob-card-name {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.mob-card-top .badge {
    font-size: .7rem !important;
    font-weight: 600 !important;
    padding: .25rem .6rem !important;
    border-radius: 999px !important;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.4;
}

.mob-card-phone {
    font-size: .85rem;
    color: #64748b;
    margin-bottom: .45rem;
    font-variant-numeric: tabular-nums;
}

.mob-card-phone:empty {
    display: none;
}

.mob-card-products {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem .5rem;
    margin-bottom: .55rem;
}

.mob-product-item {
    font-size: .875rem;
    color: #1e293b;
    font-weight: 500;
}

.mob-qty {
    font-size: .78rem;
    color: #94a3b8;
    font-weight: 400;
}

.mob-card-total {
    font-size: 1.05rem;
    font-weight: 800;
    color: #4338ca;
    margin-bottom: .5rem;
    letter-spacing: -.01em;
}

.mob-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .75rem;
    color: #94a3b8;
    margin-bottom: .3rem;
    gap: .5rem;
}

.mob-card-manager {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mob-card-date {
    white-space: nowrap;
    flex-shrink: 0;
}

.mob-card-comment {
    font-size: .8rem;
    color: #64748b;
    border-left: 3px solid #d8def0;
    padding-left: .6rem;
    margin-bottom: .5rem;
    word-break: break-word;
}

.mob-card-address {
    color: #334155;
    font-style: normal;
    font-weight: 500;
    margin-bottom: .2rem;
}

.mob-card-note {
    color: #64748b;
    font-style: italic;
}

.mob-card-divider {
    border: none;
    border-top: 1px solid #f1f5f9;
    margin: .65rem 0 .6rem;
}

.mob-card-actions {
    display: flex;
    gap: .5rem;
    margin-top: 0.15rem;
}

.mob-btn-edit,
.mob-btn-delete {
    flex: 1;
    padding: .5rem .25rem;
    border-radius: 9px;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    transition: background .13s;
    min-height: 40px;
    -webkit-tap-highlight-color: transparent;
}

.mob-btn-edit {
    border: 1.5px solid #c7d2fe;
    background: #fafafe;
    color: #4f46e5;
}

.mob-btn-edit:hover,
.mob-btn-edit:active {
    background: #ede9fe;
}

.mob-btn-delete {
    border: 1.5px solid #fecaca;
    background: #fafafe;
    color: #ef4444;
}

.mob-btn-delete:hover,
.mob-btn-delete:active {
    background: #fee2e2;
}

.mob-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: #94a3b8;
    font-size: .9rem;
}

.mob-empty i {
    display: block;
    font-size: 2rem;
    margin-bottom: .5rem;
    color: #cbd5e1;
}

.mob-wh-card-list {
    padding: 0;
}

.mob-wh-card {
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    border-radius: 18px;
    border: 1px solid #e8ecf3;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.07);
    padding: .9rem 1rem;
    margin-bottom: .75rem;
}

.mob-wh-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .3rem;
}

.mob-wh-title {
    font-size: .975rem;
    font-weight: 700;
    color: #1e293b;
    flex: 1;
    min-width: 0;
    word-break: break-word;
    line-height: 1.3;
}

.mob-wh-sku {
    font-size: .68rem;
    background: #ede9fe;
    color: #5b21b6;
    padding: .2rem .55rem;
    border-radius: 6px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: .02em;
}

.mob-wh-desc {
    font-size: .82rem;
    color: #64748b;
    margin-bottom: .65rem;
    line-height: 1.4;
}

.mob-wh-desc:empty {
    display: none;
}

.mob-wh-bottom {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}

.mob-wh-qty-ctrl {
    display: inline-flex;
    align-items: center;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
}

.mob-wh-qty-btn {
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background .1s;
}

.mob-wh-qty-btn:active {
    background: #e2e8f0;
}

.mob-wh-qty-sep {
    width: 1px;
    height: 20px;
    background: #e2e8f0;
    flex-shrink: 0;
}

.mob-wh-qty-val {
    min-width: 38px;
    text-align: center;
    font-size: .9rem;
    font-weight: 700;
    color: #1e293b;
    padding: 0 4px;
}

.mob-wh-qty-ok {
    color: #1e293b;
}

.mob-wh-qty-zero {
    color: #ef4444;
}

.mob-wh-price {
    font-size: .9rem;
    font-weight: 700;
    color: #1e293b;
    margin-left: auto;
    white-space: nowrap;
}

.mob-wh-price-none {
    color: #94a3b8;
    font-weight: 400;
}

.mob-wh-actions {
    display: flex;
    gap: .4rem;
    flex-shrink: 0;
}

.mob-wh-btn {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    -webkit-tap-highlight-color: transparent;
    transition: background .13s;
}

.mob-wh-edit-btn {
    color: #4f46e5;
    border-color: #c7d2fe;
}

.mob-wh-edit-btn:active {
    background: #ede9fe;
}

.mob-wh-del-btn {
    color: #ef4444;
    border-color: #fecaca;
}

.mob-wh-del-btn:active {
    background: #fee2e2;
}

@media (max-width: 399px) {
    .mob-card-name { font-size: .9rem; }
    .mob-wh-title { font-size: .9rem; }
    .mob-card-total { font-size: .975rem; }
    .mob-btn-edit,
    .mob-btn-delete { font-size: .78rem; }
}

/* opl inline edit — адаптив */
@media (max-width: 1023.98px) {
    .opl-row.opl-editing {
        flex-wrap: wrap;
        gap: .5rem;
    }

    .opl-edit-fields {
        flex: 1 1 100%;
        gap: .35rem;
    }

    .opl-edit-fields .opl-edit-price,
    .opl-edit-fields .opl-edit-qty {
        width: 68px;
    }

    .opl-row.opl-editing .opl-actions {
        flex: 1;
        justify-content: flex-end;
    }
}

@media (max-width: 399px) {
    .opl-edit-fields .opl-edit-price,
    .opl-edit-fields .opl-edit-qty {
        width: 58px;
    }
}
