/* EntryOne-Max — minimal design system */
:root {
  --bg: #0f172a;
  --panel: #111827;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 18px rgba(0,0,0,.06);
}
*,*::before,*::after { box-sizing:border-box; }
html,body { margin:0; padding:0; font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Inter,sans-serif; color:var(--text); background:#f8fafc; }
body.landing { background:linear-gradient(140deg,#0f172a,#1e3a8a); color:#fff; min-height:100vh; }
body.landing h1 { margin:0 0 .5rem; font-size:2rem; }
body.landing .card { background:rgba(255,255,255,.06); color:#fff; backdrop-filter: blur(8px); border:1px solid rgba(255,255,255,.12); }
body.landing .btn { background:#fff; color:#0f172a; }

h1,h2,h3 { margin:0 0 .75rem; }
a { color:var(--primary); text-decoration:none; }
a:hover { text-decoration:underline; }
.muted { color:var(--muted); }
.small { font-size:.875rem; }
.tiny { font-size:.75rem; }

.card { background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:1.5rem; box-shadow:var(--shadow); }
.stack { display:flex; flex-direction:column; gap:.75rem; }
.row   { display:flex; gap:.75rem; flex-wrap:wrap; }
.row > * { flex:1 1 auto; }

label { display:block; font-size:.875rem; color:var(--muted); margin-bottom:.35rem; }
input, select, textarea {
  width:100%; padding:.6rem .75rem; border-radius:8px; border:1px solid var(--border);
  font:inherit; background:#fff; color:inherit; outline:none;
}
input:focus, select:focus, textarea:focus { border-color:var(--primary); box-shadow:0 0 0 3px rgba(37,99,235,.18); }

.btn {
  display:inline-flex; align-items:center; justify-content:center;
  padding:.45rem .9rem; border-radius:8px; border:1px solid var(--border);
  background:#f8fafc; color:var(--text); cursor:pointer; font-weight:600; font-size:.875rem;
  line-height:1.25; vertical-align:middle; white-space:nowrap;
  transition:background .15s ease;
}
.btn:hover { background:#eef2f7; text-decoration:none; }
.btn.primary { background:var(--primary); color:#fff; border-color:var(--primary); }
.btn.primary:hover { background:var(--primary-dark); }
.btn.danger  { background:var(--danger); color:#fff; border-color:var(--danger); }
.btn.warn    { background:var(--warn); color:#fff; border-color:var(--warn); }
.btn.success { background:var(--success); color:#fff; border-color:var(--success); }
.btn:disabled { opacity:.6; cursor:not-allowed; }
.btn.tiny    { padding:.3rem .6rem; font-size:.75rem; border-radius:6px; }

/* Adjacent buttons get a consistent gap so action cells, modal footers, and
   any inline button groups stop running into each other. Containers that
   already use CSS `gap:` (.row, .flex-end, .stack) reset this so the gap
   doesn't double up. */
.btn + .btn { margin-left:.4rem; }
.row       > .btn + .btn,
.flex-end  > .btn + .btn,
.stack     > .btn + .btn { margin-left:0; }

table { border-collapse:collapse; width:100%; font-size:.9rem; }
th,td { padding:.5rem .75rem; text-align:left; border-bottom:1px solid var(--border); vertical-align:top; }
th { background:#f8fafc; font-weight:600; color:#334155; position:sticky; top:0; }

.badge { display:inline-block; padding:.15rem .5rem; font-size:.75rem; border-radius:99px; background:#e2e8f0; color:#334155; }
.badge.ok { background:#dcfce7; color:#166534; }
.badge.warn { background:#fef3c7; color:#92400e; }
.badge.danger { background:#fee2e2; color:#991b1b; }
.badge.admin { background:#ede9fe; color:#5b21b6; }
.badge.marshal { background:#ffe4e6; color:#9f1239; }

.nav { display:flex; align-items:center; gap:1rem; padding:1rem 1.5rem; background:#0f172a; color:#fff; }
.nav a { color:#cbd5e1; font-weight:600; }
.nav a.active, .nav a:hover { color:#fff; }
.nav .spacer { flex:1; }

.layout { display:grid; grid-template-columns:220px 1fr; min-height:100vh; }
.sidebar { background:#111827; color:#e2e8f0; padding:1.25rem 1rem; }
.sidebar h2 { color:#fff; font-size:1.1rem; }
.sidebar a { display:block; padding:.5rem .75rem; border-radius:6px; color:#cbd5e1; margin-bottom:.2rem; }
.sidebar a:hover, .sidebar a.active { background:#1f2937; color:#fff; text-decoration:none; }
.main { padding:1.5rem; overflow:auto; }

/* kiosk */
/* CSS custom properties drive the branding. Defaults match the original
   EntryOne-Max look; client.js overrides them at runtime from /me.branding. */
.kiosk {
  --brand-bg-1:    #0f172a;
  --brand-bg-2:    #1e40af;
  --brand-button:  #2563eb;
  --brand-buttext: #ffffff;
  min-height:100vh;
  background:linear-gradient(160deg, var(--brand-bg-1), var(--brand-bg-2));
  color:#fff;
}
.kiosk .big { font-size:3rem; font-weight:700; letter-spacing:-.02em; }
.kiosk .card { color:var(--text); }
.kiosk .toast { position:fixed; left:50%; top:2rem; transform:translateX(-50%); background:#16a34a; color:#fff; padding:1rem 2rem; border-radius:10px; font-size:1.2rem; font-weight:600; box-shadow:var(--shadow); z-index:100; }
.kiosk .toast.err { background:#dc2626; }

/* Branded primary buttons inside the kiosk follow the chosen accent.
   We only re-skin .btn.primary so cancel/back buttons stay neutral. */
.kiosk .btn.primary {
  background: var(--brand-button);
  border-color: var(--brand-button);
  color: var(--brand-buttext);
}
.kiosk .btn.primary:hover {
  filter: brightness(0.92);
  background: var(--brand-button);
}

/* Branding bar at the top of every kiosk screen */
.brand-bar {
  display:flex; align-items:center; gap:.75rem;
  color:#fff;
}
.brand-bar img {
  height:38px; max-width:160px; object-fit:contain;
  background:#fff; padding:3px; border-radius:6px;
}
.brand-bar .brand-name {
  font-size:1.1rem; font-weight:700; letter-spacing:.02em;
}

/* kiosk shell — full-viewport flex column so the landing always fills the screen */
.kiosk-shell {
  min-height:100vh; min-height:100dvh;
  display:flex; flex-direction:column;
  padding:1.25rem clamp(1rem, 3vw, 2.5rem);
  gap:1rem;
  box-sizing:border-box;
}
.kiosk-header {
  display:flex; align-items:center; justify-content:space-between;
  gap:1rem; flex-wrap:wrap;
}
.kiosk-foot { padding:.5rem 0; }

/* landing tiles — equal-width, fill-remaining-height */
.kiosk-tiles {
  flex:1;
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:1.25rem;
  align-items:stretch;
}
.tile {
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:1rem;
  border:none; border-radius:18px;
  padding:2rem 1.5rem;
  font: inherit; color:#fff; cursor:pointer;
  text-align:center;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.18);
  box-shadow:0 8px 30px rgba(0,0,0,.25);
  transition:transform .12s ease, background .15s ease, box-shadow .15s ease;
  min-height:280px;
}
.tile:hover { transform:translateY(-3px); background:rgba(255,255,255,.12); }
.tile:active { transform:translateY(0); }
.tile-icon  { font-size:clamp(3rem, 8vw, 5.5rem); line-height:1; }
.tile-title { font-size:clamp(1.6rem, 4vw, 2.4rem); font-weight:700; letter-spacing:-.01em; line-height:1.1; }
.tile-sub   { font-size:clamp(.9rem, 1.5vw, 1.1rem); color:#cbd5e1; max-width:24ch; line-height:1.35; }

.tile-employee   { background:linear-gradient(160deg,rgba(34,197,94,.18),rgba(22,163,74,.30)); border-color:rgba(74,222,128,.35); }
.tile-contractor { background:linear-gradient(160deg,rgba(245,158,11,.18),rgba(217,119,6,.32)); border-color:rgba(252,211,77,.35); }
.tile-visitor    { background:linear-gradient(160deg,rgba(59,130,246,.18),rgba(37,99,235,.32)); border-color:rgba(147,197,253,.35); }

/* check-in panel grid expands to fill the remaining space */
.kiosk-checkin-grid { flex:1; align-items:stretch; min-height:0; }
.kiosk-checkin-grid > .card { display:flex; flex-direction:column; min-height:0; }
.kiosk-checkin-grid #qr-reader { flex:1; min-height:240px; }
.kiosk-checkin-grid #v-list { flex:1; overflow:auto; min-height:0; }

/* visitor card — center within available space, comfortably wide */
.kiosk-visitor-card {
  align-self:center; width:100%; max-width:720px;
}

@media (max-width: 900px) {
  .kiosk-tiles { grid-template-columns:1fr; }
  .tile { min-height:160px; padding:1.2rem; }
  .kiosk-checkin-grid { grid-template-columns:1fr !important; }
}

.grid { display:grid; gap:1rem; }
.grid.k-2 { grid-template-columns:repeat(2,1fr); }
.grid.k-3 { grid-template-columns:repeat(3,1fr); }
.grid.k-4 { grid-template-columns:repeat(4,1fr); }
@media (max-width:768px) { .grid.k-2,.grid.k-3,.grid.k-4 { grid-template-columns:1fr; } .layout { grid-template-columns:1fr; } }

.hidden { display:none !important; }
.scroll-x { overflow-x:auto; }
.flex-end { display:flex; justify-content:flex-end; gap:.5rem; }
.mt-1 { margin-top:1rem; } .mt-2 { margin-top:2rem; } .mb-1 { margin-bottom:1rem; }

#qr-reader { border-radius:12px; overflow:hidden; background:#000; }
#qr-reader video { width:100%; }

/* ------------------------------------------------------------------ *
 * Kiosk feedback flash overlay
 * ------------------------------------------------------------------ *
 * Fires for ~700ms on every check-in / check-out / unrecognised scan
 * so the user gets instant, unmistakable visual feedback even when
 * the camera is at the far end of the room and the toast text is
 * unreadable. The overlay is `pointer-events:none` so it never
 * intercepts the next scan / tap.
 *
 * Coloured by --flash-color (set by client.js right before showing).
 * Plain transparent -> opaque -> transparent pulse, no spinning, no
 * animation libraries — works on the cheapest kiosk hardware.
 */
.flash-overlay {
  position: fixed; inset: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  z-index: 999;
  transition: opacity .18s ease;
}
.flash-overlay.show  { opacity: .55; }
.flash-overlay.ok    { background: #16a34a; }
.flash-overlay.bad   { background: #dc2626; }
