:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f8fafc;
  color: #334155;
}

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

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: clamp(1rem, 4vw, 2rem);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  background: #f8fafc;
  color: #334155;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.ambient-background {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-orb {
  position: absolute;
  z-index: 0;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.8;
  animation: float 20s infinite ease-in-out alternate;
}

.orb-1 {
  width: 400px;
  height: 400px;
  top: -100px;
  left: -100px;
  background: rgba(147, 197, 253, 0.4);
}

.orb-2 {
  width: 500px;
  height: 500px;
  right: -100px;
  bottom: -150px;
  background: rgba(196, 181, 253, 0.4);
  animation-delay: -5s;
}

.orb-3 {
  width: 300px;
  height: 300px;
  top: 40%;
  left: 50%;
  margin-top: -150px;
  margin-left: -150px;
  background: rgba(167, 243, 208, 0.4);
  animation-duration: 25s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, 40px) scale(1.1); }
  100% { transform: translate(-20px, 20px) scale(0.9); }
}

.login-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  margin: auto;
}

.card {
  width: 100%;
  padding: 2rem 2.5rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: slide-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.logo-container {
  margin-bottom: 1.5rem;
  text-align: center;
}

.logo-img {
  display: inline-block;
  width: auto;
  height: 55px;
  max-width: 70%;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.05));
}

h1 {
  margin: 0;
  color: #0f172a;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: #64748b;
  font-size: 0.95rem;
}

.error-message {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0 0 1.5rem;
  padding: 0.875rem 1rem;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.95rem;
}

.error-message svg {
  width: 18px;
  height: 18px;
  margin-top: 0.1rem;
  flex: 0 0 auto;
}

.database-selector {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.toggle-container {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.toggle-option {
  position: relative;
  flex: 1 1 0;
}

.toggle-option input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.toggle-btn {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  border: 2px solid #000411;
  border-radius: 999px;
  background: transparent;
  color: #000411;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.toggle-btn:hover { background: rgba(0, 4, 17, 0.05); }

.toggle-option input[type="radio"]:checked + .toggle-btn {
  background: #000411;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(0, 4, 17, 0.2);
}

.toggle-option input[type="radio"]:focus-visible + .toggle-btn {
  outline: 3px solid #2563eb;
  outline-offset: 3px;
}

.input-group {
  position: relative;
  margin-bottom: 1.25rem;
}

.input-group > label {
  display: block;
  margin-bottom: 0.5rem;
  color: #0f172a;
  font-size: 0.95rem;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  min-height: 50px;
  padding: 0.875rem 1.25rem;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background-color: #ffffff;
  color: #0f172a;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
  font: inherit;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

#password { padding-right: 3.25rem; }
input::placeholder { color: #64748b; opacity: 1; }
input:hover, select:hover { border-color: #94a3b8; }

input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  border-color: #2563eb;
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12), 0 4px 12px rgba(15, 23, 42, 0.08);
}

input[aria-invalid="true"] { border-color: #dc2626; }

select {
  padding-right: 3rem;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%2364748b%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 1.25rem center;
  background-size: 1rem;
}

select option { background: #ffffff; color: #0f172a; }
.password-wrapper { position: relative; }

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.password-toggle:hover { background: #f1f5f9; color: #0f172a; }

.field-help,
.status-message {
  color: #64748b;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.field-help { margin: 0.45rem 0 0; }

.status-message {
  min-height: 1.15rem;
  margin: -0.25rem 0 0.75rem;
  text-align: center;
}

.status-message:empty { min-height: 0; margin: 0; }

.status-message[data-state="success"] { color: #047857; }
.status-message[data-state="warning"] { color: #b45309; }
.status-message[data-state="loading"] { color: #1d4ed8; }

.submit-btn {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 50px;
  padding: 0.875rem 1rem;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 0;
  border-radius: 999px;
  background: #000411;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 4, 17, 0.2);
  cursor: pointer;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.submit-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.submit-btn > * {
  position: relative;
  z-index: 1;
}

.submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 4, 17, 0.3);
}

.submit-btn:hover:not(:disabled)::after { opacity: 1; }
.submit-btn:active:not(:disabled) { transform: translateY(0); }
.submit-btn:disabled { cursor: wait; opacity: 0.65; }

@media (max-width: 480px) {
  body { padding: 0.75rem; }
  .card { padding: 1.5rem 1.25rem; border-radius: 20px; }
  .toggle-container { gap: 0.625rem; }
  .toggle-btn { padding-inline: 0.75rem; font-size: 0.9rem; }
}

@media (max-height: 720px) {
  body { align-items: flex-start; }
  .login-wrapper { margin-block: 0; }
  .logo-container { margin-bottom: 1rem; }
}

@media (pointer: coarse) {
  .toggle-btn,
  .password-toggle,
  .submit-btn { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .toggle-btn,
  input,
  select,
  .submit-btn { border: 1px solid ButtonText; }
}
