@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@400;500;600;700&display=swap');

:root {
    font-family: 'Kanit', system-ui, sans-serif;
    color: #172234;
    background: #f1f4f5;
    --muted: #526373;
    --green: #0c614b;
    --border: #d8e2e0;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button, .button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .7; }
:focus-visible { outline: 3px solid #248969; outline-offset: 3px; }
.top { background: #fff; border-bottom: 1px solid var(--border); }
.top-inner, .layout, footer { max-width: 1152px; margin-inline: auto; }
.top-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; white-space: nowrap; }
.brand-icon { display: grid; place-items: center; width: 36px; height: 36px; background: #0e634d; border-radius: 11px; }
.brand-icon i { width: 17px; height: 17px; border: 2px dashed #c8f5df; border-radius: 4px; position: relative; }
.brand-icon i::after { content: ''; position: absolute; height: 2px; background: #c8f5df; inset: 6px -4px auto; }
nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
nav a, .nav-button { display: inline-block; padding: 9px 12px; border-radius: 9px; color: var(--muted); font-size: .91rem; font-weight: 600; white-space: nowrap; }
nav .selected, nav a:hover, .nav-button:hover { color: var(--green); background: #e9f4ef; }
.nav-button { border: 0; background: transparent; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; padding: clamp(24px, 6vw, 78px) 24px 24px; align-items: stretch; }
.intro { position: relative; overflow: hidden; border-radius: 26px; min-height: 490px; padding: clamp(25px, 4vw, 48px); background: radial-gradient(ellipse at 66% 100%, #145b4a, transparent 73%), #102e2b; color: #f6fffa; }
.role { display: inline-flex; align-items: center; gap: 8px; border: 1px solid #ffffff32; color: #c9f2df; background: #ffffff0d; border-radius: 50px; padding: 6px 13px; font-size: .82rem; font-weight: 700; }
.role span { width: 7px; height: 7px; border-radius: 50%; background: #8ef0be; }
h1 { font-size: clamp(2.1rem, 4.4vw, 3.5rem); margin: 18px 0 7px; line-height: 1.15; letter-spacing: -.035em; }
.intro p { margin: 0; color: #c2dbd2; line-height: 1.6; max-width: 340px; }
.graphic { position: absolute; inset: auto 0 28px; height: 215px; display: grid; place-items: center; pointer-events: none; }
.orbit { position: absolute; border: 1px solid #caffdf29; border-radius: 50%; width: 225px; height: 225px; }
.orbit-two { width: 310px; height: 310px; }
.mock-card { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 17px; width: 244px; border-radius: 19px; padding: 18px; transform: rotate(-10deg); background: #e4fff2; box-shadow: 0 18px 50px #001f1e80; }
.mock-code canvas { display: block; width: 85px; height: 85px; }
.mock-lines b { display: block; background: #255d4f; opacity: .48; height: 9px; width: 100%; border-radius: 10px; margin: 9px 0; }
.mock-lines b + b { width: 64%; opacity: .24; }
.scan-line { position: absolute; width: 72%; height: 2px; background: #a1ffcb; box-shadow: 0 0 15px 2px #9effc393; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 26px; padding: clamp(23px, 4vw, 48px); display: flex; flex-direction: column; justify-content: center; box-shadow: 0 15px 36px #233a3610; min-width: 0; }
h2 { margin: 0 0 8px; font-size: clamp(1.48rem, 3vw, 2rem); line-height: 1.3; overflow-wrap: anywhere; }
.hint { color: var(--muted); margin: 0 0 12px; font-size: .91rem; line-height: 1.55; }
.panel form { display: grid; }
.panel form > label { margin: 14px 0 7px; font-weight: 600; }
input:not([type=hidden]) { min-width: 0; width: 100%; padding: 13px 14px; border: 1px solid #bbc9c7; border-radius: 10px; background: #fbfdfc; color: #172234; }
.code-field, .code-value { font-family: 'IBM Plex Mono', Consolas, monospace; letter-spacing: .12em; font-weight: 700; }
.code-field { text-transform: uppercase; }
.primary, .secondary { min-height: 45px; border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; }
.primary { background: var(--green); color: white; }
.primary:hover { background: #094a39; }
form > .primary { margin-top: 18px; justify-content: space-between; }
.secondary { background: #f0f6f3; color: var(--green); border-color: #d1e4dc; }
.secondary:hover { background: #e3f2eb; }
.notice { padding: 13px 15px; border-radius: 11px; margin: 0 0 16px; overflow-wrap: anywhere; }
.notice.error { color: #912b2c; background: #fff0ee; }
.notice.success { background: #eaf7ef; color: #114b39; }
.code-value { margin: 8px 0 12px; }
.employee-card { text-align: center; }
.caption { color: var(--muted); margin: 0 0 5px; font-size: .86rem; font-weight: 600; }
.qr { margin: 16px auto 0; width: min(100%, 248px); border: 1px solid var(--border); border-radius: 17px; overflow: hidden; }
.qr canvas { width: 100%; height: auto; display: block; }
.upload { border: 1px dashed #a7bfba; border-radius: 13px; padding: 12px; background: #f8fbfa; display: grid; gap: 10px; }
.upload .hint { margin: 0; }
#photo-preview { width: 100%; max-height: 180px; object-fit: contain; border-radius: 9px; }
#photo-video { max-height: 260px; border-radius: 9px; background: #132c2a; }
.viewfinder { position: relative; background: #132c2a; aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; display: grid; place-items: center; }
video { width: 100%; height: 100%; object-fit: contain; }
.target { pointer-events: none; position: absolute; width: 53%; aspect-ratio: 1; border: 2px dashed #b7ffd7; border-radius: 14px; }
.scan-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.scan-actions > *:not(input) { flex: 1; white-space: nowrap; }
.result { display: flex; align-items: center; gap: 14px; border: 1px solid var(--border); border-radius: 12px; padding: 12px; overflow-wrap: anywhere; }
.result img { width: 78px; height: 92px; object-fit: cover; background: #edf3f2; border-radius: 9px; }
.result h3 { margin: 0; }
.result .code-value { margin-bottom: 0; font-size: .86rem; }
.visually-hidden { position: absolute; width: 1px !important; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; padding: 0 !important; }
.scan-actions:focus-within label { outline-offset: 3px; }
.scan-actions:has(input:focus-visible) label { outline: 3px solid #248969; }
footer { display: flex; gap: 10px; padding: 6px 24px 24px; font-size: .8rem; color: var(--muted); }
footer span { padding-left: 10px; border-left: 1px solid #b8c9c6; }
@media (max-width: 740px) {
    .top-inner { flex-wrap: wrap; padding: 12px 16px; gap: 8px; }
    nav a, .nav-button { padding-inline: 8px; }
    .layout { grid-template-columns: 1fr; padding: 16px 16px 20px; gap: 12px; }
    .intro { min-height: auto; padding: 22px; border-radius: 20px; }
    .intro h1 { margin-top: 12px; }
    .graphic { display: none; }
    .panel { border-radius: 20px; }
    footer { padding-inline: 16px; }
}

/* Large camera workspace and employee photo. */
#photo-preview {
    max-height: 440px;
    background: #e9f0ed;
}
#photo-video {
    height: 420px;
    max-height: none;
}
.viewfinder {
    aspect-ratio: 1;
}
.result {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    gap: 16px;
    text-align: center;
    margin-top: 20px;
}
.result img {
    width: 100%;
    height: auto;
    max-height: 440px;
    object-fit: contain;
    border-radius: 12px;
}
.result h3 {
    font-size: clamp(1.5rem, 5vw, 2rem);
    line-height: 1.4;
}
.result .code-value {
    font-size: 1.05rem;
}
@media (max-width: 740px) {
    .panel { padding: 20px 16px; }
    .primary, .secondary { min-height: 52px; }
    #photo-preview { max-height: 65vh; }
    .result { padding: 10px; }
    .result img { max-height: 65vh; }
    body.camera-open { overflow: hidden; }
    .camera-active {
        position: fixed;
        inset: 0;
        z-index: 100;
        height: 100vh;
        height: 100dvh;
        border: 0;
        border-radius: 0;
        background: #0c1917;
        padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
        display: flex;
        flex-direction: column;
        gap: 12px;
        overflow: auto;
    }
    .camera-active .viewfinder,
    .camera-active #photo-video {
        flex: 1;
        min-height: 0;
        width: 100%;
        height: 0;
        max-height: none;
        aspect-ratio: auto;
        background: #0c1917;
        object-fit: contain;
    }
    .camera-active .target { width: min(75%, 340px); }
    .camera-active .scan-actions { flex-shrink: 0; margin: 0; }
    .camera-active .hint { color: #d4e8df; margin: 0; text-align: center; }
    .camera-active .primary,
    .camera-active .secondary { flex-shrink: 0; min-height: 56px; }
    .upload.camera-active #photo-preview,
    .upload.camera-active #photo,
    .upload.camera-active #upload-status { display: none; }
    .upload.camera-active #take-photo {
        order: 1;
        background: #fff;
        color: #124635;
        border: 3px solid #96dfb8;
        font-size: 1.2rem;
    }
}
