:root{font-family:system-ui,-apple-system,"Segoe UI",Tahoma,sans-serif;color:#14233d;background:#f3f6fb}*{box-sizing:border-box}body{margin:0}header{background:#102c53;color:white;padding:20px 6%;display:flex;justify-content:space-between;align-items:center;gap:10px}header a{color:#f6d28c;text-decoration:none}main{max-width:900px;margin:32px auto;padding:0 18px}.card{background:white;border:1px solid #dce5f1;border-radius:18px;padding:26px;box-shadow:0 10px 28px #112c4d0c}h1{font-size:1.6rem;margin:0 0 12px}p{line-height:1.8}.muted{color:#627087}.field{margin:18px 0}label{font-weight:700;display:block;margin-bottom:8px}input,select{width:100%;padding:13px;border:1px solid #bccbdc;border-radius:10px;font:inherit;background:white}input[type=file]{padding:11px}.hint{font-size:.9rem;color:#69788b;margin-top:5px}button,.btn{display:inline-block;background:#173b6b;color:white;border:0;border-radius:10px;padding:12px 20px;font:inherit;font-weight:700;cursor:pointer;text-decoration:none}button:disabled{opacity:.6}.secondary{background:#f2e6ca;color:#102c53}.row{display:flex;gap:12px;flex-wrap:wrap}.row>*{flex:1}.notice{padding:13px 15px;background:#fff6df;border:1px solid #e7d39b;border-radius:10px}.error{background:#fff0f0;border-color:#f1b7b7}.ok{background:#e9f9ef;border-color:#a3dab7}.preview{max-width:100%;max-height:220px;border-radius:10px;display:none;margin-top:8px}.scroll{overflow-x:auto}table{width:100%;border-collapse:collapse;white-space:nowrap}th,td{padding:12px;border-bottom:1px solid #e6edf5;text-align:right}th{background:#edf3f9}.tiny{font-size:.85rem}footer{text-align:center;padding:28px;color:#64748b}@media(max-width:640px){header{padding:15px}main{margin:18px auto}.card{padding:18px}}
.hidden-file{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}.approval{margin-top:8px;color:#9a5610;font-weight:700}.ok-text{color:#166534}.review-images{display:grid;grid-template-columns:1fr 1fr;gap:14px}.review-images img{display:block;width:100%;max-height:300px;object-fit:contain;border:1px solid #ddd;border-radius:10px;margin-top:8px}.editor-overlay[hidden],section[hidden]{display:none!important}.editor-overlay{position:fixed;inset:0;z-index:9999;background:#07172acc;display:flex;justify-content:center;align-items:center;padding:12px}.editor-box{background:white;border-radius:16px;padding:16px;width:min(620px,100%);max-height:96dvh;overflow:auto}.editor-box h2{margin:0 0 8px}.editor-box canvas{display:block;width:auto;max-width:100%;height:auto;max-height:53dvh;aspect-ratio:auto;margin:12px auto;border:3px solid #193a65;touch-action:none}.editor-actions{display:flex;gap:7px;flex-wrap:wrap;margin-bottom:12px}.editor-actions button{padding:9px 12px;flex:1}.modal-open{overflow:hidden}@media(max-width:640px){.review-images{grid-template-columns:1fr}.editor-box{padding:12px}.editor-box canvas{max-height:48dvh}}

/* Mobile camera canvas containment — 2026-10-26 */
.editor-overlay{box-sizing:border-box;max-width:100vw;max-height:100dvh;overflow:hidden}
.editor-box{box-sizing:border-box;min-width:0;max-width:100%;width:min(620px,100%);max-height:calc(100dvh - 24px);overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain}
.editor-box canvas{box-sizing:border-box;display:block;width:100%;height:auto;max-width:100%;max-height:none;object-fit:contain;margin:10px auto;touch-action:none}
/* Intrinsic canvas is 1000×700 for passport, 720×900 for portrait.
   Constrain width by both available card width and available screen height. */
#editCanvas[data-image-kind="passport"]{width:min(100%, 64dvh);aspect-ratio:10 / 7}
#editCanvas[data-image-kind="portrait"]{width:min(100%, 38dvh);aspect-ratio:4 / 5}
#cornersCanvas{display:block;max-width:100%;height:auto;object-fit:contain}
.editor-actions button,.editor-box .row>*{min-width:0}
@media(max-width:640px){.editor-overlay{padding:8px}.editor-box{padding:12px;max-height:calc(100dvh - 16px)}#editCanvas[data-image-kind="passport"]{width:min(100%, 55dvh)}#editCanvas[data-image-kind="portrait"]{width:min(100%, 35dvh)}}
/* Passport perspective selection: touch-friendly mobile canvas */
#cornersOverlay .editor-box{width:min(680px,100%)}
#cornersCanvas{width:100%;max-width:100%;height:auto;max-height:55dvh;object-fit:contain;touch-action:none;border:2px solid #173b6b;border-radius:7px}
#cornersOverlay .row button{min-width:0;padding:10px 8px}
#cornersCanvas{width:min(100%, 58dvh);max-height:none;object-fit:fill;margin:10px auto}

/* Keep controls exclusive to their respective editor on iOS Safari. */
#passportCornersButton[hidden],#whiteBgToggle[hidden],.editor-overlay[hidden]{display:none!important}
