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

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    background: radial-gradient(1200px 800px at 10% 10%, #e7f6ff 0%, #f6f3ff 45%, #ffffff 100%);
    color: #1e1e2f;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: #0b1f3a;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand-link { display: inline-flex; text-decoration: none; color: inherit; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo-wrap {
    display: grid;
    place-items: center;
    width: 58px;
    height: 44px;
    padding: 5px;
    border-radius: 14px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 8px 20px rgba(0,0,0,.12);
}
.brand-logo-wrap img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.brand-mark {
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, #1dd3b0, #5a8dee);
    display: grid; place-items: center; font-weight: 700; color: #0b1f3a;
}
.brand-text small { display: block; font-size: 12px; opacity: 0.7; }

.topnav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.topnav a { color: #d7e3ff; text-decoration: none; font-size: 14px; }
.topnav a:hover { color: #fff; }
.topnav a.active { color: #1dd3b0; font-weight: 600; }
.logout-form { margin: 0; }

.content { padding: 32px; max-width: 1200px; width: 100%; margin: 0 auto; }

.auth { display: grid; place-items: center; padding: 60px 16px; }
.auth-card {
    background: #fff; border-radius: 18px; padding: 32px; width: 100%; max-width: 420px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    text-align: center;
}
.auth-card h1 { margin: 0 0 8px; }
.auth-card form { display: grid; gap: 8px; }
.auth-card label { text-align: center; }
.auth-card input { text-align: center; }
.auth-card .btn { margin-top: 8px; }
.muted { color: #6b7280; font-size: 14px; }
.auth-footer { margin-top: 16px; font-size: 14px; }

label { display: block; font-size: 13px; color: #4b5563; margin: 10px 0 6px; }
input, select, textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    font-size: 14px;
}
textarea { min-height: 90px; }

.money-field {
    position: relative;
}
.money-field .prefix {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    font-weight: 600;
    font-size: 14px;
    pointer-events: none;
}
.money-field input {
    padding-left: 40px;
}

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 16px; border-radius: 10px; border: none;
    cursor: pointer; text-decoration: none; font-weight: 600;
}
.btn.wide { width: 160px; }
.btn.primary { background: #1dd3b0; color: #0b1f3a; }
.btn.ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.2); }
.btn.outline { background: transparent; color: #0b1f3a; border: 1px solid #0b1f3a; }
.btn.danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; }
.alert.success { background: #e6fffb; color: #0f766e; }
.alert.error { background: #fee2e2; color: #b91c1c; }
.alert.warn { background: #fef3c7; color: #92400e; }

.dashboard .hero {
    background: #fff; border-radius: 18px; padding: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.06);
}
.cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(240px,1fr)); gap: 16px; margin-top: 20px; }
.card { background: #fff; border-radius: 16px; padding: 20px; text-decoration: none; color: inherit; box-shadow: 0 6px 20px rgba(0,0,0,0.05); }
.card h3 { margin-top: 0; }

.badge { display: inline-block; padding: 6px 10px; border-radius: 999px; font-size: 12px; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #b91c1c; }

.status .badge {
    padding: 8px 13px;
    font-size: 14px;
    font-weight: 700;
}

.panel { background: #fff; border-radius: 18px; padding: 24px; box-shadow: 0 10px 30px rgba(0,0,0,0.06); }
.grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 16px; }
.grid .full { grid-column: 1 / -1; }
.grid.two { grid-template-columns: 180px 1fr; }
.form-inline { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.form-inline label { margin: 0; }
.form-inline input[type="date"] { width: 160px; }
.form-vertical { max-width: 520px; display: grid; gap: 12px; }
.form-stack { display: grid; gap: 12px; margin-bottom: 16px; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form select, .inline-form input { width: auto; }
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}
.filter-form input, .filter-form select {
    width: 220px;
    max-width: 100%;
}
.filter-form .btn { width: auto; }
.filter-field {
    display: flex;
    flex-direction: column;
    min-width: 220px;
    flex: 1 1 220px;
}
.filter-field label {
    margin: 0 0 4px;
    font-size: 12px;
    color: #6b7280;
}
.config-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    align-items: end;
}
.config-form label { margin: 0; }
.config-form .full { grid-column: 1 / -1; }
.config-form-wide textarea { min-height: 200px; }
.config-summary {
    margin: 16px 0;
}
.config-summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    font-size: 14px;
    color: #1f2937;
    word-break: break-all;
}
.config-summary-row div {
    min-width: 220px;
    flex: 1 1 220px;
}
.row-link { cursor: pointer; }
.row-link:hover { background: #f8fafc; }
.table-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.checkbox-row { display: flex; align-items: center; justify-content: flex-start; margin: 6px 0 12px; }
.checkbox-row label { display: inline-flex; align-items: center; gap: 8px; margin: 0; }

.summary {
    display: flex;
    gap: 20px;
    margin: 12px 0 6px;
    font-size: 14px;
    color: #1f2937;
}

.centered { text-align: center; }
.centered .form-vertical { margin: 0 auto; }
.centered .form-stack { width: 100%; }
.centered input,
.centered textarea,
.centered select { text-align: center; }
.centered .qr-wrap { justify-content: center; }
.centered .qr-info { text-align: center; }
.centered .qr-info textarea { margin: 0 auto; }
.qr-display.column {
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.qr-display.column textarea {
    width: 360px;
    max-width: 100%;
}
.qr-value {
    font-size: 30px;
    font-weight: 700;
    color: #0b1f3a;
}
.qr-key {
    font-size: 14px;
    color: #4b5563;
}

.pix-form .money-field {
    width: 80%;
    margin: 0 auto;
}
.pix-form .form-stack > div > input {
    width: 80%;
    margin: 0 auto;
}

.dot {
    padding: 0 6px;
    color: #9ca3af;
}

.payment-status {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #0f172a;
    font-size: 13px;
}
.payment-status .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f59e0b;
}
.payment-status.paid {
    background: #dcfce7;
    color: #166534;
}
.payment-status.paid .dot {
    background: #22c55e;
}
.pulse {
    animation: pulse 1.2s infinite;
}
@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

.code {
    background: #0f172a;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 10px;
    overflow: auto;
    font-size: 12px;
}

.textarea-large {
    min-height: 90px;
    resize: vertical;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.readonly {
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
}

.qr-box canvas {
    width: 240px;
    height: 240px;
}
.qr-box {
    width: 240px;
    height: 240px;
    display: grid;
    place-items: center;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 8px;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #e5e7eb; font-size: 14px; }

.qr-wrap, .qr-display { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.qr-info textarea, .qr-details textarea { width: 360px; }

.paywall-card { background: #fff; border-radius: 18px; padding: 24px; max-width: 520px; margin: 0 auto; box-shadow: 0 10px 30px rgba(0,0,0,0.06); }
.paywall-info { margin: 16px 0; display: grid; gap: 8px; }

@media (max-width: 720px) {
    .content { padding: 16px; }
    .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
    .topnav { gap: 10px; }
    .qr-info textarea, .qr-details textarea { width: 100%; }
}

/* QR Code payment screen */
.qr-payment-panel {
    display: grid;
    place-items: center;
}

.qr-live-area[hidden],
.payment-confirmed-card[hidden] {
    display: none !important;
}

.qr-timer {
    width: 420px;
    max-width: 100%;
    padding: 14px;
    border: 1px solid #dbeafe;
    border-radius: 16px;
    background: linear-gradient(135deg, #f8fbff, #ecfeff);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.qr-timer-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    color: #475569;
}

.qr-timer-head strong {
    color: #0b1f3a;
    font-size: 18px;
}

.qr-progress-bar {
    overflow: hidden;
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: #e2e8f0;
}

.qr-progress-bar span {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #1dd3b0, #5a8dee);
    transition: width .3s ease, background .3s ease;
}

.qr-timer.is-ending .qr-progress-bar span {
    background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.qr-timer.is-expired .qr-progress-bar span {
    width: 100% !important;
    background: #ef4444;
}

.payment-confirmed-card,
.qr-expired-card {
    width: min(620px, 100%);
    margin: 0 auto;
    padding: 28px;
    border-radius: 24px;
    background: #ffffff;
    border: 1px solid #dcfce7;
    box-shadow: 0 22px 60px rgba(22, 101, 52, .16);
}

.payment-confirmed-card h1 {
    margin: 8px 0 8px;
    color: #14532d;
}

.confirmed-kicker {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: #dcfce7;
    color: #166534;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.confirmed-animation {
    display: grid;
    place-items: center;
    width: 112px;
    height: 112px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: radial-gradient(circle, #bbf7d0 0%, #dcfce7 52%, rgba(220, 252, 231, 0) 70%);
    animation: successGlow 1.4s ease-in-out infinite;
}

.confirmed-check {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    font-size: 42px;
    font-weight: 800;
    box-shadow: 0 12px 26px rgba(22, 163, 74, .28);
    animation: successPop .55s ease both;
}

@keyframes successGlow {
    0%, 100% { transform: scale(1); opacity: .9; }
    50% { transform: scale(1.06); opacity: 1; }
}

@keyframes successPop {
    0% { transform: scale(.6); opacity: 0; }
    70% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.receipt-card {
    margin-top: 20px;
    padding: 18px;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    text-align: left;
}

.receipt-card h3 {
    margin: 0 0 14px;
    color: #0b1f3a;
}

.receipt-card dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}

.receipt-card dt {
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.receipt-card dd {
    margin: 4px 0 0;
    color: #0f172a;
    font-weight: 700;
    word-break: break-word;
}

.qr-actions-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
}

/* Firebase simplified search */
.firebase-simple-filter {
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #f8fafc;
}

.firebase-simple-filter input[type="text"] {
    flex: 1 1 360px;
    min-width: min(360px, 100%);
}

.firebase-simple-filter select {
    width: 160px;
}

.panel .btn.ghost {
    color: #0b1f3a;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

/* Dashboard home cards */
.dashboard .hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #ffffff 0%, #eef6ff 100%);
}

.dashboard .hero::after {
    content: "";
    position: absolute;
    right: -80px;
    top: -90px;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(29, 211, 176, .28), rgba(90, 141, 238, .08) 58%, transparent 70%);
}

.dashboard-cards {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.dashboard-card {
    position: relative;
    overflow: hidden;
    min-height: 240px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 22px;
    border: 1px solid rgba(226, 232, 240, .9);
    background: linear-gradient(145deg, #ffffff, #f8fbff);
    box-shadow: 0 14px 34px rgba(15, 23, 42, .08);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.dashboard-card::before {
    content: "";
    position: absolute;
    right: -46px;
    top: -46px;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: var(--card-glow, rgba(29, 211, 176, .14));
}

.dashboard-card:hover {
    transform: translateY(-4px);
    border-color: rgba(90, 141, 238, .35);
    box-shadow: 0 22px 48px rgba(15, 23, 42, .12);
}

.card-icon {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border-radius: 17px;
    background: var(--card-icon-bg, #e0f2fe);
    color: var(--card-icon-color, #0b1f3a);
}

.card-icon svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.card-kicker {
    position: relative;
    z-index: 1;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.dashboard-card h3,
.dashboard-card p,
.dashboard-card strong {
    position: relative;
    z-index: 1;
}

.dashboard-card h3 {
    margin: 0;
    color: #0b1f3a;
}

.dashboard-card p {
    margin: 0;
    color: #475569;
}

.dashboard-card strong {
    margin-top: auto;
    color: #0f766e;
    font-size: 14px;
}

.card-extrato { --card-glow: rgba(90, 141, 238, .16); --card-icon-bg: #dbeafe; --card-icon-color: #1d4ed8; }
.card-cobranca { --card-glow: rgba(29, 211, 176, .18); --card-icon-bg: #ccfbf1; --card-icon-color: #0f766e; }
.card-qrcode { --card-glow: rgba(245, 158, 11, .18); --card-icon-bg: #fef3c7; --card-icon-color: #b45309; }
.card-credenciais { --card-glow: rgba(139, 92, 246, .15); --card-icon-bg: #ede9fe; --card-icon-color: #6d28d9; }

.credential-onboarding {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr);
    gap: 22px;
    margin-top: 20px;
    padding: 28px;
    border-radius: 24px;
    background:
        radial-gradient(circle at 92% 12%, rgba(29, 211, 176, .32), transparent 18rem),
        linear-gradient(135deg, #0b1f3a, #111c64);
    color: #fff;
    box-shadow: 0 20px 52px rgba(11, 31, 58, .22);
}

.credential-onboarding::after {
    content: "";
    position: absolute;
    right: -60px;
    bottom: -80px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
}

.credential-onboarding-copy,
.credential-onboarding-steps {
    position: relative;
    z-index: 1;
}

.onboarding-kicker {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(29, 211, 176, .16);
    color: #99f6e4;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.credential-onboarding h2 {
    max-width: 680px;
    margin: 14px 0 10px;
    font-size: clamp(24px, 4vw, 38px);
    line-height: 1.05;
}

.credential-onboarding p {
    max-width: 720px;
    margin: 0;
    color: #d7e3ff;
}

.onboarding-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.credential-onboarding .btn.outline {
    color: #fff;
    border-color: rgba(255,255,255,.5);
}

.credential-onboarding-steps {
    display: grid;
    gap: 12px;
    align-content: center;
}

.credential-onboarding-steps div {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 16px;
    background: rgba(255,255,255,.08);
    backdrop-filter: blur(10px);
}

.credential-onboarding-steps strong {
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: #1dd3b0;
    color: #0b1f3a;
}

.credential-onboarding-steps span {
    color: #f8fafc;
    font-size: 13px;
    font-weight: 600;
}

.account-panel h1,
.account-panel h2 {
    margin-bottom: 4px;
}

.panel-heading-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.account-form {
    gap: 18px;
}

.account-password-box {
    padding: 18px;
    border-radius: 18px;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
}

.account-actions {
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 720px) {
    .receipt-card dl {
        grid-template-columns: 1fr;
    }

    .qr-actions-row .btn {
        width: 100%;
    }

    .firebase-simple-filter input[type="text"],
    .firebase-simple-filter select,
    .firebase-simple-filter .btn {
        width: 100%;
    }

    .credential-onboarding {
        grid-template-columns: 1fr;
        padding: 22px;
    }

    .onboarding-actions .btn,
    .account-actions .btn {
        width: 100%;
    }
}
