:root {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #f7f7f5;
    background: #111311;
    font-synthesis: none;
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; width: 100%; min-height: 100%; background: #111311; }
body { min-height: 100dvh; overflow-x: hidden; }
button { font: inherit; }
.app-shell { min-height: 100dvh; background: #111311; }

.home-screen { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 28px 20px max(28px, env(safe-area-inset-bottom)); gap: 42px; }
.home-brand { text-align: center; }
.brand-mark { margin: 0 auto 12px; width: 58px; height: 58px; display: grid; place-items: center; border: 2px solid #dfe6db; border-radius: 20px; font-size: 34px; color: #dfe6db; }
.home-brand h1 { margin: 0; font-size: clamp(26px, 7vw, 38px); letter-spacing: -.035em; }
.home-brand p { margin: 8px 0 0; color: #9ca59b; font-size: 15px; }
.home-actions { display: grid; gap: 16px; width: min(100%, 520px); margin: 0 auto; }
.home-action { min-height: 150px; border: 0; border-radius: 26px; padding: 24px; display: flex; align-items: center; justify-content: center; gap: 18px; font-size: clamp(23px, 6vw, 32px); font-weight: 850; letter-spacing: .03em; cursor: pointer; box-shadow: 0 18px 40px rgba(0,0,0,.22); }
.home-action.capture { background: #e8f0e4; color: #172016; }
.home-action.audit { background: #dddfd9; color: #181b18; }
.home-action-icon { font-size: 1.25em; }

.workflow-screen, .session-screen { min-height: 100dvh; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.workflow-header { min-height: 68px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; background: #151815; position: sticky; top: 0; z-index: 10; }
.workflow-title { font-size: 17px; font-weight: 850; letter-spacing: .035em; }
.workflow-subtitle { margin-top: 2px; color: #929b91; font-size: 12px; }
.icon-button, .finish-button { border: 0; cursor: pointer; }
.icon-button { width: 42px; height: 42px; border-radius: 14px; background: #252a25; color: white; font-size: 31px; line-height: 1; }
.finish-button { background: #f0f2ed; color: #161916; font-weight: 800; border-radius: 13px; padding: 11px 14px; font-size: 13px; }

.camera-panel { position: relative; background: black; }
.camera-shell { position: relative; width: 100%; max-width: 640px; margin: 0 auto; background: #050505; }
.camera-view { width: 100%; min-height: 240px; overflow: hidden; background: #050505; position: relative; transition: box-shadow .12s ease; }
.camera-view.scan-hit { box-shadow: inset 0 0 0 6px #aee69f; }
/* The decoder maps pixels using video.clientWidth/clientHeight. Keep the
   native aspect ratio so the preview and the decoded QR region stay aligned. */
.camera-view video { width: 100% !important; height: auto !important; object-fit: contain !important; }
.camera-view > div { border: 0 !important; }
.camera-view img[alt*="Camera"] { display: none !important; }
.camera-controls { position: absolute; z-index: 5; right: 10px; bottom: 10px; display: flex; gap: 7px; pointer-events: none; }
.camera-control { pointer-events: auto; min-height: 38px; border: 1px solid rgba(255,255,255,.22); border-radius: 12px; padding: 7px 10px; background: rgba(16,18,16,.78); color: #f2f4ef; display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; backdrop-filter: blur(8px); cursor: pointer; }
.camera-control.active { background: rgba(218,232,206,.92); color: #142014; border-color: rgba(255,255,255,.36); }
.camera-control:disabled { opacity: .42; cursor: default; }
.camera-control-icon { font-size: 17px; line-height: 1; }
.camera-hint { position: absolute; z-index: 4; left: 10px; bottom: 12px; max-width: calc(100% - 210px); padding: 6px 8px; border-radius: 9px; background: rgba(8,10,8,.68); color: #b7beb5; font-size: 10px; line-height: 1.25; pointer-events: none; }
.camera-error { position: absolute; z-index: 6; left: 10px; right: 10px; top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; border: 1px solid rgba(255,177,166,.28); border-radius: 12px; background: rgba(59,33,30,.9); color: #ffd0c9; font-size: 11px; line-height: 1.35; backdrop-filter: blur(8px); }
.camera-error button { flex: 0 0 auto; border: 0; border-radius: 9px; padding: 7px 9px; background: #f1e7e4; color: #2a1715; font-size: 11px; font-weight: 850; cursor: pointer; }
.camera-error button:disabled { opacity: .55; cursor: default; }
.capture-flash { pointer-events: none; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(172, 234, 151, .20); color: #c5ffb3; font-size: 84px; font-weight: 900; text-shadow: 0 4px 24px rgba(0,0,0,.5); }
.capture-status { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 12px; color: #aab2a8; font-size: 12px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #89d77c; box-shadow: 0 0 0 4px rgba(137,215,124,.12); }

.thumbnail-strip { display: flex; gap: 9px; overflow-x: auto; padding: 8px 12px 2px; scrollbar-width: none; }
.thumbnail-strip::-webkit-scrollbar { display: none; }
.thumbnail-card { flex: 0 0 108px; height: 92px; border-radius: 15px; overflow: hidden; background: #232623; position: relative; border: 1px solid #343934; }
.thumbnail-card img, .thumbnail-pending { width: 100%; height: 100%; object-fit: cover; }
.thumbnail-pending { display: grid; place-items: center; color: #8d958c; font-weight: 900; letter-spacing: 4px; }
.thumbnail-card span { position: absolute; left: 5px; bottom: 5px; padding: 3px 6px; border-radius: 7px; background: rgba(0,0,0,.66); color: white; font-size: 10px; }

.session-list { padding: 14px 12px 40px; display: grid; gap: 10px; }
.new-session-button { min-height: 62px; border: 0; border-radius: 18px; background: #e8f0e4; color: #172016; padding: 14px 16px; display: flex; align-items: center; justify-content: center; gap: 9px; font-weight: 850; cursor: pointer; }
.new-session-button span { font-size: 24px; line-height: 1; }
.session-card { width: 100%; border: 1px solid #333833; border-radius: 18px; background: #1d211d; color: white; padding: 17px 16px; display: grid; grid-template-columns: 1fr auto 24px; align-items: center; gap: 10px; text-align: left; cursor: pointer; }
.session-date { font-weight: 780; }
.session-meta { color: #9da79b; font-size: 13px; }
.session-arrow { color: #909990; font-size: 26px; }
.empty-state { padding: 40px 24px; color: #9ba39a; text-align: center; }
.empty-state.compact { padding: 22px 24px; }

.audit-scan-error { margin: 8px 12px 0; padding: 10px 12px; border: 1px solid rgba(255,177,166,.28); border-radius: 12px; background: #3b211e; color: #ffd0c9; font-size: 12px; }
.reference-panel { margin: 10px 12px; height: min(37dvh, 390px); min-height: 220px; border-radius: 20px; overflow: hidden; background: #202420; border: 1px solid #333933; display: grid; place-items: center; }
.reference-panel img { width: 100%; height: 100%; object-fit: contain; background: #090a09; }
.reference-panel.unexpected { border-color: #b95d50; background: #321b18; }
.reference-placeholder, .no-reference-image { text-align: center; color: #9da59c; padding: 30px; }
.no-reference-image small { color: #737b72; }
.unexpected-message { display: grid; place-items: center; gap: 10px; color: #ffb4a7; text-align: center; }
.unexpected-message span { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: #733229; color: white; font-size: 34px; font-weight: 900; }
.wrong-button { width: calc(100% - 24px); margin: 2px 12px 8px; min-height: 64px; border: 0; border-radius: 18px; background: #e05045; color: white; font-size: 20px; font-weight: 900; letter-spacing: .025em; cursor: pointer; }
.wrong-button span { margin-right: 8px; }
.audit-recent { display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 7px 12px; scrollbar-width: none; }
.audit-recent::-webkit-scrollbar { display: none; }
.audit-icon { flex: 0 0 46px; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; font-weight: 900; border: 0; }
.audit-icon.ok { background: #233b25; color: #9ee49b; }
.audit-icon.wrong { background: #572722; color: #ffaaa0; cursor: pointer; }
.audit-icon.unexpected-icon { background: #4a371d; color: #ffd18b; }
.audit-icon.pending { background: #303430; color: #b3bab2; }

.update-link { align-self: center; border: 0; background: transparent; color: #8f988e; padding: 8px 14px; font-size: 13px; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }

.thumbnail-missing { width: 100%; height: 100%; display: grid; place-items: center; padding: 10px; background: #292d29; color: #aeb5ad; font-size: 12px; font-weight: 750; text-align: center; }
.thumbnail-missing.large { min-height: 210px; font-size: 16px; }
.thumbnail-card .thumbnail-time { left: 5px; right: auto; bottom: 5px; }
.thumbnail-card .quantity-badge { position: absolute; top: 5px; right: 5px; min-width: 30px; padding: 4px 7px; border-radius: 9px; background: rgba(10,12,10,.82); color: #f5f7f2; font-size: 12px; line-height: 1; }

.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.64); backdrop-filter: blur(2px); }
.edit-sheet, .issues-sheet { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; width: min(100%, 720px); max-height: min(88dvh, 780px); margin: 0 auto; overflow-y: auto; padding: 10px 16px max(18px, env(safe-area-inset-bottom)); border: 1px solid #353a35; border-bottom: 0; border-radius: 24px 24px 0 0; background: #191d19; box-shadow: 0 -20px 60px rgba(0,0,0,.38); }
.sheet-handle { width: 46px; height: 5px; border-radius: 999px; margin: 2px auto 14px; background: #4b514a; }
.edit-preview { min-height: 210px; max-height: 38dvh; border-radius: 18px; overflow: hidden; background: #0b0c0b; border: 1px solid #303530; }
.edit-preview img { display: block; width: 100%; height: 100%; max-height: 38dvh; object-fit: contain; }
.quantity-edit-row { display: grid; grid-template-columns: 52px 1fr 52px; gap: 9px; align-items: stretch; margin-top: 14px; }
.quantity-edit-row > button, .seen-editor > button { border: 1px solid #3a403a; border-radius: 14px; background: #272c27; color: white; font-size: 25px; font-weight: 800; cursor: pointer; }
.quantity-edit-row label { min-width: 0; display: grid; gap: 5px; color: #9da59c; font-size: 12px; }
.quantity-edit-row input, .seen-editor input { width: 100%; min-width: 0; border: 1px solid #3a403a; border-radius: 14px; background: #101210; color: white; padding: 11px 12px; font: inherit; font-size: 18px; font-weight: 800; text-align: center; outline: none; }
.sheet-primary, .update-apply { width: 100%; margin-top: 10px; border: 0; border-radius: 15px; padding: 14px 16px; background: #e8f0e4; color: #172016; font-weight: 850; cursor: pointer; }
.sheet-primary:disabled, .update-apply:disabled { opacity: .55; cursor: default; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.sheet-actions button, .file-action { min-height: 46px; display: grid; place-items: center; border: 1px solid #3a403a; border-radius: 14px; background: #242824; color: #eef1eb; font-weight: 750; cursor: pointer; }
.hidden-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.sheet-message { margin: 10px 2px 0; color: #aeb6ad; font-size: 13px; text-align: center; }
.sheet-delete { width: 100%; margin-top: 16px; border: 1px solid #693a35; border-radius: 14px; padding: 12px; background: #321e1b; color: #ffaaa0; font-weight: 800; cursor: pointer; }
.sheet-close { border: 0; background: transparent; color: #aeb5ad; padding: 12px 14px; cursor: pointer; }
.sheet-close:not(.compact) { width: 100%; margin-top: 2px; }
.sheet-close.compact { padding: 8px; }

.audit-quantity { width: calc(100% - 24px); margin: 0 12px 8px; border: 1px solid #3b413b; border-radius: 18px; padding: 10px 14px; background: #202420; color: white; display: grid; grid-template-columns: auto auto 1fr; align-items: baseline; justify-content: center; column-gap: 5px; cursor: pointer; }
.audit-quantity strong { font-size: 32px; line-height: 1; }
.audit-quantity span { color: #b5bcb4; font-size: 19px; font-weight: 750; }
.audit-quantity small { justify-self: end; align-self: center; font-size: 13px; font-weight: 800; }
.audit-quantity.ok { border-color: #315a35; background: #1e3020; }
.audit-quantity.ok small { color: #9ee49b; }
.audit-quantity.missing, .audit-quantity.not-seen { border-color: #725c2b; background: #332a18; }
.audit-quantity.missing small, .audit-quantity.not-seen small { color: #f2cd75; }
.audit-quantity.excess { border-color: #76512d; background: #342418; }
.audit-quantity.excess small { color: #f4bb79; }
.audit-quantity.wrong { border-color: #7d3f38; background: #351f1c; }
.audit-quantity.wrong small { color: #ffaaa0; }
.seen-editor { display: grid; grid-template-columns: 46px minmax(80px,1fr) 46px 72px; gap: 8px; margin: 0 12px 10px; }
.seen-editor > button { min-height: 46px; }
.seen-editor .seen-save { border: 0; background: #dfe8da; color: #182017; font-size: 14px; }
.wrong-button.corrected { background: #29362a; color: #b9e8b5; }
.issues-link { width: calc(100% - 24px); margin: 0 12px 2px; min-height: 43px; border: 0; border-radius: 13px; background: transparent; color: #aeb5ad; display: flex; justify-content: center; align-items: center; gap: 8px; cursor: pointer; }
.issues-link span { min-width: 26px; padding: 3px 7px; border-radius: 999px; background: #2d322d; color: white; font-size: 12px; font-weight: 850; }
.audit-icon.missing, .audit-icon.not-seen { background: #473b20; color: #f1ce7f; }
.audit-icon.excess { background: #4b3521; color: #f4bd7b; }

.issues-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.issues-header strong { display: block; font-size: 15px; letter-spacing: .025em; }
.issues-header small { display: block; margin-top: 3px; color: #949d93; font-size: 12px; }
.issues-list { display: grid; gap: 9px; }
.issue-card { min-height: 82px; display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 12px; padding: 8px; border: 1px solid #363c36; border-radius: 16px; background: #202420; }
.issue-card.missing, .issue-card.not-seen { border-color: #67552d; }
.issue-card.excess { border-color: #6a4b2e; }
.issue-card.wrong { border-color: #713d37; }
.issue-card.unexpected-icon { border-color: #67502e; }
.issue-image { width: 82px; height: 66px; overflow: hidden; display: grid; place-items: center; border-radius: 12px; background: #101210; color: #b7bdb5; font-size: 26px; font-weight: 900; }
.issue-image img { width: 100%; height: 100%; object-fit: cover; }
.issue-card strong, .issue-card small { display: block; }
.issue-card small { margin-top: 4px; color: #9ea69d; }
.issues-empty { padding: 34px 18px; border-radius: 16px; background: #203022; color: #a9e7a5; text-align: center; font-weight: 800; }

.update-screen { min-height: 100dvh; }
.update-card { width: min(calc(100% - 28px), 520px); margin: clamp(36px, 10dvh, 100px) auto 30px; padding: 24px; border: 1px solid #343a34; border-radius: 24px; background: #1b1f1b; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.22); }
.update-symbol { width: 62px; height: 62px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 20px; background: #292e29; color: #e3e9df; font-size: 34px; }
.update-card h2 { margin: 0; font-size: 21px; }
.update-card p { margin: 8px 0 20px; color: #99a298; font-size: 14px; line-height: 1.5; }
.update-apply { background: #b8e7ae; }
.update-progress { margin-top: 16px; color: #b5bdb4; font-size: 13px; display: flex; justify-content: center; align-items: center; gap: 8px; }
.update-progress span { width: 9px; height: 9px; border-radius: 50%; background: #a8df9d; animation: update-pulse 1s ease-in-out infinite alternate; }
.update-message { margin-top: 14px; padding: 11px 12px; border-radius: 13px; background: #252a25; color: #c4cbc2; font-size: 13px; line-height: 1.45; }
.update-message.success { background: #203421; color: #b7e8b3; }
.update-message.warning { background: #3a301c; color: #efd089; }
.update-message.error { background: #3b211e; color: #ffb1a6; }
@keyframes update-pulse { from { opacity: .35; transform: scale(.8); } to { opacity: 1; transform: scale(1.1); } }

#blazor-error-ui { display: none; position: fixed; left: 12px; right: 12px; bottom: 12px; padding: 12px; border-radius: 12px; background: #7d2e29; color: white; z-index: 1000; }
.loading-progress { position: absolute; display: block; width: 72px; height: 72px; inset: 50% auto auto 50%; transform: translate(-50%, -50%); }
.loading-progress circle { fill: none; stroke: #464d46; stroke-width: .55rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child { stroke: #dfe7dc; stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%)), 500%; transition: stroke-dasharray .05s ease-in-out; }
.loading-progress-text { position: absolute; inset: calc(50% + 48px) auto auto 50%; transform: translateX(-50%); color: #aab1a9; }

@media (min-width: 760px) {
    .workflow-screen, .session-screen { width: min(720px, 100%); margin: 0 auto; border-inline: 1px solid #222722; }
    .home-action { min-height: 168px; }
}
