:root {
    --front-text: #0a0a0a;
    --front-title: #0a0a0a;
    --front-muted: #737373;
    --front-border: #e5e5e5;
    --front-border-soft: #e5e5e5;
    --front-primary: #171717;
    --front-green: #00a85a;
    --front-blue: #171717;
    --front-danger: #dc2626;
    --front-page: #f7f7f7;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--front-text);
    background: #ffffff;
    font-family: Montserrat, "Segoe UI", Arial, Helvetica, sans-serif;
}

button,
input {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.pay-page {
    width: 100%;
    min-height: 100vh;
    display: grid;
    /* Keep the payment card centered in the viewport. */
    align-content: center;
    justify-items: center;
    padding: 16px;
    background: var(--front-page);
}

.pay-wrap,
.pay-card {
    width: 100%;
    max-width: 672px;
    margin: 0 auto;
    padding: 24px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 0 0 1px rgba(10, 10, 10, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
}

.pay-title {
    margin: 0 0 24px;
    color: var(--front-title);
    font-size: 24px;
    line-height: 32px;
    font-weight: 700;
    letter-spacing: 0;
    text-align: center;
}

.pay-form {
    display: grid;
    gap: 28px;
}

.pay-section {
    display: grid;
    gap: 12px;
}

.pay-label {
    display: block;
    margin: 0;
    color: var(--front-text);
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
}

.required {
    color: var(--front-danger);
}

.pay-methods {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.pay-methods.has-toggle {
    margin-bottom: 0;
}

.pay-method {
    position: relative;
    min-height: 112px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 10px;
    color: #737373;
    background: #ffffff;
    border: 2px solid var(--front-border);
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
}

.pay-methods.is-single {
    grid-template-columns: 1fr;
}

.pay-method:hover {
    border-color: rgba(23, 23, 23, 0.4);
}

.pay-method.is-active {
    color: var(--front-primary);
    border-color: var(--front-primary);
}

.pay-method-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    display: none;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: var(--front-primary);
    border-radius: 999px;
}

.pay-method.is-active .pay-method-check {
    display: flex;
}

.pay-method-check svg {
    width: 12px;
    height: 12px;
}

.pay-method-icon {
    position: relative;
    width: 72px;
    max-width: 100%;
    height: 36px;
}

.pay-method-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pay-method-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.25;
}

.payment-toggle-wrap {
    margin: 0;
}

.payment-toggle-wrap[hidden] {
    display: none;
}

.payment-toggle-btn {
    width: 100%;
    height: 38px;
    color: var(--front-primary);
    background: #ffffff;
    border: 1px solid var(--front-border-soft);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.payment-toggle-btn:hover {
    border-color: var(--front-primary);
}

.pay-input {
    width: 100%;
    height: 36px;
    margin: 0;
    padding: 4px 10px;
    color: var(--front-text);
    background: transparent;
    border: 1px solid var(--front-border);
    border-radius: 6px;
    outline: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    /* iOS Safari 对小于 16px 的输入框会自动放大整页来聚焦，必须 >= 16px */
    font-size: 16px;
}

.pay-input:focus {
    border-color: var(--front-primary);
    box-shadow: 0 0 0 3px rgba(23, 23, 23, 0.12);
}

.amount-title {
    margin: 0;
    color: var(--front-muted);
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    text-align: center;
}

.amount-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.amount-btn {
    min-height: 38px;
    padding: 10px 8px;
    color: var(--front-text);
    background: #ffffff;
    border: 1px solid var(--front-border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
}

.amount-btn:hover {
    border-color: rgba(23, 23, 23, 0.4);
}

.amount-btn.is-active {
    color: var(--front-primary);
    background: #ffffff;
    border: 2px solid var(--front-primary);
}

.deposit-btn {
    width: 100%;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #ffffff;
    background: var(--front-primary);
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-transform: none;
}

.deposit-btn:hover {
    background: #2a2a2a;
}

.deposit-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-spinner {
    width: 14px;
    height: 14px;
    display: none;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.deposit-btn.is-processing .btn-spinner {
    display: inline-block;
}

.pay-msg {
    min-height: 20px;
    margin: 0;
    color: var(--front-danger);
    font-size: 13px;
    line-height: 1.35;
    text-align: center;
}

.pay-msg.is-success {
    color: var(--front-green);
}

.return-wrap {
    padding-top: 8px;
}

.return-details {
    display: grid;
    gap: 14px;
}

.return-details p {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--front-border-soft);
    color: var(--front-muted);
}

.return-details .pay-msg {
    display: block;
    padding-bottom: 0;
    border-bottom: 0;
}

.return-details strong {
    color: var(--front-title);
}

.back-link {
    width: 100%;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--front-primary);
    background: #ffffff;
    border: 1px solid var(--front-border-soft);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
}

.back-link:hover {
    border-color: var(--front-primary);
}

.close-order-btn {
    width: 100%;
    height: 40px;
    color: #ffffff;
    background: var(--front-danger);
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.close-order-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-loading {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(247, 247, 247, 0.92);
}

.page-loading[hidden] {
    display: none;
}

.page-loading-box {
    min-height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 18px;
    color: var(--front-primary);
    background: #ffffff;
    border: 1px solid var(--front-border-soft);
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(23, 23, 23, 0.08);
    font-size: 14px;
    font-weight: 700;
}

.page-spinner {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    border: 2px solid var(--front-border-soft);
    border-top-color: var(--front-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

@media (min-width: 640px) {
    .pay-methods {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .pay-page {
        padding: 12px;
        align-items: start;
    }

    .pay-card,
    .pay-wrap {
        padding: 16px 12px 20px;
        box-shadow: none;
        border-radius: 10px;
    }

    .pay-title {
        margin-bottom: 16px;
        font-size: 20px;
        line-height: 26px;
    }

    .pay-form {
        gap: 18px;
    }

    .pay-methods {
        gap: 8px;
    }

    .pay-method {
        min-height: 76px;
        gap: 4px;
        padding: 8px 6px;
        border-radius: 10px;
    }

    .pay-method-icon {
        width: 48px;
        height: 22px;
    }

    .pay-method-name {
        font-size: 12px;
    }

    .pay-method-check {
        top: 4px;
        right: 4px;
        width: 16px;
        height: 16px;
    }

    .amount-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .amount-btn {
        padding: 8px 4px;
        font-size: 13px;
    }
}
