:root {
    color-scheme: light;
    --green: #20a96b;
    --green-dark: #148253;
    --green-soft: #ecf9f3;
    --ink: #17221c;
    --muted: #69756e;
    --line: #e2e8e4;
    --surface: #ffffff;
    --background: #f4f7f5;
}

* { box-sizing: border-box; }

html {
    min-width: 280px;
    background: var(--background);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100svh;
    color: var(--ink);
    background: var(--background);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overscroll-behavior-y: none;
}

button, textarea { font: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }

.payment-page {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding:
        max(24px, env(safe-area-inset-top))
        max(12px, env(safe-area-inset-right))
        max(28px, env(safe-area-inset-bottom))
        max(12px, env(safe-area-inset-left));
}

.payment-header { margin-bottom: 16px; text-align: center; }
.payment-header h1 { margin: 10px 0 4px; font-size: 19px; line-height: 1.15; letter-spacing: .065em; }
.payment-header p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

.lock {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 28px;
    border-radius: 7px;
    background: var(--green);
}
.lock::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 14px;
    left: 6px;
    top: -10px;
    border: 3px solid var(--green);
    border-bottom: 0;
    border-radius: 10px 10px 0 0;
}
.lock::after {
    content: "";
    position: absolute;
    width: 4px;
    height: 8px;
    left: 14px;
    top: 10px;
    border-radius: 4px;
    background: #fff;
}

.payment-card, .instructions {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 14px 40px rgba(23, 34, 28, .06);
}

.payment-card { min-height: 250px; padding: 18px; border-radius: 16px; }
.loading-state, .error-state { min-height: 330px; padding: 72px 8px 40px; text-align: center; }
.loading-state h2, .error-state h2 { margin: 18px 0 8px; font-size: 20px; }
.loading-state p, .error-state p { max-width: 330px; margin: 0 auto; color: var(--muted); font-size: 14px; line-height: 1.55; }

.spinner {
    display: inline-block;
    width: 46px;
    height: 46px;
    border: 4px solid #dceee4;
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-state > span {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: 0 auto;
    border-radius: 50%;
    color: #a03b35;
    background: #ffefed;
    font-weight: 800;
}
.error-state button, .copy-area button {
    border: 0;
    border-radius: 10px;
    color: #fff;
    background: var(--green);
    cursor: pointer;
    font-weight: 700;
}
.error-state button { min-height: 48px; margin-top: 20px; padding: 11px 20px; }
.error-state button:hover, .copy-area button:hover { background: var(--green-dark); }

.value-block { text-align: center; }
.value-block span { display: block; color: var(--muted); font-size: 12px; }
.value-block strong { display: block; margin: 2px 0; font-size: 29px; line-height: 1.15; letter-spacing: -.035em; }
.value-block small { color: var(--green-dark); font-size: 12px; }

.qr-wrapper {
    width: min(72vw, 260px);
    margin: 16px auto 10px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #fff;
}
.qr-wrapper img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.scan-label { max-width: 290px; margin: 0 auto; color: var(--muted); font-size: 12px; line-height: 1.45; text-align: center; }

.separator { display: flex; align-items: center; gap: 9px; margin: 18px 0 14px; color: #8a958e; font-size: 10px; text-transform: uppercase; }
.separator::before, .separator::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.pix-state label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; }
.copy-area { display: grid; gap: 9px; }
.copy-area textarea {
    width: 100%;
    min-height: 68px;
    max-height: 68px;
    padding: 10px;
    resize: none;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: 0;
    color: #4f5a54;
    background: #f8faf9;
    font: 9.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
    scrollbar-width: thin;
}
.copy-area textarea:focus { border-color: var(--green); }
.copy-area button { min-height: 52px; font-size: 15px; }
.copy-feedback { min-height: 17px; margin: 7px 0 0; color: var(--green-dark); font-size: 11px; text-align: center; }

.instructions { margin-top: 12px; padding: 20px 18px; border-radius: 16px; }
.instructions h2 { margin: 0 0 16px; font-size: 17px; }
.instructions ol { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.instructions li { display: grid; grid-template-columns: 28px 1fr; gap: 11px; align-items: start; }
.instructions li > span {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--green-dark);
    background: var(--green-soft);
    font-size: 12px;
    font-weight: 800;
}
.instructions p { margin: 3px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.instructions strong { color: var(--ink); }

footer { display: flex; justify-content: center; align-items: center; gap: 7px; margin-top: 16px; color: #78837c; font-size: 11px; }
.shield { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; color: #fff; background: var(--green); font-size: 10px; }

@media (min-width: 521px) {
    .payment-page { padding-top: 44px; }
    .payment-header { margin-bottom: 24px; }
    .payment-header h1 { margin-top: 13px; font-size: 22px; }
    .payment-header p { font-size: 13px; }
    .lock { width: 42px; height: 36px; border-radius: 9px; }
    .lock::before { width: 20px; height: 18px; left: 9px; top: -13px; border-radius: 12px 12px 0 0; }
    .lock::after { width: 5px; height: 10px; left: 18px; top: 12px; }
    .payment-card { padding: 28px; border-radius: 18px; }
    .qr-wrapper { width: 280px; margin-top: 22px; padding: 10px; }
    .scan-label { font-size: 13px; }
    .separator { margin: 24px 0 18px; font-size: 11px; }
    .copy-area textarea { min-height: 78px; max-height: 78px; padding: 12px; font-size: 10px; }
    .copy-area button { min-height: 48px; font-size: 14px; }
    .instructions { margin-top: 16px; padding: 24px 26px; border-radius: 18px; }
}

@media (max-width: 340px) {
    .payment-page { padding-left: 8px; padding-right: 8px; }
    .payment-card { padding: 14px; }
    .payment-header h1 { font-size: 17px; }
    .qr-wrapper { width: min(70vw, 224px); }
    .instructions { padding: 18px 14px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
