:root{font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color-scheme:dark}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{min-height:100%}
body{margin:0;height:100vh;height:100svh;overflow:hidden;display:grid;place-items:start center;background:radial-gradient(circle at 50% -10%,#193850,#071018 62%);color:#f8fafc}
[hidden]{display:none!important}
.card{width:min(100vw,34rem);height:min(100vh,52rem);height:min(100svh,52rem);padding:max(.75rem,env(safe-area-inset-top)) max(.75rem,env(safe-area-inset-right)) max(.75rem,env(safe-area-inset-bottom)) max(.75rem,env(safe-area-inset-left));display:flex;flex-direction:column;border-radius:1.35rem;background:linear-gradient(165deg,rgba(22,42,58,.98),rgba(7,18,27,.99));border:1px solid rgba(148,163,184,.16);box-shadow:0 28px 70px -28px rgba(0,0,0,.85)}
.topbar{display:grid;grid-template-columns:2.15rem 1fr 2.15rem;align-items:center;gap:.5rem;margin-bottom:.45rem}
.topbar::after{content:''}
h1{margin:0;text-align:center;font-size:clamp(1rem,4.2vw,1.25rem);font-weight:760;letter-spacing:.01em;color:#f8fafc;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
h2{margin:0;font-size:1rem}
.icon-btn{width:2.05rem;height:2.05rem;padding:0;margin:0;border-radius:50%;background:rgba(148,163,184,.12);color:#dbeafe;font-weight:800;font-style:italic;font-family:ui-serif,Georgia,serif;border:1px solid rgba(148,163,184,.24);box-shadow:none}
.status-row,.controls{display:grid;grid-template-columns:1fr 1fr;gap:.45rem}
.status-row{margin-bottom:.5rem}
.app-status{padding:.45rem .35rem;border-radius:999px;font-weight:750;text-align:center;font-size:.78rem;display:flex;align-items:center;justify-content:center;gap:.35rem;border:1px solid rgba(255,255,255,.07)}
.app-status::before{content:'';width:.42rem;height:.42rem;border-radius:50%;background:currentColor;box-shadow:0 0 6px currentColor}
.connected{background:rgba(6,78,59,.48);color:#6ee7b7}
.scanning,.connecting{background:rgba(30,58,138,.48);color:#93c5fd}
.busy,.reconnecting{background:rgba(120,53,15,.48);color:#fcd34d}
.disconnected{background:rgba(127,29,29,.48);color:#fca5a5}
.content{position:relative;flex:1;min-height:0;display:flex;flex-direction:column;gap:.45rem;padding-top:.75rem}
.mode-switch{flex:none;display:flex;gap:.18rem;padding:.2rem;border-radius:.85rem;background:rgba(2,6,23,.58);border:1px solid rgba(148,163,184,.13)}
button{width:100%;padding:.68rem;border:0;border-radius:.72rem;font:inherit;font-size:.92rem;font-weight:720;background:linear-gradient(180deg,#5eead4,#2dd4bf);color:#04211d;margin:0;box-shadow:0 6px 16px -8px rgba(45,212,191,.65);transition:transform .12s ease,background .12s ease,border-color .12s ease;cursor:pointer}
button:active{transform:translateY(1px) scale(.985)}
.mode-tab{flex:1;padding:.48rem .35rem;border-radius:.63rem;background:transparent;color:#94a3b8;box-shadow:none;font-size:.82rem}
.mode-tab[aria-pressed=true]{background:rgba(94,234,212,.14);color:#99f6e4;box-shadow:inset 0 0 0 1px rgba(94,234,212,.28)}
.secondary{background:rgba(226,232,240,.92);color:#0f172a;box-shadow:none}
.danger{background:rgba(251,113,133,.15);color:#fecdd3;border:1px solid rgba(251,113,133,.28);box-shadow:none}
.quiet{padding:.55rem;background:rgba(148,163,184,.1);border:1px solid rgba(148,163,184,.2);color:#cbd5e1;box-shadow:none}
.quiet.danger{background:rgba(251,113,133,.12);color:#fecdd3;border-color:rgba(251,113,133,.28)}
.camera-stage{position:relative;min-height:7rem;flex:1 1 auto;overflow:hidden;border-radius:1rem;background:#020617;border:1px solid rgba(125,211,252,.16);box-shadow:inset 0 0 0 1px rgba(255,255,255,.03)}
video{display:block;width:100%;height:100%;object-fit:cover;touch-action:manipulation}
.ocr-region{position:absolute;border:2px solid #5eead4;border-radius:.3rem;background:rgba(45,212,191,.11);box-shadow:0 0 0 9999px rgba(2,6,23,.34),0 0 18px rgba(94,234,212,.45);pointer-events:none}
canvas{display:none}
.mode-block{display:flex;flex-direction:column;gap:.45rem;min-height:0;animation:reveal .16s ease-out}
#qrIdle{flex:1}
#qrActive{flex:none}
#ocrCapture{flex:none}
.empty-state{align-items:center;justify-content:center;text-align:center;padding:1rem}
.empty-state h2{font-size:1.12rem}
.empty-state p{margin:0 0 .3rem;color:#94a3b8;font-size:.88rem}
.empty-state button{max-width:18rem}
.scan-mark{width:3.8rem;height:3.8rem;margin-bottom:.35rem;border:2px solid rgba(94,234,212,.55);border-radius:1rem;background:radial-gradient(circle,#5eead4 0 10%,transparent 11%),linear-gradient(90deg,transparent 46%,rgba(94,234,212,.16) 47% 53%,transparent 54%),linear-gradient(transparent 46%,rgba(94,234,212,.16) 47% 53%,transparent 54%);box-shadow:0 12px 30px -15px rgba(45,212,191,.8)}
.entry{flex:1;min-height:0;overflow:hidden}
.entry-page{flex:1;min-height:0;display:flex;flex-direction:column;gap:.45rem}
.form-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:.42rem .5rem}
.form-grid .full{grid-column:1/-1}
.entry label,.field-label{min-width:0;font-size:.76rem;font-weight:700;color:#cbd5e1}
.entry input{display:block;width:100%;min-width:0;padding:.55rem .62rem;border:1px solid rgba(148,163,184,.27);border-radius:.58rem;background:rgba(2,6,23,.52);color:#fff;font-size:.96rem;margin:0;transition:border-color .12s ease,box-shadow .12s ease}
.entry input:focus{outline:none;border-color:#2dd4bf;box-shadow:0 0 0 3px rgba(45,212,191,.18)}
.entry input[name$=cuin]{font-family:ui-monospace,monospace;letter-spacing:.035em}
.input-shell{display:grid;grid-template-columns:minmax(0,1fr) 2rem;gap:.25rem;align-items:stretch;margin-top:.14rem}
.cuin-shell{grid-template-columns:minmax(0,1fr) 2.35rem 2rem}
.clear-input,.placeholder-key{width:2rem;padding:0;border-radius:.52rem;background:rgba(148,163,184,.11);border:1px solid rgba(148,163,184,.2);color:#cbd5e1;box-shadow:none;font-size:1.25rem;line-height:1}
.placeholder-key{width:2.35rem;color:#99f6e4;border-color:rgba(45,212,191,.3);font-family:ui-monospace,monospace;font-size:.92rem}
.field-row{display:flex;flex-direction:column}
.field-row .field-label{cursor:pointer;padding:.05rem 0}
.field-row .field-label:active{color:#5eead4}
.optional{float:right;color:#64748b;font-size:.68rem;font-weight:650}
.captured{flex:none;margin:0;padding:.42rem .55rem;border-radius:.6rem;background:rgba(45,212,191,.08);font-size:.78rem;color:#94a3b8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.captured b{color:#5eead4;font-family:ui-monospace,monospace}
.tokens{display:flex;flex-wrap:wrap;align-content:flex-start;gap:.35rem;max-height:4.25rem;overflow:auto;padding:.05rem}
.chip{width:auto;display:inline-block;padding:.36rem .62rem;font-size:.78rem;line-height:1.1;border-radius:999px;background:rgba(45,212,191,.13);color:#99f6e4;border:1px solid rgba(45,212,191,.32);box-shadow:none}
.hint{margin:0;color:#94a3b8;font-size:.79rem;text-align:center}
.detail-link{display:flex;align-items:center;justify-content:space-between;padding:.52rem .62rem;background:rgba(148,163,184,.08);border:1px solid rgba(148,163,184,.16);color:#dbeafe;box-shadow:none;text-align:left;font-size:.8rem}
.detail-link span{color:#64748b;font-size:.72rem}
.actions{margin-top:auto}
.section-title{display:flex;align-items:center;gap:.65rem;padding:.15rem 0 .3rem}
.section-title .back-button{width:2.25rem;height:2.25rem;padding:0;border-radius:50%;background:rgba(148,163,184,.1);border:1px solid rgba(148,163,184,.2);color:#e2e8f0;box-shadow:none;font-size:1.6rem;line-height:1}
.section-title h2{font-size:.95rem}
.section-title p{margin:.05rem 0 0;color:#64748b;font-size:.7rem}
#ocrDetails>button:last-child,#manualDetails>button:last-child{margin-top:auto}
.manual-reference{flex:none;padding:.38rem;border-radius:.72rem;background:#020617;border:1px solid rgba(94,234,212,.26)}
.reference-title{display:flex;justify-content:space-between;gap:.5rem;margin:0 .1rem .3rem;color:#94a3b8;font-size:.67rem;font-weight:700}
.reference-title span:last-child{color:#5eead4}
.reference-viewport{height:clamp(4.75rem,14dvh,6.5rem);overflow:auto;overscroll-behavior:contain;touch-action:none;scrollbar-width:thin;scrollbar-color:#2dd4bf #0f172a;border-radius:.38rem;background:#fff}
.manual-reference canvas{display:block;width:auto;max-width:none;height:100%;background:#fff}
.feedback{flex:none;min-height:1.35rem;display:flex;align-items:flex-end;justify-content:space-between;gap:.5rem}
.status{font-size:.76rem;font-weight:600;line-height:1.25}
.ok{color:#5eead4}
.err{color:#fca5a5}
.count{flex:none;font-size:.7rem;font-weight:700;color:#64748b;white-space:nowrap}
.info-overlay{position:absolute;inset:0;z-index:5;display:flex;align-items:center;justify-content:center;padding:.5rem;background:rgba(5,7,13,.8);border-radius:1rem}
.info-box{width:100%;max-height:100%;overflow:auto;padding:1rem;border-radius:.9rem;background:#111f2e;border:1px solid rgba(94,234,212,.22);box-shadow:0 18px 40px -12px rgba(0,0,0,.8)}
.info-box h2{margin:0 0 .55rem;font-size:1.05rem}
.info-box p{margin:0 0 .7rem;color:#e2e8f0;font-size:.88rem;line-height:1.45}
@keyframes reveal{from{opacity:0;transform:translateY(.15rem)}to{opacity:1;transform:none}}
@media(max-height:35rem){.card{padding:.5rem;border-radius:0}.topbar{margin-bottom:.28rem}.status-row{margin-bottom:.3rem}.app-status{padding:.3rem}.content,.mode-block,.entry-page{gap:.3rem}.mode-switch{padding:.14rem}.mode-tab{padding:.36rem}.camera-stage{min-height:5rem}.entry input{padding:.38rem .5rem;font-size:.88rem}.form-grid{gap:.27rem .4rem}.manual-reference{padding:.27rem}.reference-viewport{height:4.4rem}.detail-link,button{padding:.48rem}.feedback{min-height:1rem}.status{font-size:.69rem}}
@media(min-width:35rem){body{place-items:center}.card{width:min(92vw,34rem);height:min(96vh,52rem);height:min(96svh,52rem)}}
