/* ============================================================
   KCC Voucher Manager — Restaurant scanner (PWA at /scan)
   Reproduces UI:UX/scanner.html screen for screen. Mobile-first,
   fills the real viewport (no phone bezel).
   ============================================================ */

:root {
    --sc-navy: #14306e;
    --sc-ink: #1c1c1e;
    --sc-muted: #6e6e73;
    --sc-fill: rgba(118, 118, 128, .12);
    --sc-bg: #f2f2f7;
    --sc-green: #0b5e2e;
    --sc-amber: #f2b300;
    --sc-amber-ink: #1f1600;
    --sc-red: #9e1218;
    --sc-blue: #2650c8;
    --sc-offline: #3d434c;
    --sc-font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;
    --sc-mono: ui-monospace, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0; background: #0b0f1a; color: var(--sc-ink); font-family: var(--sc-font);
    -webkit-font-smoothing: antialiased; overscroll-behavior: none; -webkit-user-select: none; user-select: none;
    -webkit-tap-highlight-color: transparent;
}
a { color: var(--sc-navy); }
button { font-family: inherit; transition: transform .18s cubic-bezier(.3, .7, .4, 1), background-color .2s, border-color .2s, opacity .2s; -webkit-tap-highlight-color: transparent; }
button:active:not(:disabled) { transform: scale(.96); }
button:disabled { cursor: default; }
input { font-family: inherit; -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }

/* ── Keyframes (copied from UI:UX/css/scanner.css) ───────── */
@keyframes kccScan{0%{transform:translateY(0)}100%{transform:translateY(var(--scan-travel, 236px))}}
@keyframes kccCountdown{from{transform:scaleX(1)}to{transform:scaleX(0)}}
@keyframes kccPop{0%{transform:scale(.6);opacity:0}100%{transform:scale(1);opacity:1}}
@keyframes kccIn{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
@keyframes kccFade{from{opacity:0}to{opacity:1}}
@keyframes kccResult{from{opacity:0;transform:scale(1.06)}to{opacity:1;transform:none}}
@keyframes kccIcon{0%{transform:scale(.4);opacity:0}60%{transform:scale(1.08);opacity:1}100%{transform:scale(1);opacity:1}}
@keyframes kccSheet{from{transform:translateY(100%)}to{transform:translateY(0)}}
@keyframes kccDot{0%{transform:scale(.3)}60%{transform:scale(1.25)}100%{transform:scale(1)}}
@keyframes kccBreath{0%,100%{transform:scale(1)}50%{transform:scale(1.025)}}
@keyframes kccShakeA{0%,100%{transform:translateX(0)}20%{transform:translateX(-14px)}40%{transform:translateX(12px)}60%{transform:translateX(-8px)}80%{transform:translateX(4px)}}
@keyframes kccShakeB{0%,100%{transform:translateX(0)}20%{transform:translateX(-14px)}40%{transform:translateX(12px)}60%{transform:translateX(-8px)}80%{transform:translateX(4px)}}
@keyframes kccDraw{from{stroke-dashoffset:30}to{stroke-dashoffset:0}}
@keyframes kccSpin{to{transform:rotate(360deg)}}

/* ── App frame: full viewport, centred column on big screens ── */
.sc {
    position: fixed; top: 0; right: 0; bottom: 0; left: 0; margin: 0 auto; max-width: 640px; background: var(--sc-bg);
    display: flex; flex-direction: column; overflow: hidden;
    height: 100vh; height: 100dvh;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
}
.scr { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }

/* ── 1 Login: choose restaurant ──────────────────────────── */
.login { background: #fff; padding: 36px 24px 24px; gap: 24px; animation: kccFade .3s ease; overflow-y: auto; }
.login__brand { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 12px; }
.login__brand img { height: 64px; width: auto; }
.eyebrow { font-size: 15px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--sc-muted); }
.login__pick { display: flex; flex-direction: column; gap: 16px; flex: 1; animation: kccIn .38s cubic-bezier(.2, .8, .2, 1); }
.login__title { font-size: 24px; font-weight: 600; }
.rest-btn {
    min-height: 132px; border-radius: 20px; border: none; background: var(--sc-fill); display: flex; flex-direction: column;
    align-items: flex-start; justify-content: center; gap: 6px; padding: 18px 24px; cursor: pointer; text-align: left; color: var(--sc-ink);
}
.rest-btn:active { background: #e5e5ea; }
.rest-btn__name { font-size: 34px; font-weight: 700; }
.rest-btn__line { font-size: 17px; color: var(--sc-muted); line-height: 1.35; }
.rest-btn--test .rest-btn__name::after { content: 'SANDBOX'; font-size: 12px; font-weight: 700; letter-spacing: .1em; margin-left: 10px; vertical-align: middle; color: var(--sc-blue); }
.login__empty { font-size: 17px; color: var(--sc-muted); line-height: 1.45; text-align: center; padding: 24px 8px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(20, 48, 110, .15); border-top-color: var(--sc-navy); animation: kccSpin .8s linear infinite; align-self: center; margin: 32px 0; }

/* ── 1b PIN pad ──────────────────────────────────────────── */
.pin {
    background: var(--sc-navy); color: #fff; align-items: center; padding: 18px 24px 26px;
    animation: kccIn .38s cubic-bezier(.2, .8, .2, 1); overflow-y: auto;
}
.pin__top { width: 100%; display: flex; align-items: center; }
.pill-back {
    height: 44px; padding: 0 16px 0 10px; border-radius: 22px; border: none; background: rgba(255, 255, 255, .14); color: #fff;
    font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 4px; cursor: pointer;
}
.pin__head { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 24px; margin-top: min(34px, 3vh); text-align: center; }
.pin__head .eyebrow { color: #fff; opacity: .75; }
.pin__name { font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1.05; }
.pin__sub { font-size: 18px; opacity: .85; margin-top: 4px; }
.pin__dots { display: flex; gap: 18px; height: 16px; align-items: center; margin-top: 22px; margin-top: min(28px, 3vh); }
.pin__dots.shake-a { animation: kccShakeA .45s cubic-bezier(.36, .07, .19, .97); }
.pin__dots.shake-b { animation: kccShakeB .45s cubic-bezier(.36, .07, .19, .97); }
.pdot { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .85); }
.pdot.is-on { background: #fff; border-color: #fff; animation: kccDot .3s cubic-bezier(.34, 1.56, .64, 1); }
.pin__msg { min-height: 24px; margin-top: 14px; font-size: 16px; font-weight: 600; color: #ffd7d9; text-align: center; line-height: 1.35; }
.keypad {
    --k: 72px;
    margin-top: auto; padding-top: 12px; display: grid; grid-template-columns: repeat(3, var(--k));
    grid-gap: 12px 26px; gap: 12px 26px; gap: min(16px, 1.8vh) 26px; justify-content: center;
}
.key {
    width: var(--k); height: var(--k); border-radius: 50%; border: none; background: rgba(255, 255, 255, .14); color: #fff;
    font-size: calc(var(--k) * .45); font-weight: 400; cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-variant-numeric: tabular-nums;
}
.key:active:not(:disabled) { background: rgba(255, 255, 255, .38); }
.key--del { background: transparent; }
.key--del:active:not(:disabled) { background: rgba(255, 255, 255, .14); }
.key--go { background: #fff; color: var(--sc-navy); animation: kccDot .3s cubic-bezier(.34, 1.56, .64, 1); }
.key--go:disabled { background: rgba(255, 255, 255, .06); color: rgba(255, 255, 255, .3); animation: none; }
.keypad.is-locked .key { opacity: .35; }
.pin__foot { margin-top: 18px; margin-top: min(22px, 2.4vh); font-size: 15px; opacity: .75; }

/* ── 2 Start shift ───────────────────────────────────────── */
.shift { background: #fff; animation: kccIn .38s cubic-bezier(.2, .8, .2, 1); overflow-y: auto; }
.shift__head { background: var(--sc-navy); color: #fff; padding: 28px 24px 22px; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.shift__hello { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.shift__hello span:first-child { font-size: 16px; opacity: .85; }
.shift__hello span:last-child { font-size: 30px; font-weight: 700; }
.btn-outline-w { height: 48px; padding: 0 16px; border-radius: 12px; border: 1.5px solid rgba(255, 255, 255, .4); background: transparent; color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; flex-shrink: 0; }
.shift__body { padding: 28px 24px; display: flex; flex-direction: column; gap: 18px; flex: 1; }
.shift__title { display: flex; flex-direction: column; gap: 4px; }
.shift__title span:first-child { font-size: 24px; font-weight: 600; }
.shift__title span:last-child { font-size: 17px; color: var(--sc-muted); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; grid-gap: 14px; gap: 14px; }
.tile {
    height: 150px; border-radius: 20px; border: 2px solid var(--sc-navy); background: #fff; display: flex; flex-direction: column;
    justify-content: flex-end; align-items: flex-start; gap: 6px; padding: 18px; cursor: pointer; color: var(--sc-ink); text-align: left;
}
.tile:active { background: #eef1f8; }
.tile__name { font-size: 26px; font-size: clamp(22px, 6.8vw, 32px); font-weight: 700; letter-spacing: -.02em; line-height: 1.05; overflow-wrap: anywhere; hyphens: auto; }
.tile__note { font-size: 16px; color: var(--sc-navy); font-weight: 600; }
.tile--off { border: 2px dashed #d1d1d6; background: var(--sc-bg); color: #8e8e93; cursor: default; }
.tile--off .tile__note { color: #8e8e93; font-weight: 400; }
.shift__none { background: var(--sc-bg); border-radius: 16px; padding: 16px 18px; font-size: 17px; line-height: 1.45; }

/* ── 3 Ready to scan ─────────────────────────────────────── */
.ready { background: #0b0f1a; animation: kccFade .35s ease; }
.rhead { background: var(--sc-ink); color: #fff; padding: 20px 20px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.rhead__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.rhead__title { font-size: 22px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rhead__sub { font-size: 15px; opacity: .8; }
.rhead__count { display: flex; flex-direction: column; align-items: flex-end; }
.rhead__count b { font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.rhead__count span { font-size: 13px; opacity: .8; text-transform: uppercase; letter-spacing: .06em; }
.rhead--check { background: var(--sc-blue); animation: kccFade .25s ease; }
.rhead--check .rhead__title { letter-spacing: .04em; }
.rhead--check .rhead__sub { opacity: .9; }

.vf {
    flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
    background: radial-gradient(ellipse at 50% 40%, #2a2f3a 0%, #12151d 70%); overflow: hidden; min-height: 0;
}
.vf__cam { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 0; overflow: hidden; }
.vf__cam #reader { position: absolute !important; top: 0; right: 0; bottom: 0; left: 0; width: 100% !important; height: 100% !important; border: 0 !important; padding: 0 !important; }
.vf__cam video { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100% !important; height: 100% !important; object-fit: cover; display: block; }
.vf__cam canvas, .vf__cam #qr-shaded-region, .vf__cam img { display: none !important; }
.vf__cam.is-live + .vf__shade { opacity: 1; }
.vf__shade { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 1; background: rgba(8, 10, 16, .28); opacity: 0; transition: opacity .3s; pointer-events: none; }
.vf__badge { position: relative; z-index: 2; animation: kccIn .32s cubic-bezier(.2, .8, .2, 1); font-size: 40px; font-weight: 700; letter-spacing: .12em; color: #fff; background: var(--sc-blue); padding: 6px 18px; border-radius: 10px; }
.frame {
    --f: 220px; --c: #fff;
    width: var(--f); height: var(--f); position: relative; z-index: 2; overflow: hidden; animation: kccBreath 2.8s ease-in-out infinite;
}
.frame span.c { position: absolute; width: 44px; height: 44px; transition: border-color .3s; }
.frame .c-tl { top: 0; left: 0; border-top: 5px solid var(--c); border-left: 5px solid var(--c); border-radius: 14px 0 0 0; }
.frame .c-tr { top: 0; right: 0; border-top: 5px solid var(--c); border-right: 5px solid var(--c); border-radius: 0 14px 0 0; }
.frame .c-bl { bottom: 0; left: 0; border-bottom: 5px solid var(--c); border-left: 5px solid var(--c); border-radius: 0 0 0 14px; }
.frame .c-br { bottom: 0; right: 0; border-bottom: 5px solid var(--c); border-right: 5px solid var(--c); border-radius: 0 0 14px 0; }
.frame .line {
    position: absolute; left: 14px; right: 14px; top: 2px; height: 3px; border-radius: 2px; background: var(--c);
    box-shadow: 0 0 14px var(--c); opacity: .85; --scan-travel: calc(var(--f) - 4px);
    animation: kccScan 1.6s ease-in-out infinite alternate;
}
.ready.is-check .frame { --c: #6f94ff; }
.vf__hint { position: relative; z-index: 2; font-size: 18px; color: #c9cfdb; text-align: center; padding: 0 32px; line-height: 1.35; text-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
.vf__busy { position: absolute; z-index: 3; top: 0; right: 0; bottom: 0; left: 0; display: flex; align-items: center; justify-content: center; background: rgba(8, 10, 16, .35); }
.vf__busy .spinner { border-color: rgba(255, 255, 255, .25); border-top-color: #fff; }
.vf__type {
    position: absolute; z-index: 3; right: 12px; bottom: 12px; height: 40px; padding: 0 14px; border-radius: 20px; border: none;
    background: rgba(255, 255, 255, .16); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.vf__type:active { background: rgba(255, 255, 255, .3); }

.controls { background: #fff; display: grid; grid-template-columns: 1.3fr 1fr .8fr; grid-gap: 8px; gap: 8px; padding: 10px 10px 14px; }
.ctl {
    height: 72px; border-radius: 16px; border: none; background: var(--sc-fill); color: var(--sc-ink); display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px; font-size: 16px; font-weight: 600; cursor: pointer;
}
.ctl:active { background: var(--sc-bg); }
.ctl--check { flex-direction: row; gap: 10px; border: 2px solid #e5e5ea; background: #fff; }
.ready.is-check .ctl--check { border-color: var(--sc-blue); background: #e6edff; }
.switch { width: 42px; height: 26px; border-radius: 13px; background: #e9e9eb; position: relative; flex-shrink: 0; display: block; transition: background-color .25s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; transition: left .3s cubic-bezier(.34, 1.3, .64, 1); width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.ready.is-check .switch { background: var(--sc-blue); }
.ready.is-check .switch::after { left: 19px; }

/* ── Sheets (menu, undo, type code) ──────────────────────── */
.dim {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: rgba(8, 12, 24, .55); display: flex; align-items: flex-end; z-index: 5;
    animation: kccFade .25s ease; transition: opacity .28s ease;
}
.dim.is-closing { opacity: 0; }
.sheet {
    width: 100%; background: #fff; border-radius: 24px 24px 0 0; animation: kccSheet .44s cubic-bezier(.32, .72, 0, 1);
    transition: transform .3s cubic-bezier(.32, .72, 0, 1); padding: 12px 20px 20px; display: flex; flex-direction: column; gap: 10px;
    max-height: 92%; overflow-y: auto;
}
.dim.is-closing .sheet { transform: translateY(100%); }
.sheet__grab { width: 44px; height: 5px; border-radius: 3px; background: #d1d1d6; align-self: center; margin-bottom: 6px; flex-shrink: 0; }
.sheet__meta { font-size: 15px; color: var(--sc-muted); padding: 0 4px; }
.sheet__title { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.sheet--gap { gap: 16px; }
.sbtn { min-height: 64px; border-radius: 16px; border: none; background: var(--sc-fill); font-size: 19px; font-weight: 600; color: var(--sc-ink); text-align: left; padding: 0 20px; cursor: pointer; }
.sbtn--close { background: var(--sc-bg); text-align: center; }
.sbtn--primary { background: var(--sc-navy); color: #fff; text-align: center; font-size: 20px; }
.sbtn--primary:disabled { background: #e5e5ea; color: #8e8e93; }
.sbtn--link { background: transparent; min-height: 56px; font-size: 18px; color: var(--sc-navy); text-align: center; }
.last-card { border: 2px solid #e5e5ea; border-radius: 16px; padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.last-card__who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.last-card__who b { font-size: 22px; font-weight: 600; }
.last-card__who span { font-size: 16px; color: var(--sc-muted); }
.last-card__time { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.reasons { display: flex; flex-direction: column; gap: 10px; }
.reasons__label { font-size: 16px; font-weight: 600; color: var(--sc-muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 56px; padding: 0 18px; border-radius: 28px; border: 2px solid transparent; background: var(--sc-fill); color: var(--sc-ink); font-size: 17px; font-weight: 600; cursor: pointer; }
.chip.is-on { border-color: var(--sc-navy); background: var(--sc-navy); color: #fff; }
.note-box { background: var(--sc-bg); border-radius: 16px; padding: 16px 18px; font-size: 17px; line-height: 1.45; color: var(--sc-ink); }
.sheet__err { color: var(--sc-red); font-weight: 600; font-size: 16px; line-height: 1.4; }
.code-input {
    height: 64px; border-radius: 16px; border: 2px solid #d1d1d6; padding: 0 16px; font-size: 22px; font-family: var(--sc-mono);
    letter-spacing: .04em; outline: none; width: 100%; text-transform: uppercase;
}
.code-input:focus { border-color: var(--sc-navy); }

/* ── 4–6 Full-screen results ─────────────────────────────── */
.res {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 10; display: flex; flex-direction: column; cursor: pointer;
    animation: kccResult .22s cubic-bezier(.2, .8, .2, 1); transition: opacity .2s ease;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
}
.res.is-leaving { opacity: 0; }
.res--green { background: var(--sc-green); color: #fff; }
.res--amber { background: var(--sc-amber); color: var(--sc-amber-ink); }
.res--red { background: var(--sc-red); color: #fff; }
.res__top { padding: 22px 24px; font-size: 17px; font-weight: 600; opacity: .9; }
.res--amber .res__top { opacity: 1; }
.res__body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; gap: min(22px, 2.4vh); padding: 0 28px; text-align: center; min-height: 0; }
.res__icon {
    --i: 130px; width: var(--i); height: var(--i); border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center;
    animation: kccIcon .5s cubic-bezier(.34, 1.56, .64, 1) both; flex-shrink: 0;
}
.res__icon svg { width: 64%; height: 64%; }
.res--green .res__icon { color: var(--sc-green); }
.res--amber .res__icon { background: var(--sc-amber-ink); color: var(--sc-amber); }
.res--red .res__icon { color: var(--sc-red); }
.res__icon .draw { stroke-dasharray: 30; animation: kccDraw .38s .16s ease-out both; }
.res__kicker { font-size: 20px; font-weight: 700; letter-spacing: .14em; }
.res__big { font-size: 52px; font-size: clamp(44px, 15vw, 64px); font-weight: 700; letter-spacing: .04em; line-height: 1; animation: kccIn .4s .08s cubic-bezier(.2, .8, .2, 1) both; }
.res__holder { font-size: 32px; font-weight: 600; animation: kccIn .4s .11s cubic-bezier(.2, .8, .2, 1) both; line-height: 1.15; word-break: break-word; }
.res__headline { font-size: 38px; font-size: clamp(34px, 11vw, 46px); font-weight: 700; line-height: 1.05; text-wrap: balance; animation: kccIn .4s .08s cubic-bezier(.2, .8, .2, 1) both; }
.res__line { font-size: 26px; font-weight: 500; line-height: 1.3; text-wrap: pretty; animation: kccIn .4s .14s cubic-bezier(.2, .8, .2, 1) both; }
.res--green .res__line { animation-delay: .14s; }
.res__foot { padding: 0 24px 28px; display: flex; flex-direction: column; gap: 10px; }
.res__bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.res--amber .res__bar { background: rgba(31, 22, 0, .18); }
.res__bar span { display: block; height: 100%; background: #fff; transform-origin: left; animation: kccCountdown var(--ms, 2000ms) linear forwards; }
.res--amber .res__bar span { background: var(--sc-amber-ink); }
.res__hint { font-size: 16px; text-align: center; opacity: .9; }
.res--amber .res__hint { font-weight: 500; opacity: 1; }

/* ── 7 Choose event ──────────────────────────────────────── */
.choose { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 10; background: #fff; display: flex; flex-direction: column; animation: kccIn .34s cubic-bezier(.2, .8, .2, 1); }
.choose__top { background: var(--sc-ink); color: #fff; padding: 22px 24px; font-size: 17px; font-weight: 600; }
.choose__body { flex: 1; display: flex; flex-direction: column; padding: 32px 24px 24px; gap: 16px; overflow-y: auto; }
.choose__title { font-size: 32px; font-weight: 700; line-height: 1.1; }
.choose__text { font-size: 18px; color: var(--sc-muted); line-height: 1.4; }
.choose__list { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.ev-btn {
    min-height: 112px; border-radius: 20px; border: 2px solid var(--sc-navy); background: #fff; color: var(--sc-ink); text-align: left;
    padding: 18px 22px; display: flex; flex-direction: column; gap: 6px; cursor: pointer;
}
.ev-btn:active { background: #eef1f8; }
.ev-btn b { font-size: 26px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.ev-btn span { font-size: 16px; color: var(--sc-muted); }
.btn-cancel { height: 60px; border-radius: 16px; border: none; background: var(--sc-bg); font-size: 18px; font-weight: 600; color: var(--sc-ink); margin-top: auto; cursor: pointer; flex-shrink: 0; }

/* ── 8 Balance (check mode) ──────────────────────────────── */
.bal { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 10; background: #eef2fa; display: flex; flex-direction: column; animation: kccIn .34s cubic-bezier(.2, .8, .2, 1); }
.bal__top { background: var(--sc-blue); color: #fff; padding: 22px 24px; display: flex; justify-content: space-between; align-items: center; }
.bal__top b { font-size: 22px; font-weight: 700; letter-spacing: .08em; }
.bal__top span { font-size: 15px; opacity: .9; }
.bal__body { flex: 1; display: flex; flex-direction: column; padding: 26px 22px 22px; gap: 18px; overflow-y: auto; }
.bal__who { display: flex; flex-direction: column; gap: 4px; }
.bal__who b { font-size: 32px; font-weight: 700; line-height: 1.1; word-break: break-word; }
.bal__who span { font-size: 17px; color: #3a3a3c; }
.bal__who code { font-size: 15px; color: var(--sc-muted); font-family: var(--sc-mono); margin-top: 4px; word-break: break-all; }
.ent { background: #fff; border-radius: 18px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; border: 1.5px solid #d6deef; }
.ent__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.ent__head small { font-size: 17px; font-weight: 600; color: var(--sc-muted); letter-spacing: 0; }
.ent__bar { height: 10px; border-radius: 5px; background: #e3e8f3; overflow: hidden; }
.ent__bar span { display: block; height: 100%; background: var(--sc-blue); }
.ent__where { font-size: 16px; color: #3a3a3c; line-height: 1.35; }
.ent--empty .ent__bar span { background: #8e8e93; }

/* ── 10 No connection ────────────────────────────────────── */
.off {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 20; animation: kccFade .25s ease; background: var(--sc-offline); color: #fff; display: flex;
    flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 32px; text-align: center;
}
.off svg { width: 96px; width: min(110px, 14vh); height: auto; }
.off__title { font-size: 42px; font-weight: 700; line-height: 1.1; }
.off__warn { font-size: 24px; font-weight: 600; line-height: 1.35; background: #fff; color: var(--sc-offline); padding: 14px 20px; border-radius: 14px; }
.off__text { font-size: 18px; opacity: .85; line-height: 1.4; }
.off__retry { height: 64px; width: 100%; border-radius: 16px; border: none; background: #fff; color: var(--sc-ink); font-size: 20px; font-weight: 600; margin-top: 12px; cursor: pointer; }
.off__retry:disabled { opacity: .6; }

/* ── Toast ───────────────────────────────────────────────── */
.sc-toast {
    position: absolute; left: 50%; bottom: 110px; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
    background: var(--sc-ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 16px; font-weight: 600;
    max-width: 90%; text-align: center; animation: kccIn .25s cubic-bezier(.2, .8, .2, 1); box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .5);
}

/* ── Hidden demo panel (?demo=1 with APP_DEBUG) ──────────── */
.demo { position: fixed; right: 8px; top: 8px; z-index: 100; background: rgba(255, 255, 255, .95); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; max-width: 180px; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
.demo b { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--sc-muted); }
.demo button { border: none; background: var(--sc-fill); border-radius: 8px; padding: 6px 8px; text-align: left; cursor: pointer; font-size: 12px; }

/* Short screens (SD60 landscape-ish, small phones) */
@media (max-height: 640px) {
    .login { padding-top: 20px; gap: 16px; }
    .login__brand img { height: 48px; }
    .rest-btn { min-height: 100px; }
    .rest-btn__name { font-size: 28px; }
    .pin__name { font-size: 32px; }
    .tile { height: 120px; }
    .tile__name { font-size: 26px; }
    .ctl { height: 60px; font-size: 15px; }
    .res__line { font-size: 22px; }
    .res__holder { font-size: 28px; }
}

/* ── Older Android WebViews (Speedata SD60, Android 8.1) ───────
   min()/clamp() sizes, upgraded only where the engine supports them. */
@supports (width: min(1px, 2px)) {
    .keypad { --k: min(80px, 9.6vh, 22vw); }
    .frame { --f: min(240px, 62vw, 34vh); }
    .res__icon { --i: min(150px, 18vh); }
}

/* Flexbox `gap` arrived in Chrome 84. scanner.js adds .no-flex-gap to <html>
   when the engine lacks it; these margins then reproduce the same spacing. */
.no-flex-gap .login > * + *, .no-flex-gap .off > * + * { margin-top: 24px; }
.no-flex-gap .vf > * + * { margin-top: 22px; }
.no-flex-gap .shift__body > * + *, .no-flex-gap .bal__body > * + *, .no-flex-gap .res__body > * + * { margin-top: 18px; }
.no-flex-gap .login__pick > * + *, .no-flex-gap .choose__body > * + *, .no-flex-gap .sheet--gap > * + * { margin-top: 16px; }
.no-flex-gap .choose__list > * + * { margin-top: 14px; }
.no-flex-gap .ent > * + * { margin-top: 12px; }
.no-flex-gap .login__brand > * + *, .no-flex-gap .sheet > * + *, .no-flex-gap .reasons > * + *, .no-flex-gap .res__foot > * + * { margin-top: 10px; }
.no-flex-gap .rest-btn > * + *, .no-flex-gap .pin__head > * + *, .no-flex-gap .tile > * + *, .no-flex-gap .ev-btn > * + * { margin-top: 6px; }
.no-flex-gap .shift__title > * + *, .no-flex-gap .shift__hello > * + *, .no-flex-gap .bal__who > * + *, .no-flex-gap .ctl > * + *, .no-flex-gap .demo > * + * { margin-top: 4px; }
.no-flex-gap .rhead__text > * + * { margin-top: 3px; }
.no-flex-gap .last-card__who > * + * { margin-top: 2px; }
.no-flex-gap .sheet--gap > * + * { margin-top: 16px; }
/* rows */
.no-flex-gap .pin__dots > * + * { margin-left: 18px; }
.no-flex-gap .shift__head > * + *, .no-flex-gap .rhead > * + *, .no-flex-gap .last-card > * + *, .no-flex-gap .ent__head > * + * { margin-left: 12px; }
.no-flex-gap .ctl--check > * + * { margin-top: 0; margin-left: 10px; }
.no-flex-gap .vf__type > * + * { margin-left: 6px; }
.no-flex-gap .pill-back > * + * { margin-left: 4px; }
.no-flex-gap .chips > * { margin: 0 8px 8px 0; }
.no-flex-gap .vf__cam, .no-flex-gap .vf__shade, .no-flex-gap .vf__busy, .no-flex-gap .vf__type { margin: 0 !important; }
