*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  background: #1a1a2e;
  color: #fff;
}

/* ---- MAIN PAGE ---- */
#main-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #000;
  transition: background-image 0.4s ease;
  position: relative;
}

#main-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
}

#main-page > * { position: relative; z-index: 1; }

.main-title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 2rem;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  padding: 0 1rem;
}

.register-btn {
  padding: 0.85rem 2.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  background: #6c63ff;
  color: #fff;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  letter-spacing: 0.03em;
  min-height: 44px;
  touch-action: manipulation;
}

.register-btn:hover { background: #574fd6; transform: translateY(-2px); }

/* Register form overlay */
.form-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.form-overlay.active { display: flex; }

.form-card {
  background: #fff;
  color: #222;
  border-radius: 4px;
  padding: 0;
  width: calc(100% - 2rem);
  max-width: 420px;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  animation: slideUp 0.22s ease;
}

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

.form-card-header {
  background: #5b50e8;
  padding: 1.4rem 1.75rem 1.2rem;
}

.form-card-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  margin-bottom: 0.2rem;
}

.form-subtitle {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.75);
}

form {
  padding: 1.5rem 1.75rem 1.25rem;
}

.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 0.4rem;
}

.required-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  background: #e53935;
  border-radius: 2px;
  padding: 0.05rem 0.35rem;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

.form-group input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  background: #fafafa;
  color: #222;
  min-height: 44px;
}

.form-group input:focus {
  border-color: #5b50e8;
  box-shadow: 0 0 0 3px rgba(91,80,232,0.12);
  background: #fff;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 0.8rem;
  background: #5b50e8;
  color: #fff;
  border: none;
  border-radius: 3px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 1.2rem;
  letter-spacing: 0.04em;
  min-height: 44px;
  touch-action: manipulation;
}

.btn-primary:hover { background: #4a40cc; }

.btn-cancel {
  display: block;
  width: 100%;
  padding: 0.6rem;
  background: none;
  color: #888;
  border: none;
  border-radius: 3px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.15s;
  margin-top: 0.5rem;
  text-align: center;
  text-decoration: underline;
}

.btn-cancel:hover { color: #444; }

.form-error {
  color: #e53935;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  min-height: 1.1em;
}

/* ---- WELCOME PAGE ---- */
#welcome-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #000;
  position: relative;
  padding: 1.5rem 1rem;
}

#welcome-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

#welcome-page > * { position: relative; z-index: 1; }

.welcome-card {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
}

.welcome-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.welcome-text {
  font-size: 1rem;
  line-height: 1.7;
  color: rgba(255,255,255,0.88);
  margin-bottom: 1.5rem;
  white-space: pre-wrap;
}

.qr-container img {
  max-width: 200px;
  width: 100%;
  border-radius: 12px;
  border: 3px solid rgba(255,255,255,0.3);
}

.qr-placeholder {
  width: 180px;
  height: 180px;
  border: 2px dashed rgba(255,255,255,0.3);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  color: rgba(255,255,255,0.4);
  font-size: 0.85rem;
}

/* ---- ADMIN PAGE ---- */
#admin-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  background: #f5f6fa;
  color: #222;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #e0e0e0;
}

.admin-header h1 {
  font-size: 1.8rem;
  color: #6c63ff;
}

.admin-header a {
  color: #6c63ff;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.section {
  background: #fff;
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

.section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #444;
  margin-bottom: 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1.5px solid #f0f0f0;
}

.upload-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.upload-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
  min-width: 140px;
}

.upload-group input[type="file"] {
  flex: 1;
  font-size: 0.9rem;
}

.upload-group button {
  padding: 0.55rem 1.2rem;
  background: #6c63ff;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.upload-group button:hover { background: #574fd6; }

.upload-preview {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.upload-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1.5px solid #e0e0e0;
}

.upload-status {
  font-size: 0.8rem;
  color: #888;
}

.text-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.text-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
}

.text-group textarea {
  width: 100%;
  min-height: 100px;
  padding: 0.75rem 1rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.text-group textarea:focus { border-color: #6c63ff; }

.text-group input[type="text"] {
  width: 100%;
  padding: 0.65rem 1rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.text-group input[type="text"]:focus { border-color: #6c63ff; }

.save-btn {
  margin-top: 0.75rem;
  padding: 0.6rem 1.4rem;
  background: #6c63ff;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.save-btn:hover { background: #574fd6; }

.save-status {
  display: inline-block;
  margin-left: 0.75rem;
  font-size: 0.82rem;
  color: #4caf50;
}

/* Users table */
.users-table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table th, table td {
  text-align: left;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid #f0f0f0;
}

table th {
  background: #f8f8fc;
  font-weight: 700;
  color: #555;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table td { color: #333; }
table tbody tr:hover { background: #fafafa; }

.empty-state {
  text-align: center;
  color: #aaa;
  padding: 2rem;
  font-size: 0.95rem;
}

/* Feedback toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #323232;
  color: #fff;
  padding: 0.75rem 1.4rem;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
  z-index: 999;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #2e7d32; }
.toast.error { background: #c62828; }

/* ---- MOBILE ---- */
@media (max-width: 480px) {
  .main-title { font-size: 1.8rem; margin-bottom: 1.5rem; }

  .form-overlay { align-items: flex-end; }
  .form-card {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 18px 18px 0 0;
    animation: slideUpMobile 0.25s ease;
  }
  @keyframes slideUpMobile {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  .form-card-header { padding: 1.2rem 1.25rem 1rem; }
  form { padding: 1.25rem 1.25rem 1.5rem; }

  .welcome-title { font-size: 1.5rem; }
  .welcome-text { font-size: 0.95rem; }
  .welcome-card { padding: 1.5rem 1.1rem; border-radius: 14px; }
  .qr-container img { max-width: 160px; }

  #admin-page { padding: 1rem 0.75rem; }
  .admin-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .admin-header h1 { font-size: 1.4rem; }
  .upload-group { flex-direction: column; align-items: flex-start; }
  .upload-group label { min-width: unset; }
  .upload-group input[type="file"] { width: 100%; }
  .upload-group button { width: 100%; padding: 0.7rem; min-height: 44px; }
  .save-btn { width: 100%; padding: 0.7rem; min-height: 44px; }

  .toast { bottom: 1rem; right: 1rem; left: 1rem; text-align: center; }
}
