.receipt-source-overlay,
.receipt-processing-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.receipt-source-sheet,
.receipt-processing-sheet {
    width: min(460px, 100%);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.97);
    color: #0f172a;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.34);
    animation: receiptSheetIn 180ms ease-out;
}

.receipt-source-sheet {
    position: relative;
    padding: 24px;
}

.receipt-source-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
}

.receipt-source-heading {
    display: flex;
    align-items: center;
    gap: 13px;
    padding-right: 28px;
}

.receipt-source-heading h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 850;
}

.receipt-source-heading p {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 0.78rem;
}

.receipt-source-icon,
.receipt-option-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.receipt-source-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 1.1rem;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.28);
}

.receipt-source-options {
    display: grid;
    gap: 10px;
    margin-top: 22px;
}

.receipt-source-options > button {
    display: grid;
    grid-template-columns: 46px 1fr auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 13px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #fff;
    color: #0f172a;
    text-align: left;
    cursor: pointer;
    transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.receipt-source-options > button:hover,
.receipt-source-options > button:focus-visible {
    transform: translateY(-1px);
    border-color: #818cf8;
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.12);
    outline: none;
}

.receipt-source-options > button:disabled {
    opacity: 0.55;
    cursor: wait;
}

.receipt-option-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    font-size: 1.05rem;
}

.receipt-option-icon.camera {
    background: #eef2ff;
    color: #4f46e5;
}

.receipt-option-icon.gallery {
    background: #ecfdf5;
    color: #059669;
}

.receipt-source-options strong,
.receipt-source-options small {
    display: block;
}

.receipt-source-options strong {
    font-size: 0.88rem;
}

.receipt-source-options small {
    margin-top: 3px;
    color: #64748b;
    font-size: 0.68rem;
    line-height: 1.4;
}

.receipt-source-options > button > .fa-chevron-right {
    color: #94a3b8;
    font-size: 0.72rem;
}

.receipt-source-note {
    margin: 16px 0 0;
    color: #64748b;
    font-size: 0.68rem;
    line-height: 1.45;
}

.receipt-processing-sheet {
    overflow: hidden;
}

.receipt-processing-top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 15px;
}

.receipt-processing-logo {
    position: relative;
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: receiptSpin 1.1s linear infinite;
}

.receipt-processing-logo::after {
    content: "";
    position: absolute;
    inset: -4px;
    border: 2px solid rgba(99, 102, 241, 0.22);
    border-top-color: #6366f1;
    border-radius: 17px;
    animation: receiptRingSpin .72s linear infinite;
}

.receipt-processing-copy {
    min-width: 0;
    flex: 1;
}

.receipt-processing-top h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 850;
}

.receipt-processing-top p {
    margin: 3px 0 0;
    overflow: hidden;
    color: #64748b;
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.receipt-progress-number {
    width: 36px;
    color: #4f46e5;
    font-size: 0.82rem;
    font-weight: 850;
    text-align: right;
    white-space: nowrap;
}

.receipt-progress-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    align-items: center;
    gap: 9px;
    padding: 0 20px;
}

.receipt-progress-track {
    height: 7px;
    margin: 0;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.receipt-progress-fill {
    width: 4%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #10b981);
    transition: width 220ms ease;
}

.receipt-skeleton-stack {
    display: grid;
    gap: 9px;
    padding: 17px 20px 20px;
}

.receipt-skeleton-line {
    position: relative;
    overflow: hidden;
    height: 13px;
    border-radius: 7px;
    background: #e8edf5;
}

.receipt-skeleton-line:nth-child(1) { width: 78%; }
.receipt-skeleton-line:nth-child(2) { width: 100%; height: 52px; border-radius: 13px; }
.receipt-skeleton-line:nth-child(3) { width: 91%; }
.receipt-skeleton-line:nth-child(4) { width: 63%; }

.receipt-skeleton-line::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.82), transparent);
    animation: receiptShimmer 1.15s infinite;
}

.receipt-processing-detail {
    min-height: 42px;
    padding: 11px 20px;
    border-top: 1px solid #eef2f7;
    background: #f8fafc;
    color: #475569;
    font-size: 0.72rem;
    line-height: 1.45;
}

.receipt-processing-sheet.is-error .receipt-processing-logo {
    background: #dc2626;
    animation: none;
}

.receipt-processing-sheet.is-error .receipt-processing-logo::after {
    display: none;
}

.receipt-processing-sheet.is-error .receipt-progress-fill {
    background: #dc2626;
}

.receipt-processing-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0 20px 18px;
    background: #f8fafc;
}

.receipt-processing-sheet.is-error .receipt-processing-actions {
    display: flex;
    justify-content: flex-end;
}

.receipt-processing-actions button {
    border: 0;
    border-radius: 10px;
    padding: 9px 15px;
    background: #0f172a;
    color: white;
    font-weight: 750;
    cursor: pointer;
}

.ai-forecast-card {
    padding: 20px;
    margin-bottom: 25px;
    border: 0;
    background: radial-gradient(circle at 0 0, rgba(255,255,255,.17), transparent 42%), linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
    color: white;
    box-shadow: 0 14px 30px -8px rgba(79, 70, 229, 0.48);
}

.ai-forecast-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
}

.ai-forecast-main {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 14px;
}

.ai-forecast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex: none;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 14px;
    background: rgba(255,255,255,.16);
    font-size: 1.2rem;
}

.ai-forecast-title {
    margin: 0;
    opacity: .9;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.ai-forecast-amount {
    margin-top: 5px;
    font-size: clamp(1.65rem, 6vw, 2.2rem);
    font-weight: 850;
    line-height: 1.08;
}

.ai-forecast-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 5px;
    margin-top: 7px;
    max-width: 430px;
    opacity: .84;
    font-size: .66rem;
    line-height: 1.42;
}

.ai-confidence-panel {
    width: 142px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,.13);
    border-radius: 15px;
    background: rgba(30, 27, 75, .26);
    text-align: left;
}

.ai-confidence-kicker {
    opacity: .76;
    font-size: .61rem;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.ai-confidence-value {
    margin-top: 2px;
    font-size: 1.35rem;
    font-weight: 900;
}

.ai-confidence-label {
    margin-top: 2px;
    font-size: .67rem;
    font-weight: 800;
}

.ai-confidence-reason {
    margin-top: 5px;
    opacity: .78;
    font-size: .58rem;
    line-height: 1.35;
}

.ai-progress-live-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: start;
    margin-top: 8px;
}

.ai-progress-activity,
.ai-progress-eta {
    font-size: .7rem;
    line-height: 1.4;
}

.ai-progress-activity {
    overflow: hidden;
    color: var(--text-light);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-progress-eta {
    color: var(--primary);
    font-weight: 800;
    white-space: nowrap;
}

.receipt-payment-source {
    min-width: 0;
    margin: 0;
    padding: 13px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 14px;
    background: var(--bg-body, #f8fafc);
}

.receipt-payment-source legend {
    padding: 0 6px;
    color: var(--text-dark, #0f172a);
    font-size: .72rem;
    font-weight: 900;
}

.receipt-payment-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
}

.receipt-payment-option {
    display: grid;
    grid-template-columns: auto 34px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    background: var(--bg-card, #fff);
    cursor: pointer;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.receipt-payment-option.is-selected {
    border-color: #6366f1;
    background: rgba(99, 102, 241, .07);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, .12);
}

.receipt-payment-option input[type="radio"] {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: #6366f1;
}

.receipt-payment-option-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
}

.receipt-payment-option-icon.account {
    color: #4f46e5;
    background: #eef2ff;
}

.receipt-payment-option-icon.cash {
    color: #15803d;
    background: #dcfce7;
}

.receipt-payment-option strong,
.receipt-payment-option small {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
}

.receipt-payment-option strong {
    font-size: .78rem;
}

.receipt-payment-option small {
    margin-top: 2px;
    color: var(--text-muted, #64748b);
    font-size: .61rem;
}

.receipt-payment-preview {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 11px;
    background: #eef2ff;
    color: #3730a3;
}

.receipt-payment-preview small,
.receipt-payment-preview strong {
    display: block;
}

.receipt-payment-preview small {
    font-size: .61rem;
    font-weight: 800;
}

.receipt-payment-preview div > strong {
    margin-top: 3px;
    font-size: .72rem;
}

.receipt-payment-preview > strong {
    flex: none;
    font-size: .9rem;
    font-weight: 900;
}

.receipt-payment-preview > strong.is-negative {
    color: #b91c1c;
}

@media (max-width: 560px) {
    .receipt-source-overlay,
    .receipt-processing-overlay {
        align-items: flex-end;
        padding: 10px;
    }

    .receipt-source-sheet,
    .receipt-processing-sheet {
        border-radius: 22px 22px 16px 16px;
    }

    .ai-forecast-layout {
        grid-template-columns: 1fr;
    }

    .ai-confidence-panel {
        width: auto;
        display: grid;
        grid-template-columns: auto auto 1fr;
        align-items: center;
        column-gap: 9px;
    }

    .ai-confidence-kicker {
        grid-column: 1 / -1;
        margin-bottom: 2px;
    }

    .ai-confidence-value,
    .ai-confidence-label,
    .ai-confidence-reason {
        margin-top: 0;
    }

    .receipt-payment-options {
        grid-template-columns: 1fr;
    }

    .receipt-payment-preview {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }
}

#receiptReviewModal input,
#receiptReviewModal select {
    box-sizing: border-box;
    min-width: 0;
}

@media (max-width: 560px) {
    #receiptReviewModal table {
        min-width: 0 !important;
        table-layout: fixed;
    }
    #receiptReviewModal thead {
        display: none;
    }
    #receiptReviewModal tbody {
        display: block;
    }
    #receiptItemsBody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        border-bottom: 1px solid var(--border-color, #e2e8f0);
        padding: 8px;
    }
    #receiptItemsBody td {
        display: block;
        min-width: 0;
        width: auto !important;
        padding: 6px !important;
    }
    #receiptItemsBody td:first-child {
        grid-column: 1 / -1;
    }
    #receiptItemsBody td::before {
        content: attr(data-label);
        display: block;
        font-size: 12px;
        font-weight: 700;
        margin-bottom: 4px;
    }
    #receiptReviewModal > div > div:first-child {
        position: static !important;
        flex-wrap: wrap;
    }
}

@keyframes receiptSheetIn {
    from { opacity: 0; transform: translateY(12px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

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

@keyframes receiptShimmer {
    to { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
    .receipt-source-sheet,
    .receipt-processing-sheet,
    .receipt-processing-logo::after,
    .receipt-processing-logo,
    .receipt-skeleton-line::after {
        animation: none;
    }
}
