:root {
  --bg: #0a0e13;
  --panel: #0e1419;
  --panel-hover: #12181f;
  --muted: #8b96a5;
  --text: #e3eaf2;
  --text-dim: #b8c4d4;
  --brand: #c41e1e;
  --brand-hover: #d93636;
  --brand-glow: rgba(196, 30, 30, 0.15);
  --ok: #10b981;
  --ok-glow: rgba(16, 185, 129, 0.15);
  --warn: #f59e0b;
  --warn-glow: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.15);
  --stroke: #1a2332;
  --stroke-light: #243142;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #0a0e13 0%, #060a0e 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: #60a5fa;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #93c5fd;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.9em;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(10, 14, 19, 0.9);
  backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--stroke);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand) 0%, #991818 100%);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px var(--brand-glow), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.title {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.15em;
  color: var(--text);
}

.nav {
  display: flex;
  gap: 12px;
}

.nav a {
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.nav a:hover {
  background: var(--panel-hover);
  border-color: var(--stroke-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.nav a.cta {
  background: linear-gradient(135deg, var(--brand) 0%, #991818 100%);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.nav a.cta:hover {
  background: linear-gradient(135deg, var(--brand-hover) 0%, #b82020 100%);
  box-shadow: 0 4px 16px var(--brand-glow);
}

.container {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 20px;
}

/* Welcome Section */
.welcome {
  margin-bottom: 48px;
  padding: 32px;
  background: linear-gradient(135deg, rgba(196, 30, 30, 0.08) 0%, rgba(196, 30, 30, 0.02) 100%);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
}

.welcome h1 {
  margin: 0 0 12px 0;
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
}

.welcome p {
  margin: 0 0 20px 0;
  color: var(--text-dim);
  font-size: 16px;
}

.quick .btn {
  display: inline-block;
}

/* Cards Grid */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 24px;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.card:hover {
  border-color: var(--stroke-light);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card h3 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.card p {
  margin: 8px 0;
  color: var(--text-dim);
  line-height: 1.5;
}

.card .muted {
  font-size: 14px;
}

.pill {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(96, 165, 250, 0.2);
  transition: all 0.2s ease;
}

.pill:hover {
  background: rgba(96, 165, 250, 0.25);
  border-color: rgba(96, 165, 250, 0.4);
  transform: translateY(-1px);
}

.row {
  display: flex;
  align-items: center;
}

.gap {
  gap: 12px;
}

/* Tables */
.tablewrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  margin-top: 20px;
}

.tab {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.tab th, .tab td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--stroke);
  text-align: left;
}

.tab th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(14, 20, 25, 0.6);
  position: sticky;
  top: 0;
}

.tab td {
  color: var(--text);
}

.tab tr:last-child td {
  border-bottom: none;
}

.tab tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Forms */
.formwrap {
  max-width: 680px;
  margin: 0 auto;
}

.formwrap h2 {
  margin: 0 0 24px 0;
  font-size: 28px;
  font-weight: 800;
}

.form {
  display: grid;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow-md);
}

.form label {
  display: grid;
  gap: 8px;
  font-weight: 500;
  color: var(--text-dim);
  font-size: 14px;
}

.form input, .form textarea, .form select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(10, 14, 19, 0.6);
  color: var(--text);
  font-size: 15px;
  transition: all 0.2s ease;
}

.form input:focus, .form textarea:focus, .form select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.days {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px;
  border: 2px dashed var(--stroke);
  border-radius: 12px;
  background: rgba(10, 14, 19, 0.3);
}

.days legend {
  font-weight: 600;
  color: var(--text-dim);
  padding: 0 8px;
  margin-bottom: 8px;
}

.days label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

/* Buttons */
.btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 11px 20px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background: var(--panel-hover);
  border-color: var(--stroke-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn.ghost {
  background: transparent;
  border-color: var(--stroke);
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.03);
}

.btn.danger {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  border-color: var(--danger);
  color: #fff;
  font-weight: 600;
}

.btn.danger:hover {
  background: linear-gradient(135deg, #f87171 0%, var(--danger) 100%);
  box-shadow: 0 4px 16px var(--danger-glow);
}

.btn.sm {
  padding: 8px 14px;
  font-size: 13px;
}

/* Series Page */
.serieshead {
  margin-bottom: 32px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}

.serieshead h2 {
  margin: 0 0 8px 0;
  font-size: 28px;
  font-weight: 800;
}

.serieshead p {
  margin: 6px 0;
}

/* Display Page */
.display {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

.display .title {
  margin: 0 0 8px 0;
  font-size: 32px;
  font-weight: 800;
}

.display .subline {
  margin: 0 0 20px 0;
  color: var(--muted);
  font-size: 15px;
}

.qrbox {
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
}

#qr canvas, #qr img {
  width: 420px;
  height: 420px;
  border-radius: 12px;
}

.attnlist {
  display: grid;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 20px;
  min-height: 300px;
  box-shadow: var(--shadow-lg);
}

.attnlist.anon {
  display: grid;
  gap: 6px;
  padding: 16px;
  justify-content: flex-start;
  align-content: flex-start;
}

.attnrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(10, 14, 19, 0.6);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  transition: all 0.2s ease;
}

.attnrow:hover {
  background: rgba(10, 14, 19, 0.8);
  border-color: var(--stroke-light);
}

.attnrow.good {
  border-color: var(--ok);
  box-shadow: 0 0 0 2px var(--ok-glow) inset;
}

.attnrow.suspicious {
  border-color: var(--warn);
  box-shadow: 0 0 0 2px var(--warn-glow) inset;
}

.attnrow.offcampus {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px var(--danger-glow) inset;
}

.attnrow .who {
  font-weight: 600;
  font-size: 15px;
}

.attnrow .when {
  color: var(--text-dim);
  font-size: 14px;
}

/* Chips */
.chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: linear-gradient(135deg, rgba(18, 24, 35, 0.9) 0%, rgba(13, 18, 26, 0.9) 100%);
  font-variant-numeric: tabular-nums;
  transition: all 0.2s ease;
}

.chip:hover {
  border-color: var(--stroke-light);
  transform: translateY(-1px);
}

.chip.micro {
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.1;
  white-space: nowrap;
}

.chip .id {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
  margin-right: 8px;
}

.chip .delta {
  opacity: 0.9;
  font-size: 12px;
}

.chip.good {
  border-color: var(--ok);
  box-shadow: 0 0 0 2px var(--ok-glow) inset;
}

.chip.warn {
  border-color: var(--warn);
  box-shadow: 0 0 0 2px var(--warn-glow) inset;
}

.chip.danger {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px var(--danger-glow) inset;
}

/* Check-in Page */
.checkin {
  max-width: 540px;
  margin: 64px auto;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.error {
  color: #fca5a5;
  font-weight: 500;
}

.ok {
  color: var(--ok);
  font-weight: 500;
}

.warn {
  color: var(--warn);
  font-weight: 500;
}

/* Modal */
.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal__panel {
  position: relative;
  margin: 8vh auto 0;
  width: min(780px, 92vw);
  background: var(--panel);
  border: 1px solid var(--stroke-light);
  border-radius: 20px;
  padding: 0;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(10, 14, 19, 0.4);
  border-radius: 20px 20px 0 0;
}

.modal__head h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.modal__close {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.modal__close:hover {
  background: rgba(255, 255, 255, 0.08);
}

.modal__body {
  padding: 20px 24px 24px;
}

.modal__meta {
  margin-bottom: 16px;
  font-size: 14px;
}

.modal__list {
  display: grid;
  gap: 10px;
  max-height: 60vh;
  overflow: auto;
  padding-right: 4px;
}

.modal__list::-webkit-scrollbar {
  width: 8px;
}

.modal__list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.modal__list::-webkit-scrollbar-thumb {
  background: var(--stroke-light);
  border-radius: 4px;
}

.modal__list::-webkit-scrollbar-thumb:hover {
  background: var(--stroke);
}

/* Footer */
.foot {
  opacity: 0.5;
  text-align: center;
  padding: 32px 0;
  font-size: 14px;
  color: var(--muted);
}

/* Responsive */
@media (max-width: 900px) {
  .display {
    grid-template-columns: 1fr;
  }
  
  .cards {
    grid-template-columns: 1fr;
  }
  
  .grid2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px 16px;
  }
  
  .container {
    padding: 0 16px;
    margin: 20px auto;
  }
  
  .welcome {
    padding: 24px;
  }
  
  .welcome h1 {
    font-size: 24px;
  }
  
  #qr canvas, #qr img {
    width: 100%;
    height: auto;
    max-width: 420px;
  }
}
