:root {
    --receipt-pink: #f3b6b4;
    --receipt-ink: #1a1a1a;
    --receipt-label: #9a9a9a;
    --receipt-line: #2a2a2a;
    --receipt-width: 300px;
}
.receipt-page {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 14px 48px;
    background: var(--receipt-pink);
    font-family: "Courier New", Courier, "Lucida Console", monospace;
    color: var(--receipt-ink);
}
.receipt-page-actions {
    width: min(100%, var(--receipt-width));
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 14px;
    font-family: system-ui, sans-serif;
}
.receipt-page-actions a,
.receipt-page-actions button {
    appearance: none;
    border: 0;
    background: rgba(255,255,255,0.75);
    color: #111;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
}
.receipt {
    width: min(100%, var(--receipt-width));
    background: #fff;
    padding: 28px 20px 34px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
    position: relative;
    /* Serrated tear-off edges — top + bottom */
    clip-path: polygon(
        0% 10px, 3.125% 0%, 6.25% 10px, 9.375% 0%, 12.5% 10px, 15.625% 0%,
        18.75% 10px, 21.875% 0%, 25% 10px, 28.125% 0%, 31.25% 10px, 34.375% 0%,
        37.5% 10px, 40.625% 0%, 43.75% 10px, 46.875% 0%, 50% 10px, 53.125% 0%,
        56.25% 10px, 59.375% 0%, 62.5% 10px, 65.625% 0%, 68.75% 10px, 71.875% 0%,
        75% 10px, 78.125% 0%, 81.25% 10px, 84.375% 0%, 87.5% 10px, 90.625% 0%,
        93.75% 10px, 96.875% 0%, 100% 10px,
        100% calc(100% - 10px),
        96.875% 100%, 93.75% calc(100% - 10px), 90.625% 100%, 87.5% calc(100% - 10px),
        84.375% 100%, 81.25% calc(100% - 10px), 78.125% 100%, 75% calc(100% - 10px),
        71.875% 100%, 68.75% calc(100% - 10px), 65.625% 100%, 62.5% calc(100% - 10px),
        59.375% 100%, 56.25% calc(100% - 10px), 53.125% 100%, 50% calc(100% - 10px),
        46.875% 100%, 43.75% calc(100% - 10px), 40.625% 100%, 37.5% calc(100% - 10px),
        34.375% 100%, 31.25% calc(100% - 10px), 28.125% 100%, 25% calc(100% - 10px),
        21.875% 100%, 18.75% calc(100% - 10px), 15.625% 100%, 12.5% calc(100% - 10px),
        9.375% 100%, 6.25% calc(100% - 10px), 3.125% 100%, 0% calc(100% - 10px)
    );
}
.receipt-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}
.receipt-brand-mark,
.receipt-brand-logo {
    width: 38px;
    height: 38px;
    color: #111;
    object-fit: contain;
}
.receipt-brand-name {
    margin: 0;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #111;
}
.receipt-studio-line {
    margin: 0;
    text-align: center;
    font-size: 0.68rem;
    color: #555;
    line-height: 1.35;
    max-width: 92%;
}
.receipt-timestamp {
    margin: 0 0 14px;
    text-align: center;
    font-size: 0.72rem;
    color: #222;
}
.token-box {
    border: 1.5px dashed #222;
    padding: 12px 10px 14px;
    margin: 8px 0 14px;
    position: relative;
    text-align: center;
}
.token-box-label {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -55%);
    background: #fff;
    padding: 0 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #111;
    line-height: 1;
}
.token-value {
    margin: 4px 0 0;
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #111;
    word-break: break-all;
}
.receipt-divider {
    border: 0;
    border-top: 1.5px dotted var(--receipt-line);
    margin: 10px 0;
    opacity: 0.85;
}
.receipt-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin: 6px 0;
    font-size: 0.8rem;
    line-height: 1.35;
}
.receipt-row .label {
    color: var(--receipt-label);
    flex: 0 1 auto;
    text-align: left;
    font-weight: 500;
}
.receipt-row .value {
    color: #111;
    font-weight: 700;
    text-align: right;
    flex: 1 1 auto;
    min-width: 0;
}
.receipt-row.is-address .value { white-space: pre-line; }
.receipt-footer {
    margin: 22px 0 4px;
    text-align: center;
}
.receipt-footer-logo {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-style: italic;
    font-weight: 800;
    font-size: 1.85rem;
    letter-spacing: 0.02em;
    color: #111;
    line-height: 1;
}

/* Payment history list modal */
#paymentsHistoryModal {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(400px, calc(100vw - 24px)) !important;
    min-height: 300px;
    max-height: min(72vh, 560px);
    height: auto;
    display: flex;
    flex-direction: column;
}
#paymentsHistoryModal[hidden] { display: none !important; }
#paymentsHistoryModal .app-modal-header { flex-shrink: 0; }
#paymentsHistoryModal .app-modal-body {
    padding: 10px 12px 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
}
#paymentsHistoryModal .profile-pay-filter { flex-shrink: 0; }
#paymentsHistoryModal .profile-pay-list,
#paymentsHistoryModal #profilePayGrid {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-right: 2px;
}

/* Standalone receipt bill modal — tall slip + overlay back icon */
.payments-bill-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10520;
    width: min(300px, calc(100vw - 28px));
    min-height: min(78dvh, 560px);
    max-height: min(92dvh, 720px);
    height: min(88dvh, 680px);
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}
.payments-bill-modal[hidden] { display: none !important; }
#paymentsBillOverlay { z-index: 10515; }

.payments-bill-back {
    position: absolute;
    top: 14px;
    left: 8px;
    z-index: 3;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: #111;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
    cursor: pointer;
}

.payments-bill-stage {
    --bill-zig: 10px;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 18px 12px 22px;
    border: 0;
    border-radius: 0;
    background: #fff;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    overflow: hidden;
    box-sizing: border-box;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    /* Cutting / tear design on top and bottom */
    clip-path: polygon(
        0% var(--bill-zig), 3.125% 0%, 6.25% var(--bill-zig), 9.375% 0%, 12.5% var(--bill-zig), 15.625% 0%,
        18.75% var(--bill-zig), 21.875% 0%, 25% var(--bill-zig), 28.125% 0%, 31.25% var(--bill-zig), 34.375% 0%,
        37.5% var(--bill-zig), 40.625% 0%, 43.75% var(--bill-zig), 46.875% 0%, 50% var(--bill-zig), 53.125% 0%,
        56.25% var(--bill-zig), 59.375% 0%, 62.5% var(--bill-zig), 65.625% 0%, 68.75% var(--bill-zig), 71.875% 0%,
        75% var(--bill-zig), 78.125% 0%, 81.25% var(--bill-zig), 84.375% 0%, 87.5% var(--bill-zig), 90.625% 0%,
        93.75% var(--bill-zig), 96.875% 0%, 100% var(--bill-zig),
        100% calc(100% - var(--bill-zig)),
        96.875% 100%, 93.75% calc(100% - var(--bill-zig)), 90.625% 100%, 87.5% calc(100% - var(--bill-zig)),
        84.375% 100%, 81.25% calc(100% - var(--bill-zig)), 78.125% 100%, 75% calc(100% - var(--bill-zig)),
        71.875% 100%, 68.75% calc(100% - var(--bill-zig)), 65.625% 100%, 62.5% calc(100% - var(--bill-zig)),
        59.375% 100%, 56.25% calc(100% - var(--bill-zig)), 53.125% 100%, 50% calc(100% - var(--bill-zig)),
        46.875% 100%, 43.75% calc(100% - var(--bill-zig)), 40.625% 100%, 37.5% calc(100% - var(--bill-zig)),
        34.375% 100%, 31.25% calc(100% - var(--bill-zig)), 28.125% 100%, 25% calc(100% - var(--bill-zig)),
        21.875% 100%, 18.75% calc(100% - var(--bill-zig)), 15.625% 100%, 12.5% calc(100% - var(--bill-zig)),
        9.375% 100%, 6.25% calc(100% - var(--bill-zig)), 3.125% 100%, 0% calc(100% - var(--bill-zig))
    );
}
.payments-bill-stage .receipt {
    --receipt-width: 100%;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 6px 4px 8px;
    box-shadow: none;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    /* Stage already has cut edges — keep article rectangular inside */
    clip-path: none;
    background: transparent;
}
.payments-bill-stage .receipt-brand {
    gap: 2px;
    margin-bottom: 4px;
    flex-shrink: 0;
}
.payments-bill-stage .receipt-brand-mark,
.payments-bill-stage .receipt-brand-logo {
    width: 28px;
    height: 28px;
}
.payments-bill-stage .receipt-brand-name {
    font-size: 0.58rem;
    letter-spacing: 0.14em;
}
.payments-bill-stage .receipt-studio-line {
    display: none; /* address shown at bottom only */
}
.payments-bill-stage .receipt-timestamp {
    margin: 0 0 8px;
    font-size: 0.58rem;
    flex-shrink: 0;
}
.payments-bill-stage .token-box {
    padding: 8px 8px 10px;
    margin: 4px 0 8px;
    flex-shrink: 0;
}
.payments-bill-stage .token-box-label {
    font-size: 0.7rem;
    padding: 0 6px;
}
.payments-bill-stage .token-value {
    font-size: 0.7rem;
}
.payments-bill-stage .receipt-divider {
    margin: 6px 0;
    flex-shrink: 0;
}
.payments-bill-stage .receipt-row {
    margin: 3px 0;
    font-size: 0.7rem;
    gap: 8px;
    line-height: 1.3;
    flex-shrink: 0;
}
.payments-bill-stage .receipt-footer {
    margin: auto 0 0;
    padding-top: 10px;
    flex-shrink: 0;
}
.payments-bill-stage .receipt-footer-logo {
    font-size: 1.35rem;
}
.payments-bill-stage .receipt-footer-address,
.payments-bill-stage .receipt-footer-contact {
    margin: 6px 0 0;
    font-size: 0.62rem;
    line-height: 1.35;
    color: #555;
    display: block;
}
.receipt-footer-address,
.receipt-footer-contact {
    margin: 8px 0 0;
    font-size: 0.62rem;
    line-height: 1.35;
    color: #555;
    font-weight: 500;
}
.receipt-footer-contact { margin-top: 4px; }

#custBillModal .payments-bill-stage {
    max-height: min(78dvh, 640px);
    min-height: min(62dvh, 480px);
    justify-content: stretch;
    align-items: stretch;
}

@media (max-width: 575.98px) {
    #paymentsHistoryModal {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px);
    }
    .payments-bill-modal {
        width: min(300px, calc(100vw - 28px)) !important;
        max-width: min(300px, calc(100vw - 28px));
        height: min(88dvh, 680px);
    }
}

@media print {
    .receipt-page { background: #fff; padding: 0; }
    .receipt-page-actions { display: none !important; }
    .receipt { box-shadow: none; }
    .payments-bill-back { display: none !important; }
}
