* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html {
  scrollbar-width: thin;
  scrollbar-color: #1e293b #0b0f19;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #0b0f19;
}

::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 6px;
  border: 2px solid #0b0f19;
}

::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

::-webkit-scrollbar-thumb:active {
  background: #0284c7;
}

body {
  background-color: #0b0f19;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-header {
  background-color: #111827;
  color: #ffffff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #1f2937;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.logo-icon {
  font-size: 22px;
}

.logo-text {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #f8fafc;
}

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

.btn-header-action {
  background: #1f2937;
  color: #ffffff;
  border: 1px solid #374151;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-header-action:hover {
  background: #374151;
}

.session-badge {
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
  padding: 5px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.session-badge.hidden {
  display: none;
}

.alias-mini {
  font-size: 14px;
  font-weight: 700;
  color: #c7d2fe;
}

.main-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
}

.app-step {
  display: none;
  width: 100%;
  max-width: 420px;
  animation: fadeIn 0.25s ease;
}

.app-step.active {
  display: block;
}

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

.step-card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 18px;
  padding: 20px 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.step-title {
  font-size: 19px;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 4px;
}

.step-subtitle {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 14px;
}

.scanner-box {
  width: 100%;
  min-height: 220px;
  border-radius: 14px;
  overflow: hidden;
  background: #000000;
  border: 2px solid #374151;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 14px;
  position: relative;
}

.scanner-box div {
  width: 100% !important;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 14px 0;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #374151;
}

.divider span {
  padding: 0 10px;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
}

button {
  cursor: pointer;
  border: none;
  font-weight: 700;
  border-radius: 10px;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

button:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: #4f46e5;
  color: #ffffff;
  padding: 10px 16px;
  font-size: 14px;
}

.btn-primary:hover {
  background-color: #4338ca;
}

.btn-primary-large {
  background-color: #4f46e5;
  color: #ffffff;
  padding: 12px 20px;
  font-size: 15px;
  width: 100%;
  margin-top: 12px;
}

.btn-secondary-large {
  background-color: #1f2937;
  color: #e2e8f0;
  border: 1px solid #374151;
  padding: 12px 18px;
  font-size: 14px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-secondary-large:hover {
  background-color: #374151;
}

.btn-success-large {
  background-color: #10b981;
  color: #ffffff;
  padding: 14px 20px;
  font-size: 16px;
  width: 100%;
  margin-top: 16px;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-success-large:hover:not(:disabled) {
  background-color: #059669;
}

.btn-success-large:disabled {
  background-color: #374151;
  color: #64748b;
  box-shadow: none;
  cursor: not-allowed;
}

.isbn-input-form {
  display: flex;
  gap: 8px;
}

.isbn-input-form input {
  flex: 1;
  padding: 10px 14px;
  background: #0b0f19;
  border: 1px solid #374151;
  border-radius: 10px;
  font-size: 15px;
  color: #f8fafc;
  outline: none;
}

.isbn-input-form input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.welcome-box, .success-box {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 18px;
  padding: 32px 20px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.welcome-title {
  font-size: 24px;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 6px;
}

.welcome-subtitle {
  font-size: 14px;
  color: #94a3b8;
}

.success-icon {
  font-size: 60px;
  margin-bottom: 12px;
}

.success-title {
  font-size: 24px;
  font-weight: 800;
  color: #10b981;
  margin-bottom: 6px;
}

.success-subtitle {
  font-size: 14px;
  color: #94a3b8;
}

.book-card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 18px;
  padding: 18px 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.book-preview {
  display: flex;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid #1f2937;
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.book-cover-img {
  width: 75px;
  height: 105px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  background-color: #1f2937;
  border: 1px solid #374151;
}

.book-details {
  flex: 1;
  text-align: left;
}

.book-title {
  font-size: 16px;
  font-weight: 800;
  color: #f8fafc;
  line-height: 1.25;
  margin-bottom: 4px;
}

.book-author {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.book-pages {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}

.rating-prompt {
  text-align: center;
}

.rating-prompt h3 {
  font-size: 15px;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 12px;
}

.star-rating {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.star-btn {
  background: none;
  font-size: 34px;
  padding: 4px;
  cursor: pointer;
  filter: grayscale(100%);
  opacity: 0.25;
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

.star-btn.selected {
  filter: grayscale(0%);
  opacity: 1;
  transform: scale(1.15);
}

.star-label {
  font-size: 13px;
  font-weight: 600;
  color: #818cf8;
  min-height: 18px;
}

.manual-access-card {
  margin-top: 14px;
  background: #111827;
  border: 1.5px solid #1f2937;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.manual-access-card:hover {
  background: #1f2937;
  border-color: #374151;
}

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

.manual-access-icon {
  font-size: 22px;
  background: #0b0f19;
  border: 1px solid #374151;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.manual-access-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.manual-access-title {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
}

.manual-access-sub {
  font-size: 12px;
  color: #94a3b8;
}

.manual-access-arrow {
  font-size: 18px;
  font-weight: 800;
  color: #64748b;
}

.step-nav-bar {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.btn-nav-back {
  background: #1f2937;
  color: #cbd5e1;
  border: 1px solid #374151;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-nav-back:hover {
  background: #374151;
  color: #f8fafc;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0b0f19;
  border: 1.5px solid #374151;
  border-radius: 12px;
  padding: 8px 12px;
  margin: 12px 0;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.search-box:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.search-icon {
  font-size: 16px;
  color: #64748b;
}

.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 15px;
  color: #f8fafc;
}

.btn-clear-search {
  background: none;
  border: none;
  color: #64748b;
  font-size: 14px;
  padding: 0 4px;
  cursor: pointer;
}

.btn-clear-search:hover {
  color: #94a3b8;
}

.btn-clear-search.hidden {
  display: none;
}

.profile-list-scroll {
  max-height: 48vh;
  overflow-y: auto;
  padding: 2px 4px 8px 2px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.profile-item {
  background: #111827;
  border: 1.5px solid #1f2937;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.15s ease;
}

.profile-item:hover {
  border-color: #6366f1;
  background: #1f2937;
  transform: translateY(-1px);
}

.profile-item:active {
  transform: scale(0.99);
}

.profile-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-alias-text {
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
}

.profile-item-arrow {
  color: #475569;
  font-size: 16px;
  font-weight: 700;
}

.selected-student-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1e1b4b;
  border: 1.5px solid #4338ca;
  padding: 6px 14px;
  border-radius: 20px;
  margin-bottom: 6px;
}

.student-chip-icon {
  font-size: 16px;
}

.student-chip-name {
  font-size: 15px;
  font-weight: 800;
  color: #c7d2fe;
}

.pin-dots-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 14px 0 6px 0;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #374151;
  background: #0b0f19;
  transition: all 0.15s ease;
}

.pin-dot.filled {
  background: #6366f1;
  border-color: #6366f1;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
  transform: scale(1.15);
}

.pin-dot.error {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.pin-dots-row.shake {
  animation: shake 0.35s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.pin-status-text {
  min-height: 20px;
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 6px;
}

.pin-status-text.error {
  color: #ef4444;
}

.pin-status-text.success {
  color: #10b981;
}

.virtual-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 290px;
  margin: 6px auto 0 auto;
}

.pad-key {
  height: 56px;
  border-radius: 14px;
  background: #111827;
  border: 1px solid #1f2937;
  font-size: 22px;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: all 0.1s ease;
  user-select: none;
}

.pad-key:hover {
  background: #1f2937;
  border-color: #374151;
}

.pad-key:active {
  background: #374151;
  transform: scale(0.94);
}

.pad-key.pad-action {
  background: #1f2937;
  border: 1px solid #374151;
  color: #94a3b8;
  font-size: 18px;
}

.pad-key.pad-action:hover {
  background: #374151;
  color: #f8fafc;
}

.status-msg {
  color: #94a3b8;
  font-size: 14px;
  padding: 20px;
}

#qr-shaded-region,
.qr-shaded-region,
#qrReader div[style*="border"],
#bookScanner div[style*="border"] {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  text-align: left;
}

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

.modal-header h3 {
  font-size: 17px;
  font-weight: 800;
  color: #f8fafc;
}

.btn-modal-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  padding: 4px 8px;
  cursor: pointer;
}

.modal-subtitle {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.4;
  margin-bottom: 12px;
}

.server-config-form {
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.server-label {
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
}

.server-input {
  width: 100%;
  padding: 10px 12px;
  background: #0b0f19;
  border: 1px solid #374151;
  border-radius: 8px;
  font-size: 14px;
  color: #f8fafc;
  outline: none;
}

.server-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.server-status-box {
  min-height: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.4;
  padding: 0;
  transition: all 0.2s ease;
}

.server-status-box:not(:empty) {
  padding: 8px 12px;
  border-radius: 8px;
}

.server-status-box.success {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.server-status-box.error {
  color: #f87171;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

.modal-actions button,
.btn-secondary,
.btn-primary {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-sizing: border-box;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  transition: all 0.15s ease;
}

.btn-secondary {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #334155;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.btn-secondary:hover {
  background: #334155;
  color: #ffffff;
  border-color: #475569;
}

.btn-secondary:active {
  transform: scale(0.97);
  background: #0f172a;
}

.btn-primary {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.35);
}

.btn-primary:hover {
  background: #0369a1;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.5);
}

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

#btnTestServer {
  flex: 1;
  background: #1e293b;
  color: #f1f5f9;
  border: 1.5px solid #334155;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

#btnTestServer:hover {
  background: #334155;
  border-color: #64748b;
  color: #ffffff;
}

#btnTestServer:active {
  background: #0f172a;
  transform: scale(0.97);
}

#btnSaveServer {
  flex: 1;
  background: #0284c7;
  color: #ffffff;
  border: 1.5px solid #38bdf8;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 12px rgba(2, 132, 199, 0.4);
}

#btnSaveServer:hover {
  background: #0369a1;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.55);
}

#btnSaveServer:active {
  transform: scale(0.97);
}

body.barcode-scanner-active {
  background-color: transparent !important;
}

body.barcode-scanner-active .app-header {
  background-color: #111827 !important;
  position: relative;
  z-index: 100;
}

body.barcode-scanner-active .main-container {
  background: transparent !important;
}

body.barcode-scanner-active .step-card {
  background: transparent !important;
  box-shadow: 0 0 0 9999px #0b0f19 !important;
  overflow: hidden !important;
  position: relative;
  z-index: 10;
}

body.barcode-scanner-active .step-card > * {
  position: relative;
  z-index: 2;
}

body.barcode-scanner-active .scanner-box {
  background: transparent !important;
  box-shadow: 0 0 0 9999px #111827 !important;
  border: 2px dashed #6366f1 !important;
  position: relative;
  z-index: 1;
}

body.barcode-scanner-active .manual-access-card {
  background: #111827 !important;
}

body.barcode-scanner-active .isbn-input-form input {
  background: #0b0f19 !important;
}



