/* guardhouse.css — Guardhouse QR Verification Portal
   Dark, high-contrast, WCAG AA compliant.
   Built for a monitor/tablet in a guardhouse booth.

   Contrast audit (WCAG AA: 4.5:1 body copy, 3:1 large text):
   --text    #e8e0d0  on --bg   #0c0b09  → 14.1:1 ✓
   --text-dim #c2b49a  on --card #1a1814  →  8.2:1 ✓
   --muted   #9e9080  on --card #1a1814  →  5.5:1 ✓  (was #7a7060 = 3.6:1 ✗)
   --gold    #c9a84c  on --bg   #0c0b09  →  8.8:1 ✓
   --green   #2ecc8a  on --bg   #0c0b09  →  9.5:1 ✓
   --red     #e05555  on --bg   #0c0b09  →  5.4:1 ✓
   --orange  #e8933a  on --bg   #0c0b09  →  8.3:1 ✓
   --blue    #4c8fd9  on --bg   #0c0b09  →  6.0:1 ✓                          */

:root {
  --bg:        #0c0b09;
  --surface:   #131210;
  --card:      #1a1814;
  --border:    #2a2620;
  --border-hi: #3a3428;
  --text:      #e8e0d0;
  --text-dim:  #c2b49a;   /* secondary body text — 8.2:1 on card */
  --muted:     #9e9080;   /* labels/meta — 5.5:1 on card (WCAG AA) */
  --gold:      #c9a84c;
  --gold-dim:  #6a5535;
  --green:     #2ecc8a;
  --green-dim: #0e3d28;
  --red:       #e05555;
  --red-dim:   #3d1515;
  --orange:    #e8933a;
  --blue:      #4c8fd9;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Tenor Sans', sans-serif;
  min-height: 100vh; line-height: 1.6;
  display: flex; flex-direction: column;
}

/* Global keyboard focus ring */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ── Login screen ─────────────────────────────────────────────────────────── */
.gh-login-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg); padding: 1.5rem;
}
.gh-login-card {
  background: var(--card); border: 1px solid var(--border-hi);
  border-top: 3px solid var(--gold); padding: 2.8rem 2.4rem;
  width: 100%; max-width: 400px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.45);
}
.gh-login-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.8rem; font-weight: 300; color: var(--gold);
  text-align: center; margin-bottom: 0.2rem;
}
.gh-login-title em { font-style: italic; }
.gh-login-subtitle {
  font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); text-align: center; margin-bottom: 2rem;
}
.gh-login-field {
  display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem;
}
.gh-login-label {
  font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
}
.gh-login-input {
  background: var(--surface); border: 1px solid var(--border-hi);
  color: var(--text); font-family: 'Tenor Sans', sans-serif;
  font-size: 0.96rem; padding: 0.85rem 1rem;
  width: 100%; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 48px;
}
.gh-login-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.18);
}
.gh-login-err {
  font-size: 0.84rem; color: var(--red); min-height: 1.25rem; margin-bottom: 0.6rem;
}
.gh-login-submit {
  width: 100%; background: var(--gold); color: #100d09; border: none;
  font-family: 'Tenor Sans', sans-serif; font-size: 0.82rem;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 1rem; cursor: pointer; transition: background 0.15s;
  min-height: 50px;
}
.gh-login-submit:hover  { background: #d4b460; }
.gh-login-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.gh-login-footer {
  font-size: 0.75rem; color: var(--muted); text-align: center; margin-top: 1.4rem;
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.gh-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.8rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.gh-brand {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.3rem; font-weight: 300; color: var(--gold); letter-spacing: 0.04em;
}
.gh-brand em { font-style: italic; }
.gh-brand-sub {
  font-size: 0.7rem; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--muted); margin-top: 0.15rem;
}
.gh-clock {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.6rem; font-weight: 300; color: var(--gold); letter-spacing: 0.06em;
  text-align: right;
}
.gh-date {
  font-size: 0.72rem; letter-spacing: 0.1em; color: var(--muted);
  text-align: right; margin-top: 0.1rem;
}
.gh-logout-btn {
  background: none; border: 1px solid var(--border-hi); color: var(--muted);
  font-family: 'Tenor Sans', sans-serif; font-size: 0.72rem;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 0.5rem 0.9rem; cursor: pointer; transition: all 0.15s;
  min-height: 36px;
}
.gh-logout-btn:hover { color: var(--text); border-color: var(--muted); }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.gh-body { display: grid; grid-template-columns: 400px 1fr; flex: 1; min-height: 0; }

/* ── Scanner panel (left) ──────────────────────────────────────────────────── */
.gh-scanner {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 1.4rem;
  gap: 1rem; overflow-y: auto;
}
.gh-section-label {
  font-size: 0.7rem; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.5rem;
}

/* Camera viewfinder — capped so the full scanner fits on typical monitor */
.gh-viewfinder {
  position: relative; background: #000;
  border: 1px solid var(--border-hi);
  aspect-ratio: 1 / 1;
  max-height: 260px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.gh-viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gh-viewfinder canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.gh-finder-idle {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.8rem; color: var(--muted);
}
.gh-finder-idle svg { opacity: 0.4; }
.gh-finder-idle-text { font-size: 0.82rem; letter-spacing: 0.06em; }

/* Corner brackets overlay */
.gh-brackets { position: absolute; inset: 0; pointer-events: none; }
.gh-brackets::before, .gh-brackets::after,
.gh-brackets-b::before, .gh-brackets-b::after {
  content: ''; position: absolute;
  width: 28px; height: 28px;
  border-color: var(--gold); border-style: solid;
}
.gh-brackets::before   { top: 14px;    left: 14px;  border-width: 2px 0 0 2px; }
.gh-brackets::after    { top: 14px;    right: 14px; border-width: 2px 2px 0 0; }
.gh-brackets-b::before { bottom: 14px; left: 14px;  border-width: 0 0 2px 2px; }
.gh-brackets-b::after  { bottom: 14px; right: 14px; border-width: 0 2px 2px 0; }

/* Scan line */
.gh-scanline {
  position: absolute; left: 10%; right: 10%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: scanline 2.4s ease-in-out infinite;
  opacity: 0.7;
}
@keyframes scanline { 0%,100%{top:12%} 50%{top:84%} }

.gh-cam-btn {
  width: 100%; padding: 0.85rem;
  min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: var(--gold); color: #100d09;
  border: none; font-family: 'Tenor Sans', sans-serif;
  font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase;
  cursor: pointer; transition: background 0.15s;
}
.gh-cam-btn:hover { background: #d4b460; }
.gh-cam-btn .material-symbols-outlined { font-size: 1.1rem; }
.gh-cam-btn.stop   { background: var(--red-dim); color: var(--red); border: 1px solid var(--red); }
.gh-cam-btn.stop:hover { background: #4d1b1b; }

/* Manual entry */
.gh-manual { display: flex; gap: 0.6rem; }
.gh-input {
  flex: 1; background: var(--card); border: 1px solid var(--border-hi);
  color: var(--text); font-family: 'Tenor Sans', sans-serif;
  font-size: 0.9rem; padding: 0.7rem 0.9rem;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 44px;
}
.gh-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}
.gh-input::placeholder { color: var(--muted); }

.gh-verify-btn {
  padding: 0.7rem 1.1rem; min-height: 44px;
  background: var(--card);
  border: 1px solid var(--gold-dim); color: var(--gold);
  font-family: 'Tenor Sans', sans-serif; font-size: 0.76rem;
  letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
.gh-verify-btn:hover { background: var(--gold); color: #100d09; border-color: var(--gold); }

.gh-hint { font-size: 0.76rem; color: var(--muted); margin-top: 0.45rem; line-height: 1.5; }

/* ── Result card ────────────────────────────────────────────────────────────── */
.gh-result {
  border: 1px solid var(--border-hi);
  overflow: hidden; flex-shrink: 0;
  transition: border-color 0.25s, background 0.25s;
}
/* State-aware tint using :has() — avoids any JS changes */
.gh-result:has(.gh-result-status.green) {
  border-color: rgba(46,204,138,0.45);
  background: rgba(46,204,138,0.03);
}
.gh-result:has(.gh-result-status.red) {
  border-color: rgba(224,85,85,0.45);
  background: rgba(224,85,85,0.03);
}

.gh-result-header {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.85rem 1.1rem;
}
.gh-result-status {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}
.gh-result-status.green { background: var(--green); box-shadow: 0 0 10px rgba(46,204,138,0.6); }
.gh-result-status.red   { background: var(--red);   box-shadow: 0 0 10px rgba(224,85,85,0.6); }
.gh-result-status.grey  { background: var(--muted); }

.gh-result-title {
  font-size: 0.88rem; letter-spacing: 0.08em; text-transform: uppercase;
}
.gh-result-title.green { color: var(--green); }
.gh-result-title.red   { color: var(--red); }
.gh-result-title.grey  { color: var(--muted); }

.gh-result-body { padding: 0.9rem 1.1rem; border-top: 1px solid var(--border); }
.gh-result-idle { font-size: 0.84rem; color: var(--muted); line-height: 1.55; }

.gh-row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border);
  font-size: 0.84rem;
}
.gh-row:last-child { border-bottom: none; }
.gh-row-key {
  color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em;
  text-transform: uppercase; flex-shrink: 0;
}
.gh-row-val { text-align: right; font-size: 0.88rem; }
.gh-row-val.gold  { color: var(--gold); }
.gh-row-val.green { color: var(--green); }
.gh-row-val.red   { color: var(--red); }

.gh-result-actions { display: flex; gap: 0.6rem; margin-top: 0.9rem; }
.gh-action {
  flex: 1; min-height: 50px; padding: 0.8rem 0.5rem;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  font-family: 'Tenor Sans', sans-serif;
  font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer; border: none; transition: all 0.15s;
}
.gh-action .material-symbols-outlined { font-size: 1.1rem; line-height: 1; }
.gh-action.admit { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }
.gh-action.admit:hover { background: var(--green); color: #0a2019; }
.gh-action.deny  { background: var(--red-dim);   color: var(--red);   border: 1px solid var(--red); }
.gh-action.deny:hover  { background: var(--red);   color: #fff; }
.gh-action.log   { background: var(--card); color: var(--text-dim); border: 1px solid var(--border-hi); }
.gh-action.log:hover   { border-color: var(--muted); color: var(--text); }

/* ── Right panel (log) ──────────────────────────────────────────────────────── */
.gh-logs { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.gh-logs .gh-log-panel { flex: 1 1 50%; min-height: 0; }
.gh-logs .gh-log-panel + .gh-log-panel { border-top: 2px solid var(--border); }
.gh-log-panel { display: flex; flex-direction: column; overflow: hidden; }

.gh-log-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.6rem; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.gh-log-title {
  font-size: 0.72rem; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--muted);
}
.gh-log-count { font-size: 0.78rem; color: var(--gold); }

.gh-log-clear {
  font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); background: none; border: 1px solid var(--border);
  padding: 0.35rem 0.75rem; cursor: pointer; transition: all 0.15s; min-height: 32px;
}
.gh-log-clear:hover { color: var(--red); border-color: var(--red); }

.gh-log-body { flex: 1; overflow-y: auto; }
.gh-log-body::-webkit-scrollbar { width: 4px; }
.gh-log-body::-webkit-scrollbar-track { background: var(--surface); }
.gh-log-body::-webkit-scrollbar-thumb { background: var(--border-hi); }

.gh-log-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 0.8rem; color: var(--muted); padding: 2rem;
}
.gh-log-empty-icon {
  opacity: 0.35; display: flex; align-items: center; justify-content: center;
}
.gh-log-empty-icon .material-symbols-outlined {
  font-size: 2.6rem;
  font-variation-settings: 'FILL' 0, 'wght' 200, 'GRAD' 0, 'opsz' 40;
}
.gh-log-empty-text { font-size: 0.82rem; letter-spacing: 0.05em; }

.gh-entry {
  display: flex; align-items: flex-start; gap: 1rem;
  padding: 0.9rem 1.6rem; border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.gh-entry:hover { background: var(--surface); }

.gh-entry-dot {
  width: 8px; height: 8px; border-radius: 50%; margin-top: 0.4rem; flex-shrink: 0;
}
.gh-entry-dot.green  { background: var(--green); }
.gh-entry-dot.red    { background: var(--red); }
.gh-entry-dot.orange { background: var(--orange); }

.gh-entry-main { flex: 1; min-width: 0; }
.gh-entry-name { font-size: 0.9rem; color: var(--text); }
.gh-entry-meta { font-size: 0.76rem; color: var(--muted); margin-top: 0.15rem; }

.gh-entry-tag {
  font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.2rem 0.5rem; border-radius: 2px; white-space: nowrap;
  flex-shrink: 0; margin-top: 0.25rem;
}
.gh-entry-tag.green  { background: var(--green-dim);          color: var(--green);  border: 1px solid rgba(46,204,138,.25); }
.gh-entry-tag.red    { background: var(--red-dim);             color: var(--red);    border: 1px solid rgba(224,85,85,.25); }
.gh-entry-tag.orange { background: rgba(232,147,58,0.12);      color: var(--orange); border: 1px solid rgba(232,147,58,.25); }
.gh-entry-time { font-size: 0.74rem; color: var(--muted); white-space: nowrap; margin-top: 0.25rem; flex-shrink: 0; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
#ghToast {
  position: fixed; bottom: 1.6rem; left: 50%; transform: translateX(-50%);
  padding: 0.85rem 1.8rem; font-size: 0.86rem; z-index: 9999;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
  border-radius: 2px; white-space: nowrap;
  background: var(--card); border: 1px solid var(--border-hi); color: var(--text);
}
#ghToast.show { opacity: 1; }
#ghToast.ok   { background: var(--green-dim); border-color: var(--green); color: var(--green); }
#ghToast.err  { background: var(--red-dim);   border-color: var(--red);   color: var(--red); }

/* ── Parcel checker ─────────────────────────────────────────────────────────── */
.gh-parcel { padding-top: 1.2rem; border-top: 1px solid var(--border); }
.gh-parcel-result { margin-top: 0.8rem; }
.gh-parcel-line { font-size: 0.82rem; color: var(--muted); padding: 0.4rem 0; }
.gh-parcel-line.err { color: var(--red); }

.gh-parcel-card {
  background: var(--card); border: 1px solid var(--border-hi);
  border-radius: 8px; padding: 1rem 1.1rem;
}
.gh-parcel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.8rem; }
.gh-parcel-ref  { font-size: 1rem; color: var(--gold); letter-spacing: 0.03em; font-weight: 400; }
.gh-parcel-sub  { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }
.gh-parcel-collector { font-size: 0.8rem; color: var(--muted); margin-top: 0.3rem; }
.gh-parcel-collector .material-symbols-outlined { font-size: 0.95rem; vertical-align: -2px; }

.gh-parcel-stage {
  flex-shrink: 0; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
  font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: var(--border); color: var(--text);
}
.gh-parcel-stage.green { background: var(--green-dim); color: var(--green); }
.gh-parcel-stage.red   { background: var(--red-dim);   color: var(--red); }
.gh-parcel-stage.amber { background: rgba(232,147,58,0.18); color: var(--orange); }

.gh-parcel-actions {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem; margin-top: 0.9rem;
}
.gh-parcel-btn {
  font-family: 'Tenor Sans', sans-serif; font-size: 0.76rem; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 0.7rem 0.4rem; min-height: 42px;
  border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border-hi); background: var(--surface); color: var(--text-dim);
  transition: all 0.15s;
}
.gh-parcel-btn:hover:not(:disabled) { border-color: var(--gold); color: var(--text); }
.gh-parcel-btn:disabled { opacity: 0.5; cursor: progress; }
.gh-parcel-btn.hold:hover:not(:disabled)        { background: rgba(232,147,58,0.15); border-color: var(--orange); color: var(--orange); }
.gh-parcel-btn.collected:hover:not(:disabled)   { background: var(--green-dim); border-color: var(--green); color: var(--green); }
.gh-parcel-btn.uncollected:hover:not(:disabled) { background: var(--red-dim);   border-color: var(--red);   color: var(--red); }

.gh-parcel-locked {
  margin-top: 0.9rem; padding: 0.75rem 0.9rem; border-radius: 6px;
  background: var(--surface); border: 1px dashed var(--border-hi);
  font-size: 0.8rem; color: var(--muted); display: flex; align-items: center;
  justify-content: space-between; gap: 0.6rem; flex-wrap: wrap;
}
.gh-parcel-override {
  font-family: 'Tenor Sans', sans-serif; font-size: 0.72rem; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 0.45rem 0.8rem; border-radius: 5px; cursor: pointer;
  background: none; border: 1px solid var(--border-hi); color: var(--gold);
  transition: all 0.15s; min-height: 34px;
}
.gh-parcel-override:hover:not(:disabled) { border-color: var(--gold); background: rgba(201,168,76,0.12); }
.gh-parcel-override:disabled { opacity: 0.5; cursor: progress; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .gh-body { grid-template-columns: 360px 1fr; }
}
@media (max-width: 900px) {
  .gh-body { grid-template-columns: 1fr; }
  .gh-scanner { border-right: none; border-bottom: 1px solid var(--border); }
  .gh-viewfinder { max-height: 240px; }
  .gh-logs { max-height: 60vh; }
}
@media (max-width: 600px) {
  .gh-topbar { padding: 0.75rem 1rem; gap: 0.8rem; flex-wrap: wrap; }
  .gh-clock  { font-size: 1.3rem; }
  .gh-scanner { padding: 1rem; }
  .gh-log-header { padding: 0.8rem 1rem; }
  .gh-entry { padding: 0.8rem 1rem; flex-wrap: wrap; }
  .gh-result-actions { flex-direction: column; }

  /* Stack manual-entry input above its button so neither overflows */
  .gh-manual { flex-direction: column; }
  .gh-verify-btn { width: 100%; }

  /* Parcel action buttons stack instead of cramming 3 across */
  .gh-parcel-actions { grid-template-columns: 1fr; }
}
