:root {
  --primary: #5D38F8;
  --primary-glow: rgba(93, 56, 248, 0.22);
  --accent-pink: #FF1768;
  --bg-color: #F4F6FB;
  --surface-color: #FFFFFF;
  --surface-card: #F8FAFC;
  --surface-hover: #EEF2F6;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --border-color: #E2E8F0;
  --divider: #EDF2F7;
  --success: #059669;
  --success-bg: #ECFDF5;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --error: #E11D48;
  --error-bg: #FFF1F2;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] {
  --primary: #6D48F9;
  --primary-glow: rgba(109, 72, 249, 0.35);
  --accent-pink: #FF2E79;
  --bg-color: #0B0F17;
  --surface-color: #141B26;
  --surface-card: #1B2433;
  --surface-hover: #232E40;
  --text-main: #F1F5F9;
  --text-muted: #94A3B8;
  --border-color: #273449;
  --divider: #1E293B;
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.16);
  --warning: #F59E0B;
  --warning-bg: rgba(245, 158, 11, 0.16);
  --error: #F43F5E;
  --error-bg: rgba(244, 63, 94, 0.16);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 3px 10px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}

/* Header */
.header-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 10px;
}

.brand-logo {
  font-size: 20px;
  font-weight: 900;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.5px;
}

.brand-logo-img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 4px 14px rgba(255, 23, 104, 0.22);
  border: 1px solid rgba(255, 23, 104, 0.2);
}

.brand-logo span {
  color: var(--accent-pink);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 11px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-purple {
  background: rgba(93, 56, 248, 0.08);
  color: var(--primary);
  border: 1px solid rgba(93, 56, 248, 0.25);
}

.badge-pink {
  background: rgba(255, 23, 104, 0.08);
  color: var(--accent-pink);
  border: 1px solid rgba(255, 23, 104, 0.25);
}

.badge-green {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(5, 150, 105, 0.25);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(217, 119, 6, 0.25);
}

/* General Buttons */
.btn {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-weight: 700;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

.btn-primary {
  background: linear-gradient(135deg, #6C42F5 0%, #4D26D6 100%);
  color: #FFF;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 6px 22px rgba(93, 56, 248, 0.4);
}

.btn-secondary {
  background: var(--surface-color);
  color: var(--text-main);
  border: 1.5px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  color: var(--text-main);
  border-color: var(--text-main);
  background: var(--surface-hover);
}

.btn-danger {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(225, 29, 72, 0.25);
}

.btn-danger:hover {
  background: #FFE4E6;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Auth / Login View */
.login-card {
  background: var(--surface-color);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  padding: 32px 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: fadeIn 0.3s ease;
  margin-top: 10px;
}

.login-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.login-logo-wrap {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  overflow: hidden;
  margin-bottom: 8px;
  box-shadow: 0 10px 25px rgba(255, 23, 104, 0.25);
  border: 2px solid rgba(255, 23, 104, 0.2);
  background: var(--surface-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-header h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
}

.login-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  display: flex;
  justify-content: space-between;
}

.form-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.form-input {
  width: 100%;
  background: var(--surface-color);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 13px 14px 13px 40px;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  outline: none;
  transition: all 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(93, 56, 248, 0.15);
  background: var(--surface-card);
}

.form-input-icon {
  position: absolute;
  left: 13px;
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

.form-input-action {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
}

.form-input-action:hover {
  color: var(--text-main);
}

/* 24-Hour Expiry Alert in Login */
.expiry-notice-box {
  background: rgba(93, 56, 248, 0.06);
  border: 1px solid rgba(93, 56, 248, 0.2);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-main);
}

.expiry-notice-box strong {
  color: var(--primary);
}

/* Shift Info Banner (Logged-In) */
.shift-banner {
  background: var(--surface-color);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.shift-banner::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 3.5px;
  width: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-pink));
}

.shift-banner-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.staff-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.staff-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(93, 56, 248, 0.08);
  border: 1.5px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--primary);
  font-weight: 800;
}

.staff-details {
  display: flex;
  flex-direction: column;
}

.staff-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
}

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

.countdown-box {
  background: var(--warning-bg);
  border: 1px solid rgba(217, 119, 6, 0.3);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--warning);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.3px;
  animation: pulseGlow 2.5s infinite;
}

@keyframes pulseGlow {
  0%, 100% { border-color: rgba(217, 119, 6, 0.3); }
  50% { border-color: rgba(217, 119, 6, 0.65); box-shadow: 0 0 10px rgba(217, 119, 6, 0.15); }
}

.shift-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.shift-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: #E2E8F0;
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-pink));
  border-radius: 10px;
  transition: width 0.5s ease;
}

/* Stats Counter Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat-box {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}

.stat-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.stat-number {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.2;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 3px;
}

.stat-total { color: var(--text-main); }
.stat-valid { color: var(--success); }
.stat-warn { color: var(--warning); }
.stat-err { color: var(--error); }

/* Scanner Card */
.scanner-card {
  background: var(--surface-color);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  padding: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#qr-reader {
  width: 100% !important;
  border: none !important;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#qr-reader video {
  border-radius: var(--radius-md);
  object-fit: cover !important;
  width: 100% !important;
}

#qr-reader__scan_region {
  background: #000;
}

#qr-reader__dashboard {
  padding: 0 !important;
}

.scanner-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.manual-entry-box {
  display: flex;
  gap: 8px;
  background: #F8FAFC;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px 6px 4px 12px;
  align-items: center;
  transition: border-color 0.2s;
}

.manual-entry-box:focus-within {
  border-color: var(--primary);
  background: var(--surface-card);
}

.manual-entry-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 700;
  flex: 1;
  font-family: monospace;
  letter-spacing: 0.5px;
}

/* Alert Display Card */
.alert-card {
  padding: 20px;
  border-radius: var(--radius-xl);
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border: 2px solid transparent;
  animation: popIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-lg);
}

@keyframes popIn {
  0% { transform: scale(0.88); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
  0% { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}

.alert-valid {
  background: #ECFDF5;
  border-color: #10B981;
  color: #065F46;
}

.alert-rescan {
  background: #FFFBEB;
  border-color: #F59E0B;
  color: #92400E;
}

.alert-fake {
  background: #FFF1F2;
  border-color: #F43F5E;
  color: #9F1239;
}

.status-icon-bubble {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  margin-bottom: 12px;
}

.bubble-valid {
  background: rgba(16, 185, 129, 0.15);
  border: 2.5px solid #10B981;
  color: #059669;
}

.bubble-rescan {
  background: rgba(245, 158, 11, 0.15);
  border: 2.5px solid #F59E0B;
  color: #D97706;
}

.bubble-fake {
  background: rgba(244, 63, 94, 0.15);
  border: 2.5px solid #F43F5E;
  color: #E11D48;
}

.pass-info-box {
  width: 100%;
  background: var(--surface-card);
  border-radius: var(--radius-md);
  padding: 14px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  text-align: left;
  margin: 14px 0;
  color: var(--text-main);
}

.info-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--divider);
  padding-bottom: 6px;
}

.info-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.info-row span {
  color: var(--text-muted);
  font-size: 12px;
}

.info-row strong {
  font-weight: 700;
  color: var(--text-main);
}

.timestamp-box {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  margin-top: 4px;
}

/* History / Activity Log */
.history-card {
  background: var(--surface-color);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-retention-tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: #F1F5F9;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.history-search-input {
  width: 100%;
  background: #F8FAFC;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.history-search-input:focus {
  border-color: var(--primary);
  background: var(--surface-card);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.history-list::-webkit-scrollbar {
  width: 5px;
}

.history-list::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}

.history-item {
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  transition: background 0.15s;
}

.history-item:hover {
  background: #F1F5F9;
}

.history-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-name {
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-code {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-muted);
}

.history-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.history-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 4px;
  text-transform: uppercase;
}

.history-time {
  font-size: 10px;
  color: var(--text-muted);
}

.empty-history {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Modal Popup */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 999;
}

.modal-content {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 22px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.15);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 90vh;
  overflow-y: auto;
  animation: popIn 0.25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.close-btn:hover {
  color: var(--text-main);
}

/* Responsive tweaks */
@media (max-width: 400px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Animated Offline Radar Banner */
.offline-banner {
  background: #FFFBEB;
  border: 1.5px solid #F59E0B;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.15);
  animation: fadeIn 0.3s ease;
}

.offline-radar {
  position: relative;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.radar-dot {
  font-size: 14px;
  z-index: 2;
}

.radar-wave {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid #F59E0B;
  animation: radarWavePulse 1.6s infinite ease-out;
}

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

.offline-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.offline-info strong {
  font-size: 12px;
  font-weight: 800;
  color: #B45309;
}

.offline-info span {
  font-size: 11px;
  color: #78350F;
  line-height: 1.35;
}

/* ============================================================== */
/* DARK MODE COMPONENT REFINEMENTS                                */
/* ============================================================== */
[data-theme="dark"] .progress-track {
  background: #273449;
}

[data-theme="dark"] .history-retention-tag {
  background: var(--surface-card);
  color: var(--text-muted);
  border-color: var(--border-color);
}

[data-theme="dark"] .history-item {
  background: var(--surface-card);
  border-color: var(--border-color);
}

[data-theme="dark"] .history-item:hover {
  background: var(--surface-hover);
}

[data-theme="dark"] .alert-valid {
  background: #064E3B;
  border-color: #10B981;
  color: #D1FAE5;
}

[data-theme="dark"] .alert-rescan {
  background: #78350F;
  border-color: #F59E0B;
  color: #FEF3C7;
}

[data-theme="dark"] .alert-fake {
  background: #881337;
  border-color: #F43F5E;
  color: #FFE4E6;
}

[data-theme="dark"] .offline-banner {
  background: #2D1D05;
  border-color: #D97706;
}

[data-theme="dark"] .offline-info strong {
  color: #FBBF24;
}

[data-theme="dark"] .offline-info span {
  color: #FDE68A;
}

[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.7);
}

