.order-create-shell {
    min-height: 100%;
    padding: 16px 18px 22px;
}

.order-create {
    --order-ink: #241713;
    --order-muted: #625957;
    --order-accent: var(--primary);
    --order-accent-text: color-mix(in srgb, var(--order-accent) 45%, #000);
    --order-border: color-mix(in srgb, var(--order-accent) 18%, #fff);
    --order-divider: color-mix(in srgb, var(--order-accent) 22%, #d1d5db);
    --order-input-border: #c9cdd7;
    --order-heading: color-mix(in srgb, var(--order-accent) 8%, #fff);
    --order-surface: color-mix(in srgb, var(--order-accent) 2%, #fff);
    --order-price: #d71320;
    --order-shadow: 0 4px 12px color-mix(in srgb, var(--order-accent) 7%, transparent);
    display: grid;
    gap: 16px;
    padding: 12px 20px 18px;
    border-radius: 22px;
    background: var(--order-surface);
    color: var(--order-ink);
    box-shadow: 0 8px 20px color-mix(in srgb, var(--order-accent) 9%, transparent);
}

.order-create-section-heading {
    display: flex;
    align-items: center;
    gap: 14px;
}

.order-create-section-heading h2 {
    margin: 0 0 3px;
    color: var(--order-ink);
    font-weight: 750;
    line-height: 1.2;
}

.order-create-section-heading h2 { font-size: 1.125rem; }

.order-create-section-heading p {
    margin: 0;
    color: var(--order-muted);
    line-height: 1.35;
}

.order-create-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(145deg, var(--order-heading), var(--order-border));
    color: var(--order-accent-text);
    font-size: 1.4rem;
    text-decoration: none;
}

.order-create-panel {
    min-width: 0;
    border: 1px solid var(--order-border);
    border-radius: 17px;
    background: var(--order-surface);
    box-shadow: var(--order-shadow);
}

.order-create-section-heading {
    padding: 10px 14px;
    border-radius: 16px 16px 0 0;
    background: linear-gradient(105deg, var(--order-surface), var(--order-heading));
}

.order-create-fields {
    display: grid;
    gap: 12px;
    padding: 12px 20px 14px;
}

.order-create-info .order-create-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: clamp(20px, 3vw, 42px);
}

.order-create-fields > div { min-width: 0; }
.order-create-fields > div > :last-child { margin-bottom: 0 !important; }

.order-create-fields .form-label {
    margin-bottom: 4px;
    color: var(--order-ink);
    font-weight: 650;
    line-height: 20px;
}

.order-create-fields :is(.form-control, .select2-selection),
.order-create .note-tb {
    min-height: 38px;
    border: 1px solid var(--order-input-border);
    border-radius: 9px;
    background-color: #fff;
    color: var(--order-ink);
}

.order-create-fields .select2-container { display: block; width: 100% !important; }
.order-create-fields .select-0 { position: absolute; }
.order-create-fields .select2-selection__rendered { line-height: 36px !important; }
.order-create-fields textarea.form-control { height: 68px; min-height: 68px; resize: vertical; }
.order-create-fields textarea::placeholder,
.order-create .note-tb::placeholder { color: var(--order-muted); font-style: italic; }

.order-create-field-icon,
.order-create-note { position: relative; }

.order-create-field-icon > i,
.order-create-note > i {
    position: absolute;
    top: 43px;
    inset-inline-start: 12px;
    z-index: 1;
    color: var(--order-muted);
    font-size: 1.05rem;
    line-height: 1;
    pointer-events: none;
    transform: translateY(-50%);
}

.order-create-field-icon :is(.form-control, .select2-selection__rendered),
.order-create-note .note-tb { padding-inline-start: 36px !important; }
.order-create-note > i { top: 50%; }

.order-create-product-body { padding: 10px 18px 16px; }
.order-create-table { margin-top: 12px; border: 1px solid var(--order-border); border-radius: 12px; overflow-x: auto; }
.order-create-table table { margin-bottom: 0; }

.order-create-table .product-table :is(th, td) {
    padding: 7px 10px;
    border-color: var(--order-border);
    color: var(--order-ink);
}

.order-create-table .product-table th {
    background: color-mix(in srgb, var(--order-accent) 12%, #fff);
    font-size: .875rem;
    text-transform: none;
    white-space: nowrap;
}

.order-create-table .product-table tr:last-child td { border-bottom: 0; }
.order-create-table :is(th, td):first-child { width: 60px; text-align: center; }
.order-create:not(.order-detail) .order-create-table :is(th, td):nth-child(2) { width: 92px; }
.order-create-table :is(th, td):nth-child(4) { min-width: 84px; }
.order-create-table :is(th, td):nth-child(7) { width: 21%; min-width: 120px; }
.order-create-table .order-quantity-control { margin-inline: auto; }
.order-create-table .note-tb { min-height: 34px; }
.order-create-subtotal { font-weight: 700; white-space: nowrap; }

.order-create-image { width: 64px; height: 44px; }
.order-create-image :is(.product-box, .product-img) { width: 100%; height: 100%; border-radius: 8px; }
.order-create-image .product-box {
    display: grid;
    place-items: center;
    border: 1px solid var(--order-border);
    background: var(--order-heading);
    color: #72666b;
    font-size: 1.45rem;
}

.order-create .product-name { padding: 0; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.order-create .product-code { color: var(--order-muted); font-size: .85em; }
.order-create .price-promotion > * { display: block; }
.order-create :is(.product-price, .product-price-promotion) { color: var(--order-price); font-weight: 750; white-space: nowrap; }
.order-create .product-price-old { color: var(--order-muted); font-size: .8em; white-space: nowrap; }
.order-create .order-quantity-control {
    border-color: var(--order-border);
    background: var(--order-surface);
    box-shadow: var(--order-shadow);
}

.order-create .order-quantity-control:focus-within { border-color: var(--order-accent); }
.order-create .order-quantity-control .btn-qty:focus-visible { outline-color: var(--order-accent); }
.order-create .order-quantity-control .btn-plus {
    background: var(--order-accent);
    border-color: var(--order-accent);
    color: var(--primaryText);
}

.order-create .remove-row {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 36px;
    padding: 0;
    border-radius: 9px;
    background: #fceeea;
    color: var(--order-price);
    font-size: 1rem;
}

.order-create .remove-row:hover { background: #fae1dc; color: #ab101b; }
.order-create-empty { margin: 12px 0 0; color: var(--order-muted); }
.order-create-product-body:has(#productOnDesktop > tr) .order-create-empty { display: none; }
.order-create-delivery { padding: 14px 20px; overflow-wrap: anywhere; }
.order-create-delivery .order-delivery-title { margin-bottom: 6px; color: var(--order-accent-text) !important; }
.order-create-delivery .delivery-info > div { max-width: 100%; }

.order-create-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 24px;
    min-width: 0;
}

.order-create-total { display: grid; gap: 4px; min-width: 210px; margin: 0; }
.order-create-total > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.order-create-total dt { font-weight: 500; }
.order-create-total dd { margin: 0; color: var(--order-accent-text); font-weight: 750; }
.order-create-total .total-last-amount { font-size: 1.25rem; }
.order-create-actions { display: flex; gap: 10px; padding-inline-start: 24px; border-inline-start: 1px solid var(--order-divider); }

.order-create .order-create-outline { border-color: var(--order-accent); color: var(--order-accent-text); }
.order-create .order-create-cancel { border-color: var(--order-divider); color: var(--order-ink); }
.order-create :is(.order-create-outline, .order-create-cancel):hover { background: var(--order-heading); color: var(--order-accent-text); }
.order-create .remove-row:focus-visible { outline: 2px solid var(--order-accent); outline-offset: 2px; }

.order-detail-meta {
    display: flex;
    flex-wrap: wrap;
    column-gap: 10px;
}

.order-detail-approved { color: var(--order-accent-text); }
.order-detail-heading-actions { display: flex; gap: 8px; }
.order-detail-heading-actions .btn-outline-danger { border-color: var(--bs-btn-border-color); }
.order-detail .order-create-table { margin-top: 0; }
.order-detail-note { overflow-wrap: anywhere; white-space: pre-wrap; }
.order-detail .order-quantity-control .product-qty.is-invalid { color: var(--bs-danger); }
.order-detail .damage-input-wrap:has(.is-invalid) .invalid-feedback { display: block; }

@media (max-width: 991.98px) {
    .order-create-shell { padding: 0; }
    .order-create { display: flex; flex-direction: column; min-height: calc(100dvh - var(--app-header-height)); gap: 16px; padding: 14px 12px 0; background: transparent; box-shadow: none; }
    .order-create-section-heading p { font-size: .875rem; }
    .order-create-info > .order-create-section-heading { display: none; }
    .order-create-info .order-create-fields { grid-template-columns: minmax(0, 1fr); }
    .order-create-fields { padding: 14px; }
    .order-create-fields :is(.form-control, .select2-selection), .order-create .note-tb { min-height: 42px; }
    .order-create .order-create-fields input.tflatpickr.form-control { min-height: 42px; }
    .order-create-fields textarea.form-control { height: 62px; min-height: 62px; }
    .order-create-fields .select2-selection__rendered { line-height: 40px !important; }
    .order-create-field-icon > i { top: 45px; }
    .order-create-section-heading { gap: 9px; }
    .order-create-products .order-create-icon { background: transparent; }
    .order-create-product-body { padding: 10px 12px 14px; }
    .order-create-cards { display: grid; gap: 10px; margin-top: 10px; }
    .order-create-cards:empty { margin-top: 0; }

    .order-create-product-card {
        --order-quantity-width: clamp(92px, 29vw, 132px);
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) calc(var(--order-quantity-width) - 48px) 38px;
        grid-template-areas: 'image title title remove' 'image price quantity quantity' 'note note note note';
        gap: 8px 10px;
        align-items: center;
        min-width: 0;
        padding: 10px;
        border: 1px solid var(--order-border);
        border-radius: 14px;
        background: var(--order-surface);
        box-shadow: var(--order-shadow);
    }

    .order-create-product-card .order-create-image { grid-area: image; width: clamp(44px, 15vw, 72px); height: clamp(50px, 16vw, 76px); }
    .order-create-product-card .order-create-product-title { grid-area: title; }
    .order-create-product-card .remove-row { grid-area: remove; justify-self: end; align-self: start; }
    .order-create-product-card .order-create-product-price { grid-area: price; }
    .order-create-product-card .order-quantity-control { grid-area: quantity; width: var(--order-quantity-width); }
    .order-create-product-card .order-create-note { grid-area: note; }
    .order-create .note-tb, .order-create-fields :is(input, textarea) { font-size: 16px; }
    .order-create-product-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 6px; color: var(--order-muted); font-size: .85rem; }
    .order-create-product-meta .product-code { font-size: inherit; }
    .order-create-product-meta .orderly:not(:has(.product-unit)) { padding-inline-end: 6px; border-inline-end: 1px solid var(--order-divider); }
    .order-create-product-meta .select2-container { min-width: 66px; max-width: 100%; }

    .order-detail .app-form-heading { flex-wrap: wrap; row-gap: 10px; }
    .order-detail-heading-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        flex-basis: 100%;
    }
    .order-detail-heading-actions .app-form-button { min-height: 44px; padding-inline: 8px; white-space: normal; }
    .order-detail .order-create-info > .order-create-section-heading { display: flex; }
    .order-detail .order-create-fields { gap: 8px; }
    .order-detail .order-create-cards { margin-top: 0; }
    .order-detail .order-create-product-card {
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas: 'image title title' 'image price quantity';
    }
    .order-detail-quantity {
        grid-area: quantity;
        justify-self: end;
        color: var(--order-muted);
        font-size: .875rem;
        text-align: end;
    }
    .order-detail :is(.order-detail-damage, .order-detail-note) {
        grid-column: 1 / -1;
        color: var(--order-muted);
        font-size: .875rem;
    }
    .order-detail-damage {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
    }
    .order-detail .order-detail-damage .order-quantity-control { width: 132px; }

    .order-create-footer {
        position: sticky;
        z-index: 10;
        bottom: 0;
        justify-content: space-between;
        gap: 8px 10px;
        margin-top: auto;
        margin-inline: -12px;
        padding: 9px 12px calc(9px + env(safe-area-inset-bottom, 0px));
        border: 1px solid var(--order-border);
        border-radius: 16px 16px 0 0;
        background: var(--order-surface);
        box-shadow: 0 -5px 15px color-mix(in srgb, var(--order-accent) 8%, transparent);
    }

    .order-create-total { min-width: 0; display: flex; flex-wrap: wrap; gap: 5px 8px; }
    .order-create-total > div { display: block; }
    .order-create-total > div + div { padding-inline-start: 8px; border-inline-start: 1px solid var(--order-divider); }
    .order-create-total dt { color: var(--order-muted); font-size: .75rem; }
    .order-create-total .total-last-amount { font-size: clamp(.93rem, 3.9vw, 1.15rem); overflow-wrap: anywhere; }
    .order-create-actions { gap: 6px; padding-inline-start: 0; border: 0; }
    .order-create .order-create-actions .app-form-button { min-height: 42px; padding-inline: 10px; }
    .order-create .order-create-cancel { border-color: var(--order-accent); color: var(--order-accent-text); }
    .order-detail .order-create-footer { flex-wrap: wrap; }
    .order-detail .order-create-actions { margin-inline-start: auto; }
}

@media (max-width: 359.98px) {
    .order-create-product-card { --order-quantity-width: 108px; grid-template-areas: 'image title title remove' 'price price quantity quantity' 'note note note note'; }
    .order-detail .order-create-product-card { grid-template-areas: 'image title title' 'price price quantity'; }
    .order-create .order-create-actions .app-form-button { padding-inline: 7px; }
}
