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

:root {
  --brand-50: 238 242 255;
  --brand-100: 224 231 255;
  --brand-200: 199 210 254;
  --brand-300: 165 180 252;
  --brand-400: 129 140 248;
  --brand-500: 99 102 241;
  --brand-600: 79 70 229;
  --brand-700: 67 56 202;
  --brand-800: 55 48 163;
  --brand-900: 49 46 129;

  --bg-page: #f0f2f5;
  --bg-card: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --border-focus: rgb(var(--brand-500));
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
  --shadow-card-hover: 0 8px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  --radius-card: 16px;
  --radius-input: 10px;
  --radius-button: 10px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(var(--brand-500), 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(var(--brand-400), 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(var(--brand-300), 0.02) 0%, transparent 50%);
}

#login-container {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

#login-card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 40px 36px 36px;
  width: 100%;
  transition: box-shadow 0.3s ease;
}

#login-card:hover {
  box-shadow: var(--shadow-card-hover);
}

/* ── Logo ── */
.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.login-logo img {
  max-height: 60px;
  width: auto;
  display: block;
}

.login-logo-fallback {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgb(var(--brand-500)), rgb(var(--brand-700)));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
}

/* ── Title ── */
.login-title {
  text-align: center;
  margin-bottom: 4px;
}

.login-title h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.login-subtitle {
  text-align: center;
  margin-bottom: 28px;
}

.login-subtitle p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Messages / Errors ── */
.login-messages {
  margin-bottom: 20px;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-input);
  padding: 12px 14px;
  font-size: 0.82rem;
  color: #dc2626;
  line-height: 1.5;
  margin-bottom: 10px;
}

.login-error ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.login-error li {
  padding: 2px 0;
}

.login-error-note {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius-input);
  padding: 12px 14px;
  font-size: 0.82rem;
  color: #c2410c;
  line-height: 1.5;
  margin-bottom: 10px;
}

/* ── Form ── */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}

.input-wrapper input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  font-size: 0.92rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: #f8fafc;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-input);
  outline: none;
  transition: all 0.2s ease;
  line-height: 1.5;
}

.input-wrapper input::placeholder {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.input-wrapper input:focus {
  border-color: var(--border-focus);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(var(--brand-500), 0.1);
}

.input-wrapper input.error {
  border-color: #dc2626;
}

.input-wrapper input.error:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* ── Password Toggle ── */
.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.15s ease;
  line-height: 0;
}

.password-toggle:hover {
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.04);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.password-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* ── Submit Button ── */
.login-submit {
  margin-top: 4px;
}

.login-submit button {
  width: 100%;
  padding: 13px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: #fff;
  background: linear-gradient(135deg, rgb(var(--brand-500)), rgb(var(--brand-600)));
  border: none;
  border-radius: var(--radius-button);
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
  line-height: 1.5;
}

.login-submit button:hover {
  background: linear-gradient(135deg, rgb(var(--brand-600)), rgb(var(--brand-700)));
  box-shadow: 0 4px 14px rgba(var(--brand-500), 0.35);
  transform: translateY(-1px);
}

.login-submit button:active {
  transform: translateY(0);
}

.login-submit button:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.login-submit button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Loading State ── */
.login-submit button.loading {
  color: transparent;
}

.login-submit button.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: login-spin 0.6s linear infinite;
}

@keyframes login-spin {
  to { transform: rotate(360deg); }
}

/* ── Footer ── */
.login-footer {
  text-align: center;
  margin-top: 22px;
}

.login-footer a {
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.login-footer a:hover {
  color: rgb(var(--brand-500));
}

.login-footer a:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Brand Footer ── */
.login-brand-footer {
  text-align: center;
  margin-top: 24px;
}

.login-brand-footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.login-brand-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.login-brand-footer a:hover {
  color: var(--text-secondary);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  body {
    padding: 16px;
    align-items: flex-start;
    padding-top: 48px;
  }

  #login-card {
    padding: 32px 24px 28px;
    border-radius: 14px;
  }

  .login-title h1 {
    font-size: 1.2rem;
  }

  .input-wrapper input {
    padding: 11px 14px 11px 40px;
    font-size: 16px;
  }

  .login-submit button {
    padding: 14px 20px;
  }
}

@media (max-width: 380px) {
  body {
    padding: 12px;
    padding-top: 32px;
  }

  #login-card {
    padding: 24px 16px 24px;
  }

  .login-logo {
    margin-bottom: 20px;
  }

  .login-logo img {
    max-height: 48px;
  }
}
