.form-group {
  position: relative;
  margin-bottom: 16px;
}

.form-control {
  width: 100%;
  height: 60px;
  padding: 26px 16px 10px;
  font-family: inherit;
  font-size: 16px;
  line-height: 24px;
  color: var(--ink-900);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-sizing: border-box;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.form-control:hover {
  border-color: var(--border-strong);
}

.form-control:focus {
  outline: none;
  border-color: var(--x5-green-500);
  box-shadow: var(--ring);
}

.form-control + label {
  position: absolute;
  left: 17px;
  top: 18px;
  font-size: 16px;
  line-height: 24px;
  color: var(--ink-400);
  pointer-events: none;
  transform-origin: left top;
  transition: transform 0.16s ease, color 0.16s ease;
}

.form-control:not(:placeholder-shown) + label,
.form-control:focus + label,
.form-control:-webkit-autofill + label {
  transform: translateY(-11px) scale(0.75);
  color: var(--ink-500);
}

.form-control:focus + label {
  color: var(--link);
}

.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink-900);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  caret-color: var(--ink-900);
}

.form-control[disabled] {
  background: var(--canvas-sunk);
  color: var(--ink-400);
}

.form-error .form-control {
  border-color: var(--error-600);
}

.form-error .form-control:focus {
  box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.18);
}

.password-toggle {
  appearance: none;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  outline: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-400);
  cursor: pointer;
}

.password-toggle:hover {
  background: var(--canvas-sunk);
  color: var(--ink-700);
}

.password-toggle:focus-visible {
  box-shadow: var(--ring);
}

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

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  line-height: 22px;
  cursor: pointer;
}

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

label.checkbox input[type="checkbox"]:focus-visible + i {
  border-color: var(--x5-green-500);
  box-shadow: var(--ring);
}

label.checkbox input[type="checkbox"] + i {
  position: relative;
  display: inline-block;
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-sizing: border-box;
  transition: background 0.16s ease, border-color 0.16s ease;
}

label.checkbox input[type="checkbox"]:checked + i {
  background: var(--x5-green-600);
  border-color: var(--x5-green-600);
}

label.checkbox input[type="checkbox"]:checked + i:before {
  position: absolute;
  left: 6px;
  top: 2px;
  content: "";
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 14px 24px;
  font-family: inherit;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  letter-spacing: -0.1px;
  text-align: center;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--ink-900);
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease,
    box-shadow 0.18s ease, transform 0.06s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
}

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

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

.btn-block {
  display: flex;
  width: 100%;
}

.btn:disabled {
  background: var(--canvas-sunk) !important;
  color: var(--ink-300) !important;
  border-color: transparent !important;
  cursor: not-allowed;
  transform: none;
}

.btn:disabled svg path {
  fill: var(--ink-300);
}

#kc-form-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 22px;
}

#kc-form-buttons .btn {
  width: 100%;
}

#kc-form-buttons .btn-text {
  min-height: 44px;
  background: transparent;
  border-color: transparent;
  color: var(--link);
  font-weight: 500;
}

#kc-form-buttons .btn-text:hover {
  background: var(--canvas-sunk);
  border-color: transparent;
}

.btn-reset {
  display: flex;
  align-items: center;
  margin-top: 14px;
}

.btn-reset .btn {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 14px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--link);
}

.btn-reset .btn:hover {
  background: var(--canvas-sunk);
}

.btn-reset .btn:disabled {
  background: transparent !important;
  color: var(--ink-400) !important;
}

.btn-reset .btn svg {
  flex: none;
}

.btn-reset .btn svg path {
  fill: currentColor;
}

#timer {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.alert {
  display: block;
  margin-bottom: 20px;
  padding: 16px 18px;
  font-size: 15px;
  line-height: 22px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--info-50);
  border-color: rgba(11, 123, 193, 0.2);
  color: var(--info-700);
}

.alert a {
  color: inherit;
  font-weight: 500;
}

.alert-error {
  background: var(--error-50);
  border-color: rgba(217, 45, 32, 0.22);
  color: var(--error-700);
}

.alert-warning {
  background: var(--warning-50);
  border-color: rgba(220, 104, 3, 0.22);
  color: var(--warning-700);
}

.alert-success {
  background: var(--success-50);
  border-color: rgba(14, 147, 132, 0.22);
  color: var(--success-700);
}

.otp-cells {
  display: flex;
  gap: 10px;
}

.otp-cell {
  flex: 1 1 0;
  min-width: 0;
  max-width: 56px;
  height: 68px;
  padding: 0;
  text-align: center;
  font-family: inherit;
  font-size: 28px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink-900);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-sizing: border-box;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.otp-cell:hover {
  border-color: var(--border-strong);
}

.otp-cell.is-filled {
  border-color: var(--border-strong);
}

.otp-cell:focus {
  outline: none;
  border-color: var(--x5-green-500);
  box-shadow: var(--ring);
}

.otp-cells.is-error .otp-cell {
  border-color: var(--error-600);
}

.otp-cells.is-error .otp-cell:focus {
  box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.18);
}

#input-error-otp-code {
  display: block;
  margin-top: 16px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 20px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
}

#input-error-otp-code {
  background: var(--error-50);
  border-color: rgba(217, 45, 32, 0.22);
  color: var(--error-700);
}

#input-error-otp-code span {
  color: inherit;
}

.password-rules {
  background: var(--canvas-sunk) !important;
  border-radius: var(--r-md) !important;
  color: var(--ink-500);
}

.caps-hint {
  display: block;
  margin: 6px 2px 0;
  font-size: 13px;
  line-height: 18px;
  color: var(--warning-700);
}

.caps-hint[hidden] {
  display: none;
}

.btn.is-loading {
  position: relative;
  color: transparent !important;
}

.btn-primary.is-loading,
.btn-primary.is-loading:disabled {
  background: var(--btn-primary-bg) !important;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--btn-primary-fg);
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::after {
    animation-duration: 2s;
  }
}

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

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-500);
  text-decoration: none;
}

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

.back-link svg {
  flex: none;
}

.instruction {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 22px;
  color: var(--ink-500);
}

.instruction:last-child {
  margin-bottom: 0;
}

#kc-info-message a:not(.btn),
#kc-error-message a:not(.btn) {
  color: var(--link);
  font-weight: 500;
}

#kc-form-buttons a.btn {
  text-decoration: none;
}

#kc-info {
  margin-top: 18px;
  font-size: 14px;
  line-height: 20px;
  color: var(--ink-500);
}

#kc-info p,
#kc-info .instruction {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
}

#kc-info a {
  color: var(--link);
  font-weight: 500;
}

.totp-steps {
  margin: 0 0 24px;
  padding-left: 20px;
  font-size: 15px;
  line-height: 22px;
  color: var(--ink-700);
}

.totp-steps > li {
  margin-bottom: 18px;
}

.totp-steps > li::marker {
  color: var(--ink-400);
  font-weight: 500;
}

.totp-step-text {
  margin: 0 0 8px;
}

.totp-step-note {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--ink-500);
}

.totp-apps {
  margin: 0;
  padding-left: 18px;
  list-style: disc;
  color: var(--ink-500);
}

.totp-qr {
  display: inline-block;
  margin-bottom: 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: var(--r-md);
}

.totp-qr img {
  display: block;
  width: 180px;
  height: 180px;
}

.totp-secret {
  margin: 0 0 10px;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 22px;
  letter-spacing: 1px;
  word-break: break-all;
  color: var(--ink-900);
  background: var(--canvas-sunk);
  border: 1px solid var(--card-border);
  border-radius: var(--r-md);
}

.totp-params {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
  font-size: 14px;
  line-height: 20px;
}

.totp-params dt {
  color: var(--ink-500);
}

.totp-params dd {
  margin: 0;
  color: var(--ink-900);
}

.input-error {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  line-height: 20px;
  color: var(--error-600);
}
