/* Design tokens — a validated color system (dataviz skill reference palette),
   not picked by eye. Sequential blue for brand/primary actions; the four
   status hues (good/warning/serious/critical) are reserved for state and
   never reused as decoration. Every status badge still carries a visible
   text label — color is never the only signal, since warning/serious don't
   clear high contrast on a light surface by design (their mitigation is the
   label, per the palette's own accessibility note). */
:root{
  --brand:#2a78d6;
  --brand-dark:#1c5cab;
  --brand-tint:#eaf2fc;
  --ink:#0b0b0b;
  --ink-secondary:#52514e;
  --ink-muted:#898781;
  --page:#f7f8fa;
  --page-alt:#eef1f6;
  --surface:#ffffff;
  --border:rgba(11,11,11,.11);
  --gridline:#e5e7eb;
  --baseline:#c3c2b7;
  --good:#0ca30c;        --good-tint:#e6f6e6;        --good-border:#bfe7bf;
  --warning:#c98500;     --warning-tint:#fdf2df;     --warning-border:#f0d9a0;
  --serious:#c1502b;     --serious-tint:#fbe9e2;     --serious-border:#f0c4ac;
  --critical:#d03b3b;    --critical-tint:#fbe7e7;    --critical-border:#f2c4c4;
  --radius:10px;
  --radius-lg:14px;
  --shadow-sm:0 1px 2px rgba(11,11,11,.06);
  --shadow-md:0 8px 24px rgba(11,11,11,.10);
}

*{box-sizing:border-box}
body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;background:radial-gradient(1100px 520px at 50% -12%,var(--brand-tint) 0%,transparent 62%) var(--page);color:var(--ink);margin:0;padding:1rem;font-size:16px;-webkit-font-smoothing:antialiased;min-height:100vh}
.wrap{max-width:420px;margin:0 auto}
h1{font-size:1.35rem;font-weight:700;letter-spacing:-.01em;margin:0 0 .3rem}
.sub{color:var(--ink-secondary);font-size:.9rem;margin:0 0 1.25rem}
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-sm);padding:1.1rem;margin-bottom:1rem}
label{display:block;font-size:.85rem;font-weight:600;color:var(--ink-secondary);margin:.6rem 0 .3rem}
input,select,textarea{width:100%;padding:.65rem .75rem;border:1px solid var(--border);border-radius:8px;font-size:1rem;font-family:inherit;background:var(--surface);color:var(--ink);transition:border-color .15s ease,box-shadow .15s ease}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--brand);box-shadow:0 0 0 3px var(--brand-tint)}
button{width:100%;padding:.7rem;border:0;border-radius:8px;background:var(--brand);color:#fff;font-size:1rem;font-weight:600;margin-top:1rem;cursor:pointer;box-shadow:var(--shadow-sm);transition:background-color .15s ease,transform .08s ease}
button:hover{background:var(--brand-dark)}
button:active{transform:translateY(1px)}
button.secondary{background:var(--page-alt);color:var(--ink);box-shadow:none}
button.secondary:hover{background:#e4e8ee}
.btn-link{display:block;text-align:center;width:100%;padding:.7rem;border-radius:8px;background:var(--brand);color:#fff;font-size:1rem;font-weight:600;margin-top:1rem;text-decoration:none;box-sizing:border-box;box-shadow:var(--shadow-sm);transition:background-color .15s ease}
.btn-link:hover{background:var(--brand-dark)}
button.danger{background:var(--critical)}
button.danger:hover{background:#b13030}
button:disabled{opacity:.55;cursor:not-allowed;box-shadow:none;transform:none}
.error{background:var(--critical-tint);border:1px solid var(--critical-border);color:#8a2a2a;padding:.65rem .75rem;border-radius:8px;font-size:.9rem;margin-bottom:.75rem}
.ok{background:var(--good-tint);border:1px solid var(--good-border);color:#0f6b0f;padding:.65rem .75rem;border-radius:8px;font-size:.9rem;margin-bottom:.75rem}
.offline-status{padding:.5rem .8rem;border-radius:8px;font-size:.85rem;font-weight:600;margin-bottom:1rem;text-align:center}
.offline-status.on{background:var(--good-tint);color:#0f6b0f}
.offline-status.off{background:var(--warning-tint);color:#7a4d00;border:1px solid var(--warning-border)}
.offline-result{border-width:2px;border-style:solid}
.offline-result.ok{border-color:var(--good)}
.offline-result.bad{border-color:var(--critical)}
.offline-badge{display:inline-block;background:var(--warning);color:#fff;font-size:.7rem;font-weight:700;letter-spacing:.05em;padding:.15rem .5rem;border-radius:20px;margin-bottom:.5rem}
.offline-title{font-size:1.3rem;font-weight:700}
.offline-addr{color:var(--ink-secondary);margin-top:.2rem}
.brandline{display:flex;align-items:center;gap:.55rem;font-weight:700;font-size:1.1rem;color:var(--ink);margin:0 0 1.25rem}
.brandline .mark{margin-right:0;color:var(--brand);display:inline-flex}
.brandline .mark .mark-icon{width:1.9rem;height:1.9rem}
.brandlogo{max-height:48px;max-width:160px;height:auto;width:auto;display:block;flex:0 0 auto}
.code{font-size:2.4rem;letter-spacing:.35rem;font-weight:700;text-align:center;margin:.5rem 0;color:var(--ink);font-variant-numeric:tabular-nums}
.qr{text-align:center;margin:.75rem 0}
.qr svg{width:160px;height:160px}
.status{display:inline-flex;align-items:center;gap:.35rem;padding:.25rem .65rem;border-radius:20px;font-size:.8rem;font-weight:600;border:1px solid transparent}
.status-valid,.status-active,.status-checked_out{background:var(--good-tint);color:#0f6b0f;border-color:var(--good-border)}
.status-used,.status-checked_in{background:var(--brand-tint);color:var(--brand-dark);border-color:#bcd7f5}
.status-expired,.status-revoked,.status-not_found,.status-not_yet_valid{background:var(--critical-tint);color:#9a2f2f;border-color:var(--critical-border)}
.status-exit_expired,.status-exit_revoked{background:var(--warning-tint);color:#7a4d00;border-color:var(--warning-border)}
.badge-new{display:inline-block;background:var(--brand);color:#fff;font-size:.65rem;font-weight:700;letter-spacing:.04em;text-transform:uppercase;padding:.15rem .5rem;border-radius:20px;margin-left:.5rem;vertical-align:middle}
.card.unread{border-left:3px solid var(--brand)}
.result{text-align:center;padding:1rem 0}
.result .big{font-size:1.4rem;font-weight:700;margin:.5rem 0}
.table-scroll{overflow-x:auto;margin:-1rem;padding:1rem}
table{width:100%;min-width:600px;border-collapse:collapse;font-size:.85rem}
th,td{text-align:left;padding:.5rem .4rem;border-bottom:1px solid var(--gridline);white-space:nowrap}
.row{display:flex;justify-content:space-between;align-items:center;padding:.55rem 0;border-bottom:1px solid var(--gridline);font-size:.9rem}
.row:last-child{border-bottom:0}
.top{display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem}
.top form{display:inline}
.top button{width:auto;margin:0;padding:.4rem .8rem;font-size:.85rem;background:var(--page-alt);color:var(--ink);box-shadow:none}
.filters{display:flex;gap:.5rem;flex-wrap:wrap;margin-bottom:1rem}
.filters input{width:auto;flex:1;min-width:100px}
.hint{color:var(--ink-muted);font-size:.8rem;margin-top:.25rem;line-height:1.45}
.hint a{color:var(--brand)}
.hint a:hover{color:var(--brand-dark)}
.wide{max-width:800px}
@media (min-width:960px){.wide{max-width:1150px}}
.subbar{padding:.6rem 1.25rem;font-size:.85rem;line-height:1.4;border-bottom:1px solid var(--border)}
.subbar.danger{background:var(--critical-tint);color:#8a2a2a}
/* :not([hidden]) rather than a bare display:flex — otherwise this rule's own
   specificity beats the browser's default [hidden]{display:none}, and toggling
   the `hidden` attribute in JS silently stops working. */
.modal-overlay:not([hidden]){position:fixed;inset:0;background:rgba(11,11,11,.62);display:flex;align-items:center;justify-content:center;z-index:100;padding:1rem}
.modal-box{background:var(--surface);border-radius:var(--radius-lg);padding:1.85rem 1.6rem;max-width:380px;width:100%;text-align:center;box-shadow:0 24px 60px rgba(11,11,11,.4)}
.modal-box .modal-icon{font-size:2.6rem;margin-bottom:.5rem;line-height:1}
.modal-box h2{font-size:1.25rem;margin:0 0 .6rem;font-weight:700}
.modal-box p{color:var(--ink-secondary);font-size:.95rem;line-height:1.5;margin:0 0 1.25rem}
.modal-box button{margin-top:0}
.modal-box .modal-secondary{margin-top:.6rem}

/* A small up/down comparison chip next to a stat (e.g. "vs yesterday").
   Text-labelled, never color-alone — dir=up uses --good, dir=down uses
   --critical, matching the status palette's reserved roles. */
.delta{display:inline-flex;align-items:center;gap:.25rem;font-size:.78rem;font-weight:600;margin-top:.35rem}
.delta[data-dir="up"]{color:#0f6b0f}
.delta[data-dir="down"]{color:#9a2f2f}
.delta[data-dir="flat"]{color:var(--ink-muted)}
.delta .arrow{font-size:.7rem;line-height:1}

/* Shared sign-in shell for every login screen (guardian, gate, admin, vendor
   console) — a colored gradient header band on the card itself instead of a
   flat centered brandline. --auth-accent/-dark default to brand blue; the
   vendor console overrides them to its own teal (see vendor/head.ejs) so it's
   never confused with a school's own admin login. */
:root{--auth-accent:var(--brand);--auth-accent-dark:var(--brand-dark)}
body.auth-page{padding:0;min-height:100vh;background:var(--page);position:relative;overflow-x:hidden}
.auth-dot{position:absolute;border-radius:50%;z-index:0}
.auth-dot-1{width:70px;height:70px;top:6%;left:8%;background:var(--brand-tint)}
.auth-dot-2{width:36px;height:36px;top:14%;right:12%;background:#bcd7f5}
.auth-dot-3{width:22px;height:22px;top:30%;left:20%;background:var(--brand-tint)}
.auth-dot-4{width:50px;height:50px;bottom:8%;right:8%;background:#bcd7f5}
.auth-wrap{position:relative;z-index:1;max-width:420px;margin:0 auto;padding:3.5rem 1.25rem 2rem;display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100vh;box-sizing:border-box}
.auth-wrap .auth-card{flex:none}
.auth-card{width:100%;background:var(--surface);border-radius:22px;overflow:hidden;box-shadow:0 16px 40px rgba(11,11,11,.12);animation:auth-rise .45s ease both}
@keyframes auth-rise{0%{opacity:0;transform:translateY(18px) scale(.98)}100%{opacity:1;transform:translateY(0) scale(1)}}
.auth-head{background:linear-gradient(135deg,var(--auth-accent),var(--auth-accent-dark));padding:2rem 1.5rem 2.4rem;text-align:center;color:#fff}
.auth-head .mark{width:56px;height:56px;border-radius:16px;background:rgba(255,255,255,.18);display:flex;align-items:center;justify-content:center;margin:0 auto .9rem;overflow:hidden}
.auth-head .mark svg{width:30px;height:30px}
.auth-head .mark img{max-width:70%;max-height:70%;object-fit:contain}
.auth-head h1{margin:0 0 .3rem;font-size:1.35rem}
.auth-head p{margin:0;font-size:.85rem;opacity:.85}
/* A school's own uploaded logo can be any color, so the colored gradient is
   reserved for OUR OWN mark (zero clash risk — our brand on our color). The
   moment a school has a real logo, the header goes neutral instead of
   forcing their branding to sit on our blue/teal. */
.auth-head.neutral{background:var(--page);color:var(--ink)}
.auth-head.neutral .mark{background:var(--surface);box-shadow:0 2px 8px rgba(11,11,11,.08);border:1px solid var(--border)}
.auth-head.neutral p{opacity:1;color:var(--ink-secondary)}
.auth-body{padding:1.6rem 1.5rem 1.75rem;margin-top:-1.4rem;background:var(--surface);border-radius:18px 18px 0 0;position:relative}
.auth-field{position:relative;margin-bottom:1.1rem}
.auth-field svg{position:absolute;left:.85rem;top:2.15rem;width:18px;height:18px;color:var(--ink-muted)}
.auth-field input{padding-left:2.5rem}
.auth-btn{width:100%;padding:.8rem;border:0;border-radius:10px;background:linear-gradient(135deg,var(--auth-accent),var(--auth-accent-dark));color:#fff;font-size:1rem;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:.4rem;box-shadow:0 10px 22px -8px rgba(11,11,11,.35);transition:transform .15s ease,box-shadow .15s ease}
.auth-btn:hover{transform:translateY(-2px);box-shadow:0 14px 28px -8px rgba(11,11,11,.4)}
.auth-btn:active{transform:translateY(0) scale(.98)}
.auth-btn svg{width:16px;height:16px;transition:transform .15s ease}
.auth-btn:hover svg{transform:translateX(3px)}
.auth-foot-link{text-align:center;margin-top:1.1rem;font-size:.8rem}
.auth-foot-link a{color:var(--ink-muted)}
.auth-foot-link a:hover{color:var(--brand)}
