:root {
    --po-red: #e0523c;
    --po-red-light: #fef0f0;
    --po-blue: #2c99d4;
    --po-blue-light: #eff6ff;
    --po-black: #1a1a1a;
    --po-gray-50: #f8fafb;
    --po-gray-100: #f5f5f5;
    --po-gray-200: #e5e5e5;
    --po-gray-300: #d4d4d4;
    --po-gray-400: #a3a3a3;
    --po-gray-500: #737373;
    --po-gray-600: #404040;
    --po-green: #16a34a;
    --po-green-light: #f0fdf4;
    --po-orange: #f97316;
}

.place-order-shell {
    background: var(--po-gray-50);
    min-height: 70vh;
    padding: 1.5rem 0 4rem;
}

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.place-order-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.place-order-kicker {
    color: var(--po-red);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.place-order-title {
    color: var(--po-black);
    font-size: 1.75rem;
    line-height: 1.15;
    font-weight: 800;
}

.place-order-subtitle {
    color: var(--po-gray-500);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.place-order-cart-link,
.checkout-link {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 38px;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    background: var(--po-black);
    color: #fff;
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 700;
    white-space: nowrap;
}

.place-order-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 1.5rem;
    align-items: flex-start;
}

.order-entry-panel,
.cart-side-card {
    background: #fff;
    border: 1px solid var(--po-gray-200);
    border-radius: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.order-entry-panel {
    overflow: hidden;
}

.search-toolbar {
    padding: 1rem 1rem 0.75rem 1rem;
    border-bottom: 1px solid var(--po-gray-100);
}

.order-search-box {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-height: 44px;
    padding: 0 0.875rem;
    border: 1.5px solid var(--po-gray-200);
    border-radius: 9999px;
    background: var(--po-gray-50);
    transition: all 0.2s;
}

.order-search-box:focus-within {
    border-color: var(--po-red);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(224, 82, 60, 0.08);
}

.order-search-box svg {
    color: var(--po-gray-400);
    flex-shrink: 0;
}

.order-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: var(--po-black);
    font-family: inherit;
    font-size: 0.9375rem;
}

.order-search-box kbd {
    background: #fff;
    border: 1px solid var(--po-gray-200);
    border-radius: 4px;
    color: var(--po-gray-500);
    font-family: inherit;
    font-size: 0.6875rem;
    padding: 0.125rem 0.375rem;
}

.search-helper-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 36px;
    padding: 0 1rem;
    color: var(--po-gray-500);
    font-size: 0.75rem;
    border-bottom: 1px solid var(--po-gray-100);
}

.order-results-shell {
    width: 100%;
    overflow-x: visible;
}

/* DESKTOP STYLES */
.order-results-head {
    display: grid;
    grid-template-columns: minmax(200px, 2fr) 70px 65px 70px 75px 75px 65px 95px;
    gap: 0.5rem;
    align-items: center;
    background: var(--po-gray-50);
    border-bottom: 1px solid var(--po-gray-200);
    color: var(--po-gray-500);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 0.625rem 1rem;
    white-space: nowrap;
}

.order-results-list {
    max-height: 620px;
    min-height: 320px;
    overflow-y: auto;
}

.order-result-row {
    display: grid;
    grid-template-columns: minmax(200px, 2fr) 70px 65px 70px 75px 75px 65px 95px;
    gap: 0.5rem;
    align-items: center;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--po-gray-100);
    /* background: #fff; */
    cursor: pointer;
    transition: background 0.1s;
    font-size: 0.75rem;
}

.order-result-row .product-title strong {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--po-black);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-result-row .product-title span {
    font-size: 0.68rem;
    color: var(--po-gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Desktop row highlight */
.order-result-row.selected {
    background: var(--po-red-light);
    border-left: 4px solid var(--po-red);
    box-shadow: inset 0 0 0 1px rgba(224, 82, 60, 0.2);
}

.order-result-row.selected .product-title strong {
    color: var(--po-red);
}

.order-result-row:hover {
    background: var(--po-gray-50);
}

/* Hide mobile-specific elements on desktop */
.product-details-grid,
.product-actions {
    display: none;
}

/* TABLET & MOBILE STYLES - Card layout (same fields as desktop) */
@media (max-width: 1024px) {
    .order-results-head {
        display: none;
    }

    .order-results-list {
        padding: 0.5rem;
    }

    .order-result-row {
        display: block;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
        border-radius: 12px;
        border: 1px solid var(--po-gray-200);
        background: #fff;
        transition: all 0.2s ease;
    }

    .order-result-row:last-child {
        margin-bottom: 0;
    }

    .order-result-row.selected {
        background: var(--po-red-light);
        border-color: var(--po-red);
        border-left: 4px solid var(--po-red);
    }

    .order-result-row.qty-mode {
        background: var(--po-blue-light);
        border-color: var(--po-blue);
        border-left: 4px solid var(--po-blue);
    }

    .order-result-row .product-title {
        margin-bottom: 0.5rem;
    }

    .order-result-row .product-title strong {
        font-size: 0.85rem;
        font-weight: 700;
        color: var(--po-black);
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .order-result-row .product-title span {
        font-size: 0.7rem;
        color: var(--po-gray-500);
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Grid for product details */
    .product-details-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .detail-item {
        display: flex;
        align-items: baseline;
        gap: 0.25rem;
        font-size: 0.7rem;
        flex-wrap: wrap;
    }

    .detail-label {
        color: var(--po-gray-500);
        font-weight: 500;
        font-size: 0.65rem;
    }

    .detail-value {
        color: var(--po-gray-700);
        font-weight: 500;
        font-size: 0.7rem;
    }

    .product-actions {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--po-gray-100);
    }

    .result-qty-cell {
        display: flex;
        gap: 0.5rem;
        align-items: center;
        justify-content: flex-end;
        width: 100%;
    }

    .result-qty-input {
        width: 65px;
        height: 34px;
        font-size: 0.8rem;
        padding: 0 0.35rem;
    }

    .result-add-btn {
        min-width: 60px;
        height: 34px;
        font-size: 0.75rem;
        padding: 0 0.75rem;
    }

    /* Hide original table cells */
    .order-result-row > span:not(.product-title) {
        display: none;
    }
}

/* SMALL MOBILE (below 640px) */
@media (max-width: 640px) {
    .place-order-header {
        flex-direction: column;
    }
    .place-order-cart-link {
        width: 100%;
    }
    .search-toolbar {
        padding: 0.75rem;
    }
    .order-search-box {
        border-radius: 8px;
    }
    .cart-side-item {
        grid-template-columns: 1fr;
    }
    .cart-side-actions {
        align-items: stretch;
    }
    .cart-side-item .line-total {
        text-align: left;
    }

    .order-results-list {
        padding: 0.375rem;
    }
    .order-result-row {
        padding: 0.6rem;
        margin-bottom: 0.6rem;
        border-radius: 10px;
    }
    .product-details-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.375rem;
    }
    .result-qty-input {
        width: 55px;
        height: 32px;
        font-size: 0.75rem;
    }
    .result-add-btn {
        min-width: 55px;
        height: 32px;
        font-size: 0.7rem;
    }
    .order-result-row .product-title strong {
        font-size: 0.8rem;
    }
    .order-result-row .product-title span {
        font-size: 0.65rem;
    }
}

/* TABLET (641px to 1024px) - 3 column grid for details */
@media (min-width: 641px) and (max-width: 1024px) {
    .product-details-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
}

/* Pills and shared styles */
.margin-pill,
.scheme-pill,
.stock-pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 800;
    white-space: nowrap;
}

.margin-pill {
    background: #eef2ff;
    color: #1e40af;
}

.scheme-pill {
    background: linear-gradient(135deg, var(--po-green-light), #d1fae5);
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.stock-pill.in-stock {
    background: var(--po-green);
    color: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.stock-pill.low-stock {
    background: var(--po-orange);
    color: white;
}

.stock-pill.out-of-stock {
    background: #dc2626;
    color: white;
}

.cell-muted {
    color: var(--po-gray-500);
    font-size: 0.7rem;
}

.product-title {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.result-qty-cell {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.375rem;
}

.result-qty-input {
    width: 62px;
    height: 32px;
    border: 1.5px solid var(--po-gray-200);
    border-radius: 8px;
    padding: 0 0.25rem;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    outline: none;
}

.result-qty-input:disabled {
    background: var(--po-gray-100);
    color: var(--po-gray-400);
}

.result-qty-input:focus {
    border-color: var(--po-red);
    box-shadow: 0 0 0 3px rgba(224, 82, 60, 0.2);
    background: #fff;
}

.result-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 32px;
    border: none;
    border-radius: 9999px;
    background: var(--po-black);
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0 0.5rem;
}

.result-add-btn:hover:not(:disabled) {
    background: var(--po-red);
}

.result-add-btn:active {
    transform: scale(0.96);
}

.result-add-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.order-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--po-gray-500);
    font-size: 0.875rem;
    text-align: center;
    padding: 2rem;
}

.order-cart-panel {
    position: sticky;
    top: 92px;
}

.cart-side-card {
    padding: 1rem;
}

.cart-side-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--po-gray-100);
}

.cart-side-header h2 {
    color: var(--po-black);
    font-size: 1rem;
    font-weight: 800;
}

.cart-side-header p {
    color: var(--po-gray-500);
    font-size: 0.75rem;
    margin-top: 0.125rem;
}

.cart-refresh-btn {
    border: 1px solid var(--po-gray-200);
    border-radius: 9999px;
    background: #fff;
    color: var(--po-gray-600);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.375rem 0.75rem;
}

.cart-side-items {
    display: grid;
    gap: 0.5rem;
    max-height: 340px;
    overflow-y: auto;
    padding: 0.875rem 0;
}

.cart-side-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    border: 1px solid var(--po-gray-200);
    border-radius: 8px;
    background: var(--po-gray-50);
    padding: 0.625rem;
}

.cart-side-item strong {
    display: block;
    color: var(--po-black);
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-side-item span {
    color: var(--po-gray-500);
    font-size: 0.75rem;
}

.cart-side-item .line-total {
    color: var(--po-red);
    font-weight: 800;
    white-space: nowrap;
    background: var(--po-red-light);
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
}

.cart-side-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.375rem;
}

.cart-side-remove {
    border: 1px solid #fecaca;
    border-radius: 9999px;
    background: #fff;
    color: #dc2626;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.6875rem;
    font-weight: 800;
    line-height: 1;
    min-height: 26px;
    padding: 0.25rem 0.625rem;
}

.cart-side-remove:hover {
    background: #fef2f2;
}

.cart-side-empty {
    color: var(--po-gray-500);
    border: 1px dashed var(--po-gray-300);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    font-size: 0.8125rem;
}

.cart-side-summary {
    display: grid;
    gap: 0.625rem;
    border-top: 1px solid var(--po-gray-100);
    padding-top: 0.875rem;
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--po-gray-500);
    font-size: 0.8125rem;
}

.cart-summary-row strong {
    color: var(--po-gray-600);
}

.cart-summary-row.total {
    border-top: 1px solid var(--po-gray-200);
    margin-top: 0.25rem;
    padding-top: 0.75rem;
    color: var(--po-black);
    font-weight: 800;
}

.cart-summary-row.total strong {
    color: var(--po-black);
    font-size: 1.125rem;
}

.checkout-link {
    width: 100%;
    margin-top: 1rem;
}

.place-order-toast {
    position: fixed;
    left: 50%;
    bottom: 2rem;
    transform: translateX(-50%) translateY(120%);
    background: var(--po-black);
    color: #fff;
    border-radius: 9999px;
    padding: 0.75rem 1.25rem;
    font-size: 0.8125rem;
    font-weight: 700;
    opacity: 0;
    transition: all 0.25s ease;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.place-order-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.place-order-toast.error {
    border: 1px solid #dc2626;
}

.place-order-toast.success {
    border: 1px solid var(--po-green);
}

@media (max-width: 1100px) {
    .place-order-layout {
        grid-template-columns: 1fr;
    }
    .order-cart-panel {
        position: static;
    }
}

@media (max-width: 1023px) {
    .order-search-box kbd {
        display: none;
    }
}