:root {
  --bg: #f4f5f7; --card: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #0f172a; --accent: #2563eb;
  --ok: #16a34a; --ok-bg: #dcfce7; --dup: #b45309; --dup-bg: #fef3c7; --err: #b91c1c; --err-bg: #fee2e2;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1120; --card: #111827; --ink: #e5e7eb; --muted: #94a3b8; --line: #1f2937;
    --ok-bg: #052e16; --dup-bg: #3b2305; --err-bg: #3f0d0d; --ok: #4ade80; --dup: #fbbf24; --err: #f87171; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { padding-bottom: env(safe-area-inset-bottom); -webkit-tap-highlight-color: transparent; }
button, .btn, a, summary, label { touch-action: manipulation; }
.top { position: -webkit-sticky; position: sticky; top: 0; z-index: 5; display: flex; justify-content: center; align-items: center;
  padding: calc(16px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left));
  background: var(--brand); background: linear-gradient(180deg, #0b1224 0%, #0f172a 100%); color: #fff;
  transition: padding .25s ease; }
.brand { font-weight: 700; letter-spacing: .2px; }
.navlink { color: #cbd5e1; text-decoration: none; font-size: 15px; }
.wrap { max-width: 560px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.wrap.wide { max-width: 1100px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.lbl { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.hint.err { color: var(--err); }
.input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); font-size: 16px; }
.row { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.row.between { justify-content: space-between; margin-top: 0; }
.btn { flex: 1; padding: 13px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 16px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; }
.reader { width: 100%; min-height: 60px; border-radius: 10px; overflow: hidden; background: #000; }
.reader:empty { background: var(--bg); }
.manual { margin-top: 12px; }
.manual summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.result { border-radius: 14px; padding: 18px; text-align: center; border: 2px solid transparent; }
.result.ok { background: var(--ok-bg); border-color: var(--ok); }
.result.dup { background: var(--dup-bg); border-color: var(--dup); }
.result.err { background: var(--err-bg); border-color: var(--err); }
.result.wait { background: var(--card); border-color: var(--line); }
.status { font-weight: 700; text-transform: uppercase; font-size: 13px; letter-spacing: .6px; }
.ok .status { color: var(--ok); } .dup .status { color: var(--dup); } .err .status { color: var(--err); }
.rname { font-size: 24px; font-weight: 800; margin-top: 4px; word-break: break-word; }
.rmeta { color: var(--muted); margin-top: 2px; }
.h2 { font-size: 16px; margin: 0; }
.pill { background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; font-weight: 700; }
.recent { list-style: none; margin: 10px 0 0; padding: 0; }
.recent li { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.recent li b { grid-column: 1; } .recent li span { grid-column: 1; color: var(--muted); font-size: 14px; }
.recent li time { grid-column: 2; grid-row: 1 / span 2; color: var(--muted); font-size: 13px; align-self: center; }
.recent li.dup b::after { content: " · already in"; color: var(--dup); font-weight: 500; font-size: 13px; }
.toolbar { display: grid; grid-template-columns: 1fr 1.5fr auto auto auto; gap: 10px; }
.toolbar .btn { flex: none; }
@media (max-width: 760px) { .toolbar { grid-template-columns: 1fr 1fr; } .toolbar .input { grid-column: span 2; } }
.tablewrap { overflow-x: auto; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
td.empty { text-align: center; color: var(--muted); padding: 30px; }
.link { background: none; border: 0; color: var(--err); cursor: pointer; font-size: 13px; }
.notice { background: var(--dup-bg); border: 1px solid var(--dup); border-radius: 14px; padding: 14px 16px; display: grid; gap: 6px; font-size: 15px; }
.notice .btn { text-decoration: none; text-align: center; font-size: 15px; padding: 10px 12px; }
.filebtn { display: block; text-align: center; }
.row .input { flex: 1; }
@media (min-width: 700px) { .wrap:not(.wide) { max-width: 640px; } .rname { font-size: 30px; } }
.logos { display: flex; align-items: center; justify-content: center; min-width: 0; width: 100%; max-width: 100%; }
.logo-link, .x { flex: 0 1 auto; min-width: 0; }
.x { flex: 0 0 auto; }
.logos > * + * { margin-left: 12px; } /* flex gap fallback for older iOS */
.logo-exp { height: 44px; width: auto; max-width: 38vw; display: block; object-fit: contain; object-position: center; transition: height .25s ease; }
.chip { background: #fff; border-radius: 14px; padding: 6px 12px; display: flex; align-items: center; height: 62px;
  box-shadow: 0 6px 20px rgba(0,0,0,.35); transition: height .25s ease, padding .25s ease, border-radius .25s ease; }
.logo-int { height: 50px; width: auto; max-width: 34vw; object-fit: contain; display: block; transition: height .25s ease; }
.x { color: #94a3b8; font-size: 24px; font-weight: 300; }
.logo-txt { font-size: 24px; }
/* compact header once the page is scrolled */
.top.compact { padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: 8px; }
.top.compact .logo-exp { height: 28px; }
.top.compact .chip { height: 40px; padding: 3px 8px; border-radius: 10px; }
.top.compact .logo-int { height: 32px; }
.top.compact .x { font-size: 18px; }
@media (max-width: 359px) { .logo-exp { height: 36px; } .chip { height: 52px; } .logo-int { height: 42px; } .logos > * + * { margin-left: 10px; } }
@media (min-width: 700px) { .top { padding-top: calc(22px + env(safe-area-inset-top)); padding-bottom: 22px; }
  .logo-exp { max-width: 300px; } .logo-int { max-width: 280px; }
  .logo-exp { height: 60px; } .chip { height: 82px; padding: 8px 16px; border-radius: 18px; } .logo-int { height: 66px; } .x { font-size: 32px; }
  .logos > * + * { margin-left: 22px; } }
.logo-txt { color: #fff; font-weight: 800; letter-spacing: 1px; } .logo-txt.dark { color: #0f172a; }
.logo-link.exp .logo-txt { font-size: 26px; }
.subbar { display: flex; align-items: center; justify-content: space-between;
  background: #1e293b; color: #cbd5e1; font-size: 12.5px; line-height: 1.35;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); }
.subbar > * + * { margin-left: 12px; }
.subtxt b { color: #fff; font-weight: 600; }
.navpill { flex: 0 0 auto; color: #fff; text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 8px 14px; min-height: 36px;
  display: inline-flex; align-items: center; }
.navpill:active { background: rgba(255,255,255,.22); }
@media (max-width: 480px) { .subtxt .sep, .subtxt .evt { display: none; } }
@media (min-width: 700px) { .subbar { font-size: 14px; padding-top: 10px; padding-bottom: 10px; } }

/* ---------- Interactive logos ---------- */
.logo-link { display: flex; align-items: center; text-decoration: none; position: relative;
  transition: transform .2s ease, box-shadow .3s ease, filter .3s ease; -webkit-tap-highlight-color: transparent; }
.logo-link:hover, .logo-link:focus-visible { transform: translateY(-1px) scale(1.04); }
.logo-link:active { transform: scale(.96); }
.logo-link.exp img { transition: filter .3s ease; }
.logos { animation: logosIn .6s ease-out both; }
.logo-int { animation: chipIn .7s .15s cubic-bezier(.2,.9,.3,1.3) both; }
@keyframes logosIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes chipIn { from { opacity: 0; transform: scale(.7) rotate(-6deg); } to { opacity: 1; transform: none; } }
.x { transition: transform .4s ease, color .3s ease; display: inline-block; }

/* live camera: soft pulsing ring + red "live" dot on the INTALIO chip */
.livedot { position: absolute; top: -5px; right: -5px; width: 14px; height: 14px; border-radius: 50%;
  background: #ef4444; border: 2px solid var(--brand); opacity: 0; transform: scale(.4); transition: .25s; }
body.live .livedot { opacity: 1; transform: none; animation: dot 1.2s ease-in-out infinite; }
body.live .chip { animation: ring 2s ease-out infinite; }
body.live .x { transform: rotate(90deg); color: #60a5fa; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(96,165,250,.7); } 100% { box-shadow: 0 0 0 12px rgba(96,165,250,0); } }
@keyframes dot { 50% { opacity: .35; } }

/* saving: shimmer sweep across both logos */
.top.s-wait .logo-link { overflow: hidden; }
.top.s-wait .logo-link::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; border-radius: inherit;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.55) 50%, transparent 80%);
  animation: shimmer 1s linear infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* checked in: green glow + bounce */
.top.s-ok .chip { animation: bounce .7s cubic-bezier(.3,1.6,.5,1), glowOk 1.6s ease-out; }
.top.s-ok .exp img { filter: drop-shadow(0 0 8px rgba(74,222,128,.9)); }
.top.s-ok .x { color: #4ade80; transform: rotate(360deg) scale(1.3); }
@keyframes bounce { 30% { transform: scale(1.18); } 60% { transform: scale(.95); } 100% { transform: none; } }
@keyframes glowOk { 0% { box-shadow: 0 0 0 0 rgba(74,222,128,.9); } 100% { box-shadow: 0 0 0 16px rgba(74,222,128,0); } }

/* duplicate: amber nudge */
.top.s-dup .chip { animation: nudge .5s ease, glowDup 1.6s ease-out; }
.top.s-dup .x { color: #fbbf24; }
@keyframes nudge { 25% { transform: translateY(-4px); } 50% { transform: translateY(0); } 75% { transform: translateY(-2px); } }
@keyframes glowDup { 0% { box-shadow: 0 0 0 0 rgba(251,191,36,.9); } 100% { box-shadow: 0 0 0 14px rgba(251,191,36,0); } }

/* error: red shake */
.top.s-err .logos { animation: shake .45s ease; }
.top.s-err .chip { box-shadow: 0 0 0 3px rgba(248,113,113,.9); }
.top.s-err .x { color: #f87171; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }

/* welcome stamp on successful check-in */
.stamp { display: inline-flex; align-items: center; gap: 8px; margin: -2px auto 10px; padding: 5px 12px 5px 5px;
  background: #fff; color: #0f172a; border-radius: 999px; font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,.15); animation: stampIn .55s cubic-bezier(.2,.9,.3,1.4) both; }
.stamp[hidden] { display: none; }
.stamp span { white-space: nowrap; }
.result .stamp { max-width: 100%; }
.stamp img { height: 24px; width: auto; max-width: 90px; object-fit: contain; border-radius: 6px; }
.stamp img:not([src]), .stamp img[src=""] { display: none; }
@keyframes stampIn { from { opacity: 0; transform: scale(1.6) rotate(-8deg); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* camera preview: fill the box, no letterboxing, on iOS & Android */
#reader video { width: 100% !important; height: auto !important; object-fit: cover; display: block; border-radius: 10px; }
#reader { max-height: 62vh; }
@supports (height: 100dvh) { #reader { max-height: 62dvh; } }
/* reduce heavy effects on low-power devices */
@media (prefers-reduced-transparency: reduce) { .chip { box-shadow: none; } }
