* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    overflow-x: hidden;
    font-family: Arial, Helvetica, sans-serif;
    color: #111827;
    background: #fff;
}

button,
input,
textarea {
    font: inherit;
}

[hidden] {
    display: none !important;
}

.loading {
    width: 450px;
    max-width: calc(100% - 32px);
    margin: 100px auto;
    padding: 42px;
    text-align: center;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
}

.loading h2 {
    font-size: 18px;
}

.loading p {
    font-size: 13px;
    color: #64748b;
}

.spinner {
    width: 34px;
    height: 34px;
    margin: auto;
    border: 3px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

.page {
    min-height: 100vh;
}

.order-page {
    width: 896px;
    max-width: 100%;
    margin: auto;
    padding: 0 16px 40px;
    background: #f8fafc;
}

.document {
    padding-top: 32px;
}

.paper-card,
.party-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 32px;
}

.po-head {
    padding: 24px 24px 15px;
}

.po-head h1 {
    margin: 0 0 4px;
    font-size: 26px;
    line-height: 32px;
}

.po-head .sub {
    margin: 0 0 12px;
    font-size: 18px;
    line-height: 28px;
}

.po-meta {
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.po-meta p {
    margin: 0 0 8px;
    font-size: 16px;
    line-height: 24px;
}

.po-meta p:last-child {
    margin-bottom: 0;
}

.party-card {
    border-color: #e5e7eb;
    overflow: hidden;
}

.party-toggle {
    width: 100%;
    min-height: 68px;
    padding: 20px;
    border: 0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    cursor: pointer;
}

.party-toggle:hover {
    background: #f9fafb;
}

.party-toggle h2 {
    max-width: calc(100% - 32px);
    margin: 0;
    color: #111827;
    font-size: 18px;
    font-weight: 700;
    line-height: 28px;
}

.party-arrow {
    color: #6b7280;
}

.party-body {
    padding: 0 20px 20px;
}

.party-block {
    padding: 20px 16px 0;
}

.party-block + .party-block {
    margin-top: 24px;
    border-top: 1px solid #e5e7eb;
}

@media (min-width: 601px) {
    .party-body {
        min-height: 625px;
    }
}

.party-title {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 20px;
}

.party-title > span {
    color: #111827;
    font-weight: 700;
}

.edit-link {
    padding: 0;
    border: 0;
    background: none;
    color: #2563eb;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
}

.detail {
    margin-bottom: 12px;
}

.detail:last-child {
    margin-bottom: 0;
}

.detail-label {
    margin: 0;
    color: #6b7280;
    font-size: 12px;
    line-height: 16px;
}

.detail-value {
    margin: 0;
    color: #111827;
    font-size: 14px;
    line-height: 20px;
}

.goods-card {
    padding: 24px;
    overflow: hidden;
}

.goods-card h3 {
    margin: 0 0 16px;
    color: #111827;
    font-size: 18px;
    font-weight: 700;
    line-height: 28px;
}

.table-wrap {
    overflow: hidden;
}

.goods {
    width: 100%;
    border-collapse: collapse;
    color: #111827;
    font-size: 14px;
    line-height: 20px;
}

.goods th,
.goods td {
    padding: 12px;
    border: 1px solid #d1d5db;
    text-align: left;
    vertical-align: middle;
}

.goods th {
    height: 73px;
    padding: 6px 12px;
    background: #f9fafb;
    color: #374151;
    font-weight: 600;
}

.goods td {
    height: 45px;
}

.goods th:first-child,
.goods td:first-child {
    width: 44px;
    text-align: center;
}

.goods th:nth-child(2),
.goods td:nth-child(2) {
    width: auto;
}

.goods th:nth-child(3),
.goods td:nth-child(3),
.goods th:nth-child(4),
.goods td:nth-child(4) {
    width: 48px;
    text-align: center;
}

.goods th:last-child,
.goods td:last-child {
    width: 188px;
}

.goods tfoot td {
    height: 75px;
}

.total-label {
    text-align: right !important;
    font-weight: 600;
}

.total-price {
    font-weight: 600;
}

.rate {
    margin: 8px 0 16px;
    color: #6b7280;
    font-size: 12px;
    line-height: 17px;
}

.words {
    margin: 12px 0 0;
    font-size: 14px;
    line-height: 20px;
}

.bottom-action {
    padding: 0 16px 40px;
}

.action {
    display: block;
    width: 100%;
    height: 48px;
    padding: 12px 16px;
    border: 0;
    border-radius: 8px;
    background: #111827;
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    line-height: 24px;
}

.action:hover {
    background: #374151;
}

.terms-page {
    padding: 0 16px 48px;
    color: #4b5563;
}

.topline {
    height: 64px;
    display: flex;
    align-items: center;
}

.back {
    position: relative;
    top: 10px;
    width: 28px;
    height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: #64748b;
    cursor: pointer;
    font-size: 27px;
    line-height: 40px;
}

.terms-page .back {
    position: static;
    top: auto;
    padding: 1px 6px;
    font-size: 26px;
    line-height: normal;
}

.terms-page > h1 {
    margin: 16px 0 41px;
    color: #111827;
    font-size: 20px;
    font-weight: 700;
    line-height: 24px;
}

.terms-content {
    padding: 0 25px;
    font-size: 14px;
    line-height: 22.75px;
}

.term-section {
    margin: 0 0 24px;
}

.term-head {
    min-height: 23px;
    margin: 0 0 12px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.term-head strong {
    color: #374151;
    font-size: 14px;
    font-weight: 600;
    line-height: 23px;
}

.term-text {
    padding-left: 12px;
    color: #4b5563;
    font-size: 14px;
    line-height: 22.75px;
}

.term-text p {
    margin: 0 0 8px;
}

.term-text p:last-child {
    margin-bottom: 0;
}

.term-value {
    color: #ef4444;
    font-weight: 500;
}

.term-value.accent {
    color: #16a34a;
}

.term-value.missing {
    color: #dc2626;
    font-weight: 700;
}

.divider {
    color: #9ca3af;
}

.terms-page > .action {
    margin-top: 32px;
}

.verify-page {
    width: 100%;
    max-width: 1024px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 0 12px 16px;
    background: #fff;
    color: #111827;
    font-family: Arial, Helvetica, sans-serif;
}

.verify-titlebar {
    height: 52px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.verify-titlebar .back {
    position: absolute;
    left: 0;
    top: -10px;
}

.verify-titlebar h1 {
    margin: 0;
    padding: 0 32px;
    color: #111827;
    font-size: 16px;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
}

.verify-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px 12px 0 0;
    background: #fff;
    overflow: hidden;
}

.verify-intro {
    padding: 16px 16px 0;
}

.verify-intro h2 {
    margin: 0;
    color: #111827;
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
}

.verify-intro p {
    margin: 4px 0 0;
    color: #4b5563;
    font-size: 12px;
    line-height: 20px;
}

.verify-main {
    min-height: 258px;
    margin: 12px 16px 16px;
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
}

.code-line {
    display: block;
    margin: 0;
}

.code-line > div {
    width: 100%;
    text-align: left;
}

.verify-label {
    margin: 0;
    color: #374151;
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
}

.pairing-code {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 36px;
    margin: 4px 0 0;
    color: #374151;
    cursor: pointer;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 30px;
    font-weight: 700;
    line-height: 36px;
    letter-spacing: 2px;
}

.pairing-code::after {
    content: "Tap to copy";
    margin-left: 18px;
    color: #9ca3af;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
    letter-spacing: 0;
}

.message {
    min-height: 15px;
    margin: 0;
    color: #6b7280;
    font-size: 10px;
    line-height: 15px;
    text-transform: uppercase;
}

#edit-message {
    min-height: 20px;
    margin: 4px 0 0;
    color: #dc2626;
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    text-transform: none;
}

#edit-message.ok {
    color: #15803d;
}

.pairing-time {
    margin: 6px 0 0;
    color: #6b7280;
    font-size: 12px;
    line-height: 16px;
    text-align: left;
}

.pairing-deadline {
    color: #dc2626;
    font-weight: 600;
}

.pairing-deadline strong {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 7px;
    border-radius: 4px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 15px;
}

.send,
.resend-code {
    display: block;
    width: 100%;
    height: 38px;
    margin: 12px 0 0;
    padding: 10px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #111827;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
}

.send:disabled,
.resend-code:disabled {
    cursor: wait;
    opacity: .65;
}

.notice {
    margin: 8px 12px 0;
    color: #6b7280;
    font-size: 11px;
    line-height: 17px;
    text-align: center;
}

.status-card,
.help-card {
    margin: 0;
    padding: 16px;
    border: 1px solid #e5e7eb;
    background: #fff;
}

.status-card {
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 12px 12px;
}

.status-card h3,
.help-card h3 {
    margin: 0 0 12px;
    color: #111827;
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
}

.status-row {
    min-height: 59px;
    margin: 0 0 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
}

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

.status-row p {
    margin: 0;
    color: #111827;
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
}

.status-row small {
    display: block;
    color: #6b7280;
    font-size: 11px;
    line-height: 17px;
}

.badge {
    padding: 4px 10px;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    background: #fff;
    color: #111827;
    font-size: 11px;
    line-height: 15px;
}

.badge::before {
    content: "✓ ";
}

.badge.pending::before {
    content: "● ";
    color: #d1d5db;
}

.help-card {
    margin-top: 16px;
    border-radius: 12px;
    background: #f9fafb;
}

.help-step {
    min-height: 36px;
    margin: 0 0 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.help-step:last-child {
    margin-bottom: 0;
}

.help-step .num {
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
}

.help-step p {
    margin: 0;
    color: #111827;
    font-size: 12px;
    line-height: 18px;
}

.modal-mask {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, .4);
    backdrop-filter: blur(2px);
}

.modal {
    width: 450px;
    max-width: 100%;
    max-height: calc(100vh - 32px);
    overflow: auto;
    margin: 0;
    padding: 32px;
    border: 0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 20px 45px rgba(0, 0, 0, .2);
}

.modal h3 {
    margin: 0 0 24px;
    color: #111827;
    font-size: 18px;
    font-weight: 700;
    line-height: 28px;
}

.modal .form-group {
    margin: 0 0 16px;
}

.modal .form-group label {
    display: block;
    margin: 0 0 8px;
    color: #374151;
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
}

.modal .field {
    width: 100%;
    height: 44px;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #111827;
    font-size: 14px;
    line-height: 20px;
}

.modal textarea.field {
    height: 96px;
    resize: vertical;
}

.phone-editor {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 8px;
    width: 100%;
}

.country-picker {
    position: relative;
    width: 160px;
    min-width: 0;
}

.country-trigger {
    width: 100%;
    height: 42px;
    padding: 0 34px 0 12px;
    position: relative;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #f9fafb;
    color: #111827;
    cursor: pointer;
    text-align: left;
}

.country-trigger::after {
    content: '';
    position: absolute;
    right: 13px;
    top: 16px;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid #6b7280;
    border-bottom: 1.5px solid #6b7280;
    transform: rotate(45deg);
    transition: transform .18s ease;
}

.country-picker.open .country-trigger {
    border-color: #2563eb;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.country-picker.open .country-trigger::after {
    top: 19px;
    transform: rotate(225deg);
}

.country-menu {
    width: 290px;
    max-width: min(290px, calc(100vw - 64px));
    max-height: 240px;
    overflow-y: auto;
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    left: 0;
    padding: 6px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 16px 35px rgba(15, 23, 42, .16);
    overscroll-behavior: contain;
}

.country-option {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #111827;
    cursor: pointer;
    text-align: left;
}

.country-option:hover,
.country-option:focus-visible {
    background: #f3f4f6;
    outline: none;
}

.country-option.selected {
    background: #eff6ff;
    color: #1d4ed8;
}

.country-code {
    flex: 0 0 52px;
    font-weight: 600;
}

.country-name {
    overflow: hidden;
    color: #4b5563;
    font-size: 12px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.phone-editor input {
    width: 100%;
    min-width: 0;
}

.country-option-note {
    margin: 6px 0 0;
    color: #6b7280;
    font-size: 11px;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 24px;
}

.modal-actions button {
    width: 100%;
    height: 48px;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
}

.modal-actions .cancel {
    border: 1px solid #d1d5db;
    background: #fff;
    color: #111827;
}

.modal-actions .save {
    border: 0;
    background: #111827;
    color: #fff;
}

@media (max-width: 600px) {
    .order-page {
        padding: 0 16px 40px;
    }

    .document {
        padding-top: 32px;
    }

    .po-head h1 {
        font-size: 22px;
        line-height: 28px;
    }

    .po-head .sub {
        font-size: 17px;
        line-height: 28px;
    }

    .party-toggle {
        min-height: 96px;
        padding: 20px;
    }

    .party-toggle h2 {
        max-width: 304px;
    }

    .table-wrap {
        overflow: visible;
    }

    .goods {
        width: 100%;
        max-width: 100%;
        table-layout: fixed;
        font-size: 11px;
    }

    .goods th,
    .goods td {
        height: auto;
        padding: 9px 4px;
        overflow-wrap: anywhere;
    }

    .goods th:first-child,
    .goods td:first-child {
        width: 10%;
    }

    .goods th:nth-child(2),
    .goods td:nth-child(2) {
        width: 31%;
    }

    .goods th:nth-child(3),
    .goods td:nth-child(3) {
        width: 12%;
    }

    .goods th:nth-child(4),
    .goods td:nth-child(4) {
        width: 12%;
    }

    .goods th:last-child,
    .goods td:last-child {
        width: 35%;
    }

    .bottom-action {
        padding: 0 32px 40px;
    }

    .terms-page {
        padding: 0 16px 48px;
    }

    .terms-content {
        padding: 0;
    }

    .term-head strong {
        max-width: calc(100% - 76px);
    }

    .verify-page {
        padding: 0 12px 16px;
    }

    .verify-main {
        margin: 12px 16px 16px;
        padding: 16px;
    }

    .pairing-code {
        font-size: 25px;
        letter-spacing: 1px;
    }

    .pairing-code::after {
        margin-left: 10px;
        font-size: 10px;
    }

    .status-row {
        align-items: center;
    }

    .badge {
        max-width: 150px;
        text-align: center;
    }

    .modal {
        padding: 24px;
    }

    .modal-actions {
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .phone-editor {
        grid-template-columns: 135px minmax(0, 1fr);
    }

    .country-picker {
        width: 135px;
    }

    .country-menu {
        width: 260px;
    }
}
