@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
    /* Brand */
    --primary:        #2563EB;
    --primary-hover:  #1D4ED8;
    --primary-light:  #EFF6FF;
    --primary-muted:  #BFDBFE;

    /* Semantic */
    --success:        #16A34A;
    --success-light:  #F0FDF4;
    --warning:        #D97706;
    --warning-light:  #FFFBEB;
    --danger:         #DC2626;
    --danger-light:   #FEF2F2;

    /* Neutral scale */
    --n-50:  #F8FAFC;
    --n-100: #F1F5F9;
    --n-200: #E2E8F0;
    --n-300: #CBD5E1;
    --n-400: #94A3B8;
    --n-500: #64748B;
    --n-600: #475569;
    --n-700: #334155;
    --n-800: #1E293B;
    --n-900: #0F172A;

    /* Elevation */
    --shadow-xs:  0 1px 2px rgba(15,23,42,.04);
    --shadow-sm:  0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
    --shadow-md:  0 4px 12px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
    --shadow-lg:  0 12px 32px rgba(15,23,42,.10), 0 4px 8px rgba(15,23,42,.04);
    --shadow-xl:  0 24px 48px rgba(15,23,42,.12), 0 8px 16px rgba(15,23,42,.06);

    /* Radius */
    --r-sm:  6px;
    --r-md:  10px;
    --r-lg:  16px;
    --r-xl:  20px;

    /* Transition */
    --ease: cubic-bezier(.4,0,.2,1);
}

/* ─── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

body {
    font-family: 'DM Sans', system-ui, sans-serif;
    background: var(--n-50);
    min-height: 100vh;
    color: var(--n-800);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Subtle background pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 15% 10%, rgba(37,99,235,.06) 0%, transparent 40%),
        radial-gradient(circle at 85% 90%, rgba(37,99,235,.04) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* ─── Layout ──────────────────────────────────────────────────────── */
.container {
    position: relative;
    z-index: 1;
    max-width: 860px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ─── Top bar ─────────────────────────────────────────────────────── */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border: 1px solid var(--n-200);
    border-radius: var(--r-xl);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-sm);
}

.brand {
    display: flex;
    align-items: center;
    gap: .625rem;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.brand-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--n-900);
    letter-spacing: -.02em;
}

.brand-tag {
    font-size: .7rem;
    font-weight: 500;
    color: var(--n-500);
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-top: .1rem;
}

/* Saldo pill */
.custo-info {
    cursor: pointer;
    transition: opacity .2s var(--ease);
}
.custo-info:hover { opacity: .8; }

.custo-badge {
    display: flex;
    align-items: center;
    gap: .75rem;
    background: var(--primary-light);
    border: 1px solid var(--primary-muted);
    border-radius: 999px;
    padding: .5rem 1rem;
    font-size: .875rem;
    color: var(--primary);
    font-weight: 500;
}

.custo-badge strong { font-weight: 700; }

.saldo-divider {
    width: 1px;
    height: 1rem;
    background: var(--primary-muted);
}

.saldo-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--n-500);
}

.saldo-valor {
    font-size: .875rem;
    font-weight: 700;
    color: var(--n-800);
}

/* ─── Main content ────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

/* ─── Search card ─────────────────────────────────────────────────── */
.search-container {
    width: 100%;
    max-width: 600px;
    background: #fff;
    border: 1px solid var(--n-200);
    border-radius: var(--r-xl);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.search-header {
    margin-bottom: 1.75rem;
}

.search-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--primary);
    background: var(--primary-light);
    border-radius: 999px;
    padding: .3rem .75rem;
    margin-bottom: 1rem;
}

.search-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--n-900);
    letter-spacing: -.03em;
    line-height: 1.2;
    margin-bottom: .5rem;
}

.subtitle {
    font-size: .9375rem;
    color: var(--n-500);
    line-height: 1.6;
    max-width: 380px;
    margin: 0 auto;
}

/* ─── Input group ─────────────────────────────────────────────────── */
.input-group { margin-bottom: 1rem; }

.input-wrapper {
    display: flex;
    gap: .5rem;
    background: var(--n-50);
    border: 1.5px solid var(--n-200);
    border-radius: var(--r-lg);
    padding: .4rem .4rem .4rem .75rem;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
    background: #fff;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 400;
    color: var(--n-800);
    outline: none;
    padding: .625rem 0;
    min-width: 0;
}

.search-input::placeholder { color: var(--n-400); }

.btn-pesquisar {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--r-md);
    padding: .625rem 1.25rem;
    font-family: inherit;
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s var(--ease), transform .15s var(--ease), box-shadow .2s var(--ease);
    box-shadow: 0 1px 3px rgba(37,99,235,.25);
}

.btn-pesquisar:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(37,99,235,.35);
    transform: translateY(-1px);
}

.btn-pesquisar:active { transform: translateY(0); }

/* Cost badge */
.custo-info.inline {
    margin-top: 1.25rem;
}

.custo-badge.inline {
    background: transparent;
    border: 1px solid var(--n-200);
    color: var(--n-600);
    border-radius: var(--r-md);
    font-size: .8125rem;
}

/* ─── Loading ─────────────────────────────────────────────────────── */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2.5rem;
    background: #fff;
    max-width: 600px;
    width: 100%;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--n-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

.loading p {
    font-size: .9375rem;
    font-weight: 500;
    color: var(--n-500);
}

/* ─── Result card ─────────────────────────────────────────────────── */
.resultado {
    width: 100%;
    max-width: 600px;
    background: #fff;
    border: 1px solid var(--n-200);
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    animation: fadeUp .35s var(--ease);
}

@keyframes fadeUp {
    from { opacity:0; transform:translateY(12px); }
    to   { opacity:1; transform:translateY(0); }
}

.resultado-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--n-100);
    background: var(--n-50);
}

.resultado-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--n-800);
    letter-spacing: -.01em;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .75rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .02em;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid #BBF7D0;
}

.dados-container { padding: 1.5rem; }

.result-card { text-align: center; animation: fadeUp .4s var(--ease); }

.result-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
    color: var(--success);
}

.result-icon.error {
    color: var(--danger);
}

.result-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--n-800);
    margin-bottom: .5rem;
    letter-spacing: -.02em;
}

.result-title.error { color: var(--danger); }

.result-description {
    font-size: .9rem;
    color: var(--n-500);
    line-height: 1.6;
    max-width: 380px;
    margin: 0 auto 1.5rem;
}

.btn-pdf {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--r-md);
    padding: .75rem 1.5rem;
    font-family: inherit;
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s var(--ease), box-shadow .2s var(--ease), transform .15s var(--ease);
    box-shadow: 0 1px 3px rgba(37,99,235,.25);
}

.btn-pdf:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(37,99,235,.3);
    transform: translateY(-1px);
}

/* ─── Modal backdrop ──────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeBg .25s var(--ease);
}

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

.modal-content {
    background: #fff;
    border-radius: var(--r-xl);
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: scaleIn .3s var(--ease);
    border: 1px solid var(--n-200);
}

@keyframes scaleIn {
    from { opacity:0; transform:scale(.96) translateY(8px); }
    to   { opacity:1; transform:scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--n-100);
}

.modal-header h3 {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--n-900);
    letter-spacing: -.01em;
}

.btn-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--n-100);
    border-radius: var(--r-sm);
    color: var(--n-500);
    font-size: 1.1rem;
    cursor: pointer;
    transition: background .2s, color .2s;
    line-height: 1;
}

.btn-close:hover { background: var(--n-200); color: var(--n-700); }

.modal-body { padding: 1.5rem; }

/* Saldo atual row */
.saldo-atual {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--n-50);
    border: 1px solid var(--n-200);
    border-radius: var(--r-md);
    padding: .875rem 1rem;
    margin-bottom: 1rem;
    font-size: .9rem;
    color: var(--n-600);
}

.saldo-atual strong { color: var(--danger); font-size: 1rem; font-weight: 700; }

.modal-text {
    font-size: .875rem;
    color: var(--n-600);
    line-height: 1.6;
    margin-bottom: .625rem;
}

/* Valor recarga */
.valor-recarga { margin: 1.25rem 0; }

.valor-recarga label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--n-700);
    margin-bottom: .625rem;
    letter-spacing: .02em;
}

.valor-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .5rem;
    margin-bottom: .75rem;
}

.valor-btn {
    background: #fff;
    border: 1.5px solid var(--n-200);
    border-radius: var(--r-md);
    padding: .625rem .25rem;
    font-family: inherit;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--n-600);
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}

.valor-btn:hover { border-color: var(--primary); color: var(--primary); }

.valor-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.valor-input {
    width: 100%;
    padding: .625rem .875rem;
    border: 1.5px solid var(--n-200);
    border-radius: var(--r-md);
    font-family: inherit;
    font-size: .9375rem;
    color: var(--n-800);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    background: #fff;
}

.valor-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* PIX button */
.btn-pix {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    background: var(--success);
    color: #fff;
    border: none;
    border-radius: var(--r-md);
    padding: .875rem 1rem;
    font-family: inherit;
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, box-shadow .2s, transform .15s;
    box-shadow: 0 1px 3px rgba(22,163,74,.25);
}

.btn-pix:hover {
    background: #15803D;
    box-shadow: 0 4px 12px rgba(22,163,74,.3);
    transform: translateY(-1px);
}

/* ─── QR Code modal ───────────────────────────────────────────────── */
.qr-modal { max-width: 400px; }
.qr-body  { text-align: center; }

.qr-container {
    background: var(--n-50);
    border: 1.5px dashed var(--n-300);
    border-radius: var(--r-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.qr-image { max-width: 180px; height: auto; display: block; }

.qr-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    color: var(--n-400);
    font-size: .875rem;
}

.pix-code-container { text-align: left; margin-bottom: 1.25rem; }

.pix-code-container label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--n-700);
    margin-bottom: .5rem;
}

.pix-code-wrapper { display: flex; gap: .5rem; }

#pixCode {
    flex: 1;
    padding: .625rem .75rem;
    border: 1.5px solid var(--n-200);
    border-radius: var(--r-md);
    font-family: 'DM Mono', monospace;
    font-size: .75rem;
    color: var(--n-700);
    background: var(--n-50);
    resize: none;
    height: 72px;
    outline: none;
}

.btn-copiar {
    background: var(--n-100);
    border: 1.5px solid var(--n-200);
    border-radius: var(--r-md);
    padding: 0 .875rem;
    font-family: inherit;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--n-700);
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s, border-color .2s, color .2s;
}

.btn-copiar:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Payment status */
.pagamento-status { margin-bottom: 1.25rem; }

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    margin-bottom: .375rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s ease infinite;
}

.status-dot.waiting  { background: var(--warning); }
.status-dot.success  { background: var(--success); animation: none; }

@keyframes pulse {
    0%, 100% { opacity:1; transform:scale(1); }
    50%       { opacity:.5; transform:scale(.85); }
}

#statusText { font-size: .9rem; font-weight: 600; color: var(--n-700); }

.btn-verificar {
    width: 100%;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--r-md);
    padding: .875rem 1rem;
    font-family: inherit;
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, box-shadow .2s;
}

.btn-verificar:hover { background: var(--primary-hover); }

/* ─── Toast ───────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--n-900);
    color: #fff;
    padding: .875rem 1.25rem;
    border-radius: var(--r-lg);
    font-size: .875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    max-width: 360px;
    animation: toastIn .3s var(--ease);
}

@keyframes toastIn {
    from { opacity:0; transform:translateY(8px) translateX(8px); }
    to   { opacity:1; transform:translateY(0) translateX(0); }
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger);  }

/* ─── Utility ─────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .container { padding: 1.25rem 1rem; }

    .top-bar { border-radius: var(--r-lg); }

    .brand-tag { display: none; }

    .search-container { padding: 1.75rem 1.25rem; }

    .search-title { font-size: 1.375rem; }

    .input-wrapper { flex-direction: column; padding: .5rem; }

    .btn-pesquisar { width: 100%; justify-content: center; border-radius: var(--r-md); }

    .valor-options { grid-template-columns: repeat(2, 1fr); }

    .toast { left: 1rem; right: 1rem; bottom: 1rem; }
}