:root {
  --bg: #0f172a;
  --card-bg: #ffffff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --text: #1e293b;
  --muted: #64748b;
  --success: #16a34a;
  --error: #dc2626;
  --border: #e2e8f0;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
}

#login-page {
  justify-content: center;
}

.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.card h1 {
  margin-top: 0;
  font-size: 1.5rem;
  text-align: center;
}

form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 10px;
}

input[type="text"],
input[type="password"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
}

input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s ease;
}

button:hover {
  background: var(--primary-dark);
}

form button {
  margin-top: 20px;
}

.error-text {
  color: var(--error);
  font-size: 0.85rem;
  margin: 4px 0 0;
}

.topbar {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
}

.topbar h1 {
  font-size: 1.3rem;
}

.link-btn {
  background: transparent;
  color: #cbd5e1;
  font-weight: 500;
  padding: 6px 10px;
}

.link-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

#scanner-page .card {
  max-width: 480px;
  margin-top: 16px;
}

.subtitle {
  text-align: center;
  color: var(--muted);
  margin: -8px 0 8px;
}

#reader {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  min-height: 1px;
}

.scan-controls {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.scan-controls button {
  flex: 1;
}

#stop-scan-btn {
  background: var(--error);
}

#stop-scan-btn:hover {
  background: #b91c1c;
}

.status-text {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 12px;
  min-height: 1.2em;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.modal-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #fff;
}

.modal-icon.success {
  background: var(--success);
}

.modal-icon.error {
  background: var(--error);
}

.modal h2 {
  margin: 0 0 8px;
}

.modal p {
  color: var(--muted);
  margin: 0 0 12px;
}

.modal-details {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--text);
  text-align: left;
  margin-bottom: 16px;
}

.modal-details div {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

.modal button {
  width: 100%;
}
