.mep-stock-end-service-btn {
    display: inline-flex;
    min-width: 128px;
    min-height: 44px;
    margin-left: auto;
    padding: 0 10px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid #007aff;
    border-radius: 8px;
    background: #007aff;
    color: #fff;
    font-size: 12px;
    font-weight: 850;
    line-height: 1.1;
}

.mep-stock-end-service-btn strong {
    display: inline-grid;
    min-width: 21px;
    height: 21px;
    padding: 0 5px;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    font-size: 10px;
}

.mep-stock-end-service-btn.has-reprint {
    border-color: #ff9f0a;
    background: #ff9f0a;
    color: #161616;
}

.mep-stock-end-service-btn:disabled {
    border-color: #c7c7cc;
    background: #e5e5ea;
    color: #8e8e93;
    cursor: not-allowed;
}

.mep-end-service-popup {
    width: min(520px, 100%);
    max-width: 520px;
}

.mep-end-service-heading {
    margin-bottom: 14px;
}

.mep-end-service-heading span {
    display: block;
    color: #007aff;
    font-size: 9px;
    font-weight: 900;
    line-height: 1;
}

.mep-end-service-popup .mep-end-service-heading h3 {
    margin: 5px 0 0;
    text-align: left;
}

.mep-end-service-category-label,
.mep-end-service-printer-label {
    margin: 0 0 6px;
    color: #636366;
    font-size: 11px;
    font-weight: 800;
}

.mep-end-service-popup .mep-end-service-category-select,
.mep-end-service-popup .stock-printer {
    width: 100%;
    margin: 0 0 12px;
}

.mep-end-service-popup .etiquette-btn.print:disabled {
    border-color: #c7c7cc;
    background: #e5e5ea;
    color: #8e8e93;
    cursor: not-allowed;
    opacity: 1;
}

.mep-end-service-workspace {
    max-height: min(58vh, 640px);
    padding-right: 2px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.mep-end-service-general,
.mep-end-service-item-gauge {
    display: grid;
    grid-template-columns: minmax(92px, 1fr) minmax(150px, 1.25fr);
    gap: 10px;
    align-items: center;
}

.mep-end-service-general {
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #b9d8ff;
    border-radius: 8px;
    background: #eef6ff;
}

.mep-end-service-required-banner {
    display: flex;
    margin: 0 0 10px;
    padding: 10px 11px;
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
    border: 1px solid #ff6961;
    border-radius: 8px;
    background: #fff0ef;
    box-shadow: inset 3px 0 0 #ff3b30;
}

.mep-end-service-required-banner strong {
    color: #b42318;
    font-size: 12px;
    font-weight: 900;
}

.mep-end-service-required-banner span {
    color: #7a271f;
    font-size: 11px;
    font-weight: 750;
    line-height: 1.3;
}

.mep-end-service-required-banner[hidden],
.mep-end-service-confirm-qty[hidden] {
    display: none !important;
}

.mep-end-service-overview {
    display: grid;
    margin: 0 0 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid #d1d1d6;
    border-radius: 8px;
    background: #f2f2f7;
}

.mep-end-service-overview span {
    display: flex;
    min-height: 34px;
    padding: 0 6px;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: #636366;
    font-size: 9px;
    font-weight: 800;
    white-space: nowrap;
}

.mep-end-service-overview span + span {
    border-left: 1px solid #d1d1d6;
}

.mep-end-service-overview strong {
    color: #1d1d1f;
    font-size: 13px;
}

.mep-end-service-overview .attention strong {
    color: #ff3b30;
}

.mep-end-service-general > div:first-child,
.mep-end-service-item-gauge > div:first-child {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.mep-end-service-general span,
.mep-end-service-item-gauge span {
    color: #636366;
    font-size: 10px;
    font-weight: 750;
}

.mep-end-service-general strong,
.mep-end-service-item-gauge strong {
    overflow-wrap: anywhere;
    font-size: 13px;
}

.mep-end-service-client-control,
.mep-end-service-unit-control {
    display: grid;
    min-width: 0;
    gap: 4px;
}

.mep-end-service-client-control .mep-qty-stepper,
.mep-end-service-unit-control .mep-qty-stepper {
    min-height: 42px;
}

.mep-end-service-client-control .mep-qty-stepper-value,
.mep-end-service-unit-control .mep-qty-stepper-value {
    color: #0066cc;
    font-size: 18px;
}

.mep-end-service-stepper-caption {
    display: flex;
    min-width: 0;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    color: #636366;
    font-size: 9px;
    font-weight: 750;
}

.mep-end-service-stepper-caption strong {
    color: #0066cc;
    font-size: 9px;
    white-space: nowrap;
}

.mep-end-service-stepper-caption b {
    font-size: 11px;
}

.mep-end-service-items {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 12px;
}

.mep-end-service-item {
    overflow: hidden;
    border: 1px solid #d1d1d6;
    border-radius: 8px;
    background: #fff;
}

.mep-end-service-item.needs-resolution {
    border-color: #ff9f0a;
    background: #fff8e8;
    box-shadow: inset 3px 0 0 #ff9f0a;
}

.mep-end-service-item.auto-switch {
    border-color: #64b5ff;
    background: #f2f8ff;
    box-shadow: inset 3px 0 0 #007aff;
}

.mep-end-service-item.requires-explicit-qty {
    border-color: #ff9f0a;
    box-shadow: inset 4px 0 0 #ff9f0a;
}

.mep-end-service-item.requires-explicit-qty.quantity-pending {
    border-color: #ff3b30;
    background: #fff7f6;
    box-shadow: inset 4px 0 0 #ff3b30, 0 0 0 2px rgba(255, 59, 48, 0.08);
}

.mep-end-service-item.requires-explicit-qty.qty-confirmed {
    border-color: #34c759;
    box-shadow: inset 4px 0 0 #34c759;
}

.mep-end-service-item.no-stock {
    opacity: 0.55;
}

.mep-end-service-item-head,
.mep-end-service-item.reprint {
    display: flex;
    min-height: 58px;
    padding: 8px 9px;
    align-items: center;
    justify-content: space-between;
    gap: 9px;
}

.mep-end-service-item.reprint > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
}

.mep-end-service-item.reprint > div span {
    color: #636366;
    font-size: 11px;
}

.mep-end-service-item-open {
    display: flex;
    min-width: 0;
    min-height: 42px;
    padding: 0;
    flex: 1;
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
}

.mep-end-service-item-open strong {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.15;
}

.mep-end-service-item-open span {
    color: #636366;
    font-size: 10px;
    font-weight: 750;
}

.mep-end-service-item.routine-item .mep-end-service-item-head {
    min-height: 48px;
    padding-top: 5px;
    padding-bottom: 5px;
}

.mep-end-service-item.routine-item .mep-end-service-item-open {
    min-height: 34px;
}

.mep-end-service-item.routine-item .mep-end-service-item-open strong {
    font-size: 13px;
}

.mep-end-service-item-open .mep-end-service-extra-badge {
    display: inline-flex;
    margin-top: 2px;
    padding: 3px 6px;
    border-radius: 5px;
    background: #ff3b30;
    color: #fff;
    font-size: 8px;
    font-style: normal;
    font-weight: 900;
    line-height: 1;
}

.mep-end-service-item-open .mep-end-service-switch-badge {
    display: inline-flex;
    margin-top: 2px;
    padding: 3px 6px;
    border-radius: 5px;
    background: #007aff;
    color: #fff;
    font-size: 8px;
    font-style: normal;
    font-weight: 900;
    line-height: 1;
}

.mep-stock-popup .mep-end-service-toggle {
    display: grid;
    flex: 0 0 54px;
    grid-template-columns: 46px;
    gap: 2px;
    align-items: center;
    justify-items: center;
    cursor: pointer;
}

.mep-end-service-toggle input {
    position: absolute;
    width: 1px !important;
    height: 1px !important;
    min-height: 0 !important;
    opacity: 0;
}

.mep-end-service-toggle > span {
    position: relative;
    display: block;
    width: 46px;
    height: 26px;
    border-radius: 13px;
    background: #c7c7cc;
    transition: background 150ms ease;
}

.mep-end-service-toggle > span::after {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    content: "";
    transition: transform 150ms ease;
}

.mep-end-service-toggle input:checked + span {
    background: #34c759;
}

.mep-end-service-toggle input:checked + span::after {
    transform: translateX(20px);
}

.mep-end-service-toggle small {
    color: #636366;
    font-size: 8px;
    font-weight: 800;
}

.mep-end-service-toggle.disabled {
    cursor: not-allowed;
    opacity: 0.38;
}

.mep-end-service-resolution {
    display: flex;
    padding: 9px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-top: 1px solid #ffd28a;
}

.mep-end-service-resolution p {
    margin: 0;
    font-size: 12px;
}

.mep-end-service-resolution > div {
    display: grid;
    grid-template-columns: repeat(2, 54px);
    gap: 5px;
}

.mep-end-service-resolution.catch-up {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 7px;
    background: #fff8eb;
}

.mep-end-service-resolution.catch-up p {
    line-height: 1.4;
}

.mep-end-service-resolution.catch-up p > strong:first-child {
    color: #c9342f;
}

.mep-end-service-resolution.catch-up small {
    color: #6e5a32;
    font-size: 10px;
    font-weight: 700;
}

.mep-end-service-resolution.catch-up > div {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mep-end-service-resolution.catch-up button:first-child {
    border-color: #0a7d35;
    background: #0a7d35;
    color: #fff;
}

.mep-end-service-resolution button,
.mep-end-service-use-general {
    min-height: 34px;
    padding: 0 8px;
    border: 1px solid #c7c7cc;
    border-radius: 7px;
    background: #fff;
    color: #1d1d1f;
    font-size: 11px;
    font-weight: 800;
}

.mep-end-service-allocation {
    display: grid;
    padding: 9px;
    grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    border-top: 1px solid #b9d8ff;
    background: #eef6ff;
}

.mep-end-service-allocation > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.mep-end-service-allocation span,
.mep-end-service-allocation small {
    color: #636366;
    font-size: 9px;
    font-weight: 750;
}

.mep-end-service-allocation strong {
    color: #0066cc;
    font-size: 11px;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.mep-end-service-allocation > b {
    color: #007aff;
    text-align: center;
}

.mep-end-service-allocation small {
    grid-column: 1 / -1;
    line-height: 1.25;
}

.mep-end-service-allocation.next-untouched {
    border-top-color: #a9dfb5;
    background: #f0fbf3;
}

.mep-end-service-allocation.next-untouched strong,
.mep-end-service-allocation.next-untouched > b {
    color: #197c35;
}

.mep-end-service-item-gauge {
    grid-template-columns: minmax(88px, 1fr) minmax(145px, 1.3fr) auto;
    padding: 9px;
    border-top: 1px solid #e5e5ea;
    background: #f8f8fa;
}

.mep-end-service-item-gauge.remaining {
    grid-template-columns: minmax(88px, 1fr) minmax(145px, 1.3fr);
    border-top-color: #ffd28a;
    background: #fff8e8;
}

.mep-end-service-use-general {
    min-width: 62px;
}

.mep-end-service-toggle.learned small {
    color: #007aff;
}

.mep-end-service-confirm-qty {
    grid-column: 1 / -1;
    min-height: 40px;
    border: 1px solid #007aff;
    border-radius: 7px;
    background: #007aff;
    color: #fff;
    font-size: 12px;
    font-weight: 850;
}

.mep-end-service-reprint-banner {
    display: flex;
    margin-bottom: 10px;
    padding: 10px 11px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid #ffbf57;
    border-radius: 8px;
    background: #fff5df;
}

.mep-end-service-reprint-banner strong {
    color: #9a5a00;
    font-size: 13px;
}

.mep-end-service-reprint-banner span {
    color: #6e4b16;
    font-size: 10px;
    font-weight: 700;
}

.mep-stock-action-toast {
    position: fixed;
    right: 16px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 12000;
    display: grid;
    width: min(360px, calc(100vw - 32px));
    min-height: 64px;
    padding: 10px 12px;
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    border: 1px solid #a9dfb5;
    border-radius: 8px;
    background: #f0fbf3;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    color: #155724;
    opacity: 0;
    pointer-events: none;
    transform: translateY(14px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.mep-stock-action-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.mep-stock-action-toast > span {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    background: #34c759;
    color: #fff;
    font-size: 19px;
    font-weight: 900;
}

.mep-stock-action-toast div {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.mep-stock-action-toast strong {
    font-size: 13px;
    font-weight: 900;
}

.mep-stock-action-toast small {
    overflow-wrap: anywhere;
    color: #3b6b45;
    font-size: 10px;
    font-weight: 700;
}

[data-theme="dark"] .mep-stock-end-service-btn:disabled {
    border-color: #48484a;
    background: #2c2c2e;
    color: #8e8e93;
}

[data-theme="dark"] .mep-end-service-general {
    border-color: #285d8f;
    background: #17283a;
}

[data-theme="dark"] .mep-end-service-popup .etiquette-btn.print:disabled {
    border-color: #48484a;
    background: #2c2c2e;
    color: #8e8e93;
}

[data-theme="dark"] .mep-end-service-required-banner {
    border-color: #8f3732;
    background: #3a2020;
    box-shadow: inset 3px 0 0 #ff6961;
}

[data-theme="dark"] .mep-end-service-required-banner strong { color: #ffb4af; }
[data-theme="dark"] .mep-end-service-required-banner span { color: #ffd2cf; }

[data-theme="dark"] .mep-end-service-overview {
    border-color: #48484a;
    background: #242426;
}

[data-theme="dark"] .mep-end-service-overview span + span {
    border-left-color: #48484a;
}

[data-theme="dark"] .mep-end-service-overview strong {
    color: #f2f2f7;
}

[data-theme="dark"] .mep-end-service-overview .attention strong {
    color: #ff6961;
}

[data-theme="dark"] .mep-end-service-toggle.learned small {
    color: #64b5ff;
}

[data-theme="dark"] .mep-end-service-item {
    border-color: #48484a;
    background: #242426;
    color: #f2f2f7;
}

[data-theme="dark"] .mep-end-service-item.needs-resolution,
[data-theme="dark"] .mep-end-service-item-gauge.remaining {
    border-color: #8a5b11;
    background: #3a2d18;
}

[data-theme="dark"] .mep-end-service-item.auto-switch {
    border-color: #276cae;
    background: #172b3d;
    box-shadow: inset 3px 0 0 #409cff;
}

[data-theme="dark"] .mep-end-service-item.requires-explicit-qty.quantity-pending {
    border-color: #b94c45;
    background: #351e1e;
    box-shadow: inset 4px 0 0 #ff6961, 0 0 0 2px rgba(255, 105, 97, 0.08);
}

[data-theme="dark"] .mep-end-service-item.requires-explicit-qty.qty-confirmed {
    border-color: #2f8c48;
    box-shadow: inset 4px 0 0 #4bd26a;
}

[data-theme="dark"] .mep-end-service-item-gauge {
    border-top-color: #48484a;
    background: #2c2c2e;
}

[data-theme="dark"] .mep-end-service-resolution {
    border-top-color: #8a5b11;
}

[data-theme="dark"] .mep-end-service-resolution.catch-up {
    background: #322817;
}

[data-theme="dark"] .mep-end-service-resolution.catch-up p > strong:first-child {
    color: #ff8b84;
}

[data-theme="dark"] .mep-end-service-resolution.catch-up small {
    color: #f2cd8f;
}

[data-theme="dark"] .mep-end-service-resolution.catch-up button:first-child {
    border-color: #36a85a;
    background: #16783a;
    color: #fff;
}

[data-theme="dark"] .mep-end-service-resolution button,
[data-theme="dark"] .mep-end-service-use-general {
    border-color: #5a5a5e;
    background: #3a3a3c;
    color: #fff;
}

[data-theme="dark"] .mep-end-service-allocation {
    border-top-color: #285d8f;
    background: #17283a;
}

[data-theme="dark"] .mep-end-service-allocation span,
[data-theme="dark"] .mep-end-service-allocation small {
    color: #aeaeb2;
}

[data-theme="dark"] .mep-end-service-allocation strong,
[data-theme="dark"] .mep-end-service-allocation > b {
    color: #64b5ff;
}

[data-theme="dark"] .mep-end-service-allocation.next-untouched {
    border-top-color: #2f8c48;
    background: #173820;
}

[data-theme="dark"] .mep-end-service-allocation.next-untouched strong,
[data-theme="dark"] .mep-end-service-allocation.next-untouched > b {
    color: #91e6a3;
}

[data-theme="dark"] .mep-end-service-confirm-qty {
    border-color: #409cff;
    background: #0a66c2;
    color: #fff;
}

[data-theme="dark"] .mep-end-service-item-open span,
[data-theme="dark"] .mep-end-service-item.reprint > div span,
[data-theme="dark"] .mep-end-service-toggle small,
[data-theme="dark"] .mep-end-service-general span,
[data-theme="dark"] .mep-end-service-item-gauge span {
    color: #aeaeb2;
}

[data-theme="dark"] .mep-end-service-client-control .mep-qty-stepper-value,
[data-theme="dark"] .mep-end-service-unit-control .mep-qty-stepper-value,
[data-theme="dark"] .mep-end-service-stepper-caption strong {
    color: #64b5ff;
}

[data-theme="dark"] .mep-end-service-reprint-banner {
    border-color: #8a5b11;
    background: #3a2d18;
}

[data-theme="dark"] .mep-end-service-reprint-banner strong {
    color: #ffbf57;
}

[data-theme="dark"] .mep-end-service-reprint-banner span {
    color: #e9c98e;
}

[data-theme="dark"] .mep-stock-action-toast {
    border-color: #2f8c48;
    background: #173820;
    color: #d8f8df;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.48);
}

[data-theme="dark"] .mep-stock-action-toast small {
    color: #91e6a3;
}

@media (max-width: 430px) {
    .mep-stock-header {
        gap: 8px;
    }

    .mep-stock-end-service-btn {
        min-width: 112px;
        padding: 0 8px;
        font-size: 11px;
    }

    .mep-end-service-popup {
        padding: 16px;
    }

    .mep-end-service-workspace {
        max-height: 54vh;
    }

    .mep-end-service-general,
    .mep-end-service-item-gauge,
    .mep-end-service-item-gauge.remaining {
        grid-template-columns: minmax(80px, 0.8fr) minmax(138px, 1.2fr);
    }

    .mep-end-service-item-gauge .mep-end-service-use-general {
        grid-column: 1 / -1;
        min-height: 30px;
    }
}
