/* Receipt capture uses the native dialog top layer above the existing app sheets. */
.receipt-scanner { position: fixed; inset: 0; margin: auto; width: 100vw; max-width: 520px; height: 100dvh; max-height: 100dvh; border: 0; padding: 0; background: #101d2b; color: #fff; font-family: inherit; overflow: hidden; }
.receipt-scanner:not([open]), .receipt-scanner [hidden] { display: none !important; }
.receipt-scanner::backdrop { background: #07111de6; }
.receipt-scanner-shell { height: 100%; display: grid; grid-template-rows: auto auto minmax(140px, 1fr) auto; }
.receipt-camera-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: max(16px, env(safe-area-inset-top)) 18px 10px; }
.receipt-camera-header h2 { font-size: 19px; line-height: 1.4; font-weight: 600; }
.receipt-camera-header p { color: #c7d5e5; font-size: 12px; margin-top: 3px; }
.receipt-scanner button { font: inherit; cursor: pointer; transition: background-color 150ms ease-out, opacity 150ms ease-out; }
.receipt-scanner button:focus-visible, .receipt-review :is(button,input,select,summary):focus-visible { outline: 3px solid #f0a167; outline-offset: 3px; }
.receipt-camera-icon { width: 44px; height: 44px; border: 1px solid #56708a; border-radius: 50%; background: transparent; color: #fff; font-size: 28px !important; flex-shrink: 0; }
.receipt-camera-icon:hover { background: #24384d; }
.receipt-camera-instruction { padding: 0 20px 12px; font-size: 13px; line-height: 1.6; color: #fff; }
.receipt-camera-stage { position: relative; min-height: 0; overflow: hidden; background: #070d14; }
.receipt-camera-stage video { display: block; width: 100%; height: 100%; object-fit: cover; }
.receipt-capture-frame { position: absolute; inset: 12px 12%; border: 1px solid #fff; box-shadow: 0 0 0 100vmax #06101a99; pointer-events: none; }
.receipt-frame-corner { position: absolute; width: 24px; height: 24px; border-color: #ffb08c; border-style: solid; border-width: 0; z-index: 2; }
.receipt-frame-corner.top-left { top: -2px; left: -2px; border-top-width: 3px; border-left-width: 3px; }
.receipt-frame-corner.top-right { top: -2px; right: -2px; border-top-width: 3px; border-right-width: 3px; }
.receipt-frame-corner.bottom-left { bottom: -2px; left: -2px; border-bottom-width: 3px; border-left-width: 3px; }
.receipt-frame-corner.bottom-right { bottom: -2px; right: -2px; border-bottom-width: 3px; border-right-width: 3px; }
.receipt-alignment { position: absolute; inset: 0 0 auto; height: 20%; border-bottom: 2px dashed #ffb08c; overflow: hidden; }
.receipt-alignment img { display: block; width: 100%; height: 100%; opacity: .48; object-fit: fill; }
.receipt-alignment span { position: absolute; bottom: 4px; left: 4px; padding: 3px 6px; background: #101d2b; color: #fff; font-size: 11px; }
.receipt-capture-preview { width: 100%; height: 100%; object-fit: contain; background: #101d2b; }
.receipt-camera-status { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: #101d2bf5; padding: 24px; text-align: center; }
.receipt-camera-status p { max-width: 30ch; font-size: 14px; line-height: 1.8; }
.receipt-camera-status button { min-height: 44px; padding: 8px 18px; border: 1px solid #9aafc6; border-radius: 10px; background: transparent; color: #fff; font-size: 14px; }
.receipt-camera-bottom { padding: 12px 16px max(12px, env(safe-area-inset-bottom)); }
.receipt-camera-tip { color: #f4c4a6; font-size: 12px; text-align: center; line-height: 1.6; margin-bottom: 10px; }
.receipt-camera-thumbs { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 8px; margin-bottom: 4px; }
.receipt-camera-thumb { width: 52px; height: 60px; flex: 0 0 auto; position: relative; }
.receipt-camera-thumb img { width: 42px; height: 56px; object-fit: cover; border-radius: 4px; background: #fff; }
.receipt-camera-thumb > span { position: absolute; bottom: 4px; left: 0; padding: 0 5px; background: #101d2b; font-size: 10px; }
.receipt-camera-thumb button { position: absolute; right: 0; top: -4px; width: 44px; height: 44px; border: 0; border-radius: 50%; color: #fff; background: transparent; text-align: right; padding-right: 1px; font-size: 23px; text-shadow: 0 1px 3px #000; }
.receipt-camera-controls { display: grid; grid-template-columns: 1fr 72px 1fr; align-items: center; gap: 10px; }
.receipt-camera-secondary, .receipt-camera-finish, .receipt-camera-keep { min-height: 46px; border-radius: 10px; padding: 10px 8px; font-size: 13px !important; line-height: 1.4; }
.receipt-camera-secondary { border: 1px solid #6f86a0; background: transparent; color: #fff; }
.receipt-camera-finish, .receipt-camera-keep { border: 0; background: #f3ab80; color: #15202c; font-weight: 700 !important; }
.receipt-camera-shutter { width: 68px; height: 68px; border: 2px solid #fff; border-radius: 50%; background: transparent; padding: 5px; justify-self: center; }
.receipt-camera-shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; }
.receipt-camera-shutter:active { transform: scale(.96); }
.receipt-scanner button:disabled { opacity: .42; cursor: default; }
.receipt-camera-review-controls { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; padding: 8px 0; }
.receipt-camera-save-note { margin-top: 9px; font-size: 11px; line-height: 1.5; text-align: center; color: #c7d5e5; }
.receipt-review { margin-top: 12px; border: 1px solid var(--paper3); border-radius: 12px; padding: 14px; background: #fff; color: var(--ink); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.receipt-review [hidden] { display: none !important; }
.receipt-review-heading { display: flex; justify-content: space-between; align-items: start; gap: 8px; margin-bottom: 12px; }
.receipt-review-heading h3 { font-size: 15px; font-weight: 700; }
.receipt-review-heading p, .receipt-twd, .receipt-review-help { color: var(--ink2); font-size: 12px; }
.receipt-review-tag { font-size: 11px; white-space: nowrap; background: var(--paper2); color: var(--ink2); padding: 3px 7px; border-radius: 4px; }
.receipt-progress { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; color: var(--ink2); }
.receipt-progress button, .receipt-review-actions button { min-height: 44px; border: 1px solid var(--paper3); border-radius: 9px; padding: 8px 10px; background: #fff; color: var(--ink2); font-family: inherit; font-size: 12px; cursor: pointer; }
.receipt-review-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.receipt-review-actions button { flex: 1 1 100px; }
.receipt-review-actions button[aria-pressed="true"] { border-color: #246a61; background: #e8f6f2; color: #145148; font-weight: 700; }
.receipt-overlap { border: 1px solid #b4cddf; background: #f0f6fc; padding: 10px; margin: 10px 0; border-radius: 10px; }
.receipt-overlap p + p { margin-top: 4px; font-size: 12px; color: var(--ink2); }
.receipt-review-warning { background: #fff5e5; color: #754600; padding: 10px; margin: 10px 0; border-radius: 10px; }
.receipt-review-warning ul { padding-left: 18px; }
.receipt-ack { display: flex; align-items: center; gap: 9px; min-height: 44px; margin-top: 5px; cursor: pointer; }
.receipt-ack input { width: 20px; height: 20px; accent-color: #246a61; flex: 0 0 auto; }
.receipt-segment-previews { display: flex; flex-direction: column; gap: 3px; }
.receipt-segment-previews summary, .receipt-lines > summary { cursor: pointer; min-height: 44px; padding: 10px 0; color: var(--ink2); font-weight: 600; }
.receipt-segment-previews img { display: block; max-width: 100%; max-height: 500px; object-fit: contain; margin: 0 auto 12px; }
.receipt-lines { border-top: 1px solid var(--paper2); margin-top: 8px; }
.receipt-edit-line { display: grid; grid-template-columns: minmax(0,1fr) 100px; gap: 7px 10px; padding: 12px 0; border-top: 1px solid var(--paper2); }
.receipt-edit-line strong { display: block; font-size: 13px; font-weight: 600; }
.receipt-edit-line small { display: block; font-size: 11px; color: var(--ink2); }
.receipt-line-kind { font-size: 11px; color: #4b637a; }
.receipt-amount-label { font-size: 11px; color: var(--ink2); }
.receipt-edit-line :is(input,select), .receipt-total-input input { width: 100%; min-height: 44px; padding: 8px; border: 1px solid var(--paper3); border-radius: 8px; font-family: inherit; font-size: 14px; background: #fff; color: var(--ink); }
.receipt-edit-line input { text-align: right; }
.receipt-calculation-label { display: flex; grid-column: 1 / -1; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink2); font-size: 12px; }
.receipt-calculation-label select { max-width: 170px; font-size: 12px; }
.receipt-review-sums { display: flex; gap: 12px; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--paper2); font-size: 12px; }
.receipt-final-total { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; font-size: 14px; font-weight: 600; }
.receipt-final-total small { display: block; font-size: 11px; font-weight: 400; color: var(--ink2); }
.receipt-total-input { display: flex; align-items: center; gap: 6px; width: 145px; max-width: 100%; }
.receipt-total-input input { min-width: 0; text-align: right; font-size: 17px; font-weight: 600; }
.receipt-total-input input::placeholder { color: #526579; font-size: 12px; font-weight: 400; }
.receipt-difference { margin-top: 8px; font-size: 12px; color: #8b4505; }
.receipt-confirm { margin-top: 10px; width: 100%; min-height: 46px; padding: 10px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.receipt-review button:disabled { background: var(--paper2); color: #526579; cursor: default; }
.receipt-review-help { margin-top: 10px; }
@media (max-height: 600px) { .receipt-camera-header { padding-top: max(8px,env(safe-area-inset-top)); } .receipt-camera-instruction { padding-bottom: 8px; } .receipt-camera-bottom { padding-top: 8px; } .receipt-camera-save-note { display: none; } .receipt-camera-shutter { width: 56px; height: 56px; } .receipt-camera-thumb { height: 44px; } .receipt-camera-thumb img { height: 42px; } }
@media (orientation: landscape) and (max-height: 500px) { .receipt-scanner-shell { overflow-y: auto; grid-template-rows: auto auto 210px auto; } }
@media (prefers-reduced-motion: reduce) { .receipt-scanner button { transition: none; } .receipt-camera-shutter:active { transform: none; } }
