/* =========================================================================
   STEP 3 TEST OVERLAY
   ========================================================================= */

@keyframes step3FadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}


#step3-test-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    background: #fff;
    display: none;
    overflow-y: auto;
    animation: step3FadeIn .2s ease;
}

#step3-test-overlay-close {
    position: fixed;
    top: 10px;
    right: 18px;
    z-index: 100000;
    background: none;
    border: none;
    font-size: 22px;
    color: #6c757d;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color .15s, background .15s;
}

#step3-test-overlay-close:hover {
    color: #212529;
    background: #f0f0f0;
}

#step3-test-overlay-content {
    padding: 0 32px 48px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    color: #212529;
}

/* ── Кнопка «Тест step 3» ── */
#step3-test-btn {
    display: block;
    width: 100%;
    padding: 9px;
    margin-top: 6px;
    background: #fff;
    color: #0d6efd;
    border: 1px solid #0d6efd;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
}

#step3-test-btn:hover {
    background: #f0f4ff;
}


/* =========================================================================
   HEADER
   ========================================================================= */

.s3-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0 16px;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 20px;
}

.s3-header-title {
    font-size: 17px;
    font-weight: 700;
    color: #212529;
    letter-spacing: -.2px;
}


/* =========================================================================
   TOP ROW: Origin + Destination + Summary
   ========================================================================= */

.s3-top-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

/* Pair of addr cards — equal height between themselves */
.s3-addr-pair {
    display: flex;
    flex: 1;
    gap: 16px;
    min-width: 0;
}

/* ── Address cards (Origin & Destination) ── */
.s3-addr-card {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 0;
    min-width: 0;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.s3-addr-label {
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    padding: 10px 18px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.s3-addr-body {
    padding: 14px 18px;
    flex: 1;
}

.s3-addr-flag {
    font-size: 15px;
    line-height: 1;
}

.s3-addr-name {
    font-size: 14px;
    font-weight: 600;
    color: #212529;
    margin-bottom: 2px;
}

.s3-addr-company {
    font-size: 13px;
    color: #495057;
    margin-bottom: 4px;
}

.s3-addr-link {
    font-size: 13px;
    color: #0d6efd;
    text-decoration: none;
    word-break: break-word;
}

.s3-addr-link:hover {
    text-decoration: underline;
}


/* ── Price summary card ── */
.s3-summary-card {
    width: 380px;
    flex-shrink: 0;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 16px 18px;
    background: #fff;
}

.s3-summary-carrier {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.s3-carrier-logo {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
    background: #f8f9fa;
}

.s3-carrier-name {
    font-size: 13px;
    font-weight: 700;
    color: #212529;
    line-height: 1.3;
}

.s3-carrier-date {
    font-size: 11px;
    color: #6c757d;
    margin-top: 2px;
}

.s3-summary-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.s3-sum-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #495057;
}

.s3-sum-row--total {
    border-top: 1px solid #dee2e6;
    margin-top: 4px;
    padding-top: 8px;
}

.s3-sum-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #495057;
}

.s3-sum-val {
    color: #212529;
    font-weight: 500;
    white-space: nowrap;
}

.s3-sum-total {
    font-size: 15px;
    font-weight: 700;
    color: #0d6efd;
}

.s3-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #0d6efd;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.s3-show-details {
    font-size: 12px;
    color: #0d6efd;
    text-decoration: none;
}

.s3-show-details:hover {
    text-decoration: underline;
}

.s3-left-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.s3-extra-row {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.s3-extra-card {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    min-height: 120px;
    background: #fff;
}


/* Header с иконкой справа */
.s3-card-header--flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.s3-card-icon {
    font-size: 14px;
    color: #6c757d;
    cursor: pointer;
}

/* Filters row */
.s3-card-filters {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #dee2e6;
}

.s3-filter {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    color: #6c757d;
    flex: 1;
}

.s3-filter input,
.s3-filter select {
    margin-top: 4px;
    height: 30px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 0 8px;
    font-size: 13px;
}

/* Map placeholder */
.s3-map-placeholder {
    height: 220px;
    background: #fff;
}


/* =========================================================================
   PRODUCTS BLOCK — Commercial invoice
   ========================================================================= */

.s3-products-block {
    padding: 18px 20px 20px;
    min-height: unset;
}

/* ── Header ── */
.s3-pb-header {
    margin-bottom: 14px;
}

.s3-pb-title {
    font-size: 14px;
    font-weight: 700;
    color: #212529;
    margin-bottom: 4px;
}

.s3-pb-subtitle {
    font-size: 12px;
    color: #6c757d;
    line-height: 1.5;
}

/* ── Package row ── */
.s3-pb-package-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-top: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 16px;
}

.s3-pb-package-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.s3-pb-package-icon {
    font-size: 20px;
    line-height: 1;
}

.s3-pb-package-name {
    font-size: 13px;
    font-weight: 600;
    color: #212529;
}

.s3-pb-package-dims {
    font-size: 12px;
    color: #6c757d;
    margin-top: 1px;
}

.s3-pb-package-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.s3-pb-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #0d6efd;
    background: #fff;
    border: 1px solid #0d6efd;
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s;
}

.s3-pb-upload-btn:hover {
    background: #f0f4ff;
}

.s3-pb-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 16px;
    color: #6c757d;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.s3-pb-more-btn:hover {
    background: #f8f9fa;
    color: #212529;
}

/* ── TAX ID / Export reason row ── */
.s3-pb-tax-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.s3-pb-tax-row .s3-pf-group {
    flex: 1;
}

/* ── Warning banner ── */
.s3-pb-warning {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: #856404;
    background: #fff9e6;
    border: 1px solid #ffe082;
    border-radius: 5px;
    padding: 8px 12px;
    margin-bottom: 16px;
    line-height: 1.4;
}

.s3-pb-warning-icon {
    font-size: 14px;
    color: #e6a817;
    flex-shrink: 0;
}

.s3-pb-warning-em {
    color: #e07b00;
    font-weight: 600;
}

/* ── Product item ── */
.s3-products-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 14px;
}

.s3-product-item {
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

.s3-product-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.s3-product-item-title {
    font-size: 13px;
    font-weight: 600;
    color: #212529;
}

.s3-product-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #fff;
    border: 1px solid #f5c2c7;
    border-radius: 4px;
    color: #dc3545;
    cursor: pointer;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}

.s3-product-delete-btn:hover {
    background: #dc3545;
    color: #fff;
}

.s3-product-fields {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Field rows inside product ── */
.s3-pf-row {
    display: flex;
    gap: 14px;
}

.s3-pf-row--desc .s3-pf-group--desc {
    flex: 2;
}

.s3-pf-row--desc .s3-pf-group--hs {
    flex: 1;
}

.s3-pf-row--bottom .s3-pf-group--made {
    flex: 2;
}

.s3-pf-row--bottom .s3-pf-group--price {
    flex: 1.5;
}

.s3-pf-row--bottom .s3-pf-group--qty {
    flex: 1;
}

/* ── Single field group ── */
.s3-pf-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.s3-pf-label {
    font-size: 12px;
    font-weight: 500;
    color: #495057;
    margin-bottom: 5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.s3-pf-required {
    color: #dc3545;
    font-weight: 700;
}

.s3-pf-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #0d6efd;
    color: #fff;
    font-size: 10px;
    font-style: normal;
    cursor: default;
}

.s3-pf-warn-icon {
    color: #e6a817;
    font-size: 12px;
}

.s3-pf-input {
    height: 32px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 0 10px;
    font-size: 13px;
    color: #212529;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
}

.s3-pf-input:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .12);
}

.s3-pf-select {
    height: 32px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 0 28px 0 10px;
    font-size: 13px;
    color: #212529;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236c757d' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}

.s3-pf-select:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .12);
}

/* ── Unit price with currency ── */
.s3-pf-price-wrap {
    display: flex;
    align-items: stretch;
}

.s3-pf-input--price {
    border-right: none;
    border-radius: 4px 0 0 4px;
    flex: 1;
    min-width: 0;
}

.s3-pf-currency {
    height: 32px;
    border: 1px solid #ced4da;
    border-radius: 0 4px 4px 0;
    padding: 0 20px 0 8px;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    background: #f8f9fa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%236c757d' stroke-width='1.3' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 6px center;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    flex-shrink: 0;
    box-sizing: border-box;
}

.s3-pf-currency:focus {
    outline: none;
    border-color: #86b7fe;
    z-index: 1;
}

/* ── Add product button ── */
.s3-pb-add-row {
    display: flex;
    justify-content: center;
    padding-top: 4px;
}

.s3-pb-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #0d6efd;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: background .15s;
}

.s3-pb-add-btn:hover {
    background: #f0f4ff;
}


/* =========================================================================
   DECLARED VALUE BLOCK — Exception
   ========================================================================= */

.s3-dv-block {
    padding: 0;
    min-height: unset;
    overflow: hidden;
}

/* ── Header ── */
.s3-dv-header {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
}

.s3-dv-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #0d6efd;
    color: #fff;
    font-size: 11px;
    font-style: normal;
    flex-shrink: 0;
}

.s3-dv-header-title {
    font-size: 13px;
    font-weight: 700;
    color: #212529;
}

/* ── Declared Value row ── */
.s3-dv-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
}

.s3-dv-row-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #212529;
    white-space: nowrap;
}

.s3-dv-input-wrap {
    display: flex;
    align-items: stretch;
    flex: 1;
    max-width: 340px;
}

.s3-dv-input {
    flex: 1;
    height: 32px;
    border: 1px solid #ced4da;
    border-right: none;
    border-radius: 4px 0 0 4px;
    padding: 0 10px;
    font-size: 13px;
    color: #212529;
    background: #fff;
    box-sizing: border-box;
    min-width: 0;
    transition: border-color .15s, box-shadow .15s;
}

.s3-dv-input:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .12);
}

.s3-dv-currency {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    height: 32px;
    border: 1px solid #ced4da;
    border-radius: 0 4px 4px 0;
    background: #f8f9fa;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Insured Value ── */
.s3-dv-insured {
    padding: 12px 16px 14px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.s3-dv-insured-label {
    font-size: 12px;
    color: #6c757d;
}

.s3-dv-insured-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.s3-dv-insured-name {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: #198754;
}

.s3-dv-shield {
    font-size: 13px;
    color: #198754;
}

.s3-dv-terms {
    font-size: 12px;
    color: #0d6efd;
    text-decoration: none;
    width: fit-content;
}

.s3-dv-terms:hover {
    text-decoration: underline;
}

/* ── Toggle switch ── */
.s3-dv-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.s3-dv-toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.s3-dv-toggle-track {
    display: block;
    width: 32px;
    height: 18px;
    border-radius: 9px;
    background: #ced4da;
    position: relative;
    transition: background .2s;
}

.s3-dv-toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: transform .2s;
}

.s3-dv-toggle-input:checked + .s3-dv-toggle-track {
    background: #198754;
}

.s3-dv-toggle-input:checked + .s3-dv-toggle-track::after {
    transform: translateX(14px);
}

/* ── Divider ── */
.s3-dv-divider {
    height: 1px;
    background: #dee2e6;
}

/* ── COD row ── */
.s3-dv-cod-row {
    padding: 12px 16px;
}

.s3-dv-cod-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #212529;
    cursor: pointer;
}

.s3-dv-checkbox {
    width: 15px;
    height: 15px;
    border: 1px solid #ced4da;
    border-radius: 3px;
    cursor: pointer;
    accent-color: #0d6efd;
    flex-shrink: 0;
}


/* ── Right column wrapper ── */
.s3-right-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 380px;
    flex-shrink: 0;
}

/* Убираем фиксированную ширину у самих карточек — теперь она задана колонкой */
.s3-right-col .s3-summary-card {
    width: auto;
}

/* ── Order Reference card ── */
.s3-or-title {
    font-size: 13px;
    font-weight: 700;
    color: #212529;
    margin-bottom: 6px;
}

.s3-or-subtitle {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 10px;
    line-height: 1.45;
}

.s3-or-input {
    width: 100%;
    box-sizing: border-box;
}

/* ── Internal note card ── */
.s3-in-label {
    font-size: 13px;
    font-weight: 600;
    color: #212529;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}

.s3-in-textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 72px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 13px;
    color: #212529;
    resize: vertical;
    font-family: inherit;
    line-height: 1.45;
    transition: border-color .15s, box-shadow .15s;
}

.s3-in-textarea::placeholder {
    color: #adb5bd;
}

.s3-in-textarea:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .12);
}



/* ── Pickup block ── */
.s3-pickup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.s3-pickup-title {
    font-size: 13px;
    font-weight: 700;
    color: #212529;
}

.s3-pickup-content {
    display: none;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}




/* ── Branches list ── */
.s3-branches-list {
    max-height: 260px;
    overflow-y: auto;
    padding: 6px 0;
}

.s3-branch-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background .12s, border-color .12s;
    font-size: 13px;
    color: #212529;
}

.s3-branch-item:hover {
    background: #f0f4ff;
}

.s3-branch-item--active {
    background: #eef3ff;
    border-left-color: #0d6efd;
    color: #0d6efd;
    font-weight: 600;
}

.s3-branch-distance {
    font-size: 11px;
    color: #6c757d;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 42px;
}

.s3-branch-item--active .s3-branch-distance {
    color: #0d6efd;
}

.s3-branch-label {
    line-height: 1.4;
}

.s3-branch-empty {
    padding: 14px 16px;
    font-size: 13px;
    color: #6c757d;
}





/* =========================================================================
   MADE-IN COUNTRY SEARCH (inside product item)
   ========================================================================= */

.s3-pf-group--made .s2-country-trigger {
    height: 32px;
    padding: 0 8px;
    font-size: 13px;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}

.s3-pf-group--made .s2-country-name {
    font-size: 13px;
    color: #212529;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.s3-pf-group--made .s2-country-dropdown {
    border-radius: 4px;
    border-top: 1px solid #ced4da;
    z-index: 9999;
}

.s3-pf-group--made .s2-country-list {
    max-height: 180px;
}

.s3-pf-group--made .s2-country-opt {
    font-size: 13px;
}



/* ── Description autocomplete dropdown ── */
.s3-desc-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ced4da;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    z-index: 9999;
    max-height: 200px;
    overflow-y: auto;
}

.s3-desc-opt {
    padding: 7px 10px;
    font-size: 13px;
    color: #212529;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.s3-desc-opt:last-child {
    border-bottom: none;
}

.s3-desc-opt:hover {
    background: #f0f4ff;
    color: #0d6efd;
}

@keyframes s3spin {
    to { transform: rotate(360deg); }
}

.s3-field-invalid {
    border-color: #dc3545 !important;
    outline: none;
}

.s3-field-invalid:focus {
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
}

.s3-submit-wrap {
    position: fixed;
    bottom: 24px;
    right: 32px;
    z-index: 10001;
}

.s3-submit-btn {
    padding: 10px 28px;
    background: #0d6efd;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.s3-submit-btn:hover {
    background: #0b5ed7;
}