/* ============================================
   REG Attendance - Complete Stylesheet
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --primary: #1a237e;
  --primary-light: #283593;
  --primary-dark: #0d1245;
  --accent: #ff6f00;
  --accent-light: #ff8f00;
  --accent-dark: #e65100;
  --success: #2e7d32;
  --success-light: #4caf50;
  --success-bg: #e8f5e9;
  --warning: #f57f17;
  --warning-light: #ffb74d;
  --warning-bg: #fff3e0;
  --danger: #c62828;
  --danger-light: #ef5350;
  --danger-bg: #ffebee;
  --halfday: #f9a825;
  --halfday-bg: #fffde7;
  --bg: #f5f5f5;
  --card: #ffffff;
  --text: #212121;
  --text-light: #757575;
  --text-muted: #9e9e9e;
  --border: #e0e0e0;
  --border-light: #f0f0f0;
  --radius: 16px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
  --shadow-xl: 0 8px 32px rgba(0,0,0,0.2);
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
  --safe-right: env(safe-area-inset-right);
}

/* --- Import Poppins Font (fallback) --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

/* --- Reset & Base Styles --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-top: calc(72px + var(--safe-top));
  padding-bottom: calc(64px + var(--safe-bottom) + 16px);
}

/* --- Scrollbar Hiding --- */
::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* --- Selection --- */
::selection {
  background: var(--primary-light);
  color: #fff;
}

/* ============================================
   App Header
   ============================================ */
.app-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  padding: 10px 16px calc(10px + var(--safe-top));
  padding-top: calc(10px + var(--safe-top));
  z-index: 1000;
  text-align: center;
  box-shadow: var(--shadow);
  border-radius: 0 0 var(--radius) var(--radius);
}

.app-header .logo {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.app-header .college-name {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.95;
  margin-top: 2px;
  letter-spacing: 0.3px;
}

.app-header .subtitle {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.75;
  margin-top: 1px;
  letter-spacing: 0.5px;
}

/* ============================================
   Announcement Ticker
   ============================================ */
.ticker {
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 16px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: fixed;
  top: calc(72px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 999;
  display: none;
  letter-spacing: 0.2px;
}

.ticker:empty,
.ticker.active {
  display: block;
}

/* ============================================
   Screen System
   ============================================ */
.screen {
  display: none;
  padding: 16px;
  padding-top: 40px;
  min-height: calc(100vh - 72px - 64px);
  animation: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.screen-header {
  margin-bottom: 16px;
  padding: 0 4px;
}

.screen-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
}

.screen-header .date-display {
  font-size: 13px;
  color: var(--text-light);
  font-weight: 400;
}

/* ============================================
   Camera Section
   ============================================ */
.camera-wrapper {
  position: relative;
  margin: 0 -16px;
  padding: 0 16px;
  margin-bottom: 16px;
}

.camera-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.camera-container video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
  z-index: 2;
  pointer-events: none;
}

/* --- Pulse Ring --- */
.pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120px;
  height: 120px;
  margin-left: -60px;
  margin-top: -60px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  z-index: 3;
  pointer-events: none;
  animation: pulse 1.5s ease-out infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* ============================================
   Status Chips
   ============================================ */
.chip {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  z-index: 4;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.3s ease;
  letter-spacing: 0.3px;
}

.chip-scanning {
  background: rgba(26, 35, 126, 0.9);
  color: #fff;
  animation: scanningPulse 2s ease infinite;
}

.chip-detected {
  background: rgba(245, 127, 23, 0.92);
  color: #fff;
}

.chip-matched {
  background: rgba(46, 125, 50, 0.92);
  color: #fff;
  animation: successPop 0.4s ease;
}

@keyframes scanningPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes successPop {
  0% { transform: translateX(-50%) scale(0.8); opacity: 0; }
  50% { transform: translateX(-50%) scale(1.1); }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ============================================
   Status Badges
   ============================================ */
.status-badge,
.badge-present,
.badge-absent,
.badge-late,
.badge-halfday {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-present {
  background: var(--success-bg);
  color: var(--success);
}

.badge-absent {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-late {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-halfday {
  background: var(--halfday-bg);
  color: #7c6f00;
}

/* ============================================
   Info Card
   ============================================ */
.info-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.info-card:active {
  transform: scale(0.99);
}

.date-display {
  font-size: 14px;
  color: var(--text-light);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.time-display {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

.teacher-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-top: 12px;
}

.teacher-dept {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}

.checkin-time {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 500;
}

/* ============================================
   Liveness Panel
   ============================================ */
#liveness-panel {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.4s ease;
}

.liveness-text {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 8px;
}

.liveness-timer {
  font-size: 28px;
  font-weight: 700;
  opacity: 0.95;
  font-variant-numeric: tabular-nums;
}

/* ============================================
   Success Overlay
   ============================================ */
#success-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 35, 126, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
  padding: 24px;
}

.success-content {
  text-align: center;
  color: #fff;
  animation: slideUp 0.5s ease;
}

/* --- Checkmark SVG Animation --- */
.checkmark {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
}

.checkmark-circle {
  stroke: #fff;
  stroke-width: 3;
  fill: none;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: strokeCircle 0.6s ease forwards;
}

.checkmark-check {
  stroke: #fff;
  stroke-width: 3;
  fill: none;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: strokeCheck 0.4s 0.5s ease forwards;
}

@keyframes strokeCircle {
  to { stroke-dashoffset: 0; }
}

@keyframes strokeCheck {
  to { stroke-dashoffset: 0; }
}

#success-message {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
  animation: fadeIn 0.5s 0.8s ease both;
}

#success-message .sub-message {
  font-size: 14px;
  font-weight: 400;
  opacity: 0.85;
  margin-top: 8px;
}

/* ============================================
   Bottom Navigation
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(64px + var(--safe-bottom));
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  padding-bottom: var(--safe-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  transition: color 0.2s ease, transform 0.15s ease;
  position: relative;
  min-height: 56px;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  transition: transform 0.2s ease;
}

.nav-item.active {
  color: var(--accent);
}

.nav-item.active svg {
  transform: scale(1.15);
}

.nav-item:active {
  transform: scale(0.92);
}

/* Active indicator dot */
.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

/* ============================================
   Teacher Cards (Today List)
   ============================================ */
.teacher-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.teacher-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: slideUp 0.3s ease both;
  border: 1px solid var(--border-light);
}

.teacher-card:nth-child(1) { animation-delay: 0.02s; }
.teacher-card:nth-child(2) { animation-delay: 0.04s; }
.teacher-card:nth-child(3) { animation-delay: 0.06s; }
.teacher-card:nth-child(4) { animation-delay: 0.08s; }
.teacher-card:nth-child(5) { animation-delay: 0.10s; }
.teacher-card:nth-child(6) { animation-delay: 0.12s; }
.teacher-card:nth-child(7) { animation-delay: 0.14s; }
.teacher-card:nth-child(8) { animation-delay: 0.16s; }
.teacher-card:nth-child(9) { animation-delay: 0.18s; }
.teacher-card:nth-child(10) { animation-delay: 0.20s; }

.teacher-card:active {
  transform: scale(0.98);
}

.teacher-photo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border-light);
  background: var(--bg);
}

.teacher-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.teacher-info .name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.teacher-info .dept {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.teacher-info .times {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.teacher-status {
  flex-shrink: 0;
  margin-left: 4px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  height: 48px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  letter-spacing: 0.3px;
  min-height: 48px;
  min-width: 100px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26, 35, 126, 0.3);
}

.btn-primary:active {
  box-shadow: 0 1px 4px rgba(26, 35, 126, 0.3);
}

.btn-secondary {
  background: var(--card);
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(255, 111, 0, 0.3);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  height: 36px;
  font-size: 13px;
  padding: 0 16px;
  min-height: 36px;
}

/* ============================================
   Search Section (My Record)
   ============================================ */
.search-section {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  position: sticky;
  top: calc(72px + var(--safe-top) + 8px);
  z-index: 100;
  background: var(--bg);
  padding: 8px 0;
}

.search-input {
  flex: 1;
  height: 48px;
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  background: var(--card);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* ============================================
   Profile Card (My Record)
   ============================================ */
.profile-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  transition: transform 0.2s ease;
}

.profile-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 12px;
  border: 3px solid var(--primary);
  box-shadow: var(--shadow-md);
  background: var(--bg);
}

.profile-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.profile-dept {
  font-size: 14px;
  color: var(--text-light);
  margin-top: 2px;
}

/* ============================================
   Stats Row (My Record)
   ============================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
  border: 1px solid var(--border-light);
}

.stat-card:active {
  transform: scale(0.96);
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* ============================================
   Calendar Strip (My Record)
   ============================================ */
.calendar-strip {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.calendar-strip-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.calendar-days {
  display: flex;
  gap: 8px;
}

.calendar-day {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1.5px solid var(--border-light);
  transition: all 0.2s ease;
  cursor: default;
}

.calendar-day .day-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 500;
}

.calendar-day .day-date {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.calendar-day.present {
  background: var(--success-bg);
  border-color: var(--success);
}

.calendar-day.present .day-date {
  color: var(--success);
}

.calendar-day.absent {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.calendar-day.absent .day-date {
  color: var(--danger);
}

.calendar-day.late {
  background: var(--warning-bg);
  border-color: var(--warning);
}

.calendar-day.late .day-date {
  color: var(--warning);
}

.calendar-day.halfday {
  background: var(--halfday-bg);
  border-color: var(--halfday);
}

.calendar-day.halfday .day-date {
  color: #7c6f00;
}

.calendar-day.today {
  border-color: var(--primary);
  border-width: 2px;
}

.calendar-day.sunday {
  opacity: 0.5;
}

/* ============================================
   Streak Badge (My Record)
   ============================================ */
.streak-badge {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  font-weight: 600;
  font-size: 14px;
}

.streak-badge .streak-icon {
  font-size: 20px;
}

.streak-badge .streak-count {
  font-size: 22px;
  font-weight: 700;
}

/* ============================================
   Record List (My Record)
   ============================================ */
.record-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.record-item {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  animation: slideUp 0.25s ease both;
}

.record-item .record-date {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.record-item .record-times {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.record-item .record-hours {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ============================================
   Reports Screen
   ============================================ */
.reports-intro {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.reports-intro h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.reports-intro p {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 16px;
  line-height: 1.6;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quick-stat-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 18px 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: transform 0.2s ease;
}

.quick-stat-card:active {
  transform: scale(0.96);
}

.quick-stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.quick-stat-label {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.quick-stat-card.accent .quick-stat-value {
  color: var(--accent);
}

.quick-stat-card.success .quick-stat-value {
  color: var(--success);
}

.quick-stat-card.danger .quick-stat-value {
  color: var(--danger);
}

/* ============================================
   Install Sheet (PWA)
   ============================================ */
.install-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 3000;
  animation: fadeIn 0.3s ease;
}

.install-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 28px 24px calc(24px + var(--safe-bottom));
  z-index: 3001;
  animation: slideUpSheet 0.4s ease;
  box-shadow: var(--shadow-xl);
}

@keyframes slideUpSheet {
  from {
    transform: translateX(-50%) translateY(100%);
  }
  to {
    transform: translateX(-50%) translateY(0);
  }
}

.install-sheet .sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.install-sheet .sheet-logo {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  margin: 0 auto 16px;
}

.install-sheet .sheet-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  margin-bottom: 6px;
}

.install-sheet .sheet-desc {
  font-size: 14px;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.5;
}

.install-sheet .sheet-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.install-sheet .sheet-buttons .btn {
  width: 100%;
}

/* --- iOS Install Instructions --- */
.ios-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 3000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.ios-sheet {
  background: var(--card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 28px 24px calc(24px + var(--safe-bottom));
  width: 100%;
  max-width: 480px;
  animation: slideUpSheet 0.4s ease;
}

.ios-sheet h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  text-align: center;
}

.ios-sheet ol {
  padding-left: 20px;
  font-size: 14px;
  color: var(--text);
  line-height: 2;
  margin-bottom: 20px;
}

.ios-sheet ol li {
  padding-left: 4px;
}

/* ============================================
   Pull to Refresh
   ============================================ */
.ptr-indicator {
  text-align: center;
  padding: 12px;
  font-size: 13px;
  color: var(--text-light);
  transition: opacity 0.2s ease;
  display: none;
}

.ptr-indicator.visible {
  display: block;
  animation: fadeIn 0.2s ease;
}

.ptr-indicator .ptr-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Loading States
   ============================================ */
.loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.loading-spinner {
  display: inline-block;
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

.skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 4px;
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================
   Error / Toast Messages
   ============================================ */
.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 2500;
  max-width: 90%;
  text-align: center;
  animation: slideUp 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.toast.toast-error {
  background: var(--danger);
}

.toast.toast-success {
  background: var(--success);
}

.toast.toast-warning {
  background: var(--warning);
}

/* ============================================
   Global Animations
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ============================================
   Touch Optimizations
   ============================================ */
button, a, .btn, .nav-item, .teacher-card, .stat-card, .quick-stat-card {
  min-height: 44px;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

button, .btn {
  min-height: 48px;
}

input, textarea, select {
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, textarea:focus, select:focus {
  outline: none;
}

/* ============================================
   Safe Area Support
   ============================================ */
@supports (padding-top: env(safe-area-inset-top)) {
  .app-header {
    padding-top: calc(10px + env(safe-area-inset-top));
  }

  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }

  body {
    padding-top: calc(72px + env(safe-area-inset-top));
    padding-bottom: calc(64px + env(safe-area-inset-bottom) + 16px);
  }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .pulse-ring {
    animation: none;
    opacity: 0.3;
  }
}

/* ============================================
   Dark Mode Support
   ============================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --card: #1e1e1e;
    --text: #e0e0e0;
    --text-light: #a0a0a0;
    --text-muted: #707070;
    --border: #333333;
    --border-light: #2a2a2a;
  }

  body {
    background-color: var(--bg);
  }

  .app-header {
    background: linear-gradient(135deg, #0d1245 0%, #1a237e 100%);
  }

  .camera-container {
    background: linear-gradient(135deg, #0a0a1a 0%, #0d1a2e 50%, #0a2040 100%);
  }
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.hidden { display: none !important; }
.visible { display: block !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-full { width: 100%; }

/* ============================================
   Print Styles
   ============================================ */
@media print {
  .app-header,
  .bottom-nav,
  .camera-wrapper,
  .install-overlay,
  .install-sheet,
  #success-overlay {
    display: none !important;
  }

  body {
    padding: 0;
    max-width: none;
  }

  .screen {
    display: block !important;
  }
}


/* ============================================
   SCANNER UI - New Face Detection System
   ============================================ */

/* Status Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
}
.chip-scanning {
  background: linear-gradient(135deg, #fff3e0, #ffe0b2);
  color: var(--accent);
  animation: pulse-chip 1.5s ease-in-out infinite;
}
.chip-detected {
  background: linear-gradient(135deg, #fff8e1, #ffecb3);
  color: var(--warning);
}
.chip-matched {
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  color: var(--success);
}
.chip-error {
  background: linear-gradient(135deg, #ffebee, #ffcdd2);
  color: var(--danger);
}
@keyframes pulse-chip {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.03); opacity: 1; }
}

/* Manual Section */
.manual-section {
  margin-top: 16px;
  padding: 0 12px;
}
.manual-section .divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 16px 0;
  color: var(--text-light);
  font-size: 13px;
  font-weight: 500;
}
.manual-section .divider::before,
.manual-section .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}
.manual-section .divider span {
  padding: 0 12px;
}
.btn-outline {
  width: 100%;
  min-height: 52px;
  background: #fff;
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Poppins', sans-serif;
}
.btn-outline:active {
  transform: scale(0.97);
  background: var(--primary-light);
  color: #fff;
}
.manual-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 8px;
}

/* Teacher Selector Overlay */
.teacher-selector-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.teacher-selector-box {
  background: #fff;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}
.teacher-selector-box h4 {
  margin: 0 0 16px 0;
  color: var(--primary);
  font-size: 18px;
  text-align: center;
}
.teacher-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.teacher-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 12px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}
.teacher-option:active {
  transform: scale(0.95);
  border-color: var(--primary);
  background: #e8eaf6;
}
.teacher-option img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}
.teacher-option span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.teacher-option small {
  font-size: 10px;
  color: var(--text-light);
}
.close-selector {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  background: var(--bg);
  border: none;
  border-radius: 12px;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
}

/* Success Overlay */
#success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 250;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}
.success-content {
  background: #fff;
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}
#success-message {
  margin-top: 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--success);
}
.checkmark {
  width: 60px;
  height: 60px;
}
.checkmark-circle {
  stroke: var(--success);
  stroke-width: 3;
  fill: none;
}
.checkmark-check {
  stroke: var(--success);
  stroke-width: 3;
  fill: none;
  stroke-dasharray: 50;
  stroke-dashoffset: 50;
  animation: drawCheck 0.6s ease forwards 0.3s;
}
@keyframes drawCheck {
  to { stroke-dashoffset: 0; }
}

/* Animations */
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
