:root {
  --sltc-navy: #0b2545;
  --sltc-blue: #13315c;
  --sltc-accent: #ff9f1c;
  --granted-green: #1e8e3e;
  --denied-red: #d93025;
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --text-muted: #5f6b7a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: #1a1a1a;
}

.topbar {
  background: var(--sltc-navy);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

.topbar .logout-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.container {
  max-width: 960px;
  margin: 32px auto;
  padding: 0 16px;
}

.card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 24px;
  margin-bottom: 20px;
}

.centered-card {
  max-width: 380px;
  margin: 80px auto;
}

input[type="text"], input[type="password"], input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  font-size: 14px;
  margin-top: 6px;
  margin-bottom: 16px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

button.primary {
  background: var(--sltc-blue);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
}

button.primary:hover { background: var(--sltc-navy); }

.error-msg {
  color: var(--denied-red);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 16px;
}

.result-card {
  border-radius: 8px;
  padding: 20px;
  color: #fff;
  margin-top: 20px;
}

.result-granted { background: var(--granted-green); }
.result-denied { background: var(--denied-red); }
.result-notfound { background: #6b7280; }

.result-decision {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}

#qr-reader {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
}

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

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.badge-granted { background: var(--granted-green); }
.badge-denied { background: var(--denied-red); }
.badge-notfound { background: #6b7280; }

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  background: none;
  border: 1px solid #d0d5dd;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.tab-btn.active {
  background: var(--sltc-blue);
  color: #fff;
  border-color: var(--sltc-blue);
}

.hidden { display: none !important; }

.layout-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  max-width: 1200px;
}

@media (max-width: 900px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }
}

.input-wrapper {
  display: flex;
  gap: 10px;
}

.input-wrapper input {
  margin-bottom: 0 !important;
}

.input-wrapper button {
  width: auto !important;
  white-space: nowrap;
}

.recent-scan-item {
  padding: 10px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
}

.recent-scan-item:last-child {
  border-bottom: none;
}

.recent-scan-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

/* Modal styling for password reset */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  width: 100%;
  max-width: 400px;
}

.tab-content.hidden {
  display: none !important;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border-left: 5px solid #d0d5dd;
}

.stat-card h4 {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  margin: 8px 0 4px 0;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.granted-border { border-left-color: var(--granted-green); }
.denied-border { border-left-color: var(--denied-red); }
.notfound-border { border-left-color: #6b7280; }
.user-border { border-left-color: var(--sltc-blue); }

.filter-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.nav-links {
  display: flex;
  gap: 10px;
}

.nav-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.nav-btn.active {
  color: #fff;
  background: var(--sltc-blue);
}

.page-view.hidden {
  display: none !important;
}

.secondary-btn {
  background: transparent;
  color: var(--sltc-blue);
  border: 1px solid var(--sltc-blue);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.secondary-btn:hover {
  background: rgba(19, 49, 92, 0.05);
}

/* ===================================================
   Gate-check full-page decision flash (guard visibility)
   =================================================== */

body.flash-granted {
  background: var(--granted-green) !important;
  transition: background 0.25s ease;
}
body.flash-denied {
  background: var(--denied-red) !important;
  transition: background 0.25s ease;
}
body.flash-notfound {
  background: #6b7280 !important;
  transition: background 0.25s ease;
}

/* Big, guard-readable result text */
.result-primary {
  font-size: 34px;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 4px;
  word-break: break-word;
}

.result-secondary {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 16px;
  opacity: 0.95;
}

.result-card.result-flash {
  border: 2px solid rgba(255, 255, 255, 0.5);
}

/* --- Special Access override feature --- */
.special-alert-box {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.5);
  font-weight: 700;
  font-size: 13px;
}

.special-access-btn {
  margin-top: 14px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  background: var(--sltc-accent);
  color: #1a1a1a;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.special-access-btn:hover { opacity: 0.9; }
.special-access-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===================================================
   Manage Individual Student (live search + edit panel)
   =================================================== */

.student-search-wrapper {
  position: relative;
}

.student-search-dropdown {
  position: absolute;
  top: calc(100% - 12px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(11, 37, 69, 0.14);
  max-height: 280px;
  overflow-y: auto;
  z-index: 20;
}

.student-search-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
}

.student-search-item:last-child { border-bottom: none; }
.student-search-item:hover { background: #f4f6f9; }

.student-search-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.student-search-item-reg {
  font-weight: 700;
  font-size: 13px;
  color: var(--sltc-navy);
}

.student-search-item-name {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.student-search-empty,
.student-search-loading {
  padding: 14px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.student-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 0 14px 0;
  margin-top: 6px;
  margin-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.student-detail-reg {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 2px 0;
  color: var(--sltc-navy);
}

.student-detail-name {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

.student-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 24px;
  margin-bottom: 20px;
}

.student-detail-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.student-detail-field .value {
  font-size: 14px;
  font-weight: 600;
}

.student-update-section {
  padding-top: 18px;
  border-top: 1px dashed #e5e7eb;
}