@font-face { font-family: Vazirmatn; font-weight: 400; font-display: swap; src: url(vendor/fonts/vazirmatn-arabic-400-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Vazirmatn; font-weight: 700; font-display: swap; src: url(vendor/fonts/vazirmatn-arabic-700-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Vazirmatn; font-weight: 800; font-display: swap; src: url(vendor/fonts/vazirmatn-arabic-800-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Vazirmatn; font-weight: 400; font-display: swap; src: url(vendor/fonts/vazirmatn-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF; }
@font-face { font-family: Vazirmatn; font-weight: 700; font-display: swap; src: url(vendor/fonts/vazirmatn-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF; }

:root {
  --bg: #0a0f14; --panel: #111922; --panel-2: #16212c; --line: #233140;
  --text: #e9eff5; --muted: #8b9cb0; --accent: #2dd4bf; --accent-ink: #042f2a;
  --ok: #22c55e; --warn: #f5a524; --err: #f04444;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Vazirmatn, Tahoma, sans-serif; background: var(--bg); color: var(--text); direction: rtl; display: flex; flex-direction: column; min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); flex: none; }
.top-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); } .dot.err { background: var(--err); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
.chip.warn { color: #fcd34d; border-color: #5a4a1a; } .chip.err { color: #fca5a5; border-color: #5a2020; } .chip.ok { color: #86efac; border-color: #1f4d2e; }

main { flex: 1; display: flex; flex-direction: column; }
.screen { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.screen.center { align-items: center; justify-content: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.card h1 { font-size: 20px; margin: 0 0 6px; }
.card h2 { font-size: 15px; margin: 0 0 10px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.field > span { font-size: 14px; color: var(--muted); }
.input { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 17px; width: 100%; }
.input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 11px 18px; font-weight: 700; font-size: 16px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { background: #3a1616; color: #fecaca; border-color: #5a2020; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; margin-top: 8px; padding: 14px; }
.btn:disabled { opacity: .45; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; padding: 12px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; font-size: 15px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.msg { min-height: 1.5em; color: #fca5a5; margin: 10px 0 0; }
.msg.ok { color: #86efac; }
.bigcode { font-size: 46px; font-weight: 800; letter-spacing: 8px; margin: 18px 0 6px; color: var(--accent); }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.lockhead { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.lockicon { width: 46px; height: 46px; border-radius: 14px; background: #3a1616; flex: none; position: relative; }
.lockicon::after { content: ''; position: absolute; inset: 14px 13px 10px; border: 3px solid #fca5a5; border-radius: 4px; }
.lockicon::before { content: ''; position: absolute; left: 16px; right: 16px; top: 7px; height: 12px; border: 3px solid #fca5a5; border-bottom: 0; border-radius: 9px 9px 0 0; }
.steps { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 10px; counter-reset: st; }
.steps li { display: flex; align-items: center; gap: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; counter-increment: st; }
.steps li::before { content: counter(st, persian); width: 30px; height: 30px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-weight: 800; flex: none; }
.steps li.done::before { content: '✓'; background: var(--ok); color: #052e14; }
.steps li > div { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.steps li .muted { font-size: 13px; }
.gps { margin-top: 12px; font-size: 14px; }
.recent { list-style: none; padding: 0; margin: 0; }
.recent li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.recent li:last-child { border-bottom: 0; }
.footer-actions { display: flex; justify-content: center; }

#sCam { padding: 0; gap: 0; }
.cam { position: relative; flex: 1; min-height: 52vh; background: #000; overflow: hidden; }
.cam video { position: absolute; width: 2px; height: 2px; opacity: 0; }
.cam canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.frame { position: absolute; left: 50%; top: 46%; width: min(62vw, 300px); aspect-ratio: 3 / 4; transform: translate(-50%, -50%); border: 3px solid rgba(255,255,255,.55); border-radius: 50% / 42%; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); transition: border-color .2s; }
.frame.qr { aspect-ratio: 1; border-radius: 22px; }
.frame.ok { border-color: var(--ok); } .frame.err { border-color: var(--err); } .frame.warn { border-color: var(--warn); }
.mode-pill { position: absolute; top: 12px; right: 12px; background: rgba(10,15,20,.8); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 14px; }
.cam-msg { position: absolute; left: 12px; right: 12px; bottom: 14px; text-align: center; font-size: 19px; font-weight: 700; text-shadow: 0 2px 8px #000; }
.kinds { display: flex; gap: 8px; padding: 10px 12px 0; }
.kind { flex: 1; padding: 12px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; font-size: 16px; }
.kind.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.kind.on[data-kind="leave"] { background: var(--warn); color: #3a2604; }
.kind.on[data-kind="mission"] { background: #818cf8; color: #1e1b4b; }
.result { margin: 10px 12px 0; padding: 14px; border-radius: 14px; background: #0f2a1c; border: 1px solid #1f4d2e; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.result.dup { background: var(--panel-2); border-color: var(--line); }
.result b { font-size: 19px; }
.cam-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); }
.cam-bar #camTimer { flex: 1; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.4); z-index: 20; }
.toast.err { border-color: #5a2020; color: #fecaca; } .toast.ok { border-color: #1f4d2e; color: #bbf7d0; }
