:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #2f6fed;
  --primary-dark: #1e4fbb;
  --border: #e2e4e9;
  --present: #1f9d55;
  --late: #d97706;
  --absent: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  flex-wrap: wrap;
  gap: 8px;
}

.topnav-brand { font-weight: 700; font-size: 1.1rem; }

.topnav-links a {
  color: var(--text);
  text-decoration: none;
  margin-left: 18px;
  font-size: 0.95rem;
}

.topnav-links a:hover { color: var(--primary); }

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.flash-messages { margin-bottom: 16px; }

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.flash-error { background: #fde8e8; color: #9b1c1c; }
.flash-success { background: #e6f9ee; color: #12734a; }
.flash-info { background: #e8f0fe; color: #1e4fbb; }

.login-body {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--card-bg);
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-card h1 { margin: 0 0 8px; font-size: 1.3rem; text-align: center; }

.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.login-card button,
.btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

.login-card button:hover,
.btn:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

th { color: var(--muted); font-weight: 600; }

.thumb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
}

.status-present { color: var(--present); font-weight: 600; }
.status-late { color: var(--late); font-weight: 600; }
.status-absent { color: var(--absent); font-weight: 600; }

.form-grid {
  display: grid;
  gap: 12px;
  max-width: 480px;
}

.form-grid label { font-weight: 600; font-size: 0.9rem; }

.form-grid input,
.form-grid select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.form-grid small {
  margin-top: -6px;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Scan page - result card sits near the top, the (invisible) RFID input
   is pinned toward the bottom of the screen via space-between. */
.scan-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 65vh;
  padding-top: 20px;
}

.result-card {
  width: 100%;
  max-width: 900px;
  min-height: 340px;
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  padding: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.result-body {
  display: flex;
  align-items: center;
  gap: 40px;
  text-align: left;
}

.result-card img.photo,
.result-card div.photo {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
  flex-shrink: 0;
}

.result-text {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-name { font-size: 2.6rem; font-weight: 700; }
.result-meta { color: var(--muted); font-size: 1.3rem; }
.result-status { font-size: 1.7rem; font-weight: 700; }

.result-card.error { border: 3px solid var(--absent); }
.result-card.already { border: 3px solid var(--late); }
.result-card.present { border: 3px solid var(--present); }
.result-card.late { border: 3px solid var(--late); }

.result-card.error .result-status { color: var(--absent); }
.result-card.present .result-status { color: var(--present); }
.result-card.late .result-status,
.result-card.already .result-status { color: var(--late); }

.event-picker {
  width: 100%;
  max-width: 400px;
  padding: 10px;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 900px;
  width: 100%;
  margin: 0 auto 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Deliberately invisible - the RFID reader "types" into this input like a
   keyboard, but staff shouldn't see a visible textbox on the kiosk screen.
   appearance:none strips Safari/iOS's native input chrome (rounded border +
   inset shadow), which outline:none alone does not remove. */
.rfid-input-hidden {
  width: 100%;
  max-width: 400px;
  height: 60px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  outline: none;
  box-shadow: none;
  font-size: 1px;
  appearance: none;
  -webkit-appearance: none;
}

.rfid-input-hidden::placeholder {
  color: transparent;
}

.rfid-input-hidden:focus,
.rfid-input-hidden:focus-visible {
  outline: none;
  border: none;
  box-shadow: none;
}

.logo-brand {
  height: 28px;
  width: 28px;
  object-fit: contain;
  border-radius: 6px;
  vertical-align: middle;
  margin-right: 8px;
}

.session-history-table td.numeric,
.session-history-table th.numeric {
  text-align: right;
}

/* Tables can be wider than a phone screen - let them scroll horizontally
   inside their own box instead of breaking the page layout. */
.table-responsive {
  overflow-x: auto;
}

.inline-form {
  display: inline;
}

/* ---------- Responsive: phones / narrow viewports ---------- */
@media (max-width: 640px) {
  .content {
    padding: 16px;
  }

  .topnav {
    padding: 12px 16px;
    flex-direction: column;
    align-items: flex-start;
  }

  .topnav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
  }

  .topnav-links a {
    margin-left: 0;
    padding: 4px 0;
  }

  .card {
    padding: 14px;
  }

  .form-grid {
    max-width: 100%;
  }

  .session-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    max-width: 100%;
  }

  .result-card {
    padding: 24px;
    min-height: 260px;
  }

  .result-body {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }

  .result-card img.photo,
  .result-card div.photo {
    width: 140px;
    height: 140px;
  }

  .result-name { font-size: 1.6rem; }
  .result-meta { font-size: 1rem; }
  .result-status { font-size: 1.2rem; }

  th, td {
    padding: 8px;
    font-size: 0.88rem;
  }

  .login-card {
    width: 90vw;
    max-width: 340px;
  }
}
