:root {
  --bg: #fafbfc;
  --bg-card: #ffffff;
  --text: #1a1d21;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --input-bg: #ffffff;
  --input-border: #e5e7eb;
  --input-focus: #2563eb;
  --brand-bg: #0f172a;
  --brand-accent: #3b82f6;
  --shadow: rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
  --bg: #0c0e12;
  --bg-card: #161a21;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #2d3640;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --input-bg: #1e2430;
  --input-border: #2d3640;
  --input-focus: #3b82f6;
  --brand-bg: #0a0d12;
  --brand-accent: #60a5fa;
  --shadow: rgba(0, 0, 0, 0.3);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.page {
  display: flex;
  min-height: 100vh;
}

.panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  --pad: clamp(1.5rem, 4vw, 3rem);
  padding: var(--pad);
  padding-top: calc(var(--pad) + env(safe-area-inset-top));
  padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom));
  padding-left: calc(var(--pad) + env(safe-area-inset-left));
  padding-right: calc(var(--pad) + env(safe-area-inset-right));
}

.panel--brand {
  position: relative;
  background: var(--brand-bg);
  overflow: hidden;
  padding: 0 !important;
}

/* Mobile-only background & design */
.mobile-bg,
.mobile-top-bar {
  display: none;
}

@media (max-width: 768px) {
  .panel--brand {
    display: none;
  }

  .mobile-bg {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: linear-gradient(180deg,
      var(--brand-bg) 0%,
      var(--brand-bg) 28%,
      var(--bg) 28%,
      var(--bg) 100%);
  }

  [data-theme="dark"] .mobile-bg {
    background: linear-gradient(180deg,
      #0f172a 0%,
      #0f172a 26%,
      var(--bg) 26%,
      var(--bg) 100%);
  }

  .mobile-bg-glow {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200%;
    height: 200px;
    background: radial-gradient(ellipse 80% 100% at 50% 0%, rgba(59, 130, 246, 0.25), transparent 70%);
    pointer-events: none;
  }

  [data-theme="dark"] .mobile-bg-glow {
    background: radial-gradient(ellipse 80% 100% at 50% 0%, rgba(96, 165, 250, 0.2), transparent 70%);
  }

  .mobile-bg-grid {
    position: absolute;
    inset: 0;
    height: 30%;
    background-image:
      linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
  }

  .mobile-top-bar {
    display: block;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    z-index: 2;
    margin-top: max(12px, env(safe-area-inset-top));
  }

  [data-theme="dark"] .mobile-top-bar {
    background: rgba(255, 255, 255, 0.25);
  }

  .page {
    position: relative;
    z-index: 1;
  }

  .panel--form {
    align-items: flex-start;
    padding-top: max(1.25rem, env(safe-area-inset-top));
  }

  .form-wrapper {
    max-width: none;
    width: 100%;
  }

  .form-header {
    margin-bottom: 1.5rem;
  }

  .form-body {
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 32px var(--shadow);
    padding: 1.75rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
    border: none;
    border-top: 1px solid var(--border);
  }

  .form-title {
    font-size: 1.625rem;
  }

  .form-subtitle {
    margin-bottom: 1.5rem;
  }

  .field-input {
    padding: 1rem 1rem;
    font-size: 16px; /* prevents zoom on focus on iOS */
    min-height: 52px;
    border-radius: 14px;
  }

  .field-row {
    margin-top: 0.25rem;
  }

  .checkbox {
    width: 22px;
    height: 22px;
  }

  .btn--primary {
    min-height: 54px;
    border-radius: 14px;
    font-size: 1.0625rem;
    margin-top: 0.5rem;
  }
}

.design-pattern {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.pattern-gradient {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse 120% 100% at 10% 20%, rgba(59, 130, 246, 0.5), transparent 60%),
              radial-gradient(ellipse 100% 120% at 90% 80%, rgba(139, 92, 246, 0.4), transparent 60%),
              radial-gradient(ellipse 80% 80% at 50% 50%, rgba(236, 72, 153, 0.3), transparent 70%);
  animation: gradientShift 15s ease-in-out infinite;
}

.pattern-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 50px 50px;
  opacity: 0.6;
}

.pattern-circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.6;
  animation: float 20s ease-in-out infinite;
}

.pattern-circle--1 {
  width: 600px;
  height: 600px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  top: -200px;
  left: -200px;
  animation-delay: 0s;
}

.pattern-circle--2 {
  width: 500px;
  height: 500px;
  background: linear-gradient(135deg, #ec4899, #3b82f6);
  bottom: -150px;
  right: -150px;
  animation-delay: -7s;
}

.pattern-circle--3 {
  width: 450px;
  height: 450px;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  top: 30%;
  right: -100px;
  animation-delay: -14s;
}

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

@keyframes gradientShift {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

[data-theme="dark"] .pattern-gradient {
  background: radial-gradient(ellipse 100% 80% at 20% 30%, rgba(96, 165, 250, 0.3), transparent 50%),
              radial-gradient(ellipse 80% 100% at 80% 70%, rgba(167, 139, 250, 0.25), transparent 50%),
              radial-gradient(ellipse 60% 60% at 50% 50%, rgba(249, 168, 212, 0.15), transparent 70%);
}

[data-theme="dark"] .pattern-grid {
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
}

[data-theme="dark"] .pattern-circle {
  opacity: 0.5;
}

.panel--form {
  background: var(--bg);
}

.form-wrapper {
  width: 100%;
  max-width: 400px;
}

.form-header {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.lang-btn,
.theme-btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.lang-btn:hover,
.theme-btn:hover {
  background: var(--border);
}

.theme-btn .icon-moon {
  display: none;
}

[data-theme="dark"] .theme-btn .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-btn .icon-moon {
  display: block;
}

.form-body {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px var(--shadow);
}

@media (max-width: 480px) {
  .form-body {
    padding: 1.5rem;
  }
}

.form-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.375rem;
}

.form-subtitle {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-bottom: 1.75rem;
}

.login-error {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.1);
  border-radius: 10px;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

[data-theme="dark"] .login-error {
  color: #f87171;
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.4);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

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

.field-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.field-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field-input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.field-input:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

[data-theme="dark"] .field-input:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-text {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.link {
  font-size: 0.875rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.btn {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn--primary {
  background: var(--primary);
  color: white;
  margin-top: 0.25rem;
  min-height: 48px;
}

.btn--primary:hover {
  background: var(--primary-hover);
}

