
/* ========== Login (split hero + panel) ========== */
:root {
  color-scheme: light;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --auth-surface: #ffffff;
  --auth-primary: #4c44ec;
  --auth-primary-dark: #312fab;
  --auth-primary-soft: rgba(76, 68, 236, 0.12);
  --auth-text: #1f2937;
  --auth-text-muted: #6b7280;
  --auth-border: #e5e7eb;
  --auth-danger: #ef4444;
  --auth-danger-soft: rgba(239, 68, 68, 0.1);
  --auth-danger-border: rgba(239, 68, 68, 0.35);
  --auth-success: #16a34a;
  --auth-success-soft: rgba(22, 163, 74, 0.1);
  --auth-success-border: rgba(22, 163, 74, 0.35);
}

.auth-login {
  margin: 0;
  background: linear-gradient(120deg, #f2ebff 0%, #f3f3ff 40%, #f3e8ff 100%);
  color: var(--auth-text);
  overflow-x: hidden;
}

.auth-login *,
.auth-login *::before,
.auth-login *::after {
  box-sizing: border-box;
}

.auth-page {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  min-height: 100dvh;
}

.auth-hero {
  background: linear-gradient(140deg, #7a4dff 0%, #6237ff 45%, #4f2bf8 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 80px clamp(40px, 8vw, 100px);
}

.auth-page .hero-content {
  max-width: 440px;
  display: grid;
  gap: 1rem;
  text-align: left;
}

.auth-page .hero-title {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  margin: 0;
}

.auth-page .hero-subtitle {
  font-size: clamp(0.9rem, 2vw, 1rem);
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.6;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2rem, 6vw, 5rem);
}

.auth-panel-inner {
  background: var(--auth-surface);
  border-radius: 24px;
  width: 100%;
  max-width: 420px;
  padding: clamp(1.5rem, 4vw, 3rem);
  box-shadow: 0 18px 36px -12px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.auth-page .panel-title {
  font-size: clamp(1.5rem, 5vw, 1.9rem);
  margin: 0;
}

.auth-page .panel-subtitle {
  font-size: clamp(0.85rem, 3vw, 0.95rem);
  color: var(--auth-text-muted);
  line-height: 1.6;
  margin: 0;
}

.auth-page .auth-panel-inner form {
  display: grid;
  gap: 1rem;
}

.auth-page .field {
  display: grid;
  gap: 0.5rem;
}

.auth-page .input-shell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--auth-border);
  border-radius: 999px;
  padding: 0 1rem;
  background: #f9fafb;
}

.auth-page .input-shell input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.8rem 0;
  font-size: 1rem;
}

.auth-page .input-shell input:focus {
  outline: none;
}

.auth-page .toggle-password {
  border: none;
  background: none;
  color: var(--auth-primary);
  font-size: 0.8rem;
  cursor: pointer;
}

.auth-page .auth-btn {
  padding: 0.9rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.auth-page .auth-btn:hover {
  filter: brightness(1.05);
}

.auth-page .auth-btn.auth-is-loading .btn-text {
  display: none;
}

.auth-page .auth-btn .btn-loading {
  display: none;
  align-items: center;
  gap: 0.35rem;
}

.auth-page .auth-btn.auth-is-loading .btn-loading {
  display: inline-flex;
}

.auth-page .auth-link {
  color: var(--auth-primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-page .auth-link:hover {
  text-decoration: underline;
}

.auth-page .form-meta {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  font-size: 0.85rem;
  gap: 0.5rem;
}

.auth-page .auth-alert {
  padding: 0.875rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--auth-border);
  font-size: 0.95rem;
  line-height: 1.5;
  background: #fff;
  margin: 0.75rem 0;
}

.auth-page .auth-alert ul {
  margin: 0;
  padding-left: 1.1rem;
}

.auth-page .auth-alert.error {
  background: var(--auth-danger-soft);
  border-color: var(--auth-danger-border);
  color: #991b1b;
}

.auth-page .auth-alert.success {
  background: var(--auth-success-soft);
  border-color: var(--auth-success-border);
  color: #065f46;
}

.auth-page .spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin 0.65s linear infinite;
}

@keyframes auth-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1024px) {
  .auth-page {
    grid-template-columns: 1fr;
  }
  .auth-hero {
    display: none;
  }
}

@media (max-width: 768px) {
  .auth-panel {
    padding: 2rem;
  }
  .auth-panel-inner {
    padding: 1.5rem;
    border-radius: 20px;
  }
}

@media (max-width: 480px) {
  .auth-login {
    background: #f9f9ff;
  }
  .auth-panel {
    padding: 1.25rem;
  }
  .auth-panel-inner {
    max-width: 100%;
    border-radius: 18px;
    padding: 1.25rem;
    gap: 1.2rem;
  }
  .auth-page .panel-title {
    font-size: 1.4rem;
  }
  .auth-page .panel-subtitle {
    font-size: 0.8rem;
  }
  .auth-page .input-shell input {
    font-size: 0.9rem;
    padding: 0.75rem 0;
  }
  .auth-page .auth-btn {
    font-size: 0.95rem;
    padding: 0.8rem;
  }
}

@media (max-width: 360px) {
  .auth-panel-inner {
    padding: 1rem;
    border-radius: 14px;
    gap: 1rem;
  }
  .auth-page .panel-title {
    font-size: 1.2rem;
  }
  .auth-page .auth-btn {
    font-size: 0.9rem;
    width: 100%;
  }
}

/* ========== Simple card screens (verify, passwords) ========== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7ff, #eef9ff);
  padding: 24px;
}

.auth-wrapper .auth-card {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  padding: 28px;
}

.auth-wrapper.auth-card-narrow .auth-card {
  max-width: 480px;
}

.auth-wrapper .auth-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.auth-wrapper .auth-brand img {
  max-height: 56px;
}

.auth-wrapper .auth-title {
  margin: 10px 0 2px 0;
  font-size: 22px;
  line-height: 1.2;
  text-align: center;
}

.auth-wrapper .auth-subtitle {
  margin: 0 0 18px 0;
  color: #6b7280;
  text-align: center;
  font-size: 14px;
}

.auth-wrapper .form-group {
  margin-bottom: 14px;
}

.auth-wrapper .form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 13px;
  color: #374151;
}

.auth-wrapper .auth-input {
  width: 93%;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-wrapper .auth-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.auth-wrapper .form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 16px 0;
}

.auth-wrapper .remember {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #374151;
  font-size: 13px;
}

.auth-wrapper .auth-link {
  font-size: 13px;
  color: #4f46e5;
  text-decoration: none;
}

.auth-wrapper .auth-link:hover {
  color: #4338ca;
  text-decoration: underline;
}

.auth-wrapper .auth-btn {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  background: #4f46e5;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.auth-wrapper .auth-btn:hover {
  background: #4338ca;
}

.auth-wrapper .auth-alert {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}

.auth-wrapper .auth-alert.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.auth-wrapper .auth-alert.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.auth-wrapper .auth-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.auth-wrapper .auth-actions--center {
  justify-content: center;
  margin-top: 10px;
}

/* ========== L5 Quick Login (Standard / Touch / Hybrid) ========== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Author stylesheet must not defeat HTML hidden on login chrome */
.auth-login-page [hidden] {
  display: none !important;
}

.login-bootstrap-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--auth-text-muted);
  font-size: 0.9rem;
}

.login-bootstrap-status[hidden] {
  display: none !important;
}

.login-bootstrap-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(76, 68, 236, 0.25);
  border-top-color: var(--auth-primary);
  border-radius: 50%;
  animation: auth-spin 0.65s linear infinite;
}

.login-quick-error {
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: var(--auth-danger-soft);
  border: 1px solid var(--auth-danger-border);
  color: #991b1b;
  font-size: 0.95rem;
  line-height: 1.45;
}

.quick-login-methods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
}

.quick-login-submethods {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.quick-login-submethod {
  min-height: 40px;
  border: 1px solid var(--auth-border);
  border-radius: 999px;
  background: #fff;
  color: var(--auth-text);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.45rem 0.9rem;
}

.quick-login-submethod.is-active {
  border-color: var(--auth-accent);
  background: rgba(99, 102, 241, 0.08);
  color: var(--auth-accent);
}

.quick-login-method-card {
  min-height: 48px;
  border: 1px solid var(--auth-border);
  border-radius: 14px;
  background: #fff;
  color: var(--auth-text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.7rem 0.75rem;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.quick-login-method-card:hover,
.quick-login-method-card:focus-visible {
  border-color: var(--auth-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--auth-primary-soft);
}

.quick-login-method-card.is-active {
  background: var(--auth-primary-soft);
  border-color: var(--auth-primary);
  color: var(--auth-primary-dark);
}

.quick-login-heading {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
}

/* HTML hidden must win over panel display:grid (specificity bug) */
.login-method-panel[hidden],
.pin-panel[hidden],
.scan-panel[hidden],
.challenge-panel[hidden] {
  display: none !important;
}

.login-method-panel:not([hidden]) {
  display: grid;
  gap: 1rem;
}

#password_panel.login-method-panel:not([hidden]) {
  display: block;
}

.pin-panel,
.scan-panel {
  display: grid;
  gap: 1rem;
}

.pin-display {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin-dots {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  justify-content: center;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #c7c9d9;
  background: transparent;
}

.pin-dot.is-filled {
  background: var(--auth-primary);
  border-color: var(--auth-primary);
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.pin-key {
  min-height: 64px;
  border: 1px solid var(--auth-border);
  border-radius: 16px;
  background: #f8fafc;
  color: var(--auth-text);
  font-size: 1.35rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s, border-color 0.15s;
}

.pin-key:hover,
.pin-key:focus-visible {
  border-color: var(--auth-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--auth-primary-soft);
}

.pin-key:active {
  transform: scale(0.98);
  background: var(--auth-primary-soft);
}

.pin-key-action {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--auth-primary-dark);
}

.scan-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 72px;
  border-radius: 16px;
  border: 1px dashed rgba(76, 68, 236, 0.35);
  background: rgba(76, 68, 236, 0.06);
  color: var(--auth-primary-dark);
  font-weight: 600;
}

.scan-ready-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--auth-primary);
  box-shadow: 0 0 0 6px rgba(76, 68, 236, 0.15);
}

/* Scanner capture stays in DOM for paste/keyboard wedges but must not render as a field */
.badge-scan-input.sr-only,
.badge-scan-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  min-height: 0 !important;
  opacity: 0 !important;
  pointer-events: none;
}

.challenge-user {
  margin: 0;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
}

.auth-link-btn {
  border: none;
  background: none;
  color: var(--auth-primary);
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 48px;
  cursor: pointer;
  text-decoration: none;
}

.auth-link-btn:hover,
.auth-link-btn:focus-visible {
  text-decoration: underline;
  outline: none;
}

/* Wider panel for touch / hybrid keypad comfort */
body.login-mode-touch .auth-panel-inner,
body.login-mode-hybrid .auth-panel-inner {
  max-width: 520px;
}

body.login-mode-touch .pin-key,
body.login-mode-hybrid .pin-key {
  min-height: 72px;
}

@media (min-width: 1280px) {
  body.login-mode-touch .pin-key,
  body.login-mode-hybrid .pin-key {
    min-height: 78px;
  }
}

@media (max-width: 1024px) {
  body.login-mode-touch .auth-hero,
  body.login-mode-hybrid .auth-hero {
    display: none;
  }

  body.login-mode-touch .auth-page,
  body.login-mode-hybrid .auth-page {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .pin-key {
    min-height: 64px;
  }

  body.login-mode-touch .auth-panel-inner,
  body.login-mode-hybrid .auth-panel-inner {
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pin-key,
  .quick-login-method-card,
  .login-bootstrap-spinner,
  .auth-page .spinner {
    animation: none !important;
    transition: none !important;
  }
}
