:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #7b8794;
  --border: #dde3e8;
  --border-focus: #2d6cdf;
  --primary: #2d6cdf;
  --primary-hover: #245bbb;
  --primary-active: #1f4fa5;
  --danger: #c53b3b;
  --success: #2e8b57;
  --shadow: 0 18px 55px rgba(31, 41, 51, 0.10);

  --radius-card: 22px;
  --radius-control: 12px;
  --control-height: 56px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.login-card {
  width: min(100%, 468px);
  padding: 42px 42px 38px;
  background: var(--surface);
  border: 1px solid rgba(31, 41, 51, 0.06);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

body.page-2fa .login-card {
  width: min(100%, 520px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid #edf0f3;
}

.brand-logo-wrap {
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-name {
  font-size: 18px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-caption {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.lead {
  margin: 10px 0 30px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.field { margin-bottom: 20px; }

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 600;
}

.input-wrap { position: relative; }

.control {
  width: 100%;
  height: var(--control-height);
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  outline: none;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.control::placeholder { color: #a5adb5; }
.control:hover { border-color: #c6ced6; }

.control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(45, 108, 223, .11);
}

.control.password { padding-right: 54px; }

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 38px;
  height: 38px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.password-toggle:hover {
  background: #f1f4f6;
  color: var(--text);
}

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

.submit {
  width: 100%;
  height: 56px;
  margin-top: 8px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 7px 18px rgba(45, 108, 223, .18);
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}

.submit:hover {
  background: var(--primary-hover);
  box-shadow: 0 9px 22px rgba(45, 108, 223, .23);
}

.submit:active {
  background: var(--primary-active);
  transform: translateY(1px);
}

.submit:focus-visible,
.password-toggle:focus-visible {
  outline: 3px solid rgba(45, 108, 223, .23);
  outline-offset: 2px;
}

.error {
  display: none;
  margin: -4px 0 18px;
  padding: 11px 13px;
  border-radius: 10px;
  background: #fff3f3;
  color: var(--danger);
  font-size: 14px;
  line-height: 1.45;
}

.demo-note {
  margin-top: 24px;
  color: #a0a8b0;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}

.back-link {
  display: block;
  margin: 20px auto 0;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: color .15s ease;
}

.back-link:hover { color: var(--text); }

/* OTP */
.otp-group {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin: 4px 0 24px;
}

.otp-input {
  width: 100%;
  min-width: 0;
  height: 58px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  outline: none;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 24px;
  font-weight: 650;
  text-align: center;
  caret-color: var(--primary);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.otp-input:hover { border-color: #c6ced6; }

.otp-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(45, 108, 223, .11);
}

/* 2FA setup */
.setup-step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 14px;
  align-items: start;
}

.setup-step.second {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid #edf0f3;
}

.step-number {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eef4ff;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
}

.step-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}

.step-text {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.qr-wrap {
  display: flex;
  justify-content: center;
  margin: 22px 0 18px;
}

.qr-mock {
  width: 174px;
  height: 174px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.qr-inner {
  width: 100%;
  height: 100%;
  background:
    linear-gradient(90deg, #111 12px, transparent 12px) 0 0/24px 24px,
    linear-gradient(#111 12px, transparent 12px) 0 0/24px 24px,
    linear-gradient(90deg, transparent 12px, #111 12px) 12px 12px/24px 24px,
    linear-gradient(transparent 12px, #111 12px) 12px 12px/24px 24px;
  image-rendering: pixelated;
}

.secret-label {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.secret-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 9px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfc;
}

.secret-row code {
  flex: 1;
  min-width: 0;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
}

.copy-btn {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: #eef2f6;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.copy-btn:hover { background: #e5eaf0; }

body.page-2fa .otp-group {
  gap: 8px;
  margin: 17px 0 20px;
}

body.page-2fa .otp-input {
  height: 54px;
  border-radius: 11px;
  font-size: 22px;
}

/* Password recovery */
.recovery-step { display: none; }
.recovery-step.active { display: block; }

.password-hint {
  margin: -8px 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.done-step {
  text-align: center;
  padding-top: 8px;
}

.done-icon {
  width: 66px;
  height: 66px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #edf8f1;
  color: var(--success);
  font-size: 31px;
  font-weight: 700;
}

@media (max-width: 540px) {
  body {
    padding: 18px 14px;
    align-items: center;
  }

  .login-card {
    padding: 30px 24px 27px;
    border-radius: 18px;
  }

  .brand { margin-bottom: 30px; }

  h1 { font-size: 27px; }

  .otp-group { gap: 7px; }

  .otp-input {
    height: 54px;
    font-size: 22px;
  }

  .setup-step {
    grid-template-columns: 30px 1fr;
    gap: 10px;
  }
}
