/* ------------------------------------------------------------------ Guard Mode (รปภ. mode)
   Full-screen shell for gate staff: dark header (gate · clock · connection), today's counters, big bottom tabs.
   Applied by ui/guardshell.js; the pages inside are the ordinary Guard pages with larger touch targets. */
.hidden { display: none !important; }
.result-actions { position: sticky; bottom: 12px; z-index: 5; }

.gm { overflow-x: clip; max-width: 100vw; --gm-tab-h: 70px; --gm-zoom: 1; zoom: var(--gm-zoom); min-height: calc(100dvh / var(--gm-zoom)); display: flex; flex-direction: column; background: var(--bg); }
.gm[data-fs='lg'] { --gm-zoom: 1.12; }
.gm[data-fs='xl'] { --gm-zoom: 1.25; }

/* header */
.gm-top {
  position: sticky; top: 0; z-index: 70; display: flex; align-items: center; gap: 10px; min-height: 62px;
  padding: max(8px, env(safe-area-inset-top)) 14px 8px; background: var(--side-bg); color: #fff; box-shadow: 0 6px 24px rgba(20, 12, 60, .35);
}
.gm-brand { display: flex; align-items: center; gap: 9px; color: #fff; text-decoration: none !important; flex: 0 0 auto; }
.gm-logo { width: 36px; height: 36px; border-radius: 11px; background: var(--grad); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(192, 38, 211, .45); }
.gm-logo .icon { width: 20px; height: 20px; }
.gm-brand b { display: block; font: 700 15px var(--font-display); line-height: 1.1; }
.gm-brand small { display: block; margin-top: 2px; font-size: 9.5px; letter-spacing: .18em; color: #e9a5f0; font-weight: 600; text-transform: uppercase; white-space: nowrap; }
.gm-gate {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border-radius: 13px; max-width: 100%;
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .1); color: #fff; font-weight: 600; font-size: 14px;
}
.gm-gate span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-gate:hover { background: rgba(255, 255, 255, .18); }
.gm-gatewrap { flex: 0 1 auto; min-width: 0; }
.gm-spacer { flex: 1 1 0; min-width: 0; }
.gm-clock { text-align: right; line-height: 1.1; flex: 0 0 auto; }
.gm-clock b { font: 700 21px var(--font-display); letter-spacing: .02em; }
.gm-clock small { display: block; font-size: 10.5px; opacity: .78; white-space: nowrap; }
.gm-net { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 4px 10px; border-radius: 99px; background: rgba(255, 255, 255, .1); flex: 0 0 auto; }
.gm-net i { width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .25); }
.gm-net.off { background: rgba(248, 113, 113, .22); }
.gm-net.off i { background: #f87171; box-shadow: 0 0 0 3px rgba(248, 113, 113, .3); animation: pulseDot 1.2s infinite; }
.gm-btn { position: relative; width: 42px; height: 42px; border-radius: 13px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .1); color: #fff; display: grid; place-items: center; }
.gm-btn:hover { background: rgba(255, 255, 255, .18); }
.gm-btn .dot-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--red); color: #fff; font: 700 10.5px/18px var(--font-display); text-align: center; border: 2px solid #1b1445; }
.gm-user { border: 0; background: transparent; padding: 0; border-radius: 50%; display: block; }
.gm-user .avatar { width: 42px; height: 42px; border: 2px solid rgba(255, 255, 255, .5); }
.gm-top .tb-menu { color: var(--text); }
.gm-top .notif-panel { color: var(--text); }

/* counters strip */
.gm-stats { display: flex; gap: 8px; padding: 8px 14px; overflow-x: auto; background: var(--surface-3); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.gm-stats::-webkit-scrollbar { display: none; }
.gm-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.gm-chip b { font: 700 14px var(--font-display); color: var(--text); }
.gm-chip .icon { width: 15px; height: 15px; color: var(--muted); }
.gm-chip.ok .icon { color: var(--green); } .gm-chip.warn .icon { color: var(--amber); } .gm-chip.bad .icon { color: var(--red); }

/* content */
.gm-main { flex: 1 1 auto; width: 100%; max-width: 980px; margin: 0 auto; padding-bottom: calc(var(--gm-tab-h) + env(safe-area-inset-bottom) + 16px); }
.gm-main .page { padding: 14px 14px 8px; animation: none; }
.gm-main .crumbs { display: none; }
.gm-main .page-head { margin-bottom: 12px; }
.gm-main .page-head h1 { font-size: 22px; }
.gm-main .guard-wrap { max-width: none; }
body.gm-focus .gm-main { padding-bottom: 16px; }
body.gm-focus .gm-tabs { transform: translateY(110%); pointer-events: none; }

/* bottom tabs */
.gm-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 65; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--gm-tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(45, 27, 105, .12); transition: transform .2s var(--ease);
}
.gm-tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 600; text-decoration: none !important; -webkit-tap-highlight-color: transparent; }
.gm-tab .ic { position: relative; display: grid; place-items: center; width: 58px; height: 32px; border-radius: 16px; transition: background .15s, color .15s; }
.gm-tab .ic .icon { width: 24px; height: 24px; }
.gm-tab.on { color: var(--primary); }
.gm-tab.on .ic { background: var(--primary-50); }
.gm-tab em { position: absolute; top: -5px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--pink); color: #fff; font: 700 10.5px/18px var(--font-display); text-align: center; font-style: normal; }

/* Guard pages, bigger for gloves / one-handed use */
.gm .scanner { aspect-ratio: 1 / 1; max-height: 56vh; border-radius: 26px; }
.gm .manual-input { height: 62px; font-size: 20px; }
.gm .btn.lg { height: 54px; }
.gm .gate-seg { width: 100%; display: flex; }
.gm .gate-seg button { flex: 1; min-height: 48px; }
.gm .verdict { padding: 26px 18px; }
.gm .verdict .big { font-size: 30px; }
.gm .qty-stepper button { width: 46px; height: 46px; }
.gm .qty-stepper input { width: 74px; height: 46px; font-size: 18px; }
.gm .check-row .btn.sm { height: 40px; }

/* card lists (today / history) */
.gm-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.gm-h h2 { font-size: 20px; }
.gm-card {
  display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 14px 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); text-decoration: none !important; color: inherit; text-align: left; font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.gm-card:active { transform: scale(.992); }
.gm-no { color: var(--primary); font-size: 16px; }
.gm-title { font-weight: 600; font-size: 14.5px; }
.gm-plate { align-self: flex-start; padding: 3px 12px; border-radius: 10px; background: #fff; color: #111; border: 2px solid #111; font: 700 20px var(--font-display); letter-spacing: .06em; }
.gm-go { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 18px; border-radius: 12px; background: var(--grad); color: #fff; font-weight: 700; box-shadow: 0 8px 20px rgba(160, 38, 211, .3); }
.gm-go .icon { width: 18px; height: 18px; }
.gm-hist { border-left: 5px solid var(--line-strong); }
.gm-hist.accepted { border-left-color: var(--green); } .gm-hist.flagged { border-left-color: var(--amber); } .gm-hist.rejected, .gm-hist.invalid { border-left-color: var(--red); }
.gm-stat { text-align: center; padding: 14px 8px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.gm-stat b { display: block; font: 700 28px var(--font-display); }
.gm-stat span { font-size: 12px; color: var(--muted); }
.gm-stat.ok b { color: var(--green); } .gm-stat.warn b { color: var(--amber); } .gm-stat.bad b { color: var(--red); }

@media (max-width: 560px) {
  .gm-top { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .gm-brand { display: none; }   /* the gate name matters more than the logo on a phone */
  .gm-net span { display: none; } .gm-net { padding: 8px; }
  .gm-clock small { display: none; }
  .gm-gate { padding: 0 10px; }
}
@media (max-width: 440px) { .gm-net.on { display: none; } }   /* "online" needs no badge; only OFFLINE is shown */
@media (min-width: 1024px) {
  .gm-tabs { left: 50%; right: auto; width: min(980px, 100%); transform: translateX(-50%); border-radius: 22px 22px 0 0; border: 1px solid var(--line); border-bottom: 0; }
  body.gm-focus .gm-tabs { transform: translate(-50%, 110%); }
}

.gm-statgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.gm-statgrid .gm-stat { padding: 12px 4px; } .gm-statgrid .gm-stat b { font-size: 24px; }
.gm .result-actions { bottom: 0; margin: 0 -14px -8px; padding: 22px 14px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 76%, transparent); }
.gm-h h2 { font-size: 18px; }
