/* ============================================================================
   Visitor tracking — interface

   Designed for where it is used rather than for a screenshot. A guard stands at
   a barrier holding a tablet in poor light; a receptionist registers somebody
   while they wait at the desk. That means large targets, type that survives
   glare, state readable across a lobby, and never a blank screen while
   something loads.

   Three rules the sheet follows throughout.

   1. The page is paper. Colour means state — approved, waiting, stopped,
      inside — and is never spent on decoration.
   2. Numbers line up. This system is full of eight-digit gate codes, badge
      numbers, seat counts and times that people read at speed, so every
      numeral is tabular.
   3. State is never colour alone. A coloured row also carries a rail and a
      word, because a colour-blind guard has the same job to do.
   ========================================================================= */

:root {
  --bg: #F1F4F8;
  --surface: #FFFFFF;
  --surface-2: #F5F7FA;
  --surface-3: #EBEFF4;
  --line: #DFE5EC;
  --line-strong: #C6D0DA;

  --ink: #131C29;
  --ink-2: #4A5568;
  --ink-3: #6B7688;

  /* Deep teal: instruments and signage, not consumer software. */
  --accent: #0E6E80;
  --accent-2: #0A5464;
  --accent-3: #083F4C;
  --accent-soft: #E3F1F4;

  --go: #0F6B45;     --go-bg: #E4F2EA;     --go-line: #A9D6BF;
  --wait: #96590A;   --wait-bg: #FDF1DC;   --wait-line: #EDCE96;
  --stop: #B3352A;   --stop-bg: #FBE8E5;   --stop-line: #EDB6AE;
  --calm: #2B5194;   --calm-bg: #E8EEF9;   --calm-line: #B4C6E6;
  --off: #667286;    --off-bg: #EDF0F4;    --off-line: #D3DAE3;

  --rail: #FFFFFF;
  --rail-2: #FFFFFF;
  --rail-ink: #4A5568;
  --rail-ink-2: #6B7688;
  --rail-line: #DFE5EC;

  /* A radius scale rather than one value everywhere: the size of a corner
     should say how large a thing is. */
  --r-chip: 999px;
  --r-control: 8px;
  --r-card: 12px;
  --r-sheet: 16px;

  /* Elevation is reserved. Most cards are a hairline; only what floats above
     the page casts a shadow. */
  --shadow: 0 1px 2px rgba(19, 28, 41, .05);
  --shadow-lift: 0 4px 16px rgba(19, 28, 41, .10);
  --shadow-modal: 0 12px 40px rgba(19, 28, 41, .18);

  --focus: 0 0 0 3px rgba(14, 110, 128, .28);
  --step: 160ms cubic-bezier(.2, .7, .3, 1);
}

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

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.014em; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-2); }

/* A reception desk is worked by keyboard far more than anyone designing it
   expects, so focus is visible everywhere. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------------------------------------------------------------- shell -- */

#app { display: flex; min-height: 100vh; }

#rail {
  width: 232px; flex-shrink: 0;
  background: var(--rail);
  border-right: 1px solid var(--rail-line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.rail-brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--rail-line);
  display: flex; align-items: baseline; gap: 9px;
}
.rail-brand .mark { font-size: 17px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.rail-brand .site { font-size: 11.5px; color: var(--ink-3); line-height: 1.35; }

#nav { flex: 1; overflow-y: auto; padding: 10px 10px 18px; }

/* Sentence case. Shouting at somebody in their own navigation is a habit
   rather than a decision. */
.rail-group {
  font-size: 11.5px; font-weight: 600; color: var(--ink-3);
  padding: 16px 10px 6px; letter-spacing: 0; text-transform: none;
}
#nav .rail-group:first-child { padding-top: 4px; }

a.nav {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; margin: 1px 0;
  border-radius: var(--r-control);
  color: var(--rail-ink); text-decoration: none;
  font-size: 14.5px; font-weight: 500;
  transition: background var(--step), color var(--step);
}
a.nav .ico { width: 18px; text-align: center; font-size: 14px; color: var(--ink-3);
  transition: color var(--step); }
a.nav:hover { background: var(--surface-2); color: var(--ink); }
a.nav:hover .ico { color: var(--ink-2); }

/* The current screen is marked by a bar, not only a tint — the same principle
   as the status rails on rows. */
a.nav.on {
  background: var(--accent-soft); color: var(--accent-3); font-weight: 650;
  box-shadow: inset 3px 0 0 var(--accent);
}
a.nav.on .ico { color: var(--accent); }

/* Sits at the foot of the rail, above the version. */
#rail > .rail-user { border-top: 1px solid var(--rail-line); border-radius: 0; margin: 0; }
.rail-user {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
  margin: 10px; border-top: 0;
  padding: 8px 10px; border-radius: var(--r-control);
  cursor: pointer; transition: background var(--step);
}
.rail-user:hover { background: var(--surface-2); }
.rail-user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; flex-shrink: 0;
}
.rail-user .who b { font-size: 13.5px; font-weight: 650; line-height: 1.2; }
.rail-user .who span { font-size: 11.5px; color: var(--ink-3); }
.rail-version { text-align: center; font-size: 11px; color: var(--ink-3); padding: 6px 0 2px; }
.rail-version > span { display: block; }
.privacy-link { display: block; margin: 3px auto 5px; color: var(--ink-3); font-size: 10.5px; }
.provider-footer { margin-top: 12px; text-align: center; color: var(--ink-3); font-size: 11.5px; }
.provider-footer a { color: inherit; }
.platform-processor {
  margin: 12px 0 18px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--r-control); background: var(--surface-2);
  color: var(--ink-2); font-size: 12.5px;
}

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 16px 26px; display: flex; align-items: baseline; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 21px; }
.topbar .sub { color: var(--ink-3); font-size: 13.5px; }

/* Content width.
 *
 * A fixed 1180px cap left a third of a 1900px monitor empty, so the interface
 * looked abandoned in one corner of the screen. Reading text still wants a
 * limit — a list of visits 1800px wide is worse, not better — so the cap
 * scales rather than disappearing, and the layouts inside use the extra room. */
#view { padding: 22px 26px 60px; max-width: 1180px; width: 100%; }

@media (min-width: 1500px) {
  #view { max-width: 1440px; padding: 26px 34px 60px; }
  /* With the room, the day board and the lists sit side by side rather than
     stacking down a tall thin column. */
  .grid.stats { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1800px) {
  #view { max-width: 1640px; }
}

/* ---------------------------------------------------------------- cards -- */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-card); overflow: hidden;
}
.card .hd {
  padding: 13px 18px; border-bottom: 1px solid var(--line);
  font-size: 15px; font-weight: 680; letter-spacing: -.01em;
  display: flex; align-items: center; gap: 9px;
}
.card .bd { padding: 16px 18px; }

/* A card carrying a warning earns a coloured edge, not a coloured field. */
.card.alert { border-color: var(--wait-line); }
.card.alert > .bd { background: var(--wait-bg); }
.card.note { border-color: var(--calm-line); }
.card.note > .bd { background: var(--calm-bg); }

/* ------------------------------------------------------------ typography -- */

.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.hint { font-size: 12.5px; color: var(--ink-3); margin: 5px 0 0; line-height: 1.5; }
.mono { font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
  font-size: .94em; letter-spacing: -.01em; }

/* ---------------------------------------------------------------- forms -- */

/* Two columns on a wide screen. A single narrow column ran a walk-in past the
   fold, so a receptionist scrolled while somebody stood waiting. */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(248px, 1fr));
  gap: 14px 18px;
  align-items: start;
}
.form-grid > div { min-width: 0; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: block;
  margin-bottom: 5px; }
.field > label { margin-bottom: 0; }

input, select, textarea {
  font: inherit; font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  /* 44px: a target a gloved finger can hit on a tablet. */
  padding: 10px 12px; min-height: 44px; width: 100%;
  transition: border-color var(--step), box-shadow var(--step), background var(--step);
}
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #9AA5B4; }
input:hover, select:hover, textarea:hover { border-color: #AEBBC8; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--focus);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-3); color: var(--ink-3); cursor: not-allowed;
}
input[aria-invalid="true"] {
  border-color: var(--stop); box-shadow: 0 0 0 3px rgba(179, 53, 42, .16);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%234A5568' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 34px; cursor: pointer;
}

label.check {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 500; color: var(--ink); cursor: pointer;
  min-height: 32px; font-size: 14px; margin-bottom: 0;
}
label.check input[type="checkbox"] {
  width: 18px; height: 18px; min-height: 0;
  accent-color: var(--accent); cursor: pointer; flex-shrink: 0;
}

.actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-top: 18px; }

/* -------------------------------------------------------------- buttons -- */

.btn {
  font: inherit; font-weight: 620; font-size: 14.5px; line-height: 1;
  color: #fff; background: var(--accent);
  border: 1px solid transparent; border-radius: var(--r-control);
  padding: 12px 18px; min-height: 44px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap;
  transition: background var(--step), box-shadow var(--step), transform 90ms ease,
              border-color var(--step), color var(--step);
}
.btn:hover { background: var(--accent-2); }
/* Pressing depresses: on a touchscreen it is the only confirmation the person
   gets that their tap registered. */
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }

.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); border-color: #AEBBC8; }
.btn.go { background: var(--go); }
.btn.go:hover { background: #0B573A; }
.btn.deny, .btn.danger { background: var(--stop); }
.btn.deny:hover, .btn.danger:hover { background: #932A21; }
.btn.sm { font-size: 13px; padding: 8px 12px; min-height: 36px; }
.btn:disabled, .btn[disabled] {
  background: var(--surface-3); color: var(--ink-3); border-color: var(--line);
  cursor: not-allowed; transform: none;
}

/* A button that is working says so, rather than looking ignored. */
.btn.busy { position: relative; color: transparent; pointer-events: none; }
.btn.busy::after {
  content: ''; position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  border-radius: 50%; animation: spin .6s linear infinite;
}
.btn.ghost.busy::after { border-color: rgba(19,28,41,.2); border-top-color: var(--ink-2); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------- rows -- */

/* The signature device. The rail is not decoration — it says what state a
   record is in, and it reads across a room. */
.row {
  position: relative;
  padding: 13px 18px 13px 21px;
  border-bottom: 1px solid var(--line);
  transition: background var(--step);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: transparent;
}
.row.s-go::before   { background: var(--go); }
.row.s-wait::before { background: var(--wait); }
.row.s-stop::before { background: var(--stop); }
.row.s-calm::before { background: var(--calm); }
.row.s-off::before  { background: var(--off-line); }
.row.s-done::before { background: var(--off-line); }

.row .nm {
  font-size: 14.5px; font-weight: 650;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  letter-spacing: -.008em;
}
.row .nm span { font-weight: 500; color: var(--ink-2); }
.row .meta { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; line-height: 1.55; }

.row-right { float: right; display: flex; align-items: center; gap: 7px; margin-left: 14px; }

.empty { padding: 30px 18px; text-align: center; color: var(--ink-3); font-size: 13.5px; }

/* ---------------------------------------------------------------- chips -- */

.chip {
  display: inline-flex; align-items: center;
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
  padding: 3px 9px; border-radius: var(--r-chip);
  border: 1px solid transparent; white-space: nowrap;
}
.chip.APPROVED, .chip.CHECKED_IN, .chip.ACTIVE, .chip.INSIDE {
  background: var(--go-bg); color: var(--go); border-color: var(--go-line);
}
.chip.PENDING_APPROVAL, .chip.PENDING {
  background: var(--wait-bg); color: var(--wait); border-color: var(--wait-line);
}
.chip.REJECTED, .chip.DENIED, .chip.OVERDUE, .chip.EXPIRED {
  background: var(--stop-bg); color: var(--stop); border-color: var(--stop-line);
}
.chip.CANCELLED, .chip.CHECKED_OUT, .chip.DRAFT, .chip.COMPLETED, .chip.USED {
  background: var(--off-bg); color: var(--off); border-color: var(--off-line);
}
.pill {
  display: inline-flex; align-items: center;
  background: var(--accent-soft); color: var(--accent-3);
  font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: var(--r-chip);
}

/* ---------------------------------------------------------------- stats -- */

.grid.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: 14px 16px 14px 19px;
  position: relative; overflow: hidden;
}
.stat::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--line-strong);
}
.stat.s-go::before   { background: var(--go); }
.stat.s-wait::before { background: var(--wait); }
.stat.s-stop::before { background: var(--stop); }
.stat .n { font-size: 27px; font-weight: 750; letter-spacing: -.03em; line-height: 1.05; }
.stat .l { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }

/* ------------------------------------------------------------- messages -- */

.msg {
  padding: 11px 14px; border-radius: var(--r-control);
  font-size: 13.5px; line-height: 1.55; border: 1px solid transparent;
}
.msg.ok   { background: var(--go-bg);   color: var(--go);   border-color: var(--go-line); }
.msg.err  { background: var(--stop-bg); color: var(--stop); border-color: var(--stop-line); }
.msg.info { background: var(--calm-bg); color: var(--calm); border-color: var(--calm-line); }

#toast {
  position: fixed; bottom: 22px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 550;
  box-shadow: var(--shadow-modal);
  opacity: 0; pointer-events: none;
  transition: opacity var(--step), transform var(--step);
  z-index: 200; max-width: min(560px, 90vw); text-align: center;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--stop); }

/* -------------------------------------------------------------- loading -- */

/* A skeleton, not a spinner and not an ellipsis. At a gate an ambiguous pause
   looks like a system that has stopped, and somebody starts tapping. */
.skel {
  background: linear-gradient(90deg, var(--surface-3) 25%, #F4F7FA 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: 6px; height: 13px;
}
.skel.wide { width: 60%; }
.skel.narrow { width: 38%; margin-top: 7px; height: 11px; }
.skel-row { padding: 15px 18px 15px 21px; border-bottom: 1px solid var(--line); }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

#loadbar {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: var(--accent); z-index: 300;
  transition: width 240ms ease, opacity 240ms ease;
}
#loadbar.on { width: 70%; }
#loadbar.done { width: 100%; opacity: 0; }

/* --------------------------------------------------------------- modals -- */

.modal-back {
  position: fixed; inset: 0;
  background: rgba(19, 28, 41, .5);
  display: grid; place-items: center; padding: 20px; z-index: 150;
  animation: fade var(--step) both;
}
.modal {
  background: var(--surface); border-radius: var(--r-sheet);
  box-shadow: var(--shadow-modal);
  width: min(560px, 100%); max-height: 90vh; overflow-y: auto;
  animation: rise 200ms cubic-bezier(.2,.7,.3,1) both;
}
.modal .hd { padding: 16px 20px; border-bottom: 1px solid var(--line);
  font-size: 16px; font-weight: 700; }
.modal .bd { padding: 18px 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.99); } }

/* ------------------------------------------------------------ key/value -- */

.kv-list > div {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.kv-list > div:last-child { border-bottom: 0; }
.kv-list span { color: var(--ink-3); }
.kv-list b { font-weight: 650; text-align: right; }

/* ---------------------------------------------------------------- kiosk -- */

/* A checkbox with its sentence. Written by two screens and styled by neither,
   so the global full-width input rule stretched the box across the card. */
.consent { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; line-height: 1.45; }
.consent > input[type="checkbox"] { width: 20px; height: 20px; flex: 0 0 20px; margin: 2px 0 0; }

/* Site capacity controls, one row per site. */
.cap-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; margin-top: 8px; }
.cap-row > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.cap-row input[type="number"] { min-height: 36px; }
.cap-check { flex-direction: row !important; align-items: center; gap: 7px !important; min-height: 36px; }
.cap-check input { width: 18px; height: 18px; }

/* Visitor type requirements: a row of small controls under each type, which
   wrap onto their own lines on a phone rather than squeezing to nothing. */
.vt-rules { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; margin-top: 8px; }
.vt-rules > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.vt-rules select, .vt-rules input[type="number"] { min-height: 36px; }
.vt-check { display: flex !important; flex-direction: row !important; align-items: center; gap: 7px !important; min-height: 36px; }
.vt-check input { width: 18px; height: 18px; }

/* ---------- contractor attendance ----------
   A month read across a row, the way a muster roll is read on paper: one line
   per worker, one column per day. State is a letter as well as a colour, so the
   grid survives a greyscale printout and a colour-blind supervisor. */
.att-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 12px 16px 0; }
.att-bar > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.att-bar select, .att-bar input { min-width: 180px; max-width: 100%; }
.att-actions { flex-direction: row !important; gap: 8px !important; margin-left: auto; }
.att-rules { padding: 8px 16px 4px; margin: 0; }
.att-wrap { overflow-x: auto; margin: 0 16px 4px; border: 1px solid var(--line); border-radius: var(--r-control); }
.att-sum, .att { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 13px; }
.att-sum th, .att-sum td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.att-sum th { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3);
  background: var(--surface-2); font-weight: 600; }
.att-sum tr:last-child td { border-bottom: 0; }
.att-warn { color: var(--stop); }
.att th, .att td { border-bottom: 1px solid var(--line); }
.att tbody tr:last-child th, .att tbody tr:last-child td { border-bottom: 0; }
.att thead th { background: var(--surface-2); font-weight: 600; color: var(--ink-2); }
.att-name { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left;
  padding: 7px 12px; min-width: 190px; max-width: 240px; font-weight: 600; border-right: 1px solid var(--line); }
thead .att-name { background: var(--surface-2); }
.att-name span { display: block; font-weight: 400; font-size: 11px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-day { padding: 5px 0; min-width: 28px; font-size: 12px; line-height: 1.15; text-align: center; }
.att-day span { font-size: 10px; color: var(--ink-3); font-weight: 400; }
.att-dayoff { color: var(--ink-3); }
.att-today { box-shadow: inset 0 -2px 0 var(--accent); color: var(--accent); }
.att-tot { padding: 5px 10px; text-align: right; white-space: nowrap; border-left: 1px solid var(--line); }
.att-c { position: relative; text-align: center; font-weight: 700; font-size: 12px; min-width: 28px; height: 30px;
  padding: 0; font-style: normal; }
.att-p { color: var(--go); background: var(--go-bg); }
.att-h { color: var(--wait); background: var(--wait-bg); }
.att-a { color: var(--stop); background: var(--stop-bg); }
.att-o { color: var(--off); background: var(--off-bg); font-weight: 400; }
.att-n { color: var(--ink-3); }
.att-x { background: var(--surface); }
/* Late: a corner, so the letter still says what the day was. */
.att-late::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid;
  border-width: 0 7px 7px 0; border-color: transparent var(--wait) transparent transparent; }
.att-rev { color: var(--stop); background: var(--stop-bg); box-shadow: inset 0 0 0 1.5px var(--stop); }
.att-live { box-shadow: inset 0 0 0 1.5px var(--go); }
.att-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 16px 14px; }
.att-legend span { display: inline-flex; align-items: center; gap: 6px; }
.att-legend .att-c { display: inline-grid; place-items: center; width: 22px; height: 20px; min-width: 0;
  border-radius: 4px; font-size: 11px; }
.att-week { display: flex; flex-wrap: wrap; gap: 8px; }
.att-wd { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: var(--r-control); font-weight: 500; cursor: pointer; }
.att-wd input { margin: 0; }
@media print {
  .att-wrap { overflow: visible; border: 0; }
  .att-name { position: static; }
}

/* A tablet on a stand, used by a stranger who has never seen it before: every
   target larger, every instruction shorter. */
.kcard {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sheet); padding: 28px; box-shadow: var(--shadow-lift);
}
.kbtn {
  font: inherit; font-size: 19px; font-weight: 650;
  padding: 20px 26px; min-height: 68px; border-radius: 12px;
  border: 1px solid transparent; background: var(--accent); color: #fff;
  cursor: pointer; transition: background var(--step), transform 90ms ease;
}
.kbtn:hover { background: var(--accent-2); }
.kbtn:active { transform: translateY(1px); }
.kbtn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.kmsg { font-size: 17px; line-height: 1.55; }

/* The dimming layer behind the slide-over menu.
 *
 * Only `#scrim.show` was ever defined, so the element relied on having no
 * height to stay out of the way — which is true until anything gives it one,
 * and then an invisible sheet covers the page and swallows every tap. Stated
 * explicitly instead. */
#scrim { display: none; }

/* ---------------------------------------------------------- the day board --
 *
 * These rules were lost when the stylesheet was rewritten in 2.22.0. The markup
 * kept emitting them, so the timeline degraded into a bare column of hour
 * numbers and the legend into a run-on line of words — which is what it looked
 * like on a real desktop, and what a stylesheet rewrite does when it is written
 * against remembered markup rather than the markup that exists.
 */

.dayboard { padding: 16px 18px 14px; }

/* A day, laid out as a day.
 *
 * This was a thin bar per visit on a shared strip, which told you a visit
 * existed somewhere near an hour and nothing else — two visits at the same time
 * overlapped into one smear, and the hour a bar sat under was a guess.
 *
 * Now each visit is a block on a lane, with its name and time inside it where
 * there is room, and hour columns you can read against. It is a calendar,
 * because "who is here between two and three" is a calendar question.
 */
.scale {
  position: relative;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

/* An hour column. Ruled, so a block can be read against the time rather than
   estimated from its left edge. */
.scale .hour {
  position: absolute; top: 0; bottom: 0;
  border-left: 1px solid var(--line);
  font-size: 11px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  padding-left: 6px;
  pointer-events: none;
}
.scale .hour:first-child { border-left: 0; }
.scale .hour span {
  position: relative; top: 5px;
  background: var(--surface); padding-right: 4px;
}
/* The working hours a building actually runs, tinted so early and late read as
   outside the day rather than as empty. */
.scale .hour.off { background: var(--surface-2); }

/* One visit. Tall enough to carry a name, which is the thing somebody is
   looking for when they glance at this. */
.scale .block {
  position: absolute; height: 26px; border-radius: 6px;
  min-width: 10px; padding: 0 7px;
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden;
  background: var(--off); border: 1px solid rgba(255,255,255,.25);
  transition: filter 140ms ease;
  cursor: default;
}
.scale .block:hover { filter: brightness(1.08); z-index: 3; }
.scale .block .bt {
  font-weight: 500; opacity: .82;
  font-variant-numeric: tabular-nums;
}
.scale .block.s-go   { background: var(--go); }
.scale .block.s-wait { background: var(--wait); }
.scale .block.s-stop { background: var(--stop); }
.scale .block.s-calm { background: var(--calm); }
.scale .block.s-off, .scale .block.s-done {
  background: var(--surface-2); color: var(--ink-2);
  border-color: var(--line-strong);
}

/* Now. The first thing anybody looks for on a chart of today. */
.scale .now {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--stop); z-index: 4;
}
.scale .now::after {
  /* At the foot, not the head: at the top it covered the hour label it stands
     next to, so the one time you most want to read was the one hidden. */
  content: attr(data-t);
  position: absolute; bottom: 3px; left: 3px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  color: #fff; background: var(--stop);
  padding: 1px 5px; border-radius: 3px; white-space: nowrap;
}

.legend {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  margin-top: 12px; font-size: 12.5px; color: var(--ink-2);
}
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* On a phone a thirteen-hour day cannot be read across. It scrolls, with the
   hours keeping a usable width rather than being squeezed to nothing. */
@media (max-width: 760px) {
  .dayboard { overflow-x: auto; padding-bottom: 8px; }
  .scale { min-width: 640px; }
}

/* ------------------------------------------------------- other lost rules -- */

/* Approval steps shown on one line, as a chain rather than a list. */
.steps-inline {
  display: flex; flex-wrap: wrap; gap: 6px 10px;
  font-size: 12.5px; color: var(--ink-3); margin-top: 4px;
}
.steps-inline b { color: var(--ink-2); font-weight: 650; }

/* A watchlist note. Deliberately loud: it is the one row a guard must not skim. */
.wl {
  background: var(--stop-bg); border: 1px solid var(--stop-line);
  color: var(--stop); border-radius: var(--r-control);
  padding: 9px 12px; font-size: 13px; margin-top: 8px;
}

/* Two columns where the content genuinely pairs, collapsing on a narrow screen. */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .two { grid-template-columns: 1fr; } }

/* The scrolling region of the navigation rail. */
.rail-scroll { flex: 1; overflow-y: auto; padding: 10px 10px 18px; }

/* ------------------------------------------------- the photograph guide --
 *
 * A badge photograph is compared to a person standing at a gate. One taken from
 * the chin up, or of somebody's shoulder, cannot be — and the only moment
 * anybody can fix that is before the shutter. The oval says where the face
 * goes.
 */
.camstage {
  position: relative; width: 100%; max-width: 320px;
  border-radius: 8px; overflow: hidden; background: #000;
}
.camstage video { width: 100%; display: block; }

.camguide { position: absolute; inset: 0; pointer-events: none; }
.camoval {
  position: absolute; left: 19%; top: 11%; width: 62%; height: 78%;
  border: 3px dashed rgba(255, 255, 255, .75);
  border-radius: 50% / 42%;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
/* A face, but not yet where it needs to be. */
.camguide.near .camoval { border-color: #F2C14E; border-style: solid; }
/* Ready. Solid and green, so it reads at a glance from arm's length. */
.camguide.good .camoval {
  border-color: #3DD68C; border-style: solid;
  box-shadow: 0 0 0 9999px rgba(15, 107, 69, .18);
}

.camhint {
  position: absolute; left: 0; right: 0; bottom: 8px;
  text-align: center; font-size: 12.5px; font-weight: 600; color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  pointer-events: none;
}

/* --------------------------------------------------------------- narrow -- */

/* On a phone the rail slides over, rather than becoming a strip across the top.
 *
 * Both were defined at once — a strip at 900px and a slide-over at 860px — so
 * on a real phone the rail appeared as a cut-off bar sitting over dimmed
 * content, with no way to dismiss it. One behaviour now, and it is the one the
 * markup and the toggle button were built for. */
@media (max-width: 900px) {
  /* A small button is a mouse affordance. On a phone it is a mis-tap.
   *
   * .btn.sm is 36px, which is fine at a desk and wrong in a hand — and the two
   * worst offenders were Approve and Reject on the approvals screen, sitting
   * side by side as the most consequential taps in the product and the smallest
   * targets in it. Everything a finger can reach is at least 44px here, with
   * real space between adjacent actions. */
  .btn.sm { min-height: 44px; padding: 10px 14px; font-size: 14px; }

  /* Actions below the record, never above it.
   *
   * .row-right is floated, which puts it first in the visual order on a narrow
   * screen — so Approve and Reject appeared above the visitor's name, and the
   * decision was reachable before the thing being decided could be read. A
   * flex column with an explicit order puts them back underneath. */
  .row { display: flex; flex-direction: column; }
  .row > .nm { order: 1; }
  .row > .meta { order: 2; }
  .row > .row-right {
    order: 3; float: none; margin: 12px 0 0;
    display: flex; gap: 10px; flex-wrap: wrap;
  }
  .row > .row-right .btn { flex: 1 1 auto; min-width: 104px; }
}

/* The rail becomes a slide-over below 900px.
 *
 * This query used to be nested inside the one above — a mistake introduced
 * while adding touch-target rules. Nested media queries are valid, so nothing
 * failed loudly: instead every rule after this point, including the badge
 * styles and the desktop menu-button rule, silently applied only on narrow
 * screens. On a desktop the menu button appeared and the day board lost its
 * chart. */
@media (max-width: 900px) {
  #rail {
    position: fixed; z-index: 50; left: 0; top: 0;
    width: 268px; height: 100vh;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 8px 0 32px rgba(19, 28, 41, .16);
  }
  #rail.open { transform: none; }
  .topbar { padding: 14px 16px 14px 62px; }   /* room for the menu button */
  #view { padding: 16px 16px 48px; }
  .form-grid { grid-template-columns: 1fr; }
  .row-right { float: none; margin: 0 0 8px; }
}

.badge-card {
  width: 268px; border-radius: 12px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lift);
}
.badge-card .top {
  background: var(--ink); color: #fff; font-size: 10.5px; font-weight: 800;
  letter-spacing: .22em; padding: 10px 15px;
  display: flex; justify-content: space-between; align-items: center;
}
.badge-card .hole { width: 10px; height: 10px; border-radius: 50%; border: 2px solid rgba(255,255,255,.55); }
.badge-card .body { padding: 15px; }
.badge-card .vn { font-size: 17px; font-weight: 750; line-height: 1.2; letter-spacing: -0.02em; }
.badge-card .vc { font-size: 12.5px; color: var(--ink-2); }
.badge-card .kv { font-size: 11.5px; color: var(--ink-2); margin-top: 10px; line-height: 1.75; }
.badge-card .kv b { color: var(--ink); }
.badge-card .qr { margin-top: 12px; text-align: center; }
.badge-card .qr img { image-rendering: pixelated; width: 136px; height: 136px; }
.badge-card .ft {
  border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.badge-card .stamp {
  font-size: 9px; font-weight: 800; border: 1.5px solid var(--go); color: var(--go);
  padding: 2px 7px; border-radius: 4px; transform: rotate(-3deg);
}

/* ---------------- misc ---------------- */
.checks { font-size: 13.5px; line-height: 1.95; }
.checks .ok::before { content: "✓"; color: var(--go); font-weight: 800; margin-right: 7px; }
.checks .bad::before { content: "✕"; color: var(--stop); font-weight: 800; margin-right: 7px; }
/* Nearly full is neither a pass nor a refusal: the guard may still let this
   person in, and should know the next one may not get in. */
.checks .warn::before { content: "!"; color: var(--wait); font-weight: 800; margin-right: 7px; }
.checks .warn { color: var(--wait); }
.empty { padding: 34px 18px; text-align: center; color: var(--ink-3); font-size: 13px; }
.empty b { display: block; color: var(--ink-2); font-size: 14px; margin-bottom: 4px; }
.note-line { padding: 11px 18px; font-size: 11.5px; color: var(--ink-3); background: var(--surface-2); }
.bar-track { height: 5px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--calm); border-radius: 3px; }
.timeline { font-size: 12.5px; line-height: 1.9; }
.timeline .t { color: var(--ink-3); font-family: ui-monospace, monospace; font-size: 11px; margin-right: 9px; }
.msg { border-radius: var(--radius-sm); padding: 13px 15px; font-size: 13.5px; line-height: 1.6; }
.msg.ok { background: var(--go-bg); color: var(--go); }
.msg.err { background: var(--stop-bg); color: var(--stop); }
.msg.info { background: var(--calm-bg); color: var(--calm); }

/* The toast is styled once, on #toast above. A second .toast rule set survived
   the v2.22.0 redesign and competed with it — which is how a message could be
   written to an element that never became visible. */

/* ---------------- sign in ---------------- */
.signin {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  /* A faint wash rather than a dark slab — the form should feel like paper. */
  background:
    radial-gradient(900px 420px at 50% -5%, var(--accent-soft) 0%, rgba(230,243,246,0) 70%),
    var(--bg);
}
.signin-box { width: 100%; max-width: 380px; }

/* The button matches the fields above it.
 *
 * It sat inside a flex .actions row and came out nine pixels narrower than the
 * inputs — not enough to name, enough to make the card look slightly out of
 * true. Stated directly instead. */
.signin-go { width: 100%; margin-top: 18px; }

/* A quiet way out for somebody who has forgotten their password, rather than a
   second bordered button competing with Sign in. */
.linkish {
  background: none; border: 0; padding: 8px 0; margin-top: 4px;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--accent);
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
  min-height: 40px;
}
.linkish:hover { color: var(--accent-2); }
.linkish:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.signin-brand { color: var(--ink); font-size: 27px; font-weight: 800; letter-spacing: -0.035em; display: flex; align-items: center; gap: 10px; }
.signin-sub { color: var(--ink-2); font-size: 13px; margin: 7px 0 22px; }

/* ---------------- responsive ---------------- */
@media (max-width: 860px) {
  #rail { position: fixed; z-index: 50; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; }
  #rail.open { transform: none; }
  #railToggle { display: block; }
  #scrim.show { display: block; position: fixed; inset: 0; background: rgba(19,30,50,.45); z-index: 45; }
  .topbar { padding-left: 60px; }
  #view { padding: 18px 14px 36px; }
}
@media (max-width: 640px) {
  /* The overlap fix: actions drop below the text instead of floating over it. */
  .row-right { float: none; margin: 10px 0 0; flex-wrap: wrap; }
  .stat .n { font-size: 26px; }
  .topbar h1 { font-size: 15.5px; }
  .topbar .sub { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------------- print: badge only ---------------- */
@media print {
  @page { size: auto; margin: 8mm; }
  body { background: #fff; }
  #rail, .topbar, #toast, #railToggle, .no-print, .btn, .actions { display: none !important; }
  #main, #view { padding: 0; max-width: none; }
  /* Hide anything off the path from #view down to the badge. Marking only the
     direct children of #view was not enough: the badge sits inside a grid,
     inside a column, so the grid was hidden and the page came out blank. */
  body.printing-badge #view > *:not(.print-path):not(.print-target) { display: none !important; }
  body.printing-badge .print-path > *:not(.print-path):not(.print-target) { display: none !important; }
  body.printing-badge .print-path { display: block !important; padding: 0 !important;
    margin: 0 !important; border: none !important; box-shadow: none !important;
    background: none !important; grid-template-columns: none !important; }
  /* The badge itself and everything inside it must survive the rule above. */
  body.printing-badge .print-target, body.printing-badge .print-target * { display: revert; }
  body.printing-badge .print-target .actions { display: none !important; }
  /* The wrapper is a card on screen; on paper it is just a container. The badge
     draws its own border, so the wrapper must not draw a second one round it. */
  .print-target, .print-target .card, .print-target .hd {
    border: none !important; box-shadow: none !important; background: none !important;
    padding: 0 !important; margin: 0 !important; }
  .print-target .hd { display: none !important; }
  .badge-card { box-shadow: none !important; border: 2px solid #000 !important; width: 85mm; page-break-inside: avoid; }
  .badge-card .top, .badge-card .stamp { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Browsers drop background images when printing to save ink, and some drop
     images inside hidden ancestors entirely. The visitor's face is the point of
     the badge, so it is forced through. */
  .badge-card img { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important;
    display: inline-block !important; }
}

/* ============================================================
   Faces, and the day board
   Reception recognises people, not visit codes. Every list that a
   human scans shows the face first; the code is for the record.
   ============================================================ */

/* ---- person cell ---- */
.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.face {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover; background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; color: #fff; letter-spacing: .01em;
}
.face.sm { width: 30px; height: 30px; font-size: 11px; }
/* A photograph in that slot rather than initials. object-fit so a portrait
   taken on a phone is cropped to the circle instead of squashed into it. */
img.face { object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); }

/* A face with a name under it. Twelve unlabelled circles told a guard nothing
   about who was in the building. */
.onsite-person { display: inline-flex; flex-direction: column; align-items: center;
  gap: 4px; width: 56px; }
.onsite-name { font-size: 11px; color: var(--ink-2); max-width: 56px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.face.lg { width: 60px; height: 60px; font-size: 19px; }
/* Initial tints: six muted hues, picked by name, so a repeat visitor keeps
   the same colour and becomes recognisable even without a photo. */
.face.t0 { background: #3E6E8E; } .face.t1 { background: #6A5A93; }
.face.t2 { background: #2F7A64; } .face.t3 { background: #9A5F3C; }
.face.t4 { background: #7A5470; } .face.t5 { background: #45657F; }
.person .who { min-width: 0; }

/* ---- day board ----
   The working day as a single bar: where we are now, when people arrive,
   who is still inside. Answers "how busy is the rest of my day" at a glance. */
.dayboard { padding: 18px; }
.dayboard .scale {
  position: relative; height: 62px;
  border-radius: 8px; background: var(--surface-2);
  border: 1px solid var(--line); overflow: hidden;
}
.dayboard .hour {
  position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line);
}
.dayboard .hour span {
  position: absolute; top: 4px; left: 5px; font-size: 9.5px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.dayboard .now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--stop); z-index: 3; }
.dayboard .now::after {
  content: "NOW"; position: absolute; top: -1px; left: 4px;
  font-size: 9px; font-weight: 800; color: #fff; background: var(--stop);
  padding: 1px 4px; border-radius: 3px; letter-spacing: .06em;
}
.dayboard .block {
  position: absolute; height: 15px; border-radius: 8px; z-index: 2;
  border: 1px solid rgba(255, 255, 255, .5);
}
.dayboard .block.s-go { background: var(--go); }
.dayboard .block.s-calm { background: var(--calm); }
.dayboard .block.s-wait { background: var(--wait); }
.dayboard .block.s-off { background: var(--line-strong); }
.dayboard .block.s-stop { background: var(--stop); }
.dayboard .legend {
  display: flex; gap: 14px; flex-wrap: wrap; margin-top: 11px;
  font-size: 11.5px; color: var(--ink-2);
}
.dayboard .legend i {
  width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px;
  vertical-align: -1px;
}

/* ---- occupancy meter ---- */
.meter { display: flex; height: 9px; border-radius: 5px; overflow: hidden; background: var(--line); }
.meter i { display: block; height: 100%; }
.meter-key { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.meter-key b { color: var(--ink); font-variant-numeric: tabular-nums; }
.meter-key i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

/* ---- refinements ---- */
.card .hd .pill {
  margin-left: auto; font-size: 11px; font-weight: 700; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 20px; padding: 2px 10px;
}
.row.click:hover .nm { color: var(--accent-2); }
.stat { transition: box-shadow .15s ease, transform .15s ease; }
.stat:hover { box-shadow: var(--shadow-lift); }
.split { display: flex; align-items: flex-start; gap: 14px; }
.split .grow { flex: 1; min-width: 0; }
.kv-list { font-size: 13px; line-height: 1.9; color: var(--ink-2); }
.kv-list b { color: var(--ink); font-weight: 600; }
.section-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 9px;
}

/* ============================================================
   Spacing fallbacks
   Flex `gap` is unsupported in older engines (and in the badge
   printer's browser). Margins give the same result everywhere;
   `gap` simply refines it where supported.
   ============================================================ */
.dayboard .legend { gap: 0; }
.dayboard .legend > span { margin-right: 18px; }
.meter-key { gap: 0; }
.meter-key > span { margin-right: 20px; }
.person { gap: 0; }
.person > .face { margin-right: 11px; }
.actions { gap: 0; }
.actions > * { margin-right: 9px; margin-bottom: 4px; }
.row-right { gap: 0; }
.row-right > * { margin-left: 6px; }
.tabs { gap: 0; }
.tabs > a { margin-right: 6px; margin-bottom: 6px; }
.split { gap: 0; }
.split > *:first-child { margin-right: 14px; }
.check { gap: 0; }
.check > input { margin-right: 8px; }
.card .hd { gap: 0; }
.card .hd > * { margin-left: 8px; }
.card .hd > *:first-child { margin-left: 0; }
/* A title is a text node, so the grey note after it is the first *element*
   and lost its spacing above: "Roll callsemergency and drills". */
.card .hd > .muted.small { margin-left: 8px; }
#rail a.nav { gap: 0; }
#rail a.nav .ico { margin-right: 10px; }
.rail-user { gap: 0; }
.rail-user .avatar { margin-right: 10px; }
.btn { gap: 0; }

/* ============================================================
   Right-to-left (Arabic, Urdu)
   The rail moves to the right, status edges flip, and floats mirror.
   ============================================================ */
html.rtl body { direction: rtl; }
html.rtl #app { flex-direction: row-reverse; }
html.rtl .row::before, html.rtl .stat::before { left: auto; right: 0; }
html.rtl .row-right { float: left; margin-left: 0; margin-right: 14px; }
html.rtl .row-right > * { margin-left: 0; margin-right: 6px; }
html.rtl .person > .face { margin-right: 0; margin-left: 11px; }
html.rtl .rail-user .avatar { margin-right: 0; margin-left: 10px; }
html.rtl #rail a.nav .ico { margin-right: 0; margin-left: 10px; }
html.rtl #rail a.nav .badge, html.rtl .card .hd .count,
html.rtl .card .hd .pill, html.rtl .topbar .spacer { margin-left: 0; margin-right: auto; }
html.rtl .actions > * { margin-right: 0; margin-left: 9px; }
html.rtl .dayboard .legend > span, html.rtl .meter-key > span { margin-right: 0; margin-left: 18px; }
html.rtl .topbar .sub { margin-left: 0; margin-right: 12px; }
html.rtl select { background-position: left 12px center; padding-right: 12px; padding-left: 34px; }
/* Codes, numbers and registrations stay left-to-right inside RTL text. */
html.rtl .mono, html.rtl .tnum, html.rtl .stat .n { direction: ltr; unicode-bidi: embed; }


/* Build version, small and out of the way — but present, so a support call
   starts with "which version are you on" and gets an answer. */
.rail-version {
  padding: 8px 14px 12px; font-size: 10.5px; color: var(--ink-3);
  border-top: 1px solid var(--rail-line); text-align: center;
  font-variant-numeric: tabular-nums;
}


/* Modal — used for anything shown once that must not be missed, such as
   recovery codes. Deliberately blocking: the codes cannot be recovered later,
   so dismissing it by accident should not be easy. */
.modal-back {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(20, 33, 61, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 18px 48px rgba(20, 33, 61, .22);
  width: 100%; max-width: 460px; max-height: 90vh; overflow: auto;
}
.modal > .hd {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 15px;
}
.modal > .bd { padding: 18px; }
@media print {
  .modal-back { position: static; background: none; padding: 0; }
  .modal { box-shadow: none; border: none; max-width: none; }
}

/* The signed-in indicator: a small lamp, because a guard glancing at a shared
   terminal wants to know at once whose session it is. */
.rail-brand .lamp {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--go); flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--go-bg);
}
.rail-brand { flex-wrap: wrap; }
.rail-brand .mark { flex-shrink: 0; }
.rail-brand .site { width: 100%; }
.rail-user .who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.rail-user .who b { font-size: 13.5px; font-weight: 650; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-user .who span { font-size: 11.5px; color: var(--ink-3); }
.rail-user .chev { color: var(--ink-3); font-size: 16px; }
.rail-user:hover { text-decoration: none; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* A quiet divider inside a long form, so related fields read as one group.
   The walk-in form has three: who is visiting, the visit, and the photograph. */
.fieldset {
  border: 0; padding: 16px 0 0; margin: 18px 0 0;
  border-top: 1px solid var(--line);
}
.fieldset > .lg {
  display: block; font-size: 12.5px; font-weight: 700;
  color: var(--ink-2); margin-bottom: 11px;
}

/* A plain vertical stack, for screens that are one thing after another rather
   than a grid of panels. */
.stack { display: flex; flex-direction: column; gap: 14px; }

/* The menu button belongs to the narrow layout only. */
#railToggle { display: none; }
@media (max-width: 900px) {
  /* Fixed, so it stays reachable as the page scrolls — a menu that scrolls
     away on a phone is a menu somebody has to hunt for. */
  #railToggle {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; top: 10px; left: 12px; z-index: 55;
    width: 42px; height: 42px; border-radius: var(--r-control);
    background: var(--surface); border: 1px solid var(--line-strong);
    box-shadow: var(--shadow); cursor: pointer; font-size: 18px; color: var(--ink);
  }
  /* Tapping anywhere off the panel closes it. Without this the only way out is
     the button, which is behind the panel that is covering it. */
  #scrim.show {
    display: block; position: fixed; inset: 0;
    background: rgba(19, 28, 41, .45); z-index: 45;
  }
}

/* A button inside a stacked field would otherwise stretch the full width,
   which makes a small action look like the main one. */
.field > .btn, .field > button.btn { align-self: flex-start; }
.field > div > .btn { flex-shrink: 0; }

/* ------------------------------------------------- signed agreement record -- */
/* The exact text a visitor signed, set as a document rather than a form, and
   printed without the console around it. */
.signed-record { max-width: 760px; }
.signed-record .sr-body { white-space: pre-wrap; line-height: 1.6; font-size: 14px; margin-top: 14px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2, #fafbfc); }
.signed-record .sr-sig { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line); }
.signed-record .sr-sig img { max-width: 320px; height: auto; display: block; }
@media print {
  .signed-record { border: none !important; box-shadow: none !important; max-width: none; }
  .signed-record .sr-body { background: none; }
}

/* ------------------------------------------------------- bulk selection -- */
.bulk-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--surface-2, #f7f9fa); }
.bulk-bar select { width: auto; min-width: 150px; }
.bulk-bar input:not([type=checkbox]) { flex: 1; min-width: 180px; width: auto; }
.bulk-bar .vt-check { margin: 0; display: inline-flex !important; font-weight: 500; }
/* A tick-box beside each person, not on a line of its own: the row makes room
   on the left and the box sits in it, centred, whatever the row holds. */
.row:has(> .row-pick) { padding-left: 52px; }
.row-pick { position: absolute; left: 20px; top: 50%; transform: translateY(-50%);
  width: 18px !important; height: 18px; margin: 0; accent-color: var(--brand, #0f766e); cursor: pointer; }

/* --------------------------------------------------------------- events -- */
.ev-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 12px; }
.ev-stat b { font-size: 24px; font-weight: 750; letter-spacing: -.02em; display: block; line-height: 1.1; }
.ev-stat span { font-size: 12px; color: var(--ink-3); }
.tbl { width: 100%; border-collapse: collapse; margin-top: 6px; }
.tbl th, .tbl td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-weight: 600; color: var(--ink-3); font-size: 12px; }

/* ------------------------------------------------------ safety induction -- */
.tbl-wrap { overflow-x: auto; padding: 0 16px 12px; }
.ind-q { border: 1px solid var(--line); border-radius: var(--r-control, 10px); padding: 12px; margin: 0 0 10px; }
.ind-qh { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.ind-opt { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.ind-opt input:not([type=radio]) { flex: 1; min-width: 0; width: auto; }
.ind-right { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-3);
  white-space: nowrap; margin: 0; cursor: pointer; }
.ind-right input { width: 16px !important; height: 16px; margin: 0; accent-color: var(--brand, #0f766e); }
.ind-right:has(input:checked) { color: var(--brand, #0f766e); font-weight: 700; }
.ind-video { position: relative; padding-top: 56.25%; margin-top: 10px; border-radius: 10px; overflow: hidden; background: #0B1220; }
.ind-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ind-who { display: flex; flex-wrap: wrap; gap: 2px 22px; }
.ind-who .vt-check { margin: 0 0 4px; }

/* -------------------------------------------------------- door readers -- */
table.kv { border-collapse: collapse; width: 100%; }
table.kv td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.kv td:first-child { color: var(--ink-2); width: 46%; padding-right: 10px; }
table.kv tr:last-child td { border-bottom: 0; }
